thinkpool-pair 0.7.13 → 0.7.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bridge.mjs +9 -5
- package/package.json +1 -1
- package/session-store.mjs +8 -0
package/bridge.mjs
CHANGED
|
@@ -36,7 +36,7 @@ import { spawn } from 'node:child_process'
|
|
|
36
36
|
import { randomUUID } from 'node:crypto'
|
|
37
37
|
import { createClient } from '@supabase/supabase-js'
|
|
38
38
|
import { startClaudeSession } from './claude-session.mjs'
|
|
39
|
-
import { saveSession, flushSession,
|
|
39
|
+
import { saveSession, flushSession, loadAll, canResume, loadPtyId, savePtyId } from './session-store.mjs'
|
|
40
40
|
|
|
41
41
|
// Public client creds (the same anon values the web app ships — safe to embed).
|
|
42
42
|
// Override with TP_SUPABASE_URL / TP_SUPABASE_ANON if you ever need to.
|
|
@@ -776,11 +776,15 @@ channel
|
|
|
776
776
|
const startCmd = attachedCmd || autoAgent // autoAgent: account-mode auto-open (headless)
|
|
777
777
|
if (startCmd && !terms.size && !sessions.size) {
|
|
778
778
|
// Claude + structured mode → Agent SDK session; everything else → PTY.
|
|
779
|
-
// On restart, restore
|
|
780
|
-
// replay
|
|
779
|
+
// On restart, restore EVERY saved structured session for this room (not
|
|
780
|
+
// just the latest) — replay each transcript + resume its live SDK context
|
|
781
|
+
// when recent enough. Without this, backgrounded terminals died on a
|
|
782
|
+
// bridge restart even though their state was on disk. Bounded by KEEP=8;
|
|
783
|
+
// only runs on a fresh start (guard above), so a network re-subscribe
|
|
784
|
+
// with live sessions won't re-spawn them.
|
|
781
785
|
if (wantStructured(startCmd)) {
|
|
782
|
-
const
|
|
783
|
-
if (
|
|
786
|
+
const all = loadAll(room).filter((r) => r.log?.length || r.sessionId)
|
|
787
|
+
if (all.length) for (const rec of all) openStructured({ id: rec.id, resume: canResume(rec) ? rec.sessionId : undefined, log: rec.log, commands: rec.commands, mode: rec.mode })
|
|
784
788
|
else openStructured({ id: randomUUID() })
|
|
785
789
|
}
|
|
786
790
|
else {
|
package/package.json
CHANGED
package/session-store.mjs
CHANGED
|
@@ -56,6 +56,14 @@ export function canResume(rec) {
|
|
|
56
56
|
return !!(rec && rec.sessionId && rec.savedAt && (Date.now() - rec.savedAt) < RESUME_MAX_AGE_MS)
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
// EVERY saved session for the room, oldest→newest (so tabs reappear in order).
|
|
60
|
+
// Drives resume-ALL on a bridge restart — without this only the latest session
|
|
61
|
+
// came back and every backgrounded terminal died on restart despite its state
|
|
62
|
+
// sitting on disk. Bounded by KEEP (prune keeps the newest 8).
|
|
63
|
+
export function loadAll(room) {
|
|
64
|
+
return listRecs(room).sort((a, b) => (a.savedAt || 0) - (b.savedAt || 0))
|
|
65
|
+
}
|
|
66
|
+
|
|
59
67
|
// Last PTY terminal id auto-opened for an attached command. A reconnecting
|
|
60
68
|
// bridge reuses it so it re-attaches to the SAME terminal tab instead of
|
|
61
69
|
// minting a fresh UUID and breeding a new dormant "Terminal N" each restart.
|