Repository navigation
feat(ui): allow deleting locked worktrees - #16
Merged
Merged
Conversation
Locked worktrees can now be marked and deleted via the same phrase-typed force-delete confirmation used for unmerged branches and dirty worktrees, instead of being rejected outright. git requires --force twice to remove a locked worktree, so deleteWorktreesWith now passes --force --force for locked items.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
The user hit a real 'fatal: contains modified or untracked files, use --force to delete it' error from wt when deleting worktrees; that turned out to be a stale binary (an earlier fix already handled dirty worktrees on branch essa), so we rebuilt/reinstalled it. As a follow-up, the user then explicitly asked to add the ability to delete LOCKED worktrees too, which was previously hard-rejected in code (internal/action/action.go had an early 'cannot delete a locked worktree' error, and internal/ui/ui.go excluded locked worktrees from being marked at all).
We deliberately reused the existing dirty/unmerged force-delete confirmation flow rather than adding a new one: locked worktrees can now be marked (toggleMarked no longer excludes Locked, only IsCurrent), and a marked batch containing a locked worktree routes through the same phrase-typed 'delete' confirmation (modeConfirmForceDelete) already used for unmerged branches and dirty worktrees, via a new hasLockedWorktree() check alongside hasUnmergedBranch/hasDirtyWorktree. The confirmation screen lists locked worktrees in their own section, separate from the unmerged/dirty sections.
On the git side, we found (verified by hand against a real locked+dirty worktree) that git worktree remove needs --force twice to remove a locked worktree - a single --force only overrides dirty state, not a lock (git's own docs: 'To remove a locked worktree, specify --force twice'). So deleteWorktreesWith in action.go now branches: Locked items get ["--force", "--force"], Dirty-only items keep a single ["--force"], and when both are set only the double-force is used (locked implies force twice covers dirty too) - we did not stack three force flags.
Updated the README's mark/delete section and the architecture paragraph to describe this, and updated/added tests in internal/action/action_test.go and internal/ui/ui_test.go, replacing the old 'rejects locked worktree' tests with tests asserting the new force-delete-with-double---force behavior, and added ui tests mirroring the existing dirty-worktree confirmation tests. All committed on this new branch delete-locked-worktrees (branched off essa, since essa had picked up uncommitted work and is the default branch). go build/vet/gofmt/test all pass.
What Changed
git worktree remove --force --force, while retaining a single--forcefor dirty-only worktrees.Risk Assessment
✅ Low: The change is well-bounded and consistently implements locked-worktree marking, typed confirmation, separate display, and Git's required double-force removal.
Testing
The relevant package tests and full Go suite passed, and a real compiled CLI successfully marked, warned about, phrase-confirmed, and removed a locked-and-dirty Git worktree end-to-end; post-delete Git and filesystem checks confirmed both its worktree and branch were gone.
Evidence: Actual CLI force-delete confirmation screen
Evidence: Actual CLI deletion result
Evidence: Post-deletion Git and filesystem state
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
go test ./internal/action ./internal/uigo test ./...Built./cmd/wt, created a real secondary worktree, added an untracked file, and locked it usinggit worktree lock --reason 'active agent session'Ran the compiledwt --no-colorinteractively, selectedlocked-demo, pressedc,D, and Enter, and verified the separate dirty and locked warnings plus the requireddeletephrase promptTypeddeleteand pressed Enter, then verifiedgit worktree list --porcelain,git branch --list locked-demo, and the filesystem: the locked-and-dirty worktree path and branch were removedgit status --shortin the validation worktree confirmed testing left no transient repository artifacts✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.