Worktree exit dialog offers "Remove worktree" for a worktree it will refuse to remove
Version: reproduced on Claude Code 2.1.270, macOS. The 2.1.277 binary still contains the same dialog text and the same lock check, and the changelog through 2.1.277 lists no change to either.
Steps:
- In any git repository, run
claude -w probe -n probe. - From another terminal, lock the worktree with a reason Claude Code did not write:
git worktree unlock .claude/worktrees/probe then
git worktree lock --reason "held by another tool" .claude/worktrees/probe.
- Create an uncommitted file in
.claude/worktrees/probe. - Run
/exitin the Claude Code session and choose "Remove worktree".
Expected: The dialog says the worktree is locked by something else, and it either omits Remove or labels it as unavailable. At minimum, the terminal prints why the worktree was kept.
Actual: The dialog warns "You have 1 uncommitted file. These will be lost if you remove the worktree" and offers Remove. After Remove, the worktree, the file, the branch, and the lock are all intact. Nothing is printed; the reason appears only in the debug log ("cleanupWorktree: kept … locked by another live Claude Code process, or with a reason we did not write"). Keeping the worktree is correct. The dialog misleads the user about what will happen.
Related: #90692, where the same dialog warns "will be lost" for commits that are already pushed and merged.