Repository navigation
feat: add alt-r shortcut to remove worktrees from switch picker - #1253
Conversation
worktrunk-bot
left a comment
There was a problem hiding this comment.
Two observations:
-
Keybindings table not updated — The new
alt-dbinding is shown in the preview controls line but missing from the keybindings table insrc/cli/mod.rsL321 (the primary source fordocs/content/switch.md). Add a row afterAlt-c:| `Alt-d` | Delete selected worktree |Then run
cargo test --test integration test_command_pages_and_skill_files_are_in_syncto sync the docs page. -
Hooks are skipped — The delete path passes
verify: falsetohandle_remove_output, so pre-remove / post-remove hooks don't run. The normalwt removeflow respects these. This may be intentional (prompting for hooks mid-picker would be disruptive), but worth a conscious decision — users relying on pre-remove hooks won't get that protection from the picker.
|
why alt+d? evaluate a number of options; consider relevance, prior art, conflicts, etc |
|
Good question — here's an evaluation of the candidates. Current picker conventions for context:
The My lean is |
|
let's do alt-r |
|
Switched to |
| // Create new worktree with query as branch name (alt-c for "create") | ||
| "alt-c:accept(create)".to_string(), | ||
| // Delete selected worktree (alt-r for "remove") | ||
| "alt-r:accept(delete)".to_string(), |
There was a problem hiding this comment.
can we name this remove, rather than delete?
| --- | ||
| 1: HEAD± | 2: log | 3: main…± | 4: remote⇅ | 5: summary [N/M] | ||
| Enter: switch | alt-c: create | Esc: cancel | ctrl-u/d: scr | ||
| Enter: switch | alt-c: create | alt-r: remove | Esc: cancel |
There was a problem hiding this comment.
why do these get cut off? because we're using an very thin width in tests?
worktrunk-bot
left a comment
There was a problem hiding this comment.
Re: rename to remove — Done in c90db80. Renamed the enum variant to PickerAction::Remove and the accept label to "remove".
Re: truncated controls in snapshots — Yes, this is the test terminal width. The preview panel gets ~59 chars (120-col terminal with right:60 split), so the controls line has always been truncated — it was ...ctrl-u/d: scr before this PR. The actual terminal at typical widths (160+ cols) shows the full line. The snapshots just capture what fits in the test viewport.
|
resolve conflicts please separately: is there any GitHub event we could trigger a |
Adds an `alt-d` keybinding in `wt switch` interactive picker that removes the highlighted worktree. Uses safe defaults (no -D, no -f) — unmerged branches are retained and dirty worktrees are not force-removed. Closes #1251 Co-Authored-By: Claude Opus 4.6 <[email protected]>
Run cargo fmt and update 7 switch picker preview snapshots to reflect the new alt-d: delete controls text. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Co-Authored-By: Claude <[email protected]>
Update the keybindings table in `wt switch --help` to document the new alt-d delete shortcut, and sync the generated docs and help snapshot. Co-Authored-By: Claude Opus 4.6 <[email protected]>
alt-r matches the `wt remove` command name and avoids the ctrl-d/alt-d modifier-slip risk that could accidentally trigger a destructive action instead of scrolling the preview. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Rename the enum variant and accept label from "delete" to "remove" to match `wt remove` terminology consistently. Co-Authored-By: Claude Opus 4.6 <[email protected]>
c90db80 to
be0c04f
Compare
Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
Conflicts resolved and rebased onto main. All CI checks green (Linux, macOS, Windows, lint, code-coverage). The On the automated conflict resolution question: GitHub doesn't expose a native event for "PR became conflicted." The closest options would be a scheduled workflow that polls |
could we do a scan of PRs authored by @worktrunk-bot as part of one of our nightly jobs, and merge the default branch into any PRs that have conflicts? |
|
Yes — this fits naturally into the nightly cleaner job. It already has The addition would be a step like: # Find open bot PRs with conflicts
CONFLICTED=$(gh pr list --author worktrunk-bot --json number,mergeable \
--jq '[.[] | select(.mergeable == "CONFLICTING")] | .[].number')
for pr in $CONFLICTED; do
gh pr checkout "$pr"
if git merge origin/main --no-edit; then
git push
gh pr comment "$pr" -b "Merged main to resolve conflicts."
else
git merge --abort
gh pr comment "$pr" -b "Automated merge from main failed — conflicts need manual resolution."
fi
git checkout main
doneA few considerations:
Want me to add this to |
Claude needs to resolve conflicts but yes, add to the start or end of a job, ask Claude to use subagents |
Adds a Step 0 to the nightly cleaner prompt that checks for open worktrunk-bot PRs with merge conflicts and resolves them using Claude subagents before proceeding to the code review sweep. Each conflicted PR gets a dedicated subagent that checks out the branch, merges main, resolves conflicts, pushes, and monitors CI. PRs are processed in parallel via the Task tool. Requested in #1253. Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
Done — #1307 adds a Step 0 to the nightly cleaner that finds conflicted |
## Summary - Adds a "Step 0" to the nightly cleaner that checks for open `worktrunk-bot` PRs with merge conflicts - Conflicted PRs are resolved using Claude subagents (Task tool), run in parallel - Each subagent checks out the PR branch, merges main, resolves conflicts, pushes, and monitors CI - Falls back to commenting on the PR if conflicts are too complex to resolve confidently Requested by @max-sixty in #1253. ## Test plan - [ ] Trigger via `workflow_dispatch` when a bot PR has conflicts to verify end-to-end - [ ] Verify no-op behavior when no bot PRs are conflicted 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: worktrunk-bot <[email protected]> Co-authored-by: Claude Opus 4.6 <[email protected]>
Summary
Adds an
alt-rkeybinding to thewt switchinteractive picker that removes the highlighted worktree directly, without needing to type the branch name or switch first.-D(force-delete unmerged branches), no-f(force-remove dirty worktrees) — matches the safety behavior requested in Feature: Interactive picker for wt remove (like wt switch) #1251wt removesuccess/failure output after picker exitsalt-r: removeCloses #1251
Test plan
cargo test --lib --bins)wt switch, highlight a worktree, pressalt-r— verify it removes the worktree and shows the success messagealt-ron main worktree — verify it shows "Cannot remove the main working tree" erroralt-ron a worktree with uncommitted changes — verify it shows the dirty worktree error🤖 Generated with Claude Code