resume picker: fix worktree-clash guidance (wrong session + shell injection)

main

Commit

Soph3mo ago

The "branch checked out in another worktree" path told the user to run entire resume <branch>, which resumes the branch's LATEST checkpoint — reintroducing the wrong-session bug for the clash case when several sessions share a branch. It also interpolated the branch (and path) into a copy-paste shell command unquoted, so a branch like x;echo pwn or a path with shell metacharacters could execute unintended tokens.

Now the guidance points the user to re-run the picker in that worktree (cd <path> && entire session resume), which preserves the selected-session flow (the picker resumes the exact session by its checkpoint). The branch is no longer part of the command — it appears only in non-executable prose — and the worktree path is shell-quoted via a new shellQuote helper.

Message building is factored into worktreeClashMessage; tests cover the picker-not-branch-arg guidance and injection-safety for both a malicious branch name and a path containing $(...) or apostrophes.

Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com Entire-Checkpoint: 2fe06f6e777d

Checkpoints

Interactive Resume Picker for Sessions

Claude CodeOpus 4.8[1m]
View session
Checkpoint 1