Skip to content

feat(git): VS Code-style branch sync control#3075

Open
TheIcarusWings wants to merge 2 commits into
pingdotgg:mainfrom
TheIcarusWings:t3code/git-sync-control
Open

feat(git): VS Code-style branch sync control#3075
TheIcarusWings wants to merge 2 commits into
pingdotgg:mainfrom
TheIcarusWings:t3code/git-sync-control

Conversation

@TheIcarusWings

@TheIcarusWings TheIcarusWings commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

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:

State Shows Action
Up to date + Fetch Fetch
Ahead ↑N Push
Behind ↓N Pull (--ff-only)
Diverged ⟳ ↓N ↑M Sync → clear "diverged" toast + Rebase & sync
No upstream Publish Push + set upstream

A 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

  • contracts: vcs.fetch / vcs.push / vcs.sync RPCs + a typed GitDivergedError.
  • server: GitVcsDriverCore.fetchCurrentBranch + syncCurrentBranch (fast-forward pull / push / publish chosen by ahead-behind; diverged history → GitDivergedError unless mode:"rebase", which runs git pull --rebase and 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.
  • client: wsRpcClient vcs.{fetch,push,sync}, action-manager operations, and useVcs{Fetch,Push,Sync}Action hooks.
  • web: new GitSyncControl wired into the branch toolbar (reuses the existing status subscription — no extra WS traffic).

Hardening

Extracts RPC_REQUIRED_SCOPE into its own module with a completeness test asserting every WsRpcGroup method declares an auth scope — this gate was previously runtime-only (a missing scope threw on a live call, not in CI).

Tests

  • Real-git integration tests for ahead→push, behind→ff-pull, diverged→typed error (clean tree), rebase→push, publish→set-upstream, and fetch.
  • Updated the affected client/web RPC mocks.
  • All 5 UI states manually verified end-to-end in the running app against a scratch repo + bare remote + teammate clone (linear history confirmed after rebase; branch + upstream confirmed after publish).

🤖 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, and vcs.sync RPCs with contract types and GitDivergedError. GitVcsDriverCore implements fetchCurrentBranch and syncCurrentBranch (fetch, ff-pull, push/publish, optional rebase with abort-on-conflict); GitWorkflowService exposes 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_SCOPE moved to rpcRequiredScope.ts with 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

  • Adds a GitSyncControl toolbar component that displays ahead/behind/publish state and exposes fetch, pull, push, and sync actions similar to VS Code's branch sync UI.
  • Implements fetchCurrentBranch, pushCurrentBranch, and syncCurrentBranch in the VCS driver and service layers; sync performs fetch + fast-forward pull/push, publishes new branches, and optionally rebases on divergence.
  • Adds vcs.fetch, vcs.push, and vcs.sync WebSocket RPCs with type-safe schemas including a GitDivergedError for diverged branches in fast-forward mode.
  • The branch selector in BranchToolbarBranchSelector is disabled while a sync action is running to prevent conflicting operations.
  • Risk: diverged branches in default (fast-forward) mode now surface a GitDivergedError rather than silently failing; rebase must be explicitly requested.

Macroscope summarized 3ef1547.

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>
@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown

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.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 7dad0a05-7acc-45cb-a72f-92b81090cd3c

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

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.

❤️ Share

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

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:XL 500-999 changed lines (additions + deletions). labels Jun 13, 2026

@cursor cursor Bot left a comment

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.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ 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.

Comment thread apps/web/src/components/GitSyncControl.tsx
Comment thread apps/web/src/components/BranchToolbarBranchSelector.tsx
@macroscopeapp

macroscopeapp Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: 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>
@juliusmarminge

Copy link
Copy Markdown
Member

please add screenshots and/or videos

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

Labels

size:XL 500-999 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants