Skip to content

fix(terminal): damp cold-park verdict oscillation (React #185) — 10 crashes - #12492

Closed
nwparker wants to merge 1 commit into
mainfrom
crashfix/w9-park-churn
Closed

nwparker wants to merge 1 commit into
mainfrom
crashfix/w9-park-churn

Conversation

@nwparker

@nwparker nwparker commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

What this fixes

Crash signature: Error: Minified React error #185 — "Maximum update depth exceeded" — thrown from
getRootForUpdatedFiber ← enqueueConcurrentHookUpdate ← dispatchSetState ← commitHookEffectListMount,
with TerminalPaneOverlayLayer$1 at the top of the component stack. Reason react-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 remaining
3 are page.activity and are handled separately (w7-activity-latch).

Root cause. The cold-park verdict is a passive-effect setState whose own veto is re-derived from
state that the verdict rewrites:

  • src/renderer/src/components/terminal-pane/use-terminal-tab-cold-parking.ts:207-214 (origin/main) vetoes
    every park candidate through canWatcherCoverParkedTerminalTab(worktreeId, terminalTab).
  • src/renderer/src/components/terminal-pane/terminal-parked-tab-watchers.ts:87 (origin/main) implements that
    predicate as const state = useAppStore.getState() — read outside React's dependency tracking — then
    resolveParkedTerminalPaneCandidates(tab, state), which is driven by terminalLayoutsByTabId,
    runtimePaneTitlesByTabId and the module-level capturedPanesByTabId registry.
  • All three of those are (re)written as a direct consequence of mounting/unmounting the very TerminalPane
    that 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 setColdParkedTerminalTabIds
    call from a passive effect, which is exactly the frame shape in the stacks above.
  • Nothing damped it. 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.
  • React's bail is if (50 < nestedUpdateCount) throw in
    node_modules/react-dom/cjs/react-dom-client.production.js:2414 (react-dom 19.2.7) — it counts commits,
    not flips.

Representative reports (Slack):

Two defects are fixed.

  1. The oscillation is undamped. A flip burst now pins the tab's verdict to NOT-parked for one window.
    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.
  2. The damping, naively added, would have leaked memory forever. A pinned tab has left the parked set with
    every hysteresis deadline already in the past, so getTerminalTabColdParkRecheckDelayMs returned null and
    no 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)) = 3 flips inside a 1 s window, where 50 is
React's NESTED_UPDATE_LIMIT, 6 is the settle cost measured by the new repro, and 12 is the assumed worst-case
commits 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:

$ cd /tmp/prproof-w9-park-churn && git checkout origin/main -- \
    src/renderer/src/components/terminal-pane/terminal-park-verdict-flip-telemetry.ts \
    src/renderer/src/components/terminal-pane/use-terminal-tab-cold-parking.ts \
    src/renderer/src/components/terminal-pane/terminal-cold-park-recheck-deadlines.ts
$ npx vitest run --config config/vitest.config.ts \
    src/renderer/src/components/terminal-pane/terminal-cold-park-verdict-loop.test.tsx

 RUN  v4.1.5 /private/tmp/prproof-w9-park-churn

 ❯ src/renderer/src/components/terminal-pane/terminal-cold-park-verdict-loop.test.tsx (2 tests | 2 failed) 30ms
     × settles the park verdict when watcher coverage tracks the pane it unmounts 25ms
     × settles at the assumed worst-case commit cost per park transition 4ms

⎯⎯⎯⎯⎯⎯⎯ Failed Tests 2 ⎯⎯⎯⎯⎯⎯⎯

 FAIL  src/renderer/src/components/terminal-pane/terminal-cold-park-verdict-loop.test.tsx > cold-park verdict oscillation > settles the park verdict when watcher coverage tracks the pane it unmounts
AssertionError: expected Error: Maximum update depth exceeded. Thi… to be null

- Expected:
null

+ Received:
Error {
  "message": "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.",
}

 ❯ src/renderer/src/components/terminal-pane/terminal-cold-park-verdict-loop.test.tsx:225:20
    223|     // Damping must land inside the burst window and settle on the saf…
    224|     // the pane stays mounted, so bells/titles/completions never go si…
    225|     expect(thrown).toBeNull()
       |                    ^
    226|     expect(parkVerdictFlipCount).toBeLessThanOrEqual(SETTLED_FLIP_BUDG…
    227|     expect(lastParkVerdict).toBe(false)

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/2]⎯

 FAIL  src/renderer/src/components/terminal-pane/terminal-cold-park-verdict-loop.test.tsx > cold-park verdict oscillation > settles at the assumed worst-case commit cost per park transition
AssertionError: expected Error: Maximum update depth exceeded. Thi… to be null

- Expected:
null

+ Received:
Error {
  "message": "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.",
}

 ❯ src/renderer/src/components/terminal-pane/terminal-cold-park-verdict-loop.test.tsx:240:20

 Test Files  1 failed (1)
      Tests  2 failed (2)
   Start at  01:42:07
   Duration  567ms

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 of
minified 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:

 FAIL  …/terminal-park-verdict-flip-telemetry.test.ts > getParkVerdictUnparkPinUntilMs > does not pin a stable verdict
TypeError: getParkVerdictUnparkPinUntilMs is not a function
 ❯ src/renderer/src/components/terminal-pane/terminal-park-verdict-flip-telemetry.test.ts:235:12

 FAIL  …/use-terminal-tab-cold-parking.test.ts > useTerminalTabColdParking measure-clock contract > re-parks a damped tab once the pin expires with no other store change
AssertionError: expected 1 to be +0 // Object.is equality

- Expected
+ Received

- 0
+ 1

 ❯ src/renderer/src/components/terminal-pane/use-terminal-tab-cold-parking.test.ts:147:33

 Test Files  4 failed (4)
      Tests  12 failed | 20 passed (32)
   Start at  01:41:57
   Duration  2.70s

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.ts
reverted to origin/main. This isolates the pin-expiry scheduling: damping works, but the damped tab never
comes back, so its pane stays mounted forever.

$ git checkout origin/main -- src/renderer/src/components/terminal-pane/terminal-cold-park-recheck-deadlines.ts
$ npx vitest run --config config/vitest.config.ts \
    src/renderer/src/components/terminal-pane/use-terminal-tab-cold-parking.test.ts

 ❯ src/renderer/src/components/terminal-pane/use-terminal-tab-cold-parking.test.ts (7 tests | 1 failed) 30ms
     × re-parks a damped tab once the pin expires with no other store change 6ms

⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯

 FAIL  …/use-terminal-tab-cold-parking.test.ts > useTerminalTabColdParking measure-clock contract > re-parks a damped tab once the pin expires with no other store change
AssertionError: expected Set{} to deeply equal Set{ 'tab-2' }

- Expected
+ Received

- Set {
-   "tab-2",
- }
+ Set {}

 ❯ src/renderer/src/components/terminal-pane/use-terminal-tab-cold-parking.test.ts:152:28
    150|       vi.advanceTimersByTime(TERMINAL_TAB_PARK_FLIP_WINDOW_MS)
    151|     })
    152|     expect(result.current).toEqual(new Set(['tab-2']))
       |                            ^

 Test Files  1 failed (1)
      Tests  1 failed | 6 passed (7)
   Start at  01:42:20
   Duration  1.20s

The scratch worktree was created with git worktree add --detach + a node_modules symlink and removed
afterwards with git worktree remove --force. No git stash was used and no tracked file in the branch
worktree was modified.

3. Green with the fix

