Skip to content

fix(switch): keep --path and --execute in the leftover-branch hint - #4841

Merged
max-sixty merged 2 commits into
mainfrom
fix/issue-4839
Nov 18, 2026
Merged

max-sixty merged 2 commits into
mainfrom
fix/issue-4839

Conversation

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

When wt switch --create failed after git worktree add -b had already written the branch, the leftover-branch hint suggested a bare wt switch <branch>. Following it created the worktree at the worktree-path template location instead of the --path given, and skipped the --execute command. WorktreeCreationFailed is raised in execute_switch, whose errors weren't wrapped in WithSwitchSuggestion the way plan_switch's are, so the hint had no flags to draw on.

SwitchPipeline::run now wraps that variant with the switch context, and the hint applies it. The hint becomes e.g. wt switch stranded --path=blocked/stranded --execute='echo hi' -- extra. --create is not in the context, so it stays out of the suggestion, which is correct now that the branch exists. Other execute_switch errors pass through unchanged, so their context chains and downcasts are untouched.

test_switch_create_leftover_branch_hint_keeps_flags fails on main (the hint ends at wt switch stranded) and passes with this change. The existing leftover-branch test still covers the no-flags form.

#4705 adds a hint for pre-start failures on the same execute_switch path. If it suggests a wt switch command, it can reuse this wrapping.

Closes #4839 — automated triage

When wt switch --create failed after git worktree add -b wrote the branch,
the hint suggested a bare `wt switch <branch>`, dropping --path,
--execute, and trailing args. WorktreeCreationFailed comes from
execute_switch, whose errors weren't wrapped in WithSwitchSuggestion the
way plan_switch's are. Wrap that variant and apply the context when
rendering its hint.

Closes #4839
@worktrunk-bot worktrunk-bot added the automated-fix Automated CI fix label Nov 18, 2026
@max-sixty
max-sixty merged commit ecf8bcd into main Nov 18, 2026
36 checks passed
@max-sixty
max-sixty deleted the fix/issue-4839 branch November 18, 2026 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automated-fix Automated CI fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wt switch --create: leftover-branch hint drops --path, --execute, and trailing args

2 participants