Repository navigation
feat(ui): confirm deletion of unmerged branches - #14
Merged
AgileIndustrialComplex merged 4 commits intoJul 19, 2026
Merged
Conversation
Replace the full sentence confirmation with a single word ("delete") per
user request - still requires deliberate typed input before force-deleting
an unmerged branch, just less verbose.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
AgileIndustrialComplex
force-pushed
the
claude/unmerged-branch-delete-confirm-0c9f13
branch
from
July 19, 2026 16:12
cf95537 to
5bfd01b
Compare
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
Add a second confirmation step before deleting a branch that has unmerged changes, per a user-provided spec. wt's existing mark-then-D-then-Enter TUI delete flow uses git branch -d (non-force), which silently refuses branches not fully merged - so those branches previously had no path to deletion at all. Design: gitdata.Collect now runs 'git branch --format=%(refname:short) --merged' (format must precede --merged for this git version, discovered via manual testing) and sets a new Item.Unmerged flag per branch. If any branch in the confirmed marked set is unmerged, the picker advances to a new modeConfirmForceDelete screen instead of deleting immediately; it lists only the unmerged branches and requires the user to type an exact confirmation phrase and press Enter before proceeding (Esc/Ctrl-C cancels the whole batch, including any merged branches marked alongside it, without touching Git state). Once confirmed, action.DeleteWorktrees deletes the whole batch in one pass: git branch -d for merged branches (unchanged from before), git branch -D (force) only for the Unmerged ones. Detached-HEAD worktree entries are excluded from the unmerged check since they have no associated branch. The confirmation phrase was originally specified by the user as the literal sentence 'Yes, I want to remove the branch that has changes that have been unmerged.' but the user later asked to simplify it, so it was changed to just 'delete' (single word, still case-sensitive typed confirmation) - this was a deliberate, explicit simplification request, not an oversight, so the shorter phrase is intentional. Separately, the user asked about being able to delete/mark branches with no worktree; investigation showed that capability was already fixed in a prior commit (5836c3a, already on the default branch 'essa') by removing a HasWorktree() restriction from toggleMarked in internal/ui/ui.go - no code change was needed for that, only rebuilding/reinstalling the local wt binary from current source, so there is no corresponding diff for it on this branch. New/updated tests cover: merge-status detection in gitdata (unit tests with a fakeRunner keyed by full git invocation, since two different 'git branch' subcommands are now issued), the new confirm-phrase UI mode (wrong phrase, exact phrase, backspace editing, Esc/Ctrl-C cancel preserving marks, mixed merged+unmerged batches), the force-delete flag selection in action.DeleteWorktrees, and a real end-to-end integration test via teatest that drives mark -> D -> Enter -> typed phrase -> Enter against a real git repo and confirms git branch -D actually removes an unmerged branch. SPEC.md and README.md were updated to document the new screen and, later, the simplified phrase.
What Changed
HEAD.delete;EscorCtrl-Ccancels the entire batch without losing marks.git branch -D, retaingit branch -dfor merged branches, and update tests and documentation for the new flow.Risk Assessment
✅ Low: The change is well-bounded, the previously identified unborn-repository regression is fixed, and the required Esc/Ctrl-C cancellation coverage is now present without introducing new material risks.
Testing
All focused and repository-wide tests passed. A real terminal session demonstrated the second unmerged-change warning, case-sensitive
deleteprompt, force deletion, and resulting Git state. Because this is a terminal TUI rather than a graphical/browser UI, reviewer-visible evidence was captured as a rendered terminal transcript instead of a screenshot.Evidence: Rendered terminal session showing the warning, exact confirmation phrase, and deletion
Evidence: Post-deletion Git state showing wip absent and main retained
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 1 issue found → auto-fixed (2) ✅
internal/gitdata/gitdata.go:105- The new unconditionalgit branch --mergedquery fails in a valid repository with an unborn HEAD (for example, immediately aftergit init, Git reports thatHEADis not a valid object). PreviouslyCollectcould finish in that state, but it now returns the command error and the picker cannot start. Skip the merged query whenbranchesis empty (or explicitly handle the unborn-HEAD error) so adding merge-status detection does not break empty repositories.🔧 Fix: Handle branch collection in unborn repositories
1 warning still open:
internal/ui/ui_test.go:437- The acceptance criterion says the new UI tests cover “Esc/Ctrl-C cancel preserving marks,” but this test exercises only Esc; there is no force-confirmation test sendingtea.KeyCtrlC. Please add Ctrl-C to this test (for example, table-drive both keys) so the required cancellation behavior is explicitly covered.🔧 Fix: Cover Ctrl-C force-delete cancellation
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
go test ./internal/gitdata ./internal/ui ./internal/actiongo test . -run 'TestIntegrationDelete(UnmergedBranchRequiresForcePhrase|MarkedBranchWithoutWorktree)$' -vgo test ./...Builtcmd/wt, created a real divergent Git repository, drovej → c → D → Enter → delete → Enterthrough the actual TUI in a PTY, and verified the unmergedwipbranch was removed whilemainremained✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.