-
Notifications
You must be signed in to change notification settings - Fork 81
refactor(claude-code): simplify session resumption logic for standalone and task mode #579
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors the session resumption logic for the claude-code module to simplify and improve reliability across both standalone and task modes. The changes remove the problematic remove-last-session-id.sh script that attempted to manage stale session data, replacing it with more robust session validation and detection functions directly in the start script.
Key changes:
- Introduces three new helper functions (
task_session_exists,is_valid_session,has_any_sessions) to improve session state detection - Simplifies the session resumption decision tree by consolidating conditional logic and removing external script dependencies
- Adds comprehensive test coverage for edge cases like partial initialization, session validation, and mode-specific behavior
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
registry/coder/modules/claude-code/scripts/start.sh |
Refactored session resumption logic with new validation functions; removed dependency on external session cleanup script; simplified conditional branches for task vs standalone modes |
registry/coder/modules/claude-code/scripts/remove-last-session-id.sh |
Removed entirely - session cleanup logic no longer needed with improved validation approach |
registry/coder/modules/claude-code/main.tf |
Removed references to remove-last-session-id.sh script; updated local variables to remove unused script encoding |
registry/coder/modules/claude-code/main.test.ts |
Added four new test cases for partial initialization detection, first build scenarios, session continuation, and task mode isolation; updated existing test to create valid JSONL session files with proper content |
registry/coder/modules/claude-code/README.md |
Updated module version to 4.2.3 across all examples; updated version pins in examples (claude_code_version, agentapi_version, boundary_version); removed cli_app from standalone mode example |
…ale, empty, or malformed session files
35C4n0r
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
…start.sh for fresh sessions
…Y to ANTHROPIC_API_KEY
…dd standalone mode configuration
…I_KEY in standalone mode configuration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
david-fraley
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lending a 👍 based on other's approval
Description
Brings session resumption up to speed with current claude-code capabilities, and should make session resumption less prone to errors across the board.
I am still testing this further to ensure that all logic path's are verified.
Type of Change
Module Information
Path:
registry/coder/modules/claude-codeNew version:
v4.2.5Breaking change: [ ] Yes [ ] No
Testing & Validation
bun test)bun fmt)Related Issues