The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
Close a resumed Pi chat that never wrote a conversation file (#1092)
lingrdd4a0fdea409f
diff --git a/cli/src/lib/sessionCheckpoint.spec.ts b/cli/src/lib/sessionCheckpoint.spec.tsindex 8dd80cfc2..902906f27 100644--- a/cli/src/lib/sessionCheckpoint.spec.ts+++ b/cli/src/lib/sessionCheckpoint.spec.ts@@ -74,11 +74,36 @@ it.each(['before', 'during'] as const)('backs up a Pi transcript first written %} finally { pi.restore() }})-it.each(['known', 'resumed', 'unreadable', 'ambiguous', 'unreadable store'] as const)('does not replace %s Pi history with only a screen', async state => {+it('closes a resumed Pi chat that never wrote a conversation file, keeping its screen', async () => {+ // Found on a real machine: a Pi chat stopped before its first reply and resumed carries resumeOnly,+ // an ID, no transcript path and no file anywhere. Close was refused for good ("conversation file is+ // unavailable") though there was no history to lose.+ const pi = await piSession()+ try {+ row.resumeOnly = true+ await expect(store.save(row)).rejects.toThrow('Could not save this terminal')+ await store.save(row, { screen: 'Waiting for the first reply' })+ const saved = await manifest()+ expect(saved.source).toBeNull()+ expect(JSON.parse(await readFile(join(directory, saved.file), 'utf8'))).toMatchObject({ engine: 'pi', screen: 'Waiting for the first reply' })+ } finally { pi.restore() }+})++it('still refuses a resumed Pi chat whose history file is gone once it was backed up', async () => {+ const pi = await piSession()+ try {+ await writeFile(pi.path, pi.history)+ await store.save(row)+ await rm(pi.path)+ row.resumeOnly = true+ await expect(store.save(row, { screen: 'Still visible' })).rejects.toThrow('conversation file is unavailable')+ } finally { pi.restore() }+})++it.each(['known', 'unreadable', 'ambiguous', 'unreadable store'] as const)('does not replace %s Pi history with only a screen', async state => {const pi = await piSession()try {if (state === 'known') row.transcriptPath = pi.path- if (state === 'resumed') row.resumeOnly = trueif (state === 'unreadable') await writeFile(pi.path, '{partial')if (state === 'unreadable store') {const folder = join(pi.path, '..')diff --git a/cli/src/lib/sessionCheckpoint.ts b/cli/src/lib/sessionCheckpoint.tsindex f1eb9250d..68b6e816b 100644--- a/cli/src/lib/sessionCheckpoint.ts+++ b/cli/src/lib/sessionCheckpoint.ts@@ -110,8 +110,10 @@ export class SessionCheckpointStore {? await findResumedTranscript('pi', s.sessionId, { cwd: s.cwd ?? undefined }) : null)// Pi announces a session ID before it writes any history. In particular,// missing credentials can leave it here indefinitely. Preserve the screen- // just as for an unbound chat; a known/resumed transcript must still save.- const unwrittenPi = s.engine === 'pi' && !source && !s.resumeOnly && !previous?.source+ // just as for an unbound chat; a known transcript, or one backed up before, must still save.+ // A resumed chat is not evidence of history: one stopped before its first reply resumes with an+ // ID, no path and no file, and refusing it left the window impossible to close.+ const unwrittenPi = s.engine === 'pi' && !source && !previous?.sourceif (!s.sessionId || s.engine === 'terminal' || unwrittenPi) {// A shell or unused chat has no native conversation. Save its terminal// instead; the close service owns the activity check and confirmation.