Skip to content

Fix transfer resolution after Claude session forks - #624

Open
sensei-woo wants to merge 1 commit into
openai:mainfrom
sensei-woo:fix-transfer-transcript-fallback
Open

Fix transfer resolution after Claude session forks#624
sensei-woo wants to merge 1 commit into
openai:mainfrom
sensei-woo:fix-transfer-transcript-fallback

Conversation

@sensei-woo

@sensei-woo sensei-woo commented Aug 10, 2026

Copy link
Copy Markdown

Summary

  • resolve /codex:transfer from Claude Code's current CLAUDE_CODE_SESSION_ID
  • prefer the current fork after compaction over stale companion hook state
  • reject duplicate session-ID matches and preserve --source as the explicit override

Root cause

Claude Code can mint a new session ID when compaction resumes through a fork. Fresh tool shells expose the new ID through CLAUDE_CODE_SESSION_ID, but the plugin currently relies on CODEX_COMPANION_TRANSCRIPT_PATH persisted by its SessionStart hook. That hook state can be missing or can still identify the parent session, causing transfer to fail or import stale history.

The same lookup also resolves worktree path drift: the current session ID is matched to the unique JSONL anywhere beneath ~/.claude/projects.

Issues

Closes #502.

Related to #514: this fixes its no-argument transcript-identification failure when Claude exposes CLAUDE_CODE_SESSION_ID, but not the separate Windows post-import ledger lookup failure.

Related upstream: anthropics/claude-code#79830 tracks the underlying compact/fork lifecycle mismatch.

Behavior

  1. An explicit --source remains authoritative.
  2. Otherwise, the current native Claude session ID is resolved first.
  3. The existing companion transcript path and companion session ID remain fallbacks.
  4. Ambiguous session-ID matches fail closed and request --source.
  5. The existing realpath containment check still requires the source to live under ~/.claude/projects.

Validation

  • node --test --test-name-pattern='transfer' tests/runtime.test.mjs
  • npm test: 92/93 passed; the unrelated background-worker status test observed running before completion
  • isolated rerun of task --background enqueues a detached worker and exposes per-job status: passed
  • structured Codex autoreview: no actionable findings; patch assessed correct at 0.9 confidence
  • reproduced against a real compact-fork pair where native session 3aab… superseded stale companion session 1cde…

@sensei-woo
sensei-woo marked this pull request as ready for review August 10, 2026 05:46
@sensei-woo
sensei-woo requested a review from a team August 10, 2026 05:46
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.

transfer: stale Claude transcript path after session enters a worktree

1 participant