$ cd /Users/nwparker/orca/crashwork/w9-park-churn
$ npx vitest run --config config/vitest.config.ts --reporter=verbose \
    src/renderer/src/components/terminal-pane/terminal-cold-park-verdict-loop.test.tsx \
    src/renderer/src/components/terminal-pane/terminal-park-verdict-flip-telemetry.test.ts \
    src/renderer/src/components/terminal-pane/terminal-cold-park-recheck-deadlines.test.ts

 RUN  v4.1.5 /Users/nwparker/orca/crashwork/w9-park-churn

 ✓ …/terminal-park-verdict-flip-telemetry.test.ts > burst damping threshold > stays under React NESTED_UPDATE_LIMIT at the assumed commits-per-flip cost 1ms
 ✓ …/terminal-park-verdict-flip-telemetry.test.ts > recordParkVerdictFlips > stays silent for a stable verdict 0ms
 ✓ …/terminal-park-verdict-flip-telemetry.test.ts > recordParkVerdictFlips > emits one burst breadcrumb once the verdict churns at render cadence 1ms
 ✓ …/terminal-park-verdict-flip-telemetry.test.ts > recordParkVerdictFlips > separates a damped burst from slow churn 0ms
 ✓ …/terminal-park-verdict-flip-telemetry.test.ts > recordParkVerdictFlips > does not pin churn spread past the burst window 0ms
 ✓ …/terminal-park-verdict-flip-telemetry.test.ts > recordParkVerdictFlips > re-arms after the window elapses 0ms
 ✓ …/terminal-park-verdict-flip-telemetry.test.ts > recordParkVerdictFlips > treats a backwards clock jump as a fresh window 0ms
 ✓ …/terminal-park-verdict-flip-telemetry.test.ts > recordParkVerdictFlips > treats an exactly-elapsed window as expired 0ms
 ✓ …/terminal-park-verdict-flip-telemetry.test.ts > recordParkVerdictFlips > honours the window, notice, burst-window and burst-limit overrides 0ms
 ✓ …/terminal-park-verdict-flip-telemetry.test.ts > recordParkVerdictFlips > keeps per-tab windows and notices independent 0ms
 ✓ …/terminal-park-verdict-flip-telemetry.test.ts > recordParkVerdictFlips > drops records for tabs that no longer exist 0ms
 ✓ …/terminal-park-verdict-flip-telemetry.test.ts > getParkVerdictUnparkPinUntilMs > does not pin a stable verdict 0ms
 ✓ …/terminal-park-verdict-flip-telemetry.test.ts > getParkVerdictUnparkPinUntilMs > reports the pin deadline one window out, then re-arms 0ms
 ✓ …/terminal-park-verdict-flip-telemetry.test.ts > getParkVerdictUnparkPinUntilMs > releases the pin when the clock jumps backwards 0ms
 ✓ …/terminal-cold-park-verdict-loop.test.tsx > cold-park verdict oscillation > settles the park verdict when watcher coverage tracks the pane it unmounts 14ms
 ✓ …/terminal-cold-park-verdict-loop.test.tsx > cold-park verdict oscillation > settles at the assumed worst-case commit cost per park transition 3ms
 ✓ …/terminal-cold-park-recheck-deadlines.test.ts > getTerminalWorktreeColdParkRecheckDelayMs > returns the next cold-park policy deadline 1ms
 ✓ …/terminal-cold-park-recheck-deadlines.test.ts > getTerminalWorktreeColdParkRecheckDelayMs > schedules no recheck when the settings kill switch disables parking 0ms
 ✓ …/terminal-cold-park-recheck-deadlines.test.ts > getTerminalWorktreeColdParkRecheckDelayMs > wakes at the retention TTL for budget candidates past the ordinary deadlines 0ms
 ✓ …/terminal-cold-park-recheck-deadlines.test.ts > getTerminalWorktreeColdParkRecheckDelayMs > wakes at the measure cool-down deadline when all ordinary deadlines have passed 0ms
 ✓ …/terminal-cold-park-recheck-deadlines.test.ts > getTerminalTabColdParkRecheckDelayMs > returns the next terminal-tab cold-park policy deadline 0ms
 ✓ …/terminal-cold-park-recheck-deadlines.test.ts > getTerminalTabColdParkRecheckDelayMs > schedules no recheck when the settings kill switch disables parking 0ms
 ✓ …/terminal-cold-park-recheck-deadlines.test.ts > getTerminalTabColdParkRecheckDelayMs > wakes at the measure cool-down deadline when all ordinary deadlines have passed 0ms
 ✓ …/terminal-cold-park-recheck-deadlines.test.ts > getTerminalTabColdParkRecheckDelayMs > wakes at the flip-damping pin deadline when all ordinary deadlines have passed 0ms
 ✓ …/terminal-cold-park-recheck-deadlines.test.ts > getTerminalTabColdParkRecheckDelayMs > takes the nearest of the pin and cool-down deadlines 0ms

 Test Files  3 passed (3)
      Tests  25 passed (25)
   Start at  01:41:27
   Duration  1.59s

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 files
live:

$ npx vitest run --config config/vitest.config.ts src/renderer/src/components/terminal-pane

 RUN  v4.1.5 /Users/nwparker/orca/crashwork/w9-park-churn

 Test Files  231 passed (231)
      Tests  3019 passed (3019)
   Start at  01:42:32
   Duration  26.64s

Full renderer suite on macOS (darwin 25.3.0, arm64):

$ npx vitest run --config config/vitest.config.ts src/renderer

 RUN  v4.1.5 /Users/nwparker/orca/crashwork/w9-park-churn

 Test Files  2122 passed | 1 skipped (2123)
      Tests  19647 passed | 4 skipped (19651)
   Start at  01:43:08
   Duration  119.92s

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/main Windows baseline
— github-item-dialog, pull-request-page, monaco undo, SourceControl host-context, and resource-session-classification. All five are pre-existing on origin/main and
unrelated 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.breadcrumb spans):

$ grep -o 'terminal_park_verdict_churn","breadcrumb.data":{[^}]*}' F0BMBBPT8ES.txt
terminal_park_verdict_churn","breadcrumb.data":{"tabId":"web-terminal-4ec4ba0e-…","flips":12,"elapsedMs":17478,"windowMs":60000,"suppressedSinceLast":2}
terminal_park_verdict_churn","breadcrumb.data":{"tabId":"web-terminal-4ec4ba0e-…","flips":12,"elapsedMs":34328,"windowMs":60000,"suppressedSinceLast":1}
terminal_park_verdict_churn","breadcrumb.data":{"tabId":"web-terminal-5ba47c7e-…","flips":12,"elapsedMs":52143,"windowMs":60000}
terminal_park_verdict_churn","breadcrumb.data":{"tabId":"web-terminal-5ba47c7e-…","flips":12,"elapsedMs":30644,"windowMs":60000}
terminal_park_verdict_churn","breadcrumb.data":{"tabId":"web-terminal-5ba47c7e-…","flips":12,"elapsedMs":20011,"windowMs":60000}
terminal_park_verdict_churn","breadcrumb.data":{"tabId":"web-terminal-5e95e5ab-…","flips":12,"elapsedMs":1186,"windowMs":60000}
terminal_park_verdict_churn","breadcrumb.data":{"tabId":"web-terminal-5e95e5ab-…","flips":12,"elapsedMs":1697,"windowMs":60000}
terminal_park_verdict_churn","breadcrumb.data":{"tabId":"web-terminal-5e95e5ab-…","flips":12,"elapsedMs":4889,"windowMs":60000}

$ grep -o 'terminal_park_verdict_churn","breadcrumb.data":{[^}]*}' F0BMU4BQGMP.txt
terminal_park_verdict_churn","breadcrumb.data":{"tabId":"web-terminal-a9795b4d-…","flips":12,"elapsedMs":1355,"windowMs":60000}

$ grep -o 'terminal_park_verdict_churn","breadcrumb.data":{[^}]*}' F0BMJ4GGJE5.txt
terminal_park_verdict_churn","breadcrumb.data":{"tabId":"web-terminal-4521f8d5-…","flips":12,"elapsedMs":2347,"windowMs":60000}

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):

distinct diagnostic bundles carrying the crumb : 9
total terminal_park_verdict_churn crumbs       : 88
crumbs with elapsedMs < 3000 (render cadence)  : 65
fastest 12 flips                               : 348 ms
flips value observed                           : [12]

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):

- boundary_id: terminal.workbench
- error_message: Minified React error #185; visit https:/[redacted-path]
- error_stack: Error: Minified React error #185; …
    at getRootForUpdatedFiber …
    at enqueueConcurrentHookUpdate …
    at dispatchSetState …
    at commitHookEffectListMount …
    at commitPassiveMountOnFiber …
