feat: transfer task list across agent sessions via CLAUDE_CODE_TASK_LIST_ID#319
Merged
Conversation
Owner
Author
PR Review SummaryCritical Issues (1 found)
Important Issues (3 found)
Suggestions (6 found)
Strengths
Documentation Updates
VerdictNEEDS FIXES — 1 critical shell injection issue must be resolved before merge. Test coverage gaps should be addressed for key code paths (destroy cleanup, daemon env var injection). Recommended Actions
|
…IST_ID
Set CLAUDE_CODE_TASK_LIST_ID env var when spawning Claude agents so task
lists persist across session stop/resume cycles. The ID is generated
deterministically from the session ID, stored in the session JSON, and
injected into both terminal and daemon spawn paths.
- Add generate_task_list_id() and task_list_env_vars() to agents/resume
- Add task_list_id field to Session struct
- Inject env var in create_session (terminal + daemon paths)
- Inject env var in open_session (resume reuses ID, fresh open generates new)
- Clean up ~/.claude/tasks/{task_list_id}/ on destroy
Closes #296
- Update save-tasks.md to reflect automatic task list persistence via --resume - Add task list cleanup to destroy.rs integration points in CLAUDE.md - Remove stale manual task list management instructions
- Fix shell injection in terminal export commands by single-quoting env var values with proper escaping for embedded single quotes - Sanitize task list ID by replacing / with - to produce flat directory names compatible with Claude Code's task storage - Prevent agent-status from dropping unknown session fields by using targeted JSON patching instead of full Session deserialize/serialize - Extract cleanup_task_list() for testability - Add tests for daemon env var injection, destroy cleanup, slash sanitization, and JSON field preservation
d8c9b17 to
cc8c875
Compare
This was referenced Feb 10, 2026
Owner
Author
PR Review SummaryCritical Issues (1 found)
Details: The Fix: Replace with: let obj = json.as_object_mut().ok_or_else(|| SessionError::IoError {
source: std::io::Error::new(
std::io::ErrorKind::InvalidData,
"session JSON root is not an object",
),
})?;
obj.insert(field.to_string(), value);Important Issues (2 found)
Suggestions (5 found)
Strengths
Type Design Assessment
VerdictNEEDS ONE FIX — The silent failure in |
- Return error from patch_session_json_field when JSON root is not an object instead of silently succeeding - Add test for non-object JSON rejection - Change cleanup_task_list log level from error! to warn! (non-fatal) - Fix misleading comments: "Existing path" → "Terminal path" - Add atomic write note to patch_session_json_field docstring
Wirasm
added a commit
that referenced
this pull request
Feb 11, 2026
sync_daemon_session_status() was using save_session_to_file() which round-trips through the Session struct, silently dropping fields from newer binary versions (e.g., task_list_id). This is the same class of bug fixed in agent_status.rs by PR #319. Changes: - Add patch_session_json_fields() for atomic multi-field JSON patching - Replace save_session_to_file() with field-level patches in sync_daemon_session_status - Add test verifying unknown fields survive multi-field patching Fixes #321
4 tasks
Wirasm
added a commit
that referenced
this pull request
Feb 11, 2026
sync_daemon_session_status() was using save_session_to_file() which round-trips through the Session struct, silently dropping fields from newer binary versions (e.g., task_list_id). This is the same class of bug fixed in agent_status.rs by PR #319. Changes: - Add patch_session_json_fields() for atomic multi-field JSON patching - Replace save_session_to_file() with field-level patches in sync_daemon_session_status - Add test verifying unknown fields survive multi-field patching Fixes #321
Wirasm
added a commit
that referenced
this pull request
Feb 11, 2026
sync_daemon_session_status() was using save_session_to_file() which round-trips through the Session struct, silently dropping fields from newer binary versions (e.g., task_list_id). This is the same class of bug fixed in agent_status.rs by PR #319. Changes: - Add patch_session_json_fields() for atomic multi-field JSON patching - Replace save_session_to_file() with field-level patches in sync_daemon_session_status - Add test verifying unknown fields survive multi-field patching Fixes #321
Wirasm
added a commit
that referenced
this pull request
Feb 11, 2026
* investigate issue #321: sync_daemon_session_status field-dropping bug * fix: use targeted JSON patching in sync_daemon_session_status (#321) sync_daemon_session_status() was using save_session_to_file() which round-trips through the Session struct, silently dropping fields from newer binary versions (e.g., task_list_id). This is the same class of bug fixed in agent_status.rs by PR #319. Changes: - Add patch_session_json_fields() for atomic multi-field JSON patching - Replace save_session_to_file() with field-level patches in sync_daemon_session_status - Add test verifying unknown fields survive multi-field patching Fixes #321
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CLAUDE_CODE_TASK_LIST_IDenv var when spawning Claude agents so task lists persist across session stop/resume cycleskild-{session_id}with/sanitized to-), stored in session JSON, and injected into both terminal and daemon spawn paths~/.claude/tasks/{task_list_id}/directoryPost-review fixes
/to-in task list IDs for flat directory namesagent_statuswithpatch_session_json_field()to prevent older binaries from dropping new fieldscleanup_task_list()for testabilitysave-tasks.md,CLAUDE.md)Related issues
save_session_to_filecall sites that could drop fields from newer versionsTest plan
cargo fmt --checkpassescargo clippy --all -- -D warningspassescargo test --allpasses (1,506 tests, 0 failures)cargo build --allpassesgenerate_task_list_id()andtask_list_env_vars()build_daemon_create_requestwithSome(task_list_id), non-Claude agents, andNonecleanup_task_list(removal, nonexistent dir, None guard)patch_session_json_fieldpreserving unknown fieldstask_list_iddeserializes toNone(serde default)Closes #296