Repository navigation
fix(chat): follow Claude continued transcripts - #779
Conversation
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Summary
Merge Risk: ⚪ Minimal · up to No actionable merge-blocking risk is established for the continued-transcript change; it is mergeable after normal checks. Security Architecture Review
Pre-merge checks |
|
cb2ed4f to
16e5434
Compare
16e5434 to
d8da207
Compare
|
Thanks for the CodeRabbit scan-cost note. A bounded rework follows. |
…ewer turns Codex review on devswha#779: the whole active transcript was reread on every lookup, a continued-in record followed by newer turns still redirected, an unreadable transcript threw instead of reaching its reader, and a continuation whose file is missing dropped the transcript that named it.
… transcript (#1057) Fixes #1021 ## Root cause `claudeTranscriptFile` in `server/claude-store.ts` (the continued-in loop, ~L350 on main) follows a `continued-in` record only when the named session has a transcript; otherwise it "keeps the transcript that named it". A `/resume` of a Claude Code session that runs in the background parks the pane on a continuation id (`parkedJobId`) that never gets a transcript, so the pane stayed on its near-empty interactive transcript (just `/resume`, its output and the record), and Chat was empty while the terminal showed the whole conversation. The gap came in with #779, which only follows continued-in ids whose file exists. ## What changed - `server/claude-store.ts`: the 64 KiB tail read is factored into `transcriptTail`; a new `backgroundJobTranscript` runs only when the continuation names no file. It reads the last `running in the background (<8 hex>)` from the same tail, takes the single `<8 hex>-*.jsonl` in the same project folder (none or more than one: no change), and, when `<config dir>/jobs/<8 hex>/state.json` names a `linkScanPath`, requires it to be that file. Any miss keeps today's behavior (the current transcript). - `server/claude-store.test.ts`: three cases with the issue's fixture, each labelled: following the job id (regression: fails on main), no or ambiguous prefix match keeps the current transcript (control), and the state.json cross-check (regression for the match; the mismatch is a control). - `changelog.d/claude-resume-background-session.md`: Fixed entry. ## Before / after - The new tests against main's `claude-store.ts`: 2 fail (both regression-labelled cases resolve the pane's own `a21fe37a-…` transcript instead of the job's `8b80137e-…`). On this branch: 42 pass, 0 fail. - A standalone script with a temp `HOME` built from the issue (pane transcript ending in the `/resume` output and a `continued-in` record to a missing id, plus the job's `8b80137e-…jsonl`) calling the exported `claudeTranscriptFile`: main resolves the near-empty pane transcript; the branch resolves `8b80137e-…jsonl`. Edge cases on the branch: two `8b80137e-*` files, no job file, no continued-in record, a mismatched `linkScanPath` and an unknown job id all keep the current transcript; a continuation whose file exists is still followed as before; a matching, absent-field or malformed `state.json` follows the job. ## Checks - `bun run typecheck`: pass - `HERDR_TEST_MODE=unit bun test ./server/claude-store.test.ts`: 42 pass, 1 skip (platform), 0 fail - `bun run test:unit`: 3518 pass, 0 fail, 8 skip in 285 files - `bun test ./server/claude-session.contract.test.ts` on an isolated herdr session: 10 pass, 0 fail Not covered: opening a background session from the agent view with Enter, which may leave no record in the pane's transcript (called out in the issue as a separate case). No live Claude Code background session was driven; fixtures follow the issue's file shapes.
Summary
continued-intranscript records until the active session fileEvidence
The affected session file contained seven metadata records, including
continued-in, and no user or assistant turns. The active transcript is stored under the continued session id.Tests
bun test ./server/claude-store.test.tsbun test ./server/conversation.test.ts ./server/claude-session.contract.test.tsbun run typecheck