From 3bd8ad36cb402fe6eefeac9026d00da040f4af8b Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Tue, 16 Jun 2026 17:07:24 -0700 Subject: [PATCH] Fix sleep wake history test contract --- src/main/daemon/daemon-pty-adapter.test.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/daemon/daemon-pty-adapter.test.ts b/src/main/daemon/daemon-pty-adapter.test.ts index 30f2e799b0e..4f6357db38f 100644 --- a/src/main/daemon/daemon-pty-adapter.test.ts +++ b/src/main/daemon/daemon-pty-adapter.test.ts @@ -744,10 +744,14 @@ describe('DaemonPtyAdapter (IPtyProvider)', () => { lastSubprocess._simulateData('first cycle content\r\n') await historyAdapter.shutdown(id, { immediate: true, keepHistory: true }) - // Why: production wake always happens after the slept session's exit - // event closed its history; wait for that close before re-spawning. const metaPath = join(historyDir, getHistorySessionDirName(id), 'meta.json') - await waitFor(() => JSON.parse(readFileSync(metaPath, 'utf-8')).endedAt !== null) + const checkpointPath = join(historyDir, getHistorySessionDirName(id), 'checkpoint.json') + // Why: keep-history sleep stays unclean so cold restore remains eligible; + // the final checkpoint is the deterministic handoff signal. + expect(JSON.parse(readFileSync(metaPath, 'utf-8')).endedAt).toBeNull() + expect(JSON.parse(readFileSync(checkpointPath, 'utf-8')).snapshotAnsi).toContain( + 'first cycle content' + ) const firstWake = await historyAdapter.spawn({ cols: 80, @@ -761,7 +765,10 @@ describe('DaemonPtyAdapter (IPtyProvider)', () => { lastSubprocess._simulateData('second cycle content\r\n') await historyAdapter.shutdown(id, { immediate: true, keepHistory: true }) - await waitFor(() => JSON.parse(readFileSync(metaPath, 'utf-8')).endedAt !== null) + expect(JSON.parse(readFileSync(metaPath, 'utf-8')).endedAt).toBeNull() + expect(JSON.parse(readFileSync(checkpointPath, 'utf-8')).snapshotAnsi).toContain( + 'second cycle content' + ) const secondWake = await historyAdapter.spawn({ cols: 80,