Skip to content

fix: capture session_id for multi-turn resume and remove output duplication#3

Merged
13rac1 merged 2 commits intomainfrom
fix/session-resume-cleanup
Apr 3, 2026
Merged

fix: capture session_id for multi-turn resume and remove output duplication#3
13rac1 merged 2 commits intomainfrom
fix/session-resume-cleanup

Conversation

@13rac1
Copy link
Copy Markdown
Owner

@13rac1 13rac1 commented Mar 28, 2026

  • Capture session_id from Claude Code's stream-json output and persist it via updateSession, enabling --resume on subsequent jobs in the same session
  • Remove the duplicate log-parsing fallback in claude_code_status that re-appended all output already captured by the streaming watcher

Based on PR #1 by @ZhangYiqun018, with the following:

  • Moved session_id parsing into parseSessionId() in stream-parser.ts (consistent with existing parseRateLimitError/parseAuthError pattern)
  • Removed tryCaptureFinalText + fs.writeFile overwrite that replaced incremental output with only the last assistant message
  • Added 8 tests

Test plan

  • npm test — 198 tests pass (8 new)
  • Start a job, verify session_id appears in logs
  • Start a second job on the same session, verify --resume is passed

ZhangYiqun018 and others added 2 commits March 28, 2026 14:20
…rite

Refactor the cherry-picked PR #1 changes:
- Extract parseSessionId() into stream-parser.ts alongside existing parsers
- Remove tryCaptureFinalText closure and fs.writeFile overwrite that
  destroyed incremental output
- Add 8 tests for parseSessionId and updateSession behavior

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 89.32% (🎯 80%) 1331 / 1490
🔵 Statements 89.32% (🎯 80%) 1331 / 1490
🔵 Functions 97.29% (🎯 80%) 72 / 74
🔵 Branches 86.77% (🎯 80%) 387 / 446
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/claude-code.ts 83.22% 78.12% 100% 83.22% 197-198, 221-235, 265-269, 274-276, 288-306, 326-328, 331-333, 335, 337-338, 376-378, 483-490, 519-550, 555, 565-575, 586, 675, 773-777
src/stream-parser.ts 90.08% 89.83% 100% 90.08% 52-53, 92-93, 112-113, 144-145, 197-198, 208-209
Generated in workflow #44 for commit 96ee6ae by the Vitest Coverage Report Action

@13rac1 13rac1 merged commit 0728391 into main Apr 3, 2026
3 checks passed
@13rac1 13rac1 deleted the fix/session-resume-cleanup branch April 3, 2026 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants