Summary#
Reduce background Git status disk and process churn by separating remote metadata refreshes from local working-tree inspection.
Problem#
The VCS remote status poller ran every 30 seconds and called the full Git status path after fetching. That path executed git status --porcelain=2 --branch plus staged and unstaged git diff --numstat, even though the poller only needed upstream divergence and pull request metadata.
Trace data from the affected environment showed the remote poll repeatedly scanning the working tree. During the reported failure burst:
- the background fetch hit its 5,003 ms timeout
git status took 5,072 ms
- staged and unstaged numstat scans each took about 7,728 ms
- unrelated process diagnostics and provider subprocesses also timed out
The failing agent-tools repository itself has one worktree and a roughly 904 KB .git directory, so repository size was not the direct cause. The broader machine does have hundreds of registered worktrees and was under significant child-process pressure. The existing polling behavior amplified that pressure by repeatedly performing unnecessary local scans and by immediately restarting remote refreshes on reconnect.
Changes#
- Add a metadata-only Git remote status operation that:
- refreshes the upstream when stale
- reads the current branch and upstream
- computes ahead/behind commit counts
- computes divergence from the default branch
- does not inspect working-tree files or run numstat scans
- Use the metadata-only operation for
GitManager.remoteStatus.
- Preserve cached remote status across stream reconnects.
- When a cached remote snapshot exists, wait until the configured interval before starting another automatic refresh instead of refreshing immediately.
Explicit refreshes and initial uncached subscriptions continue to refresh immediately.
Verification#
vp test apps/server/src/vcs/GitVcsDriverCore.test.ts
vp test apps/server/src/vcs/VcsStatusBroadcaster.test.ts
vp run typecheck
vp check
The two focused backend suites pass with 24 tests.
The complete vp test run produced 372 passing files and 34 unrelated failures. Most failures are existing web test alias-resolution errors for ~/... imports; several orchestration tests also timed out while the machine was experiencing the same process pressure investigated here.
Note
Reduce Git status polling churn by skipping remote refresh when cached snapshot exists#
- Adds
statusDetailsRemote to GitVcsDriver (GitVcsDriverCore.ts), a new remote-only status path that reads branch, upstream, ahead/behind, and default-branch counts without inspecting the working tree.
GitManager.readRemoteStatus now calls statusDetailsRemote instead of statusDetails, avoiding unnecessary working-tree work during remote polling.
VcsStatusBroadcaster.streamStatus delays the first background remote refresh by the configured interval when a cached remote snapshot is already present, rather than always refreshing immediately.
- Behavioral Change: clients that subscribe to
streamStatus while a remote cache entry exists will now wait up to one full polling interval before receiving an updated remote status.
Macroscope summarized 5cac56a.
Note
Medium Risk
Changes remote status semantics and polling timing for stream subscribers; behavior is well-tested but affects VCS status freshness on reconnect.
Overview
Reduces background Git status churn by splitting remote-only metadata from full local working-tree inspection.
Adds statusDetailsRemote on the Git VCS driver: it still refreshes stale upstreams and computes branch, upstream, ahead/behind, and default-branch divergence via lightweight rev-parse / rev-list calls, without git status --porcelain or staged/unstaged numstat scans. GitManager.readRemoteStatus now uses this path instead of full statusDetails.
VcsStatusBroadcaster defers the first automatic remote poll when a cached remote snapshot already exists: subscribers get the cache immediately and the background loop sleeps one full polling interval before the next refresh. Uncached subscriptions and explicit refreshes still run immediately.
Tests cover remote divergence without working-tree fields, origin-based default-branch detection when upstream is not origin, and delayed refresh timing with TestClock.
Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 5cac56a2e4fbe5d6d064cedc994fcd9120ba221d. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).
Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID:
acf40595-ae08-415c-b738-846039cac2e9You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment `@coderabbitai help` to get the list of available commands and usage tips.