Reduce background Git ref and port polling#4187
Conversation
- Poll first ref pages every 20 seconds and refresh menus on open - Avoid duplicate port scans and adapt lsof polling to activity - Document the retained freshness guarantees
…nd-git-ref-port-polling
…nd-git-ref-port-polling
|
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 |
ApprovabilityVerdict: Needs human review This PR significantly modifies polling intervals and subscription notification mechanics, changing how data freshness is managed throughout the application. The new semaphore-based serialization and state-dependent polling represent meaningful behavioral changes that warrant human review. You can customize Macroscope's approvability policy. Learn more. |
…nd-git-ref-port-polling
- Order subscription replay with concurrent snapshot broadcasts - Cover replay ordering with a focused concurrent regression test - Document the preview notification ordering guarantee
Summary
Reduce persistent background work from Git ref enumeration and preview port discovery while preserving freshness when users interact with either surface.
What Changed
Why
During extended use, T3 Code's resident memory climbed past 6 GB even while idle, while the renderer sustained roughly 10% CPU and the machine became noticeably warm around the CPU and GPU clusters. That pattern indicated that background work was continuing without user interaction and could compound renderer and resource pressure over long sessions.
Diagnostics identified two repeatable sources of idle churn: every retained Git-ref query, including each loaded pagination page, owned its own five-second
listRefsrevalidation loop, while preview discovery launched a broadlsofscan every three seconds. Preview subscription initialization could also scan twice, and unchanged terminal process registrations caused redundant probes. The new schedules reduce that steady subprocess load while immediate menu refreshes, terminal-process-triggered scans, and adaptive safety-net polling preserve freshness at interaction time.Validation
git diff --checkpassedProof
No standalone proof artifacts were captured; the isolated browser verification is summarized above.
Note
Medium Risk
Touches live preview discovery and Git ref caching/subscription behavior; incorrect ordering or stale snapshots could affect port lists or ref pickers, though serialization and explicit menu refresh mitigate the main regressions.
Overview
Reduces idle background work from Git ref listing and preview port discovery while keeping lists fresh when users open branch/ref UI.
Git refs (
vcs.ts) — First-page ref atoms revalidate every 20s (was 5s); paginated cursor pages refresh once per connection instead of on a timer. Inactive ref atoms expire after 30s (was 5 minutes).Preview ports (
PortScanner.ts,ws.ts) — Replaces a fixed 3slsof/probe loop with 10s when a listener is known and 20s when idle. New WebSocket subscribers replay the latest snapshot under a semaphore instead of callingscan()again; terminal PID register/unregister triggers an immediate scan only when the process set actually changes.UI (
DiffPanel.tsx) — Opening the branch comparison combobox callsrefresh()on local and remote ref queries so menus do not wait on the slower background interval.Adds
BRANCH_DETAILS.mdand PortScanner tests for snapshot replay, ordered delivery under concurrency, and skipped probes on duplicate registrations.Reviewed by Cursor Bugbot for commit 5b816e5. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Reduce background Git ref and port polling frequency
Semaphore, preventing out-of-order delivery and stale replays after newer scansDiffPanelnow triggers an immediate refresh of local and remote branch refsMacroscope summarized 5b816e5.