[BUG] claude --resume picker pulls in sessions from sibling projects whose encoded folder name shares the cwd's prefix

Resolved 💬 1 comment Opened May 20, 2026 by aperrad Closed Jun 19, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

When claude --resume is invoked from a project directory that has worktree-style sibling folders under ~/.claude/projects/ (e.g. <encoded-cwd>--claude-worktrees-<branch>), the picker also pulls in sessions from unrelated projects whose encoded folder name happens to start with the same prefix as the current cwd. This makes the picker show conversations that belong to a different project entirely.

Concretely, given two sibling directories where one name is a string-prefix of the other:

/home/me/work/foo
/home/me/work/foobar

Their encoded forms are:

~/.claude/projects/-home-me-work-foo
~/.claude/projects/-home-me-work-foobar

The picker's "worktrees of this project" enumeration appears to do startsWith(encodedCwd) over ~/.claude/projects/*, which legitimately matches -home-me-work-foo--claude-worktrees-<branch> but also wrongly matches -home-me-work-foobar because the latter just continues the name.

The session .jsonl files on disk are correctly tagged — their cwd fields point to the right project — so the only thing wrong is which folders the picker decides count as "this project + its worktrees."

What Should Happen?

claude --resume from /home/me/work/foo should only list sessions whose cwd is /home/me/work/foo or a real worktree of it (i.e. project folders matching <encodedCwd>--claude-worktrees-… or equal to <encodedCwd>). Sessions from /home/me/work/foobar should not appear.

A safe rule: after stripping the encodedCwd prefix from a candidate folder name, the remainder must be either empty (exact match) or start with the explicit worktree separator --claude-worktrees-. A bare character continuation should not qualify.

Error Messages/Logs

(none — no error is produced; the picker just lists the wrong sessions)

Steps to Reproduce

  1. Create two sibling directories where one name is a strict prefix of the other:

``
mkdir -p ~/work/foo ~/work/foobar
cd ~/work/foo && git init && echo x > a && git add a && git commit -m init
cd ~/work/foobar && git init && echo x > a && git add a && git commit -m init
``

  1. Open a Claude Code session in each, exchange one message, exit:

``
cd ~/work/foo && claude "say OK"
cd ~/work/foobar && claude "say OK"
``

  1. Make foo have at least one Claude Code worktree, so the picker enters its "all worktrees" view:

``
cd ~/work/foo && claude --worktree some-branch
# type one message, then exit
``

  1. From foo, open the resume picker:

``
cd ~/work/foo && claude --resume
``

  1. Observe: the picker footer shows Ctrl+W show all worktrees and the listed sessions include entries from ~/work/foobar (different branches, different content), not just foo and its real worktrees.

A minimal repro with foo + foobar and no worktrees on foo does not leak — the bug only manifests once the picker enters worktree-aware mode.

Claude Model

Not sure / Multiple models

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.1.145 (Claude Code)

Platform

Anthropic API

Operating System

Other Linux

Terminal/Shell

WSL (Windows Subsystem for Linux)

Additional Information

Workaround: resume by explicit session UUID instead of using the picker — claude --resume <uuid>, picking the UUID from ~/.claude/projects/<encoded-cwd>/.

On-disk evidence is fine: the session .jsonl files inside each project folder correctly carry their own cwd. The bug is purely in the picker's folder enumeration; no data has to move to fix it.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