Skip to content

transfer: stale Claude transcript path after session enters a worktree #502

Description

@J2TeamNNL

Summary

/codex:transfer fails after a Claude Code session creates or enters a Git worktree because the Codex plugin keeps the transcript path recorded at SessionStart. Claude subsequently stores the same session ID under the worktree-specific project directory.

Environment

  • Claude Code: 2.1.210
  • codex-plugin-cc: 1.0.5
  • Linux
  • Git worktree workflow via Claude Code

Reproduction

  1. Start Claude Code in a repository root.
  2. In that same Claude session, create or enter a Git worktree.
  3. Run /codex:transfer.

The plugin invokes transfer using the CODEX_COMPANION_TRANSCRIPT_PATH value written by its SessionStart hook.

Actual result

The environment value still points at the original project directory, for example:

~/.claude/projects/-home-...-sh-backend-api/<session-id>.jsonl

That file no longer exists. The real transcript with the exact same session UUID is stored at:

~/.claude/projects/-home-...-sh-backend-api--worktrees-SH-5471/<session-id>.jsonl

Transfer therefore fails with:

Claude session file not found: ~/.claude/projects/.../<session-id>.jsonl

Passing the real path explicitly works around this particular stale-path lookup. Long absolute paths are also easy to accidentally split across lines in the slash command, producing a misleading must be a JSONL file error; that is secondary to the stale automatic lookup.

Expected result

/codex:transfer should transfer the current session after Claude enters a worktree, without requiring users to find the JSONL path manually.

Suggested fix

In resolveClaudeSessionPath(), when CODEX_COMPANION_TRANSCRIPT_PATH is missing:

  1. Take its basename/session UUID.
  2. Search only under ~/.claude/projects for the exact <session-id>.jsonl.
  3. Use the result only if exactly one matching file exists; otherwise retain the current error and show candidate paths or require --source.

This is deterministic, preserves the current security boundary, and handles Claude worktree-specific project-directory naming.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions