Skip to content

Add version control command center#3177

Open
Quicksaver wants to merge 77 commits into
pingdotgg:mainfrom
Quicksaver:split/version-control-panel-work
Open

Add version control command center#3177
Quicksaver wants to merge 77 commits into
pingdotgg:mainfrom
Quicksaver:split/version-control-panel-work

Conversation

@Quicksaver

@Quicksaver Quicksaver commented Jun 19, 2026

Copy link
Copy Markdown

Summary

Adds a Git-backed Version Control command center to the right panel. It is scoped to the active project/repository cwd, works from draft or existing conversations once repository context is available, and keeps Git operations server-authoritative across browser, desktop, VS Code, and remote clients.

The panel focuses on actionable repository work rather than being a full Git dashboard: dirty working trees, local branch sync state, stashes, remotes, sibling worktrees, likely fork branches, and open change-request bases.

What Changed

  • Added SOURCE_CONTROL.md as the branch-specific behavior and validation reference for the Version Control panel.
  • Added server-side SourceControlPanelService RPC support for snapshots, branch/stash/commit/compare data, selected-file commit and stash flows, discard operations, branch actions, remote actions, and provider-derived PR/MR base checks.
  • Extended GitHub, GitLab, Azure DevOps, and Bitbucket source-control provider plumbing so actionable rows can account for open change-request bases while preserving bounded provider diagnostics.
  • Added live VCS refresh support through VcsStatusBroadcaster and VcsLocalWatch, including ref-counted local watchers, .git/ event filtering, gitignore-aware suppression, explicit local refreshes, and sibling worktree watcher retention.
  • Added the React Version Control panel UI with Actionable and Remotes sections, working-tree file selection, inline diffs, branch/stash/commit rows, searchable compare bases, guarded destructive actions, context menus, manual fetch controls, and a conservative five-minute Actionable remote fetch.
  • Centralized right-panel add-surface action metadata so the empty state and add menu share the same Version Control surface gating and action model.
  • Added dirty sibling worktree rows and cwd-scoped right-panel File previews so Git operations and file reads target the checkout that owns the displayed changes.
  • Hardened branch sync behavior around same-name remote tracking, fork branches, open PR/MR base branches, local-only publishing, diverged branch actions, branch names containing slashes, and branch worktree cwd routing.
  • Hardened working-tree handling for renamed files, quoted porcelain paths, mixed staged/unstaged rows, selected-file commit pathspec semantics, discard failures, generated commit failures, and branch deletion resolution.
  • Hardened review follow-ups for source-control thread metadata sequencing after a thread is closed/reopened and default compare ref selection for repositories whose checked-out default branch is not named main or master.
  • Hardened right-panel fallback behavior so an unavailable active Source Control surface falls back to another visible surface instead of forcing the empty right-panel state.
  • Hardened cached Version Control panel restores so cached snapshots show the refresh indicator while revalidating, and restored expanded branch/stash rows hydrate missing detail payloads even when the snapshot fingerprint is unchanged.
  • Hardened restored stash expansion and cached stash details so stash@{n} renumbering after stash create/drop operations does not show details for the wrong stash.
  • Extended shared RPC, IPC, Git, settings, client-runtime, and VCS contracts for the source-control snapshot and operation protocol.
  • Added desktop and web context-menu separator support so destructive source-control actions can be grouped consistently.
  • Added focused tests for source-control service behavior, provider base detection, VCS broadcaster/watch behavior, source-control panel state, shared Git contracts, and client-runtime VCS action helpers.

Why

T3 Code needs a compact place to answer "what repository work needs attention now?" without forcing users into a full external Git UI. This change keeps the surface decision-oriented: commit or stash selected changes, inspect branch sync state, publish or sync branches, review stashes, and notice when a PR/MR base has moved.

The server-owned design keeps behavior consistent across clients and avoids browser-side Git execution, while the periodic fetch and local watchers keep the panel current without introducing a high-frequency polling loop.

