Skip to content

Support remote branch listing and tracked checkout from branch picker#126

Merged
juliusmarminge merged 7 commits intomainfrom
codething/deb940ee
Mar 1, 2026
Merged

Support remote branch listing and tracked checkout from branch picker#126
juliusmarminge merged 7 commits intomainfrom
codething/deb940ee

Conversation

@juliusmarminge
Copy link
Copy Markdown
Member

@juliusmarminge juliusmarminge commented Mar 1, 2026

Summary

  • Extend server-side branch listing to include refs/remotes alongside local branches.
  • Parse and classify branch rows with isRemote, exclude symbolic refs (for example origin/HEAD -> origin/main), and keep local branches listed before remotes.
  • Update checkout logic to handle remote refs by creating/tracking a local branch when appropriate (git checkout --track <remote>/<branch> fallback flow).
  • Update branch contracts and toolbar UI to surface remote branches, show a remote badge, and set thread state to the derived local branch name after remote checkout.
  • Add integration coverage for mixed local/remote branch ordering and remote-only branch visibility.

Testing

  • apps/server/src/git/Layers/GitCore.test.ts: added integration test validating local-first/remote-last ordering and remote-only branch inclusion.
  • Lint: Not run.
  • Full project test suite: Not run.

Note

Medium Risk
Touches core Git branch listing/checkout behavior and expands the shared GitBranch contract, which can affect branch selection and checkout flows across clients. Adds fallbacks and tests, but edge cases around remotes/tracking and naming could still cause unexpected checkouts or UI state mismatches.

Overview
Extends server-side branch listing to include remote branches alongside locals, filtering out symbolic refs and detached-HEAD pseudo-refs, adding isRemote/remoteName metadata (including remotes with slashes), sorting locals before remotes, and falling back to empty remote data when remote lookups fail.

Updates checkout to better handle remote refs by detecting whether a ref exists locally/remotely, checking out an existing tracking branch when present, using --track when safe, and avoiding silent local-branch checkouts when a remote ref is missing (with a detached fallback when tracking would conflict).

Wires the branch picker UI to display/dedupe remote refs, show a remote badge, and after remote checkout set thread state to the derived/actual checked-out local branch; updates tests on both server and web to cover these remote and edge-case behaviors.

Written by Cursor Bugbot for commit 7a897e9. This will update automatically on new commits. Configure here.

Note

Support remote branch listing and tracked checkout in the branch picker by reworking GitCore.listBranches and GitCore.checkoutBranch in GitCore.ts

Add remote-aware branch listing with isRemote and remoteName, exclude symbolic and detached refs, sort by recency, and implement tracked checkout resolution including remotes with slashes. Update web branch picker to dedupe remote refs with local matches and show a remote badge. Extend git.GitBranch schema to carry remote metadata.

📍Where to Start

Start with GitCore.listBranches and GitCore.checkoutBranch in GitCore.ts.

Macroscope summarized 7a897e9.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 1, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codething/deb940ee

Comment @coderabbitai help to get the list of available commands and usage tips.

Comment thread apps/server/src/git/Layers/GitCore.ts
Comment thread apps/server/src/git/Layers/GitCore.ts Outdated
- Include remote refs in branch listings, ordered after local branches
- Auto-track remote branches on checkout when no local branch exists
- Update branch picker to label remote branches and store local branch name after checkout
Comment thread apps/server/src/git/Layers/GitCore.ts
- Deduplicate branch list by removing remote refs that match an existing local branch
- Move remote-ref local-name derivation into shared BranchToolbar logic
- Add logic tests for remote-ref parsing and deduplication behavior
- Move PR status indicator into the main thread info row
- Keep thread status badge and title grouped for consistent alignment
Comment thread apps/web/src/components/Sidebar.tsx
- add `remoteName` to git branch contract metadata
- resolve remote refs using full remote names (including slashes)
- avoid fallback to wrong local checkout when remote ref is missing
- update branch toolbar logic/tests to map and dedupe remote branches correctly
Comment thread apps/server/src/git/Layers/GitCore.ts Outdated
Comment thread apps/server/src/git/Layers/GitCore.ts
Comment thread apps/web/src/components/BranchToolbar.logic.ts
- ignore branch lines starting with `(` when parsing `git branch` output
- add integration test to verify detached HEAD does not appear as a branch
- Fall back to empty remote branch and remote name data when git remote queries fail
- Log warnings instead of failing `listBranches`
- Add integration test covering remote lookup failure fallback
- fall back to plain checkout (detached HEAD) when `--track` would clash with an existing local branch
- add GitCore coverage for the conflict fallback path
- simplify branch-name derivation in BranchToolbar to consistently strip the first remote segment
@juliusmarminge juliusmarminge merged commit 1af43db into main Mar 1, 2026
4 checks passed
Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is ON, but it could not run because the spend limit has been reached. To enable Bugbot Autofix, raise your spend limit in the Cursor dashboard.

return branchName;
}
return branchName.slice(firstSeparatorIndex + 1);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate function with divergent return type semantics

Low Severity

deriveLocalBranchNameFromRemoteRef exists in both GitCore.ts and BranchToolbar.logic.ts with the same name and core logic but different return-type contracts: the server version returns string | null for malformed input, while the client version returns the original branchName. This divergence creates a maintenance trap — a future developer modifying one copy may not realize the other exists or behaves differently for edge cases.

Additional Locations (1)

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant