Skip to content

fix(terminal-pane): resolve React #185 setState loop via state identity - #10632

Merged
AmethystLiang merged 1 commit into
mainfrom
crash-c5c6-react185
Jul 26, 2026
Merged

AmethystLiang merged 1 commit into
mainfrom
crash-c5c6-react185

Conversation

@AmethystLiang

Copy link
Copy Markdown
Contributor

Summary

Fixes React #185: a setState loop in TerminalPane's pane-title overlay measurement effect. The effect was calling setPaneTitleOverlayRects({}) with a fresh object literal on every pass, violating React's referential equality contract and forcing redundant renders.

Root Cause

In TerminalPane, layout measurement effects needed to reset overlay rects when the manager or container unmounted. Calling setPaneTitleOverlayRects({}) creates a new object on every effect execution, so React sees it as a state change even when the previous state was also empty — triggering the effect again immediately, forming a loop.

Solution

  1. Extract state-identity helpers to pane-title-overlay-rects.ts:

    • clearPaneTitleOverlayRects(prev) returns prev unchanged if already empty, or a new {} only if it was populated. This preserves referential equality when nothing changes.
    • arePaneTitleOverlayRectsEqual(a, b) compares rect maps with sub-pixel tolerance, used when state does legitimately change.
  2. Call clearPaneTitleOverlayRects() instead of {} in measurement effects, guaranteeing no spurious renders when clearing.

  3. Add telemetry to detect park-verdict churn (crash cluster C5): recordParkVerdictFlips observes whether the rendered cold-park status actually oscillates, emitting one breadcrumb per 60s window if ≥12 flips occur. This is observation-only and changes no logic.

  4. Extend crash-reporting coalescing to handle per-tab, high-frequency breadcrumbs like terminal_park_verdict_churn by coalescing on name alone (not message), so a many-tab storm doesn't evict the pre-crash trail.

Testing

  • pane-title-overlay-rects.test.ts: identity contracts (empty-stable returns, sub-pixel tolerance, map-count diffs)
  • terminal-park-verdict-flip-telemetry.test.ts: breadcrumb emission, window re-arming, backwards-clock handling, per-tab independence
  • crash-reporting-renderer-breadcrumbs.test.ts: coalescing by name for park-verdict churn across multiple tabs

Notes

  • AddressPicker: no changes needed. Added a note clarifying that the crashing dispatch is in @radix-ui/react-select's unmount cleanup, not our code.
  • Park-verdict telemetry is deliberately unguarded — if the effect loop exists, we want to see it, not hide it behind damping.

Preserve object identity in pane-title overlay rect state to fix infinite
re-renders. A fresh {} literal creates a new reference on every call, causing
React to treat the state as changed even when logically equivalent, triggering
the layout effect to continuously re-measure and re-set state (React #185).

Add cold-park verdict flip telemetry to diagnose crash cluster C5: records
whether parking state churns in the field for next crash bundle analysis.

Document that AddressPicker crash (cluster C6) originates in radix-ui's
SelectItem unmount cleanup, not in our component code.
@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5efda765-5c3c-43d3-9cd9-fd457a3661e4

📥 Commits

Reviewing files that changed from the base of the PR and between 468f5b7 and 505f380.

📒 Files selected for processing (9)
  • src/main/ipc/crash-reporting-renderer-breadcrumbs.test.ts
  • src/main/ipc/crash-reporting.ts
  • src/renderer/src/components/network/AddressPicker.tsx
  • src/renderer/src/components/terminal-pane/TerminalPane.tsx
  • src/renderer/src/components/terminal-pane/pane-title-overlay-rects.test.ts
  • src/renderer/src/components/terminal-pane/pane-title-overlay-rects.ts
  • 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.ts

📝 Walkthrough

Walkthrough

Adds per-tab terminal park-verdict flip telemetry with time-window handling, stale-record cleanup, and crash breadcrumb emission. Renderer breadcrumb coalescing now supports the new telemetry and broader keying rules. Pane-title overlay rectangle types and helpers move into a shared module, with state reset updates and unit tests for comparison and reference stability.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers summary, testing, and notes, but it omits required Screenshots, AI Review Report, and Security Audit sections. Add the Screenshots, AI Review Report, and Security Audit sections, and fill Testing in the template's checklist format with the required commands.
Docstring Coverage ⚠️ Warning Docstring coverage is 30.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: fixing the TerminalPane setState loop via stable state identity.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

@AmethystLiang
AmethystLiang merged commit 17617b1 into main Jul 26, 2026
4 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…e identity (stablyai#10632)

Preserve object identity in pane-title overlay rect state to fix infinite
re-renders. A fresh {} literal creates a new reference on every call, causing
React to treat the state as changed even when logically equivalent, triggering
the layout effect to continuously re-measure and re-set state (React stablyai#185).

Add cold-park verdict flip telemetry to diagnose crash cluster C5: records
whether parking state churns in the field for next crash bundle analysis.

Document that AddressPicker crash (cluster C6) originates in radix-ui's
SelectItem unmount cleanup, not in our component code.
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