Fix worktree branch selector default and loading behavior#161
Merged
juliusmarminge merged 4 commits intomainfrom Mar 3, 2026
Merged
Fix worktree branch selector default and loading behavior#161juliusmarminge merged 4 commits intomainfrom
juliusmarminge merged 4 commits intomainfrom
Conversation
- Default new worktree branch selection to the current checked-out branch when unset - Extract branch value resolution into shared logic with tests - Stabilize virtualized branch list scroll/measurement to avoid loading glitches
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
- Move branch combobox logic into `BranchToolbarBranchSelector` to simplify `BranchToolbar` - Re-fetch git branches when opening the selector so options are current - Preserve draft env mode correctly when switching between main and worktree branches
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
resolveBranchToolbarValueand add focused unit tests for the key branch-selection scenarios.setThreadBranchinto a memoized callback and auto-persist default branch metadata for new worktree threads.Testing
apps/web/src/components/BranchToolbar.logic.test.tscovering:worktreemode with no active worktree path and no explicit branch defaults tocurrentGitBranch.Note
Medium Risk
Medium risk: refactors
BranchToolbarbranch/env-mode logic and persistence, which could affect which branch/worktree a thread targets and when sessions are stopped or metadata is updated.Overview
Fixes branch selection semantics in the toolbar, especially for new worktree flow: the displayed/used base branch now defaults to the current git branch when none is explicitly chosen, preserves an explicitly selected base branch, and otherwise shows the actually checked-out branch.
Refactors the UI by extracting the combobox/virtualized branch picker into
BranchToolbarBranchSelector, adds helpers (resolveEffectiveEnvMode,resolveDraftEnvModeAfterBranchChange,resolveBranchToolbarValue) with new unit tests, and tweaks loading/virtualization behavior (invalidate only the branches query on open, stabilize scroll element refs, and re-measure on open/content changes). It also auto-persists the default base branch for new-worktree drafts and updates draft env-mode after branch/worktree changes.Written by Cursor Bugbot for commit 1bf4fcc. This will update automatically on new commits. Configure here.
Note
Fix BranchToolbar default branch selection and loading by adding
apps/web/src/components/BranchToolbarBranchSelector.tsxand usingapps/web/src/components/BranchToolbar.logic.ts::resolveDraftEnvModeAfterBranchChange,resolveEffectiveEnvMode, andresolveBranchToolbarValueIntroduce utilities to resolve env mode and toolbar branch value, refactor
BranchToolbarto delegate selection toBranchToolbarBranchSelector, and add tests for env mode and branch value resolution.📍Where to Start
Start with
resolveEffectiveEnvMode,resolveDraftEnvModeAfterBranchChange, andresolveBranchToolbarValuein BranchToolbar.logic.ts, then reviewsetThreadBranchin BranchToolbar.tsx, and the selection flow in BranchToolbarBranchSelector.tsx.Macroscope summarized 1bf4fcc.