Repository navigation
Fix workspace renderer freeze during runtime reconnects - #11472
Conversation
|
Warning Review limit reached
Next review available in: 3 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
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 |
Greptile SummaryThis PR fixes a workspace renderer hot-loop triggered by runtime reconnect flaps: each connect/disconnect event re-computed
Confidence Score: 5/5Safe to merge. The change removes work rather than adding it, is backed by a profiled Electron replay, and the two modified subsystems are independently validated by the updated test suite. The sidebar deletion is a clean subtraction: the removed code path (global all-host scan on every runtime status change) is fully covered by the per-environment scheduler already wired in useIpcEvents, which calls fetchRuntimeEnvironmentRepos, refreshRuntimeProjectWorktrees, and fetchWorktreeLineage with debouncing and throttling. No existing scan trigger is lost. The crash-reporting normalization is mechanically verified by the new toBe(4_003) assertions, and the camelCase-to-snake_case regex correctly handles all relevant key shapes. No new IPC surface, no new async paths, no behavioral change for non-reconnect renders. Files Needing Attention: No files require special attention. The only non-obvious detail is that the new flap regression test in Sidebar.test.tsx passes runtimeStatusByEnvironmentId in mock state even though the component no longer subscribes to it — this is intentional: changing that value across rerenders is exactly what proves no fetch is triggered.
|
| Filename | Overview |
|---|---|
| src/renderer/src/components/sidebar/index.tsx | Removes the reconnect-triggered global scan: deletes the runtimeStatusByEnvironmentId subscription, onlineRuntimeEnvKey memo, and reconnectRefreshRef coalescer. The runtime scheduler in useIpcEvents covers this path with per-environment debouncing. |
| src/shared/crash-reporting.ts | Adds camelCase normalization before the stack-key length-cap regex so errorStack and componentStack get 4,000-char limit instead of 240. Logic is correct; /i flag on the test pattern handles the mixed-case output of the replace. |
| src/renderer/src/components/sidebar/Sidebar.test.tsx | Replaces the old async reconnect test (which verified the now-deleted trigger) with a synchronous flap regression: cycles runtimeStatusByEnvironmentId 5 times and asserts fetchAllWorktrees is never called. |
| src/shared/crash-reporting.test.ts | Extends the frame fixture from 80 to 200 entries so the sanitized string exceeds 4,000 chars; adds toBe(4_003) assertions for errorStack and componentStack, and a 243-char assertion for a non-stack key. |
| src/renderer/src/components/sidebar/single-flight-coalescer.ts | Deleted: the coalescer is no longer referenced anywhere in the codebase now that the sidebar's reconnect scan is removed. |
| src/renderer/src/components/sidebar/single-flight-coalescer.test.ts | Deleted along with the implementation; no orphaned test coverage concern. |
| renderer-worktree-freeze-incident-2026-07-29.md | New incident report documenting the production freeze, isolated Electron replay, profiling evidence, and fix validation. No executable code; no security surface. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Runtime host reconnects] --> B{Before fix}
A --> C{After fix}
B --> D[runtimeStatusByEnvironmentId changes in store]
D --> E[Sidebar onlineRuntimeEnvKey memo recomputes]
E --> F[useEffect fires]
F --> G[reconnectRefreshRef.request]
G --> H[fetchAllWorktrees ALL hosts]
H --> I[fetchWorktreeLineage ALL hosts]
I --> J[Store update Sidebar re-renders]
J --> F
J --> K[Hot loop pinned CPU frozen scroll]
C --> L[useIpcEvents detects reconnect]
L --> M[runtimeProjectRefreshScheduler.request envId]
M --> N[Debounce 250ms + throttle 5s per environment]
N --> O[fetchRuntimeEnvironmentRepos envId]
O --> P[refreshRuntimeProjectWorktrees]
P --> Q[fetchWorktreeLineage]
Q --> R[Sidebar not subscribed to runtime status no cascade]
Reviews (1): Last reviewed commit: "fix(sidebar): isolate runtime reconnect ..." | Re-trigger Greptile
Post-review Electron QAValidated final HEAD
Final-HEAD branch and linked-PR identity: Scrolled 260-worktree sidebar after the real wheel input: |


Summary
#185captures application framesThe user-visible result is that a reconnecting remote host no longer makes worktree-sidebar scrolling progressively slower or pins the workspace renderer in a JavaScript hot loop.
Screenshots
No intended visual change. This is the fixed 266-worktree sidebar after the runtime-flap stress test; a real wheel event moved the list from
scrollTop=2419to10419.Testing
pnpm lintpnpm typecheckpnpm testpnpm buildCompleted:
pnpm exec vitest run --config config/vitest.config.ts src/shared/crash-reporting.test.ts src/renderer/src/components/sidebar/Sidebar.test.tsx src/renderer/src/hooks/runtime-project-refresh-scheduler.test.ts src/renderer/src/hooks/useIpcEvents.test.ts src/renderer/src/components/terminal-pane/TerminalPaneOverlayLayer.react185.test.tsx src/renderer/src/components/activity/activity-portal-readiness-loop.react185.test.tsxoxlinton all changed TypeScript/TSX filespnpm exec tsc --noEmit -p config/tsconfig.web.json --composite falsegit diff --checkoxlint, React Doctor lint, andoxfmtElectron replay used the real Orca dev runner with an isolated profile, 13 repo rows, 266 visible worktrees, and 3,458 detected worktree records:
During the pre-fix replay, the renderer reached 140.9% CPU and a 2.1 GiB physical footprint; all 2,353 active sample frames were in V8/JavaScript execution. After the fixed run, interval CPU returned to 0% and visible wheel scrolling remained responsive.
AI Review Report
Reviewed the complete reconnect event chain, historical introduction of both refresh paths, store merge behavior, and existing scheduler coverage.
Main risks checked:
The initial crash-stack fixture was too short after path redaction to exercise the 4,000-character cap; it was lengthened and the regression now passes.
Cross-platform review explicitly checked macOS, Linux, and Windows behavior. This change adds no shortcuts, labels, shell commands, path assumptions, native modules, or Electron platform branches. Windows runtime hosts use the same environment-scoped renderer scheduler, and SSH/folder-workspace routing is unchanged.
Security Audit
Notes
#185remains unproven.renderer-worktree-freeze-incident-2026-07-29.md.Root-cause and architecture assessment
This is a root-cause fix for the reproduced reconnect failure, not symptom suppression. The architectural defect was incorrect invalidation scope: a status change from one runtime could launch a global scan across every host. This PR removes that redundant trigger and preserves the existing per-environment refresh owner.
The resulting design has the intended properties:
An independent architecture comparison found the same mature pattern: keyed, scoped refresh queues for noisy workspace events, with broad scans reserved for explicit lifecycle boundaries.
Review verdict: high confidence in the implementation and merge readiness. The Electron replay causally validates the removed refresh storm. The remaining confidence boundary is narrower: the exact downstream React setter that emitted the original production #185 is not yet proven, so this should not be described as eliminating every possible renderer update loop. The longer stack diagnostics preserve the evidence needed if a separate loop remains.