Repository navigation
fix(renderer): break Activity and terminal React #185 loops - #12600
Conversation
📝 WalkthroughWalkthroughThe change adds sliding-window churn budgets for activity portal readiness and preserves readiness latch state across subscription churn. Activity portal publication now suppresses notifications for semantically identical targets. Thread reconciliation tests cover swap staging and settling. Terminal park-verdict telemetry now applies burst damping and temporary unpark pins. Cold-parking schedules rechecks at pin expiry and restores parking after the pin ends. Regression tests cover these behaviors. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/renderer/src/components/terminal-pane/terminal-park-verdict-flip-telemetry.ts (1)
39-46: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueNote that a flip-window reset also clears an active pin.
resetFlipWindowsclearspinnedUntilMs.recordParkVerdictFlipscalls it whenelapsedMs >= flipWindowMs. The pin deadline isnowMs + flipWindowMs, andnowMs >= windowStartMs, so the flip window always expires before the pin does. A flip recorded in that gap releases the pin early.In practice a pinned tab stays unparked, so no verdict flip occurs while the pin holds. An exogenous flip (visibility change, tab removal) is the only way to reach this path, and a fresh window is a reasonable outcome there. Consider stating that intent in the comment, or preserve
pinnedUntilMsinresetFlipWindowsand clear it only ingetParkVerdictUnparkPinUntilMs.Also applies to: 113-130
src/renderer/src/components/terminal-pane/terminal-cold-park-verdict-loop.test.tsx (1)
212-217: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueGuard the unmount when
rootwas never assigned.
afterEachcallsroot.unmount().rootis assigned inside each test. IfcreateRootthrows,afterEachraises aTypeErrorand hides the real failure.🛡️ Proposed guard
afterEach(() => { act(() => { - root.unmount() + root?.unmount() }) container.remove() })Declare it as
let root: Root | undefined.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: e5eff714-6c4f-48a0-ac69-109949338585
📥 Commits
Reviewing files that changed from the base of the PR and between 7c26cce and 25c7cdfe603c816da4d4d3afbb35a06f3841971a.
📒 Files selected for processing (19)
src/renderer/src/components/activity/ActivityPrototypePage.tsxsrc/renderer/src/components/activity/activity-portal-churn-budget.test.tssrc/renderer/src/components/activity/activity-portal-churn-budget.tssrc/renderer/src/components/activity/activity-portal-readiness-decay.react185.test.tsxsrc/renderer/src/components/activity/activity-portal-readiness-loop.react185.test.tsxsrc/renderer/src/components/activity/activity-portal-readiness-oscillation.test.tssrc/renderer/src/components/activity/activity-portal-readiness-oscillation.tssrc/renderer/src/components/activity/activity-portal-readiness-subscription-churn.react185.test.tsxsrc/renderer/src/components/activity/activity-portal-thread-reconciliation.test.tssrc/renderer/src/components/activity/activity-terminal-portal-publication-loop.react185.test.tsxsrc/renderer/src/components/activity/activity-terminal-portal.test.tsxsrc/renderer/src/components/activity/activity-terminal-portal.tssrc/renderer/src/components/terminal-pane/terminal-cold-park-recheck-deadlines.test.tssrc/renderer/src/components/terminal-pane/terminal-cold-park-recheck-deadlines.tssrc/renderer/src/components/terminal-pane/terminal-cold-park-verdict-loop.test.tsxsrc/renderer/src/components/terminal-pane/terminal-park-verdict-flip-telemetry.test.tssrc/renderer/src/components/terminal-pane/terminal-park-verdict-flip-telemetry.tssrc/renderer/src/components/terminal-pane/use-terminal-tab-cold-parking.test.tssrc/renderer/src/components/terminal-pane/use-terminal-tab-cold-parking.ts
| function renderOverlayHost(root: Root): unknown { | ||
| const consoleError = vi.spyOn(console, 'error').mockImplementation(() => {}) | ||
| let thrown: unknown = null | ||
| try { | ||
| act(() => { | ||
| root.render(<OverlayHost />) | ||
| }) | ||
| } catch (error) { | ||
| thrown = error | ||
| } | ||
| consoleError.mockRestore() | ||
| return thrown | ||
| } |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🌐 Web query:
React 19 onUncaughtError createRoot render errors no longer rethrown reportError
💡 Result:
In React 19, error handling behavior has been updated to prevent the re-throwing of errors that occur during rendering [1][2][3]. Previously, React would catch errors and re-throw them, which often resulted in duplicate error logs [4][2]. The current behavior in React 19 is as follows: 1. Uncaught Errors: Errors that are not caught by an Error Boundary are reported directly to window.reportError [1][2][3]. They are no longer re-thrown, which avoids triggering duplicate browser-level uncaught error logs [5][2]. 2. Caught Errors: Errors caught by an Error Boundary are reported to console.error [1][2][3]. 3. Customization: To allow developers to hook into these error reporting processes—for example, to send errors to a logging service or to suppress them—React 19 introduced two new configuration options for createRoot and hydrateRoot [6][4][2]: - onUncaughtError: A callback invoked when an error is thrown and not caught by an Error Boundary [6][7]. - onCaughtError: A callback invoked when an error is caught by an Error Boundary [6][7]. These changes were implemented to clean up error logging, reduce duplication, and provide a more predictable interface for production error reporting [4][7][2]. If your application or testing suite relies on the previous behavior of re-throwing errors, you may need to update your configuration using these new root options [2].
Citations:
- 1: https://github.com/react/react/blob/refs/heads/main/CHANGELOG.md
- 2: https://react.dev/blog/2024/04/25/react-19-upgrade-guide
- 3: https://github.com/react/react/releases/tag/v19.0.0
- 4: https://react.dev/blog/2024/12/05/react-19
- 5: [Fiber] Don't Rethrow Errors at the Root react/react#28627
- 6: https://react.dev/reference/react-dom/client/createRoot
- 7: Make onUncaughtError and onCaughtError Configurable react/react#28641
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf 'Package files:\n'
git ls-files | rg '(^|/)(package\.json|package-lock\.json|pnpm-lock\.yaml|yarn\.lock)$' || true
printf '\nReact version declarations:\n'
rg -n '"react"|"react-dom"|"`@testing-library/react`"' -g 'package.json' -g 'package-lock.json' -g 'pnpm-lock.yaml' -g 'yarn.lock' . || true
printf '\nTarget test outline and relevant sections:\n'
wc -l src/renderer/src/components/terminal-pane/terminal-cold-park-verdict-loop.test.tsx || true
sed -n '1,260p' src/renderer/src/components/terminal-pane/terminal-cold-park-verdict-loop.test.tsx | nl -baRepository: stablyai/orca
Length of output: 807
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf 'Target test relevant sections:\n'
sed -n '1,260p' src/renderer/src/components/terminal-pane/terminal-cold-park-verdict-loop.test.tsx | awk '{printf "%5d %s\n", NR, $0}'
printf '\nReact docs references in test file dependencies:\n'
sed -n '1,80p' package.json | awk '{printf "%5d %s\n", NR, $0}'Repository: stablyai/orca
Length of output: 18391
🏁 Script executed:
#!/bin/bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
import re
root = Path('.')
tsconfig = root / 'config/vitest.config.ts'
vite = root / 'config/vitest.config.ts'
if tsconfig.exists():
text = tsconfig.read_text(errors='replace')
if text:
print('config/vitest.config.ts exists')
for key in ['browser', 'testEnvironment', 'environment', 'deps', 'external', 'include', 'alias']:
if key in text:
print(f'\n--- relevant {key} ---')
for i, line in enumerate(text.splitlines(), 1):
if key in line or key.rstrip('s') in line:
start=max(1,i-2); end=min(len(text.splitlines()), i+3)
lines=text.splitlines(); print("\n".join(f"{n:5}: {lines[n-1]}" for n in range(start,end+1)))
if vite.exists():
print('config/vitest.config.ts exists')
PY
printf '\nSearch createRoot usage in renderer frontend tests/source:\n'
rg -n "createRoot\\(" src/mobile src/renderer 2>/dev/null | head -200 || true
printf '\nSearch onUncaughtError usages:\n'
rg -n "onUncaughtError|reportError|Maximum update depth|nested update|act\\(\\(" --glob '*.{ts,tsx,js,jsx}' . | head -200 || trueRepository: stablyai/orca
Length of output: 42940
Capture React 19 render errors through onUncaughtError.
This file uses @testing-library/react 16 with React 19. Uncaught render errors are reported by the root error callback instead of always being rethrown from act. Store uncaught errors and assert both renderedErrors, the optional thrown, and parkVerdictFlipCount so the test does not pass when the nested-update bail is handled by reportError.
|
Thanks — went through all three. Two fixed, one respectfully declined with evidence.
Worth noting for the second test case ( Flip-window reset clearing an active pin — fixed, and it was worse than "trivial". You had the mechanism exactly right: the notice window starts at the first flip and the pin one burst later, so the window always lapses first. Rather than only comment the intent, I removed That also closed a second bug your analysis pointed at indirectly:
Separately, a review pass caught something adjacent to your area: the new |
Review follow-ups on the React stablyai#185 loop fix: - key the portal descriptor equality off `keyof ActivityTerminalPortalTarget` so a new field fails the build instead of silently suppressing a publish - gate damping and breadcrumbs on pin *liveness*, and stop the 60s notice window reset from releasing an active pin - coalesce park-churn breadcrumbs by trigger so a `burst` (damping engaged a commit short of stablyai#185) cannot collapse into a slow-churn `window` slot - document that damping covers only the cold-park input of the verdict
main's stablyai#12574 grew use-terminal-tab-cold-parking.ts alongside this branch, so the merge crossed the 300-line budget. Move the last gate between a candidate and an unmounted pane — watcher coverage and the verdict-flip pin — into its own module rather than ratcheting the limit.
db2d09a to
5e1a69f
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/renderer/src/components/terminal-pane/terminal-cold-park-withheld-tabs.ts (1)
1-8: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueKeep comments concise and non-obvious.
src/renderer/src/components/terminal-pane/terminal-cold-park-withheld-tabs.ts#L1-L8,L43-L44: Replace the multi-line control-flow and historical comments with one short safety-intent comment.src/renderer/src/components/terminal-pane/terminal-cold-park-withheld-tabs.test.ts#L78-L78: Remove the comment because the adjacent assertion states the same fact.As per coding guidelines, comments in
*.tsmust be concise, non-obvious, and brief.Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 70eb6de5-a2ff-4906-8079-72179b363cc1
📒 Files selected for processing (23)
src/main/ipc/crash-reporting-renderer-breadcrumbs.test.tssrc/main/ipc/crash-reporting.tssrc/renderer/src/components/activity/ActivityPrototypePage.tsxsrc/renderer/src/components/activity/activity-portal-churn-budget.test.tssrc/renderer/src/components/activity/activity-portal-churn-budget.tssrc/renderer/src/components/activity/activity-portal-readiness-decay.react185.test.tsxsrc/renderer/src/components/activity/activity-portal-readiness-loop.react185.test.tsxsrc/renderer/src/components/activity/activity-portal-readiness-oscillation.test.tssrc/renderer/src/components/activity/activity-portal-readiness-oscillation.tssrc/renderer/src/components/activity/activity-portal-readiness-subscription-churn.react185.test.tsxsrc/renderer/src/components/activity/activity-portal-thread-reconciliation.test.tssrc/renderer/src/components/activity/activity-terminal-portal-publication-loop.react185.test.tsxsrc/renderer/src/components/activity/activity-terminal-portal.test.tsxsrc/renderer/src/components/activity/activity-terminal-portal.tssrc/renderer/src/components/terminal-pane/terminal-cold-park-recheck-deadlines.test.tssrc/renderer/src/components/terminal-pane/terminal-cold-park-recheck-deadlines.tssrc/renderer/src/components/terminal-pane/terminal-cold-park-verdict-loop.test.tsxsrc/renderer/src/components/terminal-pane/terminal-cold-park-withheld-tabs.test.tssrc/renderer/src/components/terminal-pane/terminal-cold-park-withheld-tabs.tssrc/renderer/src/components/terminal-pane/terminal-park-verdict-flip-telemetry.test.tssrc/renderer/src/components/terminal-pane/terminal-park-verdict-flip-telemetry.tssrc/renderer/src/components/terminal-pane/use-terminal-tab-cold-parking.test.tssrc/renderer/src/components/terminal-pane/use-terminal-tab-cold-parking.ts
🚧 Files skipped from review as they are similar to previous changes (21)
- src/main/ipc/crash-reporting-renderer-breadcrumbs.test.ts
- src/renderer/src/components/terminal-pane/use-terminal-tab-cold-parking.ts
- src/renderer/src/components/activity/activity-portal-churn-budget.test.ts
- src/renderer/src/components/terminal-pane/terminal-park-verdict-flip-telemetry.ts
- src/renderer/src/components/activity/activity-portal-readiness-loop.react185.test.tsx
- src/renderer/src/components/terminal-pane/use-terminal-tab-cold-parking.test.ts
- src/renderer/src/components/terminal-pane/terminal-park-verdict-flip-telemetry.test.ts
- src/renderer/src/components/activity/ActivityPrototypePage.tsx
- src/renderer/src/components/terminal-pane/terminal-cold-park-recheck-deadlines.ts
- src/renderer/src/components/activity/activity-portal-thread-reconciliation.test.ts
- src/renderer/src/components/activity/activity-terminal-portal-publication-loop.react185.test.tsx
- src/renderer/src/components/terminal-pane/terminal-cold-park-recheck-deadlines.test.ts
- src/renderer/src/components/activity/activity-portal-readiness-oscillation.test.ts
- src/renderer/src/components/activity/activity-portal-readiness-decay.react185.test.tsx
- src/main/ipc/crash-reporting.ts
- src/renderer/src/components/activity/activity-terminal-portal.test.tsx
- src/renderer/src/components/activity/activity-portal-readiness-subscription-churn.react185.test.tsx
- src/renderer/src/components/terminal-pane/terminal-cold-park-verdict-loop.test.tsx
- src/renderer/src/components/activity/activity-terminal-portal.ts
- src/renderer/src/components/activity/activity-portal-churn-budget.ts
- src/renderer/src/components/activity/activity-portal-readiness-oscillation.ts
…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.
Summary
Breaks two independent React #185 (
Maximum update depth exceeded) crash loops in the renderer.This supersedes #12492 and #12485.
Commits
fix(renderer): break activity and terminal React 185 loops— the two fixes above.fix(renderer): harden portal equality, park pin lifetime, churn crumbs— review follow-ups (see AI Review Report).refactor(terminal): extract the cold-park withholding gate— rebase fallout, see Notes.Screenshots
No visual change. The user-visible effect is the absence of a crash; both fixes settle existing surfaces on their current rendering (pane stays mounted, portal stays on its last good routing).
Testing
pnpm lintpnpm typecheckpnpm test— full renderer green; 3,132 tests across the affectedactivity/,terminal-pane/, and crash-reporting directories re-run after every change belowpnpm build(package + package (windows) green in CI)Reproduction evidence — verified by re-running the new tests against
mainwith production source unchanged. All four fail onmainand pass here:mainterminal-cold-park-verdict-loop.test.tsxError: Maximum update depth exceeded(53 verdict flips, budget 5)activity-terminal-portal-publication-loop.react185.test.tsxError: Maximum update depth exceededactivity-portal-readiness-subscription-churn.react185.test.tsxSet{'unavailable','loading'}vsSet{'unavailable'}activity-portal-readiness-decay.react185.test.tsxexpected 'unavailable' to be 'loading'Recovery is covered too: terminal re-parking after damping, and Activity returning from latched-unavailable to quiet loading without an unrelated DOM mutation.
AI Review Report
Ran the
/readiness-checklistreview across all seven areas with independent agents per area. No P0 or P1 findings. Verified clean: no unsafe casts; no unbounded growth (eventsAtcapped atlimit, the flip-recordMapis pruned againstliveTabIdseach pass, timers rebuilt per effect run); no TDZ on the newcheckReadinessclosure; the release timer provably terminates in one hop; and no wedge path — a pinned tab always retains a scheduled wakeup, andnext('ready')unconditionally clears the readiness budget.Four review findings were fixed in commit 2:
ActivityTerminalPortalTargetwould have silently suppressed a publish — the stale-routing bug this file exists to prevent. Now keyed offkeyof ActivityTerminalPortalTargetviasatisfies; confirmed empirically that adding a field is a compile error.resetFlipWindowsreleased the pin early. Damping and breadcrumbs now gate on pin liveness.pinnedUntilMsgated both breadcrumb triggers forever. Liveness fixes this too.triggerfield was erased by coalescing.terminal_park_verdict_churnwas name-only coalesced insrc/main/ipc/crash-reporting.ts, collapsing aburst(damping engaged one commit short of fix: improve scrollbar and file explorer scroll behavior #185) into a slow-churnwindowslot. Now keyed by trigger — still bounded to two slots per storm.Also addressed the CodeRabbit review: the
root?.unmount()guard and the pin-lifetime nitpick are fixed above. The one comment flagged "actionable" — that React 19 routes render errors toonUncaughtErrorinstead of rethrowing fromact— was declined with evidence: these tests do not import@testing-library/reactat all (rawcreateRoot+ React's ownact), and onmaintheexpect(thrown).toBeNull()assertion is precisely the one that fails. Full reply in the thread.Cross-platform explicitly checked:
window.setTimeout/clearTimeoutuse the DOM overload matching the existing pattern in this directory; allwindowaccess sits inside effect bodies, so node-env specs still import cleanly.Date.now()sleep/resume and NTP jumps were checked in both directions — a forward jump empties the churn window and a backward jump releases the pin; neither can wedge a pane. No keyboard shortcuts, paths, or shell behavior touched. Nothing here reachesmobile/or the paired web client (grep-confirmed).Security Audit
No input handling, command execution, path handling, auth, secrets, or dependency risk. Renderer-only behavior change; no
package.json, lockfile,.npmrc, orpatches/change, and all three branch commits are accounted for. No shell,eval, dynamic require, network sink, or URL is introduced. The only cross-process surface is the existingterminal_park_verdict_churnbreadcrumb, whose payload gains one literal string (trigger) and numbers — no user data, and the change is purely additive.ActivityTerminalPortalTargetholds a liveHTMLElementand cannot cross IPC;ParkVerdictFlipRecordisuseRef-local with no persistence, schema, or migration.Notes
Rebase fallout (commit 3).
mainadvanced 11 commits under this branch, and #12574 grewuse-terminal-tab-cold-parking.ts— the same file this PR grows. Neither is over budget alone, but CI lints the merge, and together they hit 303 effective lines against the 300 limit for.ts. Fixed by extractingterminal-cold-park-withheld-tabs.ts(the last gate between a cold-park candidate and an unmounted pane: watcher coverage and the verdict-flip pin), not by amax-linesdisable or a ratchet bump. Ships with 5 tests including the pin-lapse path. Note that a localpnpm linton a branch behindmaincannot catch this class of merge-only violation.Accepted trade-offs and follow-ups, none release-blocking:
burstcrumb for one tab reads as "damping did not reach the oscillating input".unavailablefor up to 500ms and swap early. Bounded, self-healing, and deliberately tested — the alternative is the crash.TERMINAL_TAB_PARK_FLIP_COMMIT_COST = 12is an asserted worst case, not a measurement. The test pins the arithmetic against React's 50-commit bail at exactly that cost, but not the premise.ORCA_E2E_TERMINAL_PARKING_DELAY_MSshrinks the park delay to 500ms but the 1s burst window and 60s pin are not overridable. A spec producing 3 park transitions inside 1s would hold a pane mounted for 60s. Not reproduced (needs the Electron e2e run, skipped on this PR); if the parking suite goes flaky, route the burst/pin windows throughgetTerminalParkingPolicyOverrides.