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 Plus 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: Approved Performance optimization that reduces polling intervals for Git refs and port scanning, with optimizations to avoid redundant work. Changes are well-tested, clearly documented, and limited to timing adjustments without introducing new features or behavioral complexity. 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
…nd-git-ref-port-polling
…nd-git-ref-port-polling
…nd-git-ref-port-polling
…nd-git-ref-port-polling
…nd-git-ref-port-polling
…nd-git-ref-port-polling
- Distinguish upstream behavior origin from branch helper ownership - Describe helper unit coverage without implying component integration
…nd-git-ref-port-polling
…nd-git-ref-port-polling
…nd-git-ref-port-polling
…nd-git-ref-port-polling
…nd-git-ref-port-polling
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit bb1446c. Configure here.
| listeners: new Set([...state.listeners, listener]), | ||
| }, | ||
| ]).pipe(Effect.tap(listener)), | ||
| ), |
There was a problem hiding this comment.
Leaked listener breaks port broadcasts
Medium Severity
PortDiscovery.subscribe adds the listener to scanner state and then replays the snapshot in the same acquire step. If that replay effect fails, Effect.acquireRelease skips release, so the listener stays registered even though the subscription never completed. Later broadcast runs every listener with Effect.forEach, so one failing replay listener can abort the whole broadcast and stop live port updates for other subscribers.
Reviewed by Cursor Bugbot for commit bb1446c. Configure here.


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 ref freshness semantics across client and server; behavior is well tested but stale refs could linger up to 20s unless the user opens a menu.
Overview
Cuts idle background work from Git ref lists and preview port discovery while keeping data fresh when users open branch or comparison menus.
Git refs (client-runtime): First-page ref revalidation moves from 5s to 20s; paginated cursor pages no longer tick on an interval (one-shot per connection generation). Ref list atoms use a 30s idle TTL instead of five minutes. Tests assert the new 20s interval.
UI:
refreshVcsRefsOnMenuOpencentralizes open-only ref refresh for the composer branch selector and Diff base-ref combobox (Diff refreshes local and remote); closing menus only clears search query, not refs.Port discovery (server): Replaces a fixed 3s
lsofpoll with 20s idle / 10s when a listener is already known. Subscribers get the latest snapshot under a semaphore (no duplicate scan inws.ts); terminal PID updates scan immediately but skip no-op re-registrations. New PortScanner tests cover replay, ordering, and deduped registrations.Reviewed by Cursor Bugbot for commit bb1446c. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Reduce background Git ref and port polling frequency
PortDiscoverypoll interval with adaptive intervals: 10s when listeners are active and servers are known, 20s otherwise.PortDiscoverynow receive an immediate replay of the latest snapshot instead of requiring an explicit scan in the WS handler.notificationLocksemaphore to serialize snapshot broadcasts with subscription replays, preventing stale interleaving.refreshVcsRefsOnMenuOpento centralize open-only ref refresh behavior acrossBranchToolbarBranchSelectorandDiffPanel; closing a menu no longer triggers a refresh.Macroscope summarized bb1446c.