fix(server): stop Windows terminal polling from spiking CPU - #9476
fix(server): stop Windows terminal polling from spiking CPU#9476UtkarshUsername wants to merge 11 commits into
Conversation
ApprovabilityVerdict: Not approved Macroscope's review found this PR not approvable — This PR changes production terminal polling across platforms and adds a new native sidecar protocol command with fallback and backoff behavior. Its cross-component runtime and compatibility impact is broader than a self-contained fix, warranting human review. You can add or adjust custom eligibility rules. Learn more. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit a0bc756. Configure here.
Apply exponential backoff when the sidecar fails and the spawned fallback serves instead, so a stalled sidecar no longer hot-loops PowerShell. Skip pid 0 in the Rust process table so one kernel entry cannot fail the whole event decode. Revert the Windows sidecar packaging added for the removed native dependency.

What Changed
Terminal subprocess polling no longer spawns a PowerShell CIM query every second while terminals are active. It now reads one shared process snapshot per polling tick from the existing resource-monitor sidecar (new
processTablecommand, protocol v3), on both Windows and POSIX.ps/PowerShell fallback serves instead, so a stalled sidecar can't hot-loop the expensive fallback.windows-process-treepackaging added earlier in this branch is reverted.Verification:
vp test run apps/server/src/terminal/Manager.test.ts apps/server/src/resourceTelemetry/NativeTelemetryClient.test.ts scripts/lib/cli-external-packages.test.ts(82 passed, incl. a new test that fails the sidecar table and asserts fallback data is applied while fallback spawns back off)vp test run apps/server/src/resourceTelemetry/ResourceTelemetry.test.ts apps/server/src/resourceTelemetry/ResourceTelemetryHistory.test.ts apps/server/src/resourceTelemetry/Model.test.ts apps/server/src/diagnostics/ProcessDiagnostics.test.ts(31 passed)vp run --filter t3 typecheckandvp run --filter @t3tools/scripts typecheck(clean)cargo fmt --checkfornative/resource-monitor(Rust binary tests need a native linker; CI covers that build)Why
T3 Code queried
Win32_Processthrough a fresh PowerShell process every second while terminals were active. On affected Windows machines those calls averaged roughly one second, repeatedly timed out, and kept CPUs and fans busy. The sidecar already enumerates the full process table withsysinfoand ships in desktop and CLI builds, so reusing it removes PowerShell/WMI from the polling loop without loading native code into the server process. This matchesdocs/internals/resource-telemetry.md, which exists to replace recurringps/PowerShell subprocess probes.Checklist
Implemented with GPT-5.6 using the Codex harness.
Note
Medium Risk
Bumps
RESOURCE_MONITOR_PROTOCOL_VERSIONto 3 and changes terminal activity detection on all platforms; mismatched or missing sidecar binaries fall back to spawned probes with backoff rather than failing silently.Overview
Reduces Windows terminal subprocess polling CPU by sourcing one shared process table per tick from the existing resource-monitor sidecar instead of spawning PowerShell/
pson every interval.The resource-monitor protocol moves to v3 with a new
processTablecommand and{pid, ppid, name}response, implemented in the Rust sidecar, contracts, andNativeTelemetryClient(5s timeout, same request/deferred pattern assampleNow).TerminalManagercallsNativeTelemetryClient.processTableby default (wired viaNativeTelemetryLayerLiveon the terminal layer). PowerShell CIM and POSIXpsremain fallbacks when the sidecar fails; fallback data still updates activity, but ticks count as failures.subprocessSnapshotPollDelayMsdoubles the poll delay per failure (max 60s) and resets after a successful snapshot or when no sessions are running.Tests and fixtures use protocol v3; docs list the new command/event.
Reviewed by Cursor Bugbot for commit 3bb2be6. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add native
processTablecommand and exponential backoff to terminal pollingprocessTablecommand and response event to the resource-monitor protocol (bumped from v2 to v3) across main.rs, resourceTelemetry.ts, andNativeTelemetryClientTerminalManager.makenow usesNativeTelemetryClient.processTableas the primary subprocess snapshot source on Windows, falling back to the PowerShell-basedwindowsProcessTableSnapshotand spawned fallback data when it failssubprocessSnapshotPollDelayMsin Manager.ts: doubles the configured interval per failure (cap 60s), resets after success or when no sessions are active — this replaces the fixed-interval loop that caused CPU spikes on repeated failurespollSubprocessActivitynow returns a success flag so failed snapshots are no longer treated as successful ticksRESOURCE_MONITOR_PROTOCOL_VERSIONchanged from 2 to 3; any client or fixture still emitting v2 hello/events will be rejected by contract validation. All in-tree callers and test fixtures are updated.Macroscope summarized 3bb2be6.