Repository navigation
feat(switch): add no-cd config option - #1401
Conversation
Add `[switch] no-cd = true` config option for users who manage worktrees via tmux sessions and handle directory changes themselves. Includes `--cd` flag to override config when needed.
b187e7b to
19a53c0
Compare
worktrunk-bot
left a comment
There was a problem hiding this comment.
Clean implementation — config plumbing follows existing patterns well. Two things worth addressing:
1. Project-specific config won't take effect (should fix)
handle_switch_command resolves config.resolved(None), so [switch] no-cd under a [projects."..."] override is silently ignored. Other commands go through CommandEnv::resolved() which passes the project identifier. This is a pre-existing limitation (the repo isn't opened yet at that point), but since the PR adds tests for project-level merging of SwitchConfig, it's worth either documenting the limitation or deferring the resolution until after the repo is available.
2. Missing integration tests for the new behavior (should fix)
The unit tests cover config parsing/merging thoroughly, but there are no integration tests for:
--cdflag overridingno-cd = trueconfig- Config-based
no-cdactually suppressing the cd directive - The 3-way precedence described in the PR summary
The existing --no-cd integration tests in directives.rs would be a natural place to add a config-driven variant.
3. Help snapshots (minor)
The --cd flag is added to the CLI definition but the help snapshots (help_switch_long.snap, help_switch_short.snap) aren't updated in the diff. These will need cargo insta accept after a test run — CI will likely catch this, but wanted to flag it.
Move change_dir resolution from main.rs into handle_switch where the repo is available, enabling project-specific [switch] no-cd config. The picker path still uses global config since no repo context exists.
bf7955e to
5472a27
Compare
|
Clean, well-structured PR. The config plumbing follows existing patterns nicely (accessor, merge, resolved), and the 3-way precedence logic is clear. CI is green including codecov/patch. A few observations: Integration test coverage gap — tests verify output, not directive behaviorThe three new integration tests use However, the existing Not blocking — the current tests do cover the precedence logic. But worth considering. Unrelated snapshot change: GIT_EDITOR removalThe help snapshots ( Picker path project-config limitation (acknowledged)The comment at Overall: well done — the implementation is clean, precedence is correct, and the previous review's main asks (integration tests, help snapshots) are addressed. |
| <b><span class=c>--clobber</span></b> | ||
| Remove stale paths at target | ||
|
|
||
| <b><span class=c>--cd</span></b> |
There was a problem hiding this comment.
@worktrunk-bot can you hide this option and put it into --no-cd, in the same way we do with --progressive (i.e. keep no-cd
(@jradtilbrook lmk if you disagree, you're welcome to revert)
There was a problem hiding this comment.
No i was actually going to ask that. I think its a better approach 👍
There was a problem hiding this comment.
@worktrunk-bot all good bud?
(For the hourly reviewer — please evaluate what happened here!)
There was a problem hiding this comment.
@worktrunk-bot the issue re you not seeing messages on fork-pr inline comments should now be fixed, please now do this
There was a problem hiding this comment.
Done — I've hidden the --cd flag using the same overrides_with + hide = true pattern as --progressive/--no-progressive. The --cd flag still works but is hidden from help output, and --no-cd is the only visible flag with help text mentioning --cd as the override.
Since this is a fork PR, I can't push directly to the PR branch. I've pushed the commit to switch-no-cd-config on the main repo — @jradtilbrook can cherry-pick dccae85a, or the branch can be used directly.
Changes in the commit:
src/cli/mod.rs:--cdnow useshide = trueandoverrides_with = "no_cd"(matching the--progressivepattern)--no-cdhelp text updated to mentionUse --cd to override.- Docs, skill reference, and help snapshots updated to reflect the hidden flag
|
just for my own learning, I also use tmux sessions + worktrees, and i use have an alias like: alias wts="wt switch --no-cd" to use when I dont want to switch directories. Does this not accomplish the same thing? Or is it that user wants no cd to be the default for his config? |
@cperalt basically, I didn't want to add an alias 🤷♂️. I don't think there will ever be a time where I would want to allow it to cd either so wanted it globally configurable |
|
True thanks for the reply, yeah this makes sense! Ill probably also use this too since i also never cd lol |
ha, thanks, that makes for a more compelling reason to merge, if multiple people are setting up aliases! |
|
@worktrunk-bot please look at the messages above (I know you can't see inline review comments on forks...) |
…rompt Defense-in-depth for the recurring fork-PR push bug (#1434, #1411). The skill-level instruction alone is insufficient — the model pushes to origin before checking. Two changes: 1. Add a workflow step that detects fork PRs via `gh pr view` and sets an output flag before Claude runs. 2. When the flag is set, append "This is a FORK PR" to the system prompt so Claude sees the warning before any reasoning about pushing. 3. Move fork detection to the "First Steps" section of the running-in-ci skill and strengthen the Fork PRs section with recurrence history. Evidence: run 22985929574 on PR #1401 (fork from jradtilbrook) — bot pushed to origin creating a stray branch, then discovered the fork after the fact. Third occurrence of this pattern. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Match the --progressive/--no-progressive pattern: the rarely-used override (--cd) is hidden, the user-facing flag (--no-cd) is visible with "Use --cd to override" in help text. Also switch from conflicts_with to overrides_with for last-one-wins semantics. Co-Authored-By: Claude <[email protected]>
|
@worktrunk-bot are the per-project overrides now working? anything else to consider before we merge? |
|
Yes — per-project overrides are working for the main switch path. At The only place it doesn't apply is the picker path (no branch argument), which resolves config with As for anything else before merging — I don't see blockers. CI is fully green (all platforms + codecov). The implementation is clean, the |
is this pre-existing? open a new PR to address it if so |
|
Not pre-existing — the The fix is straightforward: Opened #1484 stacked on this branch. |
|
can you push to this PR? I don't think the stacked PR is working given it's a fork |
The picker path (wt switch without arguments) was resolving config with resolved(None), missing project-specific [switch] no-cd overrides. Since handle_select already opens a repo via current_or_recover(), pass the flag pair through and resolve change_dir inside where repo.config() provides project-aware resolution. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Summary
[switch] no-cd = trueconfig option to disable directory change by default--cdflag to override config when directory change is desired--cdflag →--no-cdflag → config → default (false)Motivation
Users who manage worktrees via tmux sessions (one session per worktree) handle directory changes themselves. For these workflows, having
wt switchautomatically change directories is unnecessary — they switch tmux sessions instead. This config option lets users disable the default cd behavior while retaining--cdfor occasional use.