Add delete worktree action to branch-folder chooser#24
Merged
Conversation
When branch-only mode locates a linked worktree, the "Open from branch folder" dialog now offers a "Delete worktree & branch" button that removes the linked worktree, deletes the local branch, and deletes the branch on origin when present. The git steps run from the clone's main tree so the worktree is dropped cleanly; a dirty worktree is force-removed after a warning, and a failed remote delete leaves the completed local cleanup in place and reports it. A confirmation dialog spells out the worktree path, local branch, and origin state, with explicit data-loss warnings for uncommitted changes and for commits that exist only on the branch (unpushed/unmerged work that `git branch -D` would orphan). Safety: - Offered only for a linked worktree (main tree can't be worktree-removed), detected via git-dir comparison so it stays correct under symlinked roots. - Default branches (main/master) are never offered. - The destructive button is out of the tab order; Cancel/Enter/Esc back out. - Reachable even when there's nothing to open (folder-only editor or a worktree with no solution file). Covered by GitService, dialog-widget, and end-to-end tests. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019JuVApu68rjnvBUEY5NCBV
The confirmation dialog now shows a checkbox for each present target — the worktree, its local branch, and the branch on origin — each ticked by default. Unticking one skips its deletion, so you can (for example) drop only the remote branch or remove the worktree while keeping its branches. Because a checked-out branch can't be deleted, keeping the worktree disables (and clears) the local-branch checkbox. Delete is disabled when nothing is selected, and the deletion carries out exactly the ticked targets, reporting precisely what it removed. Docs (Features, CHANGELOG, screenshot gallery) updated. Adds UI tests for the checkbox behaviour and a screenshot test that captures the deletion dialog and the branch-folder chooser (with its delete button) in both light and dark themes; the captured PNGs are committed to the gallery. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019JuVApu68rjnvBUEY5NCBV
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.
Summary
Adds a Delete worktree & branch action to the branch-folder chooser dialog in branch-only mode. When a linked worktree is located on a branch, users can now delete the worktree, its local branch, and the corresponding remote branch (if it exists) directly from the UI.
Key Changes
New deletion workflow: Added
DeleteWorktreeDialogconfirmation dialog that warns about uncommitted changes, orphaned commits, and remote branch status before proceeding with deletion.Git service enhancements: Extended
GitServicewith new methods:IsLinkedWorktreeAsync()— detects linked worktrees vs. main treeWorktreeRemoveAsync()— removes a worktree (with force option for dirty trees)DeleteLocalBranchAsync()/DeleteRemoteBranchAsync()— branch deletionCountOrphanedCommitsAsync()— counts commits unique to a branchOpener service integration: Added
BuildWorktreeDeletionAsync()andDeleteWorktreeAsync()to orchestrate the full deletion flow, gathering deletion metadata and executing the git operations.UI updates:
ChooserDialogwith optional delete button (shown only when a delete label is provided)MainWindow.ChooseOpenTargetAsync()to detect linked worktrees and offer delete action for non-default branchesDeleteWorktreeDialogwith visual warnings for dirty worktrees and orphaned commitsChooserViewModelto support the delete buttonSafety guards:
Test coverage: Comprehensive end-to-end tests covering:
Implementation Details
git rev-listto identify unpushed, unmerged work that would be lost.https://claude.ai/code/session_019JuVApu68rjnvBUEY5NCBV