feat(git): VS Code-style branch sync control#3075
Conversation
Adds an ahead/behind indicator with one-click fetch/pull/push/publish/sync
next to the branch in the composer toolbar, plus the standalone RPCs behind it.
- contracts: vcs.fetch / vcs.push / vcs.sync RPCs + GitDivergedError
- server: GitVcsDriverCore.fetchCurrentBranch + syncCurrentBranch (fast-forward
pull / push / publish chosen by ahead-behind; diverged history -> typed
GitDivergedError unless mode:"rebase", which runs pull --rebase and aborts
cleanly on conflict). Standalone push reuses the stacked-action driver call so
upstream + push-remote (fork) resolution stays shared.
- client: wsRpcClient vcs.{fetch,push,sync}, action-manager ops, action hooks
- web: GitSyncControl component wired into the branch toolbar
- tests: real-git integration tests for ahead/behind/diverged/rebase/publish/fetch
Also extracts RPC_REQUIRED_SCOPE into its own module with a completeness test
asserting every WsRpcGroup method declares an auth scope, so a missing scope
fails in tests instead of at runtime.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
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 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit c365aaa. Configure here.
| loading: { title: "Fetching..." }, | ||
| success: () => ({ title: "Up to date", description: "Refreshed remote-tracking refs." }), | ||
| error: (err) => ({ title: "Fetch failed", description: errorMessage(err) }), | ||
| }); |
There was a problem hiding this comment.
Fetch toast claims up to date
Medium Severity
The fetch action’s success toast always uses the title “Up to date”, even though vcs.fetch only refreshes remote-tracking refs and does not change the local branch. After a fetch, ahead/behind counts may still show the branch is behind or ahead, so the toast text contradicts the sync control state.
Reviewed by Cursor Bugbot for commit c365aaa. Configure here.
| environmentId={environmentId} | ||
| cwd={branchCwd} | ||
| status={branchStatusQuery.data} | ||
| /> |
There was a problem hiding this comment.
Branch picker ignores sync busy
Medium Severity
GitSyncControl disables its buttons while fetch, push, pull, or sync runs via useSourceControlActionRunning, but the adjacent branch combobox only respects isBranchActionPending from branch switch transitions. Users can checkout or create refs while a toolbar sync operation is still in flight on the same cwd.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit c365aaa. Configure here.
ApprovabilityVerdict: Needs human review This PR introduces a new user-facing feature (VS Code-style branch sync control) with new UI components, new RPC endpoints, and new backend git operations. New features introducing user-facing behavior warrant human review. Additionally, there are unresolved review comments about misleading toast text and potential race conditions. You can customize Macroscope's approvability policy. Learn more. |


What
Adds a VS Code-style ahead/behind sync control next to the branch in the composer toolbar, plus the standalone git RPCs behind it. Previously there was no visible ahead/behind indicator, no standalone fetch, and no one-click sync — push only existed bundled inside the stacked action.
The control is state-driven:
✓+ Fetch↑N↓N--ff-only)⟳ ↓N ↑MPublishA standalone Fetch button is always present to force-refresh the counts (the server already auto-fetches on a 30s poller; this just bypasses the wait).
How
vcs.fetch/vcs.push/vcs.syncRPCs + a typedGitDivergedError.GitVcsDriverCore.fetchCurrentBranch+syncCurrentBranch(fast-forward pull / push / publish chosen by ahead-behind; diverged history →GitDivergedErrorunlessmode:"rebase", which runsgit pull --rebaseand aborts cleanly on conflict so the tree is never left mid-rebase). The standalone push reuses the exact driver call the stacked action uses, so upstream + push-remote resolution (fork-aware) stays shared. Never force-pushes.wsRpcClientvcs.{fetch,push,sync}, action-manager operations, anduseVcs{Fetch,Push,Sync}Actionhooks.GitSyncControlwired into the branch toolbar (reuses the existing status subscription — no extra WS traffic).Hardening
Extracts
RPC_REQUIRED_SCOPEinto its own module with a completeness test asserting everyWsRpcGroupmethod declares an auth scope — this gate was previously runtime-only (a missing scope threw on a live call, not in CI).Tests
🤖 Generated with Claude Code
Note
Medium Risk
New git mutating RPCs run real fetch/pull/push/rebase in user workspaces; behavior is covered by integration tests and avoids force-push, but rebase-on-confirm still changes history on the current branch.
Overview
Adds a VS Code-style ahead/behind control beside the composer branch picker: publish, pull, push, one-click sync, and a manual Fetch, driven by existing VCS status (no extra subscription).
Contracts & server: New
vcs.fetch,vcs.push, andvcs.syncWebSocket RPCs plusGitDivergedError.GitVcsDriverCoreimplementsfetchCurrentBranch(targeted remote-tracking refresh) andsyncCurrentBranch(fetch then ff-pull / push / publish by ahead-behind; diverged history errors unlessmode: "rebase", with rebase aborted on conflict). Standalone push maps through the same driver path as stacked actions. Handlers refresh git status after each call.Client:
wsRpcClient, VCS action manager, anduseVcs{Fetch,Push,Sync}Actionhooks;GitActionsControltreats fetch/push/sync as busy operations.Hardening:
RPC_REQUIRED_SCOPEmoves out ofws.tsintorpcRequiredScope.tswith a test that everyWsRpcGroupmethod has a scope (including the new VCS RPCs under orchestration operate).Tests: Real-git integration coverage for sync paths; mocks updated across client/web tests.
Reviewed by Cursor Bugbot for commit c365aaa. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add VS Code-style branch sync control with fetch, push, and sync RPC endpoints
GitSyncControlto the branch toolbar with ahead/behind indicators and buttons for Publish, Pull, Push, Sync, and Fetch, mirroring VS Code's branch sync UX.fetchCurrentBranch,pushCurrentBranch, andsyncCurrentBranchinGitVcsDriverCore.tsandGitWorkflowService.ts, covering publish, fast-forward pull, push, and rebase+push flows.vcs.fetch,vcs.push,vcs.sync) with contracts defined inpackages/contracts/src/git.tsandrpc.ts.GitDivergedErrorfor diverged branches; the sync UI surfaces this with a secondary "Rebase & sync" action.rpcRequiredScope.tsmodule with completeness tests.Macroscope summarized c365aaa.