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.
ApprovabilityVerdict: Needs human review This PR introduces a new feature with new UI components (GitSyncControl), new RPC endpoints (fetch/push/sync), and new git operations including rebase handling for diverged branches. New user-facing features with this scope warrant human review. You can customize Macroscope's approvability policy. Learn more. |
- Fetch toast no longer claims "Up to date" — vcs.fetch only updates remote-tracking refs, so the branch may now be ahead/behind. Title is now "Fetched" with an accurate description; the badge reflects the real state. - Branch picker is disabled while a sync action (fetch/push/pull/sync) is in flight on the same cwd, preventing a checkout/create-ref from racing the git operation. Shares SYNC_BUSY_ACTIONS with GitSyncControl. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

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 fetch/push/sync and rebase-on-sync mutate remotes and working trees; scope is bounded by existing orchestration operate auth and no force-push, but diverged-history handling is user-visible and operationally sensitive.
Overview
Adds a VS Code-style sync UI beside the branch picker: ahead/behind badges, one-click publish/pull/push/sync, a always-on Fetch control, and a diverged-branch toast with Rebase & sync. The branch combobox is disabled while fetch/push/pull/sync (or stacked git actions) run on the same cwd.
Backend: New
vcs.fetch,vcs.push, andvcs.syncRPCs with contract types andGitDivergedError.GitVcsDriverCoreimplementsfetchCurrentBranchandsyncCurrentBranch(fetch, ff-pull, push/publish, optional rebase with abort-on-conflict);GitWorkflowServiceexposes fetch/push/sync to WS handlers, with standalone push mapped from the same driver path as stacked actions.Client:
wsRpcClient, VCS action manager, and hooks for fetch/push/sync;RPC_REQUIRED_SCOPEmoved torpcRequiredScope.tswith tests that every served RPC has a scope (including the three new operate-scoped methods).Tests: Real-git coverage for sync paths; mocks updated for new VCS RPCs.
Reviewed by Cursor Bugbot for commit 3ef1547. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add VS Code-style branch sync controls with fetch, push, and sync RPCs
GitSyncControltoolbar component that displays ahead/behind/publish state and exposes fetch, pull, push, and sync actions similar to VS Code's branch sync UI.fetchCurrentBranch,pushCurrentBranch, andsyncCurrentBranchin the VCS driver and service layers; sync performs fetch + fast-forward pull/push, publishes new branches, and optionally rebases on divergence.vcs.fetch,vcs.push, andvcs.syncWebSocket RPCs with type-safe schemas including aGitDivergedErrorfor diverged branches in fast-forward mode.BranchToolbarBranchSelectoris disabled while a sync action is running to prevent conflicting operations.GitDivergedErrorrather than silently failing; rebase must be explicitly requested.Macroscope summarized 3ef1547.