[BUG] End-of-session resume hint includes --worktree flag that fails when session crossed into a nested repo's worktree
What's Wrong?
When a session is started in a parent repo and cds into a worktree of a nested repo during the session, the end-of-session resume hint includes --worktree <name>, but that command fails with "No conversation found".
The session JSONL is stored under the parent repo's project key (where claude was originally launched), so the printed --worktree flag points Claude Code to look up the session under a project key that doesn't exist.
This is the inverse of #28769 (closed): there, the hint printed without --worktree when one was needed; here, the hint prints with --worktree when it shouldn't.
What Should Happen?
The printed resume command should actually work when copy-pasted. Either:
- Don't include
--worktreein the hint when the session was launched from the parent (not the worktree), or - Store the session under the worktree's project key if
--worktreeis going to be in the hint
Steps to Reproduce
- Have a parent repo
~/parentthat contains a nested repo at~/parent/nested - Create a worktree inside the nested repo, e.g.
~/parent/nested/.claude/worktrees/feature-x - From
~/parent, launchclaude - During the session, work happens in the nested repo's worktree (cwd moves to
~/parent/nested/.claude/worktrees/feature-x) - Exit. Claude prints:
````
Resume this session with:
claude --worktree feature-x --resume <session-id>
- Run that exact command from
~/parent→No conversation found with session ID: <id> - Drop
--worktreeand it resumes fine:claude --resume <session-id>
Investigation
The session JSONL lives at ~/.claude/projects/-Users-<me>-parent/<session-id>.jsonl (parent repo's project key) — confirmed by inspecting the file and the recorded cwd entries, which span both /Users/<me>/parent and /Users/<me>/parent/nested/.claude/worktrees/feature-x.
Compounding: if the same worktree name exists in both the parent and nested repos, --worktree <name> is ambiguous on its own.
Likely related to the worktree path resolution logic discussed in #45179.
Claude Code Version
2.1.123
Platform
Anthropic API
OS
macOS (Darwin 25.4.0)
Related
- #28769 (closed) — inverse symptom (missing
--worktreein hint) - #45179 (open) —
/resumepicker breaks with submodule + secondary worktree; same code path likely involved
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