Validation

  • pnpm exec vp test run apps/server/src/sourceControl/SourceControlPanelService.test.ts apps/server/src/sourceControl/GitHubSourceControlProvider.test.ts apps/server/src/sourceControl/GitLabSourceControlProvider.test.ts apps/server/src/sourceControl/AzureDevOpsSourceControlProvider.test.ts apps/web/src/components/source-control/SourceControlPanel.logic.test.ts passed: 5 files, 74 tests.
  • pnpm exec vp test run apps/server/src/sourceControl/SourceControlPanelService.test.ts apps/server/src/vcs/VcsStatusBroadcaster.test.ts apps/server/src/vcs/GitVcsDriverCore.test.ts passed: 3 files, 82 tests.
  • pnpm exec vp test run apps/web/src/components/source-control/SourceControlPanel.logic.test.ts apps/web/src/state/sourceControlPanel.test.ts passed: 2 files, 14 tests.
  • pnpm exec vp test run packages/contracts/src/git.test.ts packages/shared/src/git.test.ts packages/client-runtime/src/state/vcsAction.test.ts passed: 3 files, 30 tests.
  • pnpm exec vp test run apps/server/src/sourceControl/SourceControlPanelService.test.ts passed: 1 file, 43 tests.
  • pnpm exec vp test run apps/web/src/components/ChatView.sourceControl.test.ts passed: 1 file, 11 tests.
  • pnpm exec vp test run apps/server/src/sourceControl/SourceControlPanelService.test.ts apps/server/src/vcs/VcsStatusBroadcaster.test.ts apps/server/src/vcs/GitVcsDriverCore.test.ts passed: 3 files, 85 tests.
  • pnpm exec vp test run apps/web/src/components/source-control/SourceControlPanel.logic.test.ts passed: 1 file, 12 tests.
  • pnpm exec vp test run apps/web/src/components/source-control/SourceControlPanel.logic.test.ts apps/web/src/state/sourceControlPanel.test.ts passed: 2 files, 16 tests.
  • pnpm exec vp test run packages/contracts/src/git.test.ts packages/shared/src/git.test.ts packages/client-runtime/src/state/vcsAction.test.ts passed: 3 files, 30 tests.
  • pnpm exec vp test run apps/web/src/components/RightPanelTabs.test.tsx passed: 1 file, 3 tests.
  • pnpm exec vp check passed with 0 errors and 9 existing warnings in unrelated web files.
  • pnpm exec vp run typecheck passed.

Proof

Screenshot 2026-06-16 at 19 26 39

Note

Medium Risk
Touches server Git workflows, multi-provider PR/MR queries, and error payloads crossing RPC; behavior is heavily tested but mistakes could affect publish/pull or provider-derived actionable rows.

Overview
Adds SOURCE_CONTROL.md as the canonical reference for the Version Control right-panel behavior, merge status, and validation commands.

Provider and diagnostics hardening: Introduces sanitizeErrorCause and routes GitHub, GitLab, Azure DevOps, and Bitbucket failures through sourceControlProviderError so RPC-facing errors carry bounded causes instead of raw CLI objects. Change-request listing now passes remote repository context (--repo / project) parsed from each remote URL. Opt-in commit author avatars are added via getCommitAvatarUrl on all four providers (GitHub commit API, GitLab Avatar API, Azure DevOps commit imageUrl, Bitbucket avatar links), with GitLab CLI error classification tightened.

Desktop menus: Electron and web context menus honor explicit separator items and insert a separator before the first destructive action even when it leads the menu.

Tests: Adds a large SourceControlPanelService.test.ts suite covering snapshots, renames, discard/commit/merge/push/pull, worktrees, fork/PR actionable rows, avatars, and error wrapping; extends provider and GitHubCli / GitLabCli tests for the new APIs.

Reviewed by Cursor Bugbot for commit 41b4d6c. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Add Version Control command center panel to the right panel UI

  • Introduces a full-featured SourceControlPanel React component with working tree management, file diffs, staging, commits, branch operations, remotes, and stash support.
  • Adds SourceControlPanelService on the server exposing ~25 VCS operations, wired into the WebSocket RPC layer with read/operate scope enforcement and git status refresh after mutating calls.
  • Extends the RPC contracts (packages/contracts) with new VcsPanel* schemas, websocket method identifiers, and EnvironmentApi surface for all panel operations.
  • Adds getCommitAvatarUrl to all source control providers (GitHub, GitLab, Bitbucket, Azure DevOps) with a per-provider toggle in server settings (showCommitAuthorAvatar, default off).
  • Adds file system watching in VcsStatusBroadcaster that debounces non-.git path changes and triggers forced local status refreshes, including sibling worktree discovery.
  • Integrates the panel into ChatView with git-cwd awareness, thread metadata routing for branch/worktree changes, and right panel surface filtering when Version Control is unavailable.
  • Changes the default automatic git fetch interval from 30 seconds to 5 minutes.
  • Risk: the fetch interval change is a behavioral default shift that affects all existing installations on upgrade.

Macroscope summarized 41b4d6c.

- Query open change requests across supported remotes
- Surface actionable branch rows only when local branch is behind the MR/PR base
- Pass remote repository context to GitHub, GitLab, and Azure DevOps CLIs
…ol-panel-work

# Conflicts:
#	apps/web/src/components/ChatView.tsx
#	apps/web/src/environmentApi.ts
#	apps/web/src/environments/runtime/service.threadSubscriptions.test.ts
#	packages/client-runtime/src/wsRpcClient.ts
- Extract shared source control panel state and API wiring
- Move VS Code project scope and subagent parent resolution into runtime helpers
- Add tests for presentation state and subagent control resolution
@coderabbitai

coderabbitai Bot commented Jun 19, 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: 3b0f0549-dd35-4616-aa18-37d7d37d50d2

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.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:XXL 1,000+ changed lines (additions + deletions). labels Jun 19, 2026
Comment thread apps/server/src/sourceControl/SourceControlPanelService.ts
Comment thread apps/web/src/components/source-control/SourceControlPanel.tsx
Comment thread apps/server/src/sourceControl/SourceControlPanelService.ts
Comment thread apps/web/src/components/source-control/SourceControlPanel.tsx
Comment thread apps/web/src/components/source-control/SourceControlPanel.tsx Outdated
Comment thread apps/server/src/sourceControl/SourceControlPanelService.ts Outdated
@macroscopeapp

