Skip to content
Source
Sign inSign up
pingdotgg/t3code

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

Mergedjuliusmarmingemerged 7 commits intomain fromcodething/deb940eemerged by juliusmarminge View on GitHub

juliusmarmingecommented

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](https://cursor.com/dashboard?tab=bugbot) for commit 7a897e9b1fb1620371417650317f6a8c96972b6d. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).

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.
    1. 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.
    2. apps/web/src/components/Sidebar.tsx line 822Resolvedby juliusmarminge
    3. juliusmarminge merged this1af43db

    4. juliusmarminge closed this

    5. 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](https://www.cursor.com/dashboard?tab=spending).
      @@ -8,3 +8,10 @@
      88 queryBranches: ReadonlyArray<GitBranch> | undefined;
      99 }
      1010
      11+export function deriveLocalBranchNameFromRemoteRef(branchName: string): string {
      12+ const firstSeparatorIndex = branchName.indexOf("/");
      13+ if (firstSeparatorIndex <= 0 || firstSeparatorIndex === branchName.length - 1) {
      14+ return branchName;
      15+ }
      16+ return branchName.slice(firstSeparatorIndex + 1);
      17+}

      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 in to join this conversation.