Paginate git branch listing and search results#1691
Conversation
- add cursors, limits, and totals to branch RPCs - switch branch picker to infinite search with remote/local dedupe - update tests and fixtures for paginated branch results
|
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)
Comment |
ApprovabilityVerdict: Needs human review This PR adds pagination and search capabilities to git branch listing, modifies API contracts (GitListBranchesResult, GitStatusResult, GitListBranchesInput), and changes frontend data fetching patterns from regular queries to infinite queries. The scope of changes across contracts, server, and client layers with runtime behavior modifications warrants human review. You can customize Macroscope's approvability policy. Learn more. |
Replace the useEffect that manually seeded the infinite query cache from branchesOverviewQuery data (via setQueryData + createGitBranchSearchInfiniteData) with a prefetchInfiniteQuery call that directly fetches the first page. This is more idiomatic TanStack Query usage and avoids the indirection of copying data between separate query caches. - Remove createGitBranchSearchInfiniteData helper (no longer needed) - Remove InfiniteData/GitListBranchesResult imports from gitReactQuery.ts - Update tests to inline the infinite data construction - Remove the createGitBranchSearchInfiniteData test Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
…anchSelector The overview query (useQuery(gitBranchesQueryOptions)) is no longer needed in this component now that the infinite search query is prefetched on mount. - Use prefetched infinite search data for the current-branch fallback - Use branchesSearchQuery.isPending for the trigger disabled state - Remove gitBranchesQueryOptions import (still used by other components) Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 3 total unresolved issues (including 2 from previous reviews).
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Unused production re-export of deduplication function
- Removed the dead re-export of dedupeRemoteBranchesWithLocalMatches from BranchToolbar.logic.ts and updated the test file to import directly from @t3tools/shared/git.
Or push these changes by commenting:
@cursor push e50df67294
Preview (e50df67294)
diff --git a/apps/web/src/components/BranchToolbar.logic.test.ts b/apps/web/src/components/BranchToolbar.logic.test.ts
--- a/apps/web/src/components/BranchToolbar.logic.test.ts
+++ b/apps/web/src/components/BranchToolbar.logic.test.ts
@@ -1,7 +1,7 @@
import type { GitBranch } from "@t3tools/contracts";
import { describe, expect, it } from "vitest";
+import { dedupeRemoteBranchesWithLocalMatches } from "@t3tools/shared/git";
import {
- dedupeRemoteBranchesWithLocalMatches,
deriveLocalBranchNameFromRemoteRef,
resolveBranchSelectionTarget,
resolveDraftEnvModeAfterBranchChange,
diff --git a/apps/web/src/components/BranchToolbar.logic.ts b/apps/web/src/components/BranchToolbar.logic.ts
--- a/apps/web/src/components/BranchToolbar.logic.ts
+++ b/apps/web/src/components/BranchToolbar.logic.ts
@@ -1,9 +1,6 @@
import type { GitBranch } from "@t3tools/contracts";
import { Schema } from "effect";
-export {
- dedupeRemoteBranchesWithLocalMatches,
- deriveLocalBranchNameFromRemoteRef,
-} from "@t3tools/shared/git";
+export { deriveLocalBranchNameFromRemoteRef } from "@t3tools/shared/git";
export const EnvMode = Schema.Literals(["local", "worktree"]);
export type EnvMode = typeof EnvMode.Type;You can send follow-ups to this agent here.
- detect non-repos cleanly - derive default branch from status - drop branch overview polling
- Stub `GitCore.statusDetails.defaultRef` in git integration layers
- Load additional branch pages as the list scrolls - Resolve remote branch status from the checkout cwd


Summary
git listBranches, includingnextCursorandtotalCountmetadata.Testing
Note
Medium Risk
Medium risk because it changes the
git listBranchesRPC contract and server-side git status/branch listing behavior, plus updates multiple UI consumers to rely on the new pagination and status flags.Overview
Adds cursor-based pagination and server-side search to
GitCore.listBranches, returningnextCursor/totalCount, applying query filtering before pagination, and dedupingorigin/*remote refs when a matching local branch exists (logic moved to@t3tools/shared/git).Extends
GitStatusResult/statusDetailsto includeisRepo,hasOriginRemote, andisDefaultBranch(derived fromrefs/remotes/origin/HEADwhen available) and updatesGitManagerto gracefully return an explicit non-repo status on “not a git repository” errors.Updates the branch picker to use an infinite query (
gitBranchSearchInfiniteQueryOptions) with prefetch + scroll-to-load pagination and status text, and refactors other UI surfaces to usegit.statusfor repo detection/default-branch checks instead of branch-list queries; tests/fixtures are updated accordingly.Written by Cursor Bugbot for commit 34102bc. This will update automatically on new commits. Configure here.
Note
Paginate git branch listing and add query filtering with deduplication
query,cursor, andlimitparams toGitListBranchesInputand returnsnextCursorandtotalCountin the response, enabling server-side filtered, paginated branch listing.filterBranchesForListQueryandpaginateBrancheshelpers in GitCore.ts; dedupes origin remote refs when a matching local branch exists via a new shareddedupeRemoteBranchesWithLocalMatchesutil.useQuery(gitBranchesQueryOptions)withuseInfiniteQuery(gitBranchSearchInfiniteQueryOptions)in BranchToolbarBranchSelector.tsx, adding scroll-to-load-more and a count/loading footer.GitStatusResultwithisRepo,hasOriginRemote, andisDefaultBranchflags;GitActionsControl,ChatView, andDiffPanelnow derive repo/default-branch state from status instead of the branches query.GitManager.statusnow returns an explicit non-repo status object instead of erroring when the working directory is not a git repository.Macroscope summarized 34102bc.