macroscopeapp Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs human review

Diff is too large for automated approval analysis. A human reviewer should evaluate this PR.

You can customize Macroscope's approvability policy. Learn more.

- Treat same-name remotes as publish/pull upstreams
- Split sync-state logic into shared web module
- Cover publish target behavior with tests and docs
- Add `forceRefresh` support to query runners and runtime execution
- Refresh cached SWR atoms before resolving so panel data stays current
- Cover first-run and cached-refresh behavior with runtime tests
- Move sync refresh feedback into a compact spinner icon
- Keep the banner for non-refresh sync messages
- Sum merged working-tree row stats across both sides

- Keep default compare ref on the repository default branch

- Restrict diverged merge sync to the checked-out branch

- Surface tracked discard failures and rename sources

- Move shared panel logic into the logic module
- Infer rename status for numstat fallback entries
- Align diverged merge sync guard and disabled state
- Clarify aggregate working-tree stats and date buckets
…ol-panel-work

# Conflicts:
#	apps/desktop/src/electron/ElectronMenu.ts
#	apps/server/src/sourceControl/AzureDevOpsCli.ts
#	apps/server/src/sourceControl/AzureDevOpsSourceControlProvider.test.ts
#	apps/server/src/sourceControl/AzureDevOpsSourceControlProvider.ts
#	apps/server/src/sourceControl/GitHubCli.ts
#	apps/server/src/sourceControl/GitHubSourceControlProvider.test.ts
#	apps/server/src/sourceControl/GitHubSourceControlProvider.ts
#	apps/server/src/sourceControl/GitLabCli.ts
#	apps/server/src/sourceControl/SourceControlProvider.ts
#	apps/server/src/vcs/VcsStatusBroadcaster.ts
#	apps/server/src/ws.ts
#	apps/web/src/components/ChatView.tsx
#	apps/web/src/components/Sidebar.logic.ts
#	apps/web/src/hooks/useHandleNewThread.ts
Comment thread apps/vscode-extension/scripts/package-dependencies.mjs Outdated
Comment thread apps/vscode-extension/src/extension.ts Outdated
Comment thread apps/vscode-extension/scripts/package.mjs Outdated
Comment thread apps/web/src/session-logic.ts Outdated
Comment thread apps/server/src/vscodeWorkspaceBootstrap/http.ts Outdated
Comment thread apps/web/src/session-logic.ts Outdated
Comment thread apps/vscode-extension/src/backendManager.ts Outdated
Comment thread apps/vscode-extension/src/webview.ts Outdated
Comment thread apps/server/src/sourceControl/SourceControlPanelService.ts
Comment thread apps/web/src/components/ChatView.tsx Outdated
Comment thread apps/web/src/components/chat/ChatComposer.tsx Outdated

@macroscopeapp macroscopeapp 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.

Effect Service Conventions: one finding in DesktopBackendManager.ts. See inline comment.

Posted via Macroscope — Effect Service Conventions

Comment thread apps/desktop/src/backend/DesktopBackendManager.ts
Comment thread apps/web/src/components/ChatView.sourceControl.ts
Comment thread apps/server/src/sourceControl/SourceControlPanelService.ts
- Refresh upstream refs and branch delta counts
- Note preview and desktop backend merge impact
- Track the first fetched cwd to avoid repeats
- Trigger actionable branch loading when the panel mounts or cwd changes
- Key the source control panel by environment, thread, and cwd
- Ensure it resets when switching chat threads or repos
- Move Source Control panel availability into a helper
- Keep ChatView focused on rendering and wiring
- Add tests for visibility and availability rules
Comment thread apps/web/src/components/ChatView.sourceControl.ts
- Cache panel snapshot and UI state by environment/thread/worktree
- Restore expanded trees, selections, diffs, and enrichment data on reopen
- Describe context-keyed remounts and bounded panel state cache
- Note initial fetch-all-remotes behavior when opening a cwd
- Clarify which UI state is restored versus reloaded
Comment thread apps/web/src/components/source-control/SourceControlPanel.tsx
Comment thread apps/web/src/components/source-control/SourceControlPanel.tsx
- Show refresh state while cached snapshots revalidate
- Hydrate restored branch and stash expansions when details are missing
- Document cached panel refresh behavior in SOURCE_CONTROL.md
Comment thread apps/web/src/components/source-control/SourceControlPanel.tsx Outdated
- Use stash commit hashes for expansion and detail cache keys

- Keep positional refs for Git stash operations

- Document and test restored stash expansion behavior
- Share add-surface metadata between the empty state and menu

- Preserve Version Control availability, labels, and disabled reasons

- Refresh the source-control merge note to reflect the latest merge
- Preserve menu order while sharing action metadata
- Add coverage for action order, callbacks, and disabled reasons
- Record the latest upstream merge refs and branch deltas

- Note preserved Version Control panel customizations
- Add Android-native mobile interfaces and Ghostty terminal support
- Preserve Version Control behavior and refresh its merge notes
- Adopt responsive thread-error and platform shortcut updates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL 1,000+ 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.

1 participant