worktrunk icon indicating copy to clipboard operation
worktrunk copied to clipboard

Remove worktrees from interactive switch list

Open jtaby opened this issue 8 months ago • 5 comments

I'd love to be able to clean up work trees from the interactive wt switch menu. Right now, a "remove" option doesn't exist for the selected worktree.

I imagine if you remove the worktree you're in, it would cd me back to the main repo directory, and there would need to be a confirmation.

I can see how this would overload the concept of switching. My first attempt was to look for an "interactive list" experience, where I can browse, create/remove etc. But that doesn't exist, and the interactive switch experience quite fleshed out.

jtaby avatar Apr 01 '26 15:04 jtaby

Thanks for the suggestion! This feature actually already exists — the interactive wt switch picker supports Alt-r to remove the selected worktree in-place. The item disappears from the list immediately and the removal runs in the background.

However, this keybinding was missing from the documented keybinding table, which is likely why it wasn't discoverable. I've opened #1869 to add it to the docs.

Note: there's also a known issue (#1695) where the cursor resets to the top of the list after each Alt-r removal, which a maintainer may want to address separately.

A maintainer will review the docs fix shortly.

worktrunk-bot avatar Apr 01 '26 15:04 worktrunk-bot

thanks bot. it would be very helpful to also add it to the list of commands in the TUI of the interactive switch

Image

jtaby avatar Apr 01 '26 15:04 jtaby

Great idea — I've pushed a commit to #1869 that adds alt-r: remove to the in-picker controls bar, so it'll show up right next to the other keybindings.

worktrunk-bot avatar Apr 01 '26 16:04 worktrunk-bot

unfortunately the framework we use for the interactive picker — https://github.com/skim-rs/skim — doesn't support a good enough experience for us to document this. Specifically, removing a branch causes the selector to move back to the top; there is no way to control the position of the selector.

it's still useful to some, so I don't have plans to remove the feature — IYKYK


I think their newer version may allow this, but that is not usable yet, since the dependencies are all pinned. If anyone wants this feature, engaging with skim (respectfully) over what features are planned, would be welcome

@worktrunk-bot can we close that PR and instead open something that clarifies the current state / why it's not documented.

max-sixty avatar Apr 01 '26 22:04 max-sixty

Done — #1869 was already closed, and I've opened #1881 to track why Alt-r is intentionally undocumented (skim cursor-reset limitation, link to #1695, what would unblock documenting it).

worktrunk-bot avatar Apr 01 '26 22:04 worktrunk-bot