Repository navigation
feat(switch): make --no-cd print-only in picker mode - #1445
Merged
Merged
Conversation
When `wt switch --no-cd` opens the interactive picker, it now prints the selected branch name and exits without switching — useful for scripting without needing a separate --print flag. Co-Authored-By: Claude Opus 4.6 <[email protected]>
This was referenced Mar 11, 2026
|
Thanks @max-sixty. Would you be able to tag it too? |
max-sixty
added a commit
that referenced
this pull request
May 21, 2026
With `[switch] cd = false` or `wt switch --no-cd`, opening the interactive picker (`wt switch` with no branch argument) and selecting a worktree printed the branch name and exited — no switch, no hooks, and `Alt-c` created nothing. #1445 introduced this as an explicit print-only mode, but it surprises anyone who sets `cd = false` as a standing navigation preference (driving worktree switches through tmux or cmux): the picker silently stops doing anything. The picker now runs the same `plan_switch` → `execute_switch` pipeline as `wt switch <branch>`, suppressing only the cd directive. Pre- and post-switch hooks fire, `Alt-c` creates the worktree, and `--format=json` works in the picker too (`requires = "branch"` and the `--branches`/`--remotes` conflict are dropped from the flag). JSON emission is extracted into a shared `emit_switch_json` so the argument path and the picker produce identical output. This is a behavior change: the print-only picker mode is gone. Scripts that captured its bare-branch-name output should switch to `wt switch --format=json`, which both performs the switch and prints a structured `action`/`branch`/`path` result — now shown as a `pick` alias example in tips-patterns. The cmux recipe drops its `pick` alias workaround, since the picker fires `pre-switch` hooks directly. Closes #2837. Thanks to @endigma for the discussion that pinned down the intended behavior: the picker should be identical to passing the branch as an argument. --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Draft implementation per @max-sixty's suggestion: reuse
--no-cdto make the picker print-only instead of adding a separate--printflag.wt switch --no-cdopens the interactive picker (no branch argument), selecting a branch prints its name to stdout and exits — no switching, no cd directive, no hookswt switch --no-cd <branch>is used with an explicit branch, behavior is unchanged (switches without cd)alt-r(remove) is blocked in print mode since it's a read-only operationThis avoids adding a new CLI flag while giving the same scripting capability that #1404 proposed.
Test plan
resolve_print_identifier(switch, create, remove cases)--no-cdpicker prints branch name, emits no cd directive--no-cdtests still pass (directive suppression, hooks, execute)🤖 Generated with Claude Code