Skip to content

fix: improve wt step prune reliability and UX - #1234

Merged
max-sixty merged 4 commits into
mainfrom
prune
Feb 28, 2026
Merged

max-sixty merged 4 commits into
mainfrom
prune

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Summary

  • Mark wt step prune as [experimental]
  • Remove candidates inline as they're discovered instead of scan-then-remove — each worktree is pruned immediately, with the current worktree deferred to last
  • Handle per-candidate errors gracefully (warn and skip) rather than aborting the entire prune — dirty worktrees are caught by the same ensure_clean check that wt remove uses
  • Dry-run lists candidates with ○ lines; actual removal only shows ◎ Removing output
  • Drop redundant help text ("uncommitted changes are skipped" is inherited from wt remove; "Note: experimental" is redundant with [experimental] tag)
  • Add test for dirty worktree handling

Test plan

  • All 2740 tests pass (wt hook pre-merge --yes)
  • Snapshot tests reviewed for all prune scenarios (dry-run, multiple, dirty, locked, stale, orphan branches, current worktree, detached, min-age)
  • Manual test: run wt step prune --dry-run on a repo with merged worktrees

This was written by Claude Code on behalf of @max-sixty

max-sixty and others added 3 commits February 27, 2026 22:43
Mark prune as [experimental]. Print candidates progressively as they're
discovered instead of buffering all output. Handle per-candidate errors
gracefully (warn and skip) rather than aborting the entire prune — dirty
worktrees are now caught by the same ensure_clean check that wt remove
uses.

Co-Authored-By: Claude <[email protected]>
# Conflicts:
#	src/commands/step_commands.rs
#	tests/integration_tests/step_prune.rs
Remove candidates as they're discovered instead of collecting then
removing in a second pass. Approve hooks upfront, defer current worktree
to last. Candidate listing only appears in dry-run mode.

Drop "Worktrees with uncommitted changes are skipped" (inherited from
wt remove) and "Note: experimental" (redundant with [experimental] tag)
from help text.

Co-Authored-By: Claude <[email protected]>

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor suggestion on prune_summary — otherwise this looks good.

Comment thread src/commands/step_commands.rs Resolved
Remove unnecessary Borrow bound — both call sites pass &[Candidate] directly.

Co-Authored-By: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants