From b19317175ea6de8117ec022d8ec6ec2bbe3d996f Mon Sep 17 00:00:00 2001 From: Codeman maintainer Date: Sun, 18 Oct 2026 15:27:30 +0200 Subject: [PATCH] fix(story-mode): a stop says where it landed and what was saved before it From review round 8: "STOPPED" with the balloon "Step 3: new tests under test/." read like progress, and nothing said what the stop left. The final panel now names the step Claude last announced and the commits made before the stop: "You stop Claude here, during its step 3. Saved before the stop: 2 commits." Co-Authored-By: Claude Opus 5.5 (1M context) --- src/story-mode.ts | 8 +++++++- .../story-corpus/teammates-then-interrupt.expected.json | 2 +- test/story-corpus.test.ts | 4 +++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/story-mode.ts b/src/story-mode.ts index d4daa438..aeaf4fe5 100644 --- a/src/story-mode.ts +++ b/src/story-mode.ts @@ -2547,8 +2547,14 @@ function completePanel(turn: StoryTurn, page: Omit, trailin const laterHelpers = later.filter((e) => e.helper).length; const laterCommands = later.length - laterHelpers; const done = turn.durationMs !== undefined ? `Done in ${roughDuration(turn.durationMs)}.` : 'Done.'; + // Where a stop landed: the step Claude last announced ("Step 3: …"), and what it had saved by then. + const announced = [...page.events].reverse().find((e) => e.intent === 'say' && /^\W{0,4}step \d+\b/i.test(e.label)); + const step = announced ? /step (\d+)/i.exec(announced.label)?.[1] : undefined; + const savedBefore = page.events.reduce((n, e) => n + (e.commits ?? 0), 0); const story = turn.interrupted - ? 'You stop Claude here.' + ? `You stop Claude here${step ? `, during its step ${step}` : ''}.${ + savedBefore ? ` Saved before the stop: ${plural(savedBefore, 'commit')}.` : '' + }` : page.noneWorked ? 'Nothing Claude tried worked, so the job is not done.' : turn.endedBy === 'next prompt' diff --git a/test/fixtures/story-corpus/teammates-then-interrupt.expected.json b/test/fixtures/story-corpus/teammates-then-interrupt.expected.json index 0dc92ff3..b06a207b 100644 --- a/test/fixtures/story-corpus/teammates-then-interrupt.expected.json +++ b/test/fixtures/story-corpus/teammates-then-interrupt.expected.json @@ -300,7 +300,7 @@ { "kind": "complete", "ok": null, - "story": "You stop Claude here.", + "story": "You stop Claude here, during its step 3. Saved before the stop: 2 commits.", "director": "interrupted · 2 min 41 s · 5 tool calls · 4 files changed", "balloon": "Step 3: new tests under test/.", "tests": null, diff --git a/test/story-corpus.test.ts b/test/story-corpus.test.ts index 5fd1e624..03d65fe9 100644 --- a/test/story-corpus.test.ts +++ b/test/story-corpus.test.ts @@ -98,7 +98,9 @@ describe('Story Mode on real sessions', () => { ['human', true], ['human', true], ]); - expect(pages[3].panels.at(-1)?.story).toBe('You stop Claude here.'); + expect(pages[3].panels.at(-1)?.story).toBe( + 'You stop Claude here, during its step 3. Saved before the stop: 2 commits.' + ); }); it('a commit at the end of a test one-liner is kept, and a background helper reports back in 9 s', () => {