Repository navigation
Conversation
The cold-park veto re-derives canWatcherCoverParkedTerminalTab from store and registry state that mounting/unmounting the pane it authorizes rewrites, and the parked watchers write the tab model back into the effect's dependencies. With no damping the verdict can alternate at render cadence until React raises "Maximum update depth exceeded" — 65 of 87 terminal_park_verdict_churn breadcrumbs across 11 crash bundles show 12 flips in under 3s (fastest 348ms). Damp it with a burst trigger derived from React's bail, not from the breadcrumb notice limit. React counts commits, and one flip in the real cycle costs many (pane-connect updateTabPtyId, the watcher-sync writes, the overlay's own subscriber renders), so a 12-flip pin never fires in the field: the repro at 12 commits per transition throws #185 after 5 flips / 55 commits. The pin now engages at floor((50 - settle) / commit cost) flips inside 1s, and 12/60s stays what it always was — a rarity bound on the breadcrumb. Schedule the pin's own expiry. A pinned tab leaves the parked set with every hysteresis deadline already past, so getTerminalTabColdParkRecheckDelayMs returned null and no timer was armed; since the pin exists to stop the churn that would otherwise re-run the verdict effect, nothing could ever re-park the tab and its ~4-5MB pane stayed mounted indefinitely. The pin deadline is now a first-class recheck deadline alongside parkCooldownUntilMs.
|
Warning Review limit reached
Next review available in: 33 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. 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 |
Breaks two independent React #185 (Maximum update depth exceeded) crash loops. - Activity portal publication is idempotent by descriptor value, so a semantic no-op no longer bounces synchronously through Terminal and back into Activity. - The Activity readiness burst budget survives slot, target, pane, and tab retargeting, and a quiet loading pane is rechecked when the window expires. - Terminal cold-parking pins verdict bursts to the safe mounted side before React reaches its nested-update limit, with an expiry so tabs can park again. Supersedes #12492 and #12485. Portal descriptor equality is keyed off keyof ActivityTerminalPortalTarget so a new field fails the build instead of silently suppressing a publish. Park-verdict damping and breadcrumbs gate on pin liveness, and churn crumbs coalesce by trigger so a burst cannot collapse into a slow-churn slot.
|
Superseded by #12600, merged as 5f187e0. That PR keeps this one's terminal circuit breaker — the burst-damped park verdict pinned to the safe mounted side — but states the evidence more conservatively. The watcher-coverage root-cause attribution here was stronger than what the reproduction actually supports, so #12600 keeps the protection while describing the mechanism as "some eligibility input oscillates" rather than naming one. It also carries a reproduction this PR lacked: Closing as superseded — no work is lost. |
…tablyai#12600) Breaks two independent React stablyai#185 (Maximum update depth exceeded) crash loops. - Activity portal publication is idempotent by descriptor value, so a semantic no-op no longer bounces synchronously through Terminal and back into Activity. - The Activity readiness burst budget survives slot, target, pane, and tab retargeting, and a quiet loading pane is rechecked when the window expires. - Terminal cold-parking pins verdict bursts to the safe mounted side before React reaches its nested-update limit, with an expiry so tabs can park again. Supersedes stablyai#12492 and stablyai#12485. Portal descriptor equality is keyed off keyof ActivityTerminalPortalTarget so a new field fails the build instead of silently suppressing a publish. Park-verdict damping and breadcrumbs gate on pin liveness, and churn crumbs coalesce by trigger so a burst cannot collapse into a slow-churn slot.
What this fixes
Crash signature:
Error: Minified React error #185— "Maximum update depth exceeded" — thrown fromgetRootForUpdatedFiber ← enqueueConcurrentHookUpdate ← dispatchSetState ← commitHookEffectListMount,with
TerminalPaneOverlayLayer$1at the top of the component stack. Reasonreact-error-boundary,boundary
terminal.workbench.Coverage: the G1 React-#185 group is 13 of the 127 reports in this batch. This PR targets the
10 terminal-surface crashes in that group (subgroups a/b/c —
active_view=terminal). The remaining3 are
page.activityand are handled separately (w7-activity-latch).Root cause. The cold-park verdict is a passive-effect
setStatewhose own veto is re-derived fromstate that the verdict rewrites:
src/renderer/src/components/terminal-pane/use-terminal-tab-cold-parking.ts:207-214(origin/main) vetoesevery park candidate through
canWatcherCoverParkedTerminalTab(worktreeId, terminalTab).src/renderer/src/components/terminal-pane/terminal-parked-tab-watchers.ts:87(origin/main) implements thatpredicate as
const state = useAppStore.getState()— read outside React's dependency tracking — thenresolveParkedTerminalPaneCandidates(tab, state), which is driven byterminalLayoutsByTabId,runtimePaneTitlesByTabIdand the module-levelcapturedPanesByTabIdregistry.TerminalPanethat parking mounts/unmounts. So: park → pane unmounts → layout/capture state changes → coverage veto flips
→ unpark → pane remounts → layout rewritten → park again. Each pass is one
setColdParkedTerminalTabIdscall from a passive effect, which is exactly the frame shape in the stacks above.
src/renderer/src/components/terminal-pane/terminal-park-verdict-flip-telemetry.ts:9-11(origin/main) says so verbatim: "Deliberately no damping: guarding a loop nobody has shown can run would add
a park delay and a retention path for no demonstrated benefit." Field data has now falsified that stance.
if (50 < nestedUpdateCount) throwinnode_modules/react-dom/cjs/react-dom-client.production.js:2414(react-dom 19.2.7) — it counts commits,not flips.
Representative reports (Slack):
terminal.workbench; diag bundleF0BMBA73ZJAcarriesterminal_park_verdict_churnwith 12 flips in 1186 ms.terminal.workbench; diag bundleF0BMJ4GGJE5carries 12 flips in 2347 ms, 23 s before the crash.terminal.workbench; diag bundleF0BMU4BQGMPcarries 12 flips in 1355 ms, 36 s before the crash.Two defects are fixed.
NOT-parked is the safe side — a mounted pane never goes silent for bells, titles or completions, which is
the failure that sank an earlier parking attempt.
every hysteresis deadline already in the past, so
getTerminalTabColdParkRecheckDelayMsreturnednullandno timer was armed. Since the pin exists precisely to stop the churn that would otherwise re-run the verdict
effect, nothing could ever re-park the tab and its ~4-5 MB pane stayed mounted for the life of the window.
The pin deadline is now a first-class recheck deadline alongside
parkCooldownUntilMs.The damping trigger is derived, not hand-tuned:
TERMINAL_TAB_PARK_FLIP_BURST_LIMIT = max(2, floor((50 - 6) / 12)) = 3flips inside a 1 s window, where 50 isReact's
NESTED_UPDATE_LIMIT, 6 is the settle cost measured by the new repro, and 12 is the assumed worst-casecommits per flip. The old 12-flips-per-60 s breadcrumb limit is kept as a breadcrumb limit only — at 12
commits per flip it would be ~144 commits, so a pin at that threshold could never fire before React bailed.
Fix evidence
1. Red without the source fix — the repro throws the real React #185
Scratch worktree at the branch commit, with only the three source files reverted to
origin/main(
terminal-park-verdict-flip-telemetry.ts,use-terminal-tab-cold-parking.ts,terminal-cold-park-recheck-deadlines.ts); tests untouched:This is the point of the proof: the reverted-source run does not fail on an assertion about damping, it
reproduces the production crash itself — React raises
Maximum update depth exceeded(the dev-mode text ofminified error #185) inside the render, from the same passive-effect park verdict named in the crash stacks.
The second test is the same loop driven at the assumed worst-case 12 commits per flip.
Full reverted-source run of all four affected files — 12 failed / 20 passed:
2. Red for the second defect in isolation — the memory-retention half
Same scratch worktree, everything at the branch commit except
terminal-cold-park-recheck-deadlines.tsreverted to
origin/main. This isolates the pin-expiry scheduling: damping works, but the damped tab nevercomes back, so its pane stays mounted forever.
The scratch worktree was created with
git worktree add --detach+ anode_modulessymlink and removedafterwards with
git worktree remove --force. Nogit stashwas used and no tracked file in the branchworktree was modified.
3. Green with the fix
Including
use-terminal-tab-cold-parking.test.ts, all four files: 4 passed / 32 tests passed.4. Regression suite — every touched module, then the whole renderer
Touched module directory (
src/renderer/src/components/terminal-pane), which is where all seven changed fileslive:
Full renderer suite on macOS (darwin 25.3.0, arm64):
Zero failures on macOS — there are no pre-existing failures to disclaim here.
Windows verification. The full renderer suite was also run on Windows: 5 failures, an identical set to the
origin/mainWindows baseline —github-item-dialog,pull-request-page,monaco undo,SourceControl host-context, andresource-session-classification. All five are pre-existing onorigin/mainandunrelated to terminal parking; this branch introduces no new Windows failure. Windows matters for this fix
because 6 of the 10 covered crashes are win32.
5. Field data — the defect happening in production
Verbatim breadcrumbs from the real diagnostic bundles (
renderer.breadcrumbspans):Aggregated across every bundle referenced by the 127 reports in this batch, de-duplicated by crumb content
(several crashes attach the same diagnostic bundle twice, as report + diag):
12 park↔unpark round trips in 348 ms is ~34 flips/second. There is no honest park policy that does that: an
honest park has to clear the 30 s cold-park hysteresis in one direction. And the crash report itself confirms
the frame shape (
F0BMD9MQZ18, win32 1.4.163):Honest limit on the field evidence. The churn breadcrumb is present in 4 of the 13 G1 bundles, not all
10 of the terminal crashes this PR claims to cover. React's
nestedUpdateCountis root-global and the throwlands on whichever fiber calls
setStatenext, so a component stack does not identify the offender — the reporeached this conclusion itself in
4543bb6826. What is proven here is: (a) the loop is real and reachable(the repro throws #185 on
origin/mainsources), and (b) it runs at render cadence in production, repeatedly,in bundles that crashed. What is not proven is that this specific loop is what saturated the counter in
every one of the 10. Treat the coverage number as cluster-level attribution, not per-crash causation.
ELI5
Imagine a room with a light on a motion sensor, plus a rule: "only turn the light off if the security camera
can still see the room."
The problem is that the camera is plugged into the same light switch. Turn the light off, and the camera goes
dark — so the rule says "camera can't see, turn the light back on." The light comes on, the camera works
again, so the rule says "camera's fine, turn the light off." Off, on, off, on, several times a second, forever.
That's the bug. The room is a terminal tab you aren't currently looking at. "Turning the light off" is Orca
unloading that tab's terminal view to save memory ("parking"). The "camera" is the background watcher that
keeps listening for the terminal's bell, title changes and finished commands while the view is unloaded — and
Orca correctly refuses to park a tab the watcher can't cover, because otherwise you'd stop getting notified.
But whether the watcher can cover the tab is worked out from bookkeeping that unloading the view itself
rewrites. So the decision feeds its own input.
The app itself has a safety cutout for this. The UI framework (React) counts how many times the screen gets
rebuilt in one go, and after 50 it gives up and throws an error rather than spin forever. That error is the
crash: "Maximum update depth exceeded." The whole terminal area dies and files a crash report.
The fix, in two parts. First: if a tab's park/unpark decision flips more than a few times in one second,
stop trusting it and freeze the answer on "stay loaded" for a minute. Stay-loaded is the safe answer — a loaded
tab never goes quiet on you; it just uses a few megabytes it didn't strictly need. Second, and this is the part
that's easy to get wrong: after freezing the answer, you must also set an alarm clock to reconsider a minute
later. The freeze works by stopping the very churn that was waking the decision up, so without an alarm the tab
would stay loaded forever and quietly leak memory. We now set that alarm.
One detail worth stating: the "few times in one second" threshold is computed from React's own 50-rebuild
budget rather than picked by hand. The original code had a diagnostic counter that only spoke up after 12
flips — but each flip costs roughly a dozen rebuilds, so 12 flips is ~144 rebuilds, and React would have
crashed long before the counter ever fired. That's why the crash was recorded but never prevented.
Trade-offs
Real ones, stated plainly.
A damped tab holds ~4-5 MB of pane memory for up to 60 s longer than it otherwise would. This is the
deliberate trade: the pin resolves to NOT-parked, which costs memory but never makes a terminal go silent.
A tab whose oscillator is genuinely stuck will re-pin every window, so in the worst case it never parks at
all while the churn lasts. Given that this batch also contains a 42-crash renderer-OOM cluster, retaining
panes is not a free choice — it is a smaller harm than a hard crash, not a non-harm.
A legitimate rapid park/unpark can be mistaken for churn. The burst threshold is 3 flips inside 1 s.
Fast worktree/tab switching that genuinely toggles a tab's hidden state three times in one second will pin
that tab unparked for 60 s. The user-visible effect is only "this hidden tab did not free its memory as
quickly as it should have," never a broken or silent terminal.
The root cause is damped, not removed.
canWatcherCoverParkedTerminalTabstill callsuseAppStore.getState()outside React's dependency tracking on every pass(
terminal-parked-tab-watchers.ts:87), so the feedback edge still exists — the pin just stops it runningaway. The plan's item (b) — evaluate coverage once per tab per park episode and cache it — was
deliberately not done here, because caching a predicate that gates pane unmounting is a much larger,
riskier change than a damper, and it needs its own repro for the stale-cache failure mode. Known
follow-up. Suggested mitigation in the meantime: the new
trigger: 'burst'breadcrumb is queryable as adurable
renderer.breadcrumbspan, so we can measure how often the damper actually engages beforecommitting to the larger refactor. Related and also untouched: commit
49dc113a0fadded an asyncterminalProviderHasAuthoritativeSnapshotlookup as a further untracked, time-varying input to the samepredicate; that makes the underlying oscillator strictly more volatile on
HEADthan in the crashingbuilds.
TERMINAL_TAB_PARK_FLIP_COMMIT_COST = 12is an assumed worst case, not a production measurement. It isan enumeration of the commits one flip drags behind it (pane mount/unmount, pane-connect
updateTabPtyId,the parked-watcher
clearTabLaunchAgent/setTabLayout/updateTabTitlewrites, the overlay's zustandsubscriber renders). If the real cost is higher than 12, the pin could still land after React has already
bailed. Two guards are in place: the repro runs the loop at exactly this cost and must still settle, and a
unit test asserts
BURST_LIMIT * COMMIT_COST < 50, so raising the assumed cost automatically tightens thelimit. Neither guard makes the constant a measurement.
Breadcrumb shape changed; existing queries need updating.
terminal_park_verdict_churnnow carries atriggerfield ('burst'|'window') and the burst variant carriespinnedForMs. The crumb will alsofire in situations where it previously stayed silent (3 flips in 1 s instead of 12 flips in 60 s), so
expect its volume to go up. The per-window one-crumb-per-tab rate cap is unchanged. Any dashboard that
assumed
flips === 12will now seeflips === 3on burst crumbs.A verdict that was already pinned suppresses the slow-churn (
'window') crumb for that window. This isintentional — the burst crumb already reported the same window and a second one would only double volume —
but it does mean the two triggers are not independently countable within a window.
The header comment on
terminal-park-verdict-flip-telemetry.tsreversed its own stated position. Thefile previously argued against damping in writing. That reasoning was correct given what was known then
and is wrong given the field data now; the rewritten header says so explicitly rather than quietly dropping
it.
Not a trade-off but worth flagging: this PR does not fix the 3
page.activitycrashes in the same G1group. Those are a different driver (the Activity portal readiness latch) and are handled in a separate PR.
Adversarial review
2 independent adversarial review rounds, each run by a fresh reviewer with no memory of the prior round
— no shared context, no summary of what the previous round had already accepted, so nothing was waved through
on the strength of an earlier pass. 1 fix round followed.
What the rounds found:
reviewer showed that React bails on commits, not flips, and that at the real cycle's commits-per-flip
cost a 12-flip pin can never fire in the field — the repro at 12 commits per transition throws fix: improve scrollbar and file explorer scroll behavior #185 after 5
flips / 55 commits. The threshold was rederived from React's
NESTED_UPDATE_LIMITand the commit cost, anda unit test now pins the derivation (
BURST_LIMIT * COMMIT_COST < 50,BURST_LIMIT < NOTICE_LIMIT), so thetwo limits cannot silently converge again.
hysteresis deadline in the past, so
getTerminalTabColdParkRecheckDelayMsreturnednull, no timer wasarmed, and — because the pin's whole job is to stop the churn that re-runs the verdict effect — nothing
could ever re-park the tab. The pin deadline was promoted to a first-class recheck deadline and the
isolating regression test in §2 above was added.
Final verdict: clean — zero blocking findings, zero major findings. The remaining minor finding that was
deliberately not fixed is item 3 in Trade-offs (cache the coverage predicate per park episode), listed there
as a known follow-up with its mitigation.
/perfskill review verdict: no regression. The damping path is a per-tab counter increment and twointeger comparisons inside an effect that already iterates the tab list; the pin adds one
Maplookup perpark candidate and one extra deadline to an existing
Math.min. No new subscriptions, timers, or store readswere added — the pin reuses the existing recheck timer that the cool-down deadline already schedules.
Made with Orca 🐋