Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
Use --foreground in remove-then-switch hint (#2040)
Maximilian Roos814d9fdba11c
diff --git a/.claude/skills/writing-user-outputs/SKILL.md b/.claude/skills/writing-user-outputs/SKILL.mdindex 531f93f56..5a2c850ba 100644--- a/.claude/skills/writing-user-outputs/SKILL.md+++ b/.claude/skills/writing-user-outputs/SKILL.md@@ -406,7 +406,7 @@ shouldn't clutter user output:"To rebase onto main, run wt step rebase or wt merge"// GOOD - recovery command after shadowing a remote branch-"To switch to the remote branch, delete this branch and run without --create: wt remove feature && wt switch feature"+"To switch to the remote branch, delete this branch and run without --create: wt remove --foreground feature && wt switch feature"// BAD - command without context"wt remove feature -D deletes unmerged branches"diff --git a/src/commands/worktree/switch.rs b/src/commands/worktree/switch.rsindex e35615a46..c3427ab65 100644--- a/src/commands/worktree/switch.rs+++ b/src/commands/worktree/switch.rs@@ -363,7 +363,10 @@ fn resolve_switch_target("Branch <bold>{resolved_branch}</> exists on remote ({remote_ref}); creating new branch from base instead")));- let remove_cmd = suggest_command("remove", &[&resolved_branch], &[]);+ // `--foreground` is required: background removal leaves a placeholder+ // directory at the original path (to keep shell PWD valid), which+ // would block the subsequent `wt switch` with "Directory already exists".+ let remove_cmd = suggest_command("remove", &[&resolved_branch], &["--foreground"]);let switch_cmd = suggest_command("switch", &[&resolved_branch], &[]);eprintln!("{}",diff --git a/tests/snapshots/integration__integration_tests__switch__switch_create_remote_only.snap b/tests/snapshots/integration__integration_tests__switch__switch_create_remote_only.snapindex aee7a6223..359ee87b6 100644--- a/tests/snapshots/integration__integration_tests__switch__switch_create_remote_only.snap+++ b/tests/snapshots/integration__integration_tests__switch__switch_create_remote_only.snap@@ -46,7 +46,7 @@ exit_code: 0----- stderr -----[33m▲[39m [33mBranch [1mremote-feature[22m exists on remote (origin/remote-feature); creating new branch from base instead[39m-[2m↳[22m [2mTo switch to the remote branch, delete this branch and run without [4m--create[24m: [4mwt remove remote-feature && wt switch remote-feature[24m[22m+[2m↳[22m [2mTo switch to the remote branch, delete this branch and run without [4m--create[24m: [4mwt remove --foreground remote-feature && wt switch remote-feature[24m[22m[32m✓[39m [32mCreated branch [1mremote-feature[22m from [1mmain[22m and worktree @ [1m_REPO_.remote-feature[22m[39m[2m↳[22m [2mTo customize worktree locations, run [4mwt config create[24m[22m[33m▲[39m [33mCannot change directory — shell integration not installed[39m