Convert placement cards to real checkouts after branch placement - #28
Merged
Conversation
Opening a new-worktree placement card created the worktree and launched into it, but left the card labelled "new worktree". A second tool click (e.g. open a Console, then open Rider) therefore ran `git worktree add` for the same branch again, which git rejects — the branch is now checked out in the worktree the first click created — surfacing as "git worktree add failed". Placing a branch now converts the card in place to the real checkout it became: a created worktree becomes a deletable Worktree target, a switched clone becomes a MainClone target, with solutions re-globbed from the tree that now exists. Subsequent opens launch that folder directly. The conversion happens as soon as the placement succeeds (before the launch, which may fail to locate the editor), so the card can never fall back into trying to place the branch a second time. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QSKHusKNU5w1zMeWfj2wjc
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
Fixes a regression where opening a second tool on a freshly placed branch would fail. When a user opened a new worktree placement card with one editor (e.g., Console) and then tried to open it again with another editor (e.g., Rider), the second click would attempt to re-add the same branch to git, which would fail because the branch was already checked out in the worktree created by the first click.
Changes
MainWindow.axaml.cs: After successfully creating a worktree or switching the main clone to a branch, immediately convert the placement card to a real checkout card via the new
MaterialisePlacementAsync()method. This ensures subsequent tool clicks open the existing folder instead of attempting to place the branch again.MainWindowViewModel.cs: Added
ReplaceTarget()method to swap a placement card for the real checkout it became. ANewWorktreecard becomes aWorktreecard (now deletable), and aSwitchMainClonecard becomes aMainClonecard. Selection follows the swapped card to keep the just-opened target current.Tests: Added comprehensive regression test
Opening_a_second_tool_reuses_the_created_worktree_instead_of_re_adding_it()that verifies:Implementation Details
The
MaterialisePlacementAsync()method:DiscoveredTargetwith the correctKindand updated metadatahttps://claude.ai/code/session_01QSKHusKNU5w1zMeWfj2wjc