Fix worktree branch selection context#2868
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit daf456a. Configure here.
ApprovabilityVerdict: Needs human review This PR changes runtime behavior for worktree branch selection - removing the logic that switched to the main repo when selecting a default branch from a worktree. While scoped and well-tested, this behavioral change in a non-trivial feature area warrants human review. You can customize Macroscope's approvability policy. Learn more. |

Summary
Verification
Note
Medium Risk
Changes thread/workspace targeting for branch switches in worktree mode; wrong paths could check out the wrong directory, but scope is limited to BranchToolbar logic with updated unit tests.
Overview
Branch picker checkout now stays in the active thread worktree unless the selected ref is already checked out somewhere else (including jumping back to the main repo when that ref’s
worktreePathis the project root).resolveBranchSelectionTargetno longer usesisDefaultonVcsRef. For refs with no existing worktree, it always uses the current worktree path (or mainactiveProjectCwdwhen none) for bothcheckoutCwdandnextWorktreePath, instead of clearing the worktree and checking out the default branch in the main repo. Logic tests were updated to match.Reviewed by Cursor Bugbot for commit f76837e. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix
resolveBranchSelectionTargetto keep checkout in current worktree when selected ref has no existing worktreePreviously,
resolveBranchSelectionTargetin BranchToolbar.logic.ts would switch to the main repo when the selected ref was a default ref with no existing worktree. Now, when no existing worktree is found for the selected ref, checkout always stays in the active worktree andnextWorktreePathis set to the active worktree path. TheisDefaultfield is removed from therefNameinput type as it is no longer needed.Macroscope summarized f76837e.