- component_stack: at TerminalPaneOverlayLayer$1 …
    at WorktreeSplitSurface$1 …

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 nestedUpdateCount is root-global and the throw
lands on whichever fiber calls setState next, so a component stack does not identify the offender — the repo
reached this conclusion itself in 4543bb6826. What is proven here is: (a) the loop is real and reachable
(the repro throws #185 on origin/main sources), 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.

  1. 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.

  2. 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.

  3. The root cause is damped, not removed. canWatcherCoverParkedTerminalTab still calls
    useAppStore.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 running
    away. 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 a
    durable renderer.breadcrumb span, so we can measure how often the damper actually engages before
    committing to the larger refactor. Related and also untouched: commit 49dc113a0f added an async
    terminalProviderHasAuthoritativeSnapshot lookup as a further untracked, time-varying input to the same
    predicate; that makes the underlying oscillator strictly more volatile on HEAD than in the crashing
    builds.

  4. TERMINAL_TAB_PARK_FLIP_COMMIT_COST = 12 is an assumed worst case, not a production measurement. It is
    an enumeration of the commits one flip drags behind it (pane mount/unmount, pane-connect updateTabPtyId,
    the parked-watcher clearTabLaunchAgent/setTabLayout/updateTabTitle writes, the overlay's zustand
    subscriber 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 the
    limit. Neither guard makes the constant a measurement.

  5. Breadcrumb shape changed; existing queries need updating. terminal_park_verdict_churn now carries a
    trigger field ('burst' | 'window') and the burst variant carries pinnedForMs. The crumb will also
    fire 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 === 12 will now see flips === 3 on burst crumbs.

  6. A verdict that was already pinned suppresses the slow-churn ('window') crumb for that window. This is
    intentional — 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.

  7. The header comment on terminal-park-verdict-flip-telemetry.ts reversed its own stated position. The
    file 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.activity crashes in the same G1
group. 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:

  • The damping threshold had originally been expressed in flips and set at the breadcrumb notice limit. A
    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_LIMIT and the commit cost, and
    a unit test now pins the derivation (BURST_LIMIT * COMMIT_COST < 50, BURST_LIMIT < NOTICE_LIMIT), so the
    two limits cannot silently converge again.
  • A reviewer found that the pin, as first written, was a permanent unpark: a pinned tab has every
    hysteresis deadline in the past, so getTerminalTabColdParkRecheckDelayMs returned null, no timer was
    armed, 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.

/perf skill review verdict: no regression. The damping path is a per-tab counter increment and two
integer comparisons inside an effect that already iterates the tab list; the pin adds one Map lookup per
park candidate and one extra deadline to an existing Math.min. No new subscriptions, timers, or store reads
were added — the pin reuses the existing recheck timer that the cool-down deadline already schedules.

Made with Orca 🐋

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.
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@nwparker, you've reached your PR review limit, so we couldn't start this review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f59f9130-a833-4c2f-926b-171d4a6af3ad

📥 Commits

Reviewing files that changed from the base of the PR and between e9cf106 and 0ab549e.

📒 Files selected for processing (7)
  • src/renderer/src/components/terminal-pane/terminal-cold-park-recheck-deadlines.test.ts
  • src/renderer/src/components/terminal-pane/terminal-cold-park-recheck-deadlines.ts
  • src/renderer/src/components/terminal-pane/terminal-cold-park-verdict-loop.test.tsx
  • src/renderer/src/components/terminal-pane/terminal-park-verdict-flip-telemetry.test.ts
  • src/renderer/src/components/terminal-pane/terminal-park-verdict-flip-telemetry.ts
  • src/renderer/src/components/terminal-pane/use-terminal-tab-cold-parking.test.ts
  • src/renderer/src/components/terminal-pane/use-terminal-tab-cold-parking.ts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

nwparker added a commit that referenced this pull request Aug 5, 2026
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.
@nwparker

nwparker commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

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: terminal-cold-park-verdict-loop.test.tsx throws the real Maximum update depth exceeded on main (53 verdict flips against a budget of 5), and models the worst-case store commits per park transition so the derived burst limit stays regression-tested against React's 50-commit bail.

Closing as superseded — no work is lost.

@nwparker nwparker closed this Aug 5, 2026
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant