Repository navigation
fix(terminal): stop parking pass queueing no-op renders that trip React #185 during worktree removal - #23636
Conversation
…lose bursts Removing an active worktree with many terminal panes closed each pane in its own commit. Every commit re-ran the parking pass, whose functional setters queued a render even when the sets were unchanged, so each commit left work pending and React's nested-update counter climbed past 50 (#185), taking down the terminal workbench boundary. Dispatch only when a set actually changes.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Parking pass no longer queues no-op renders —
use-terminal-parking-pass.tsnow mirrors the three dispatched id sets in a ref and calls the value setter only whenhaveSameIdSetreports a real difference, replacing functional updaters that returnedcurrent(which React still treats as a queued update during a pending-work burst). - Regression test added —
use-terminal-parking-pass.test.tsxdrives a host hook through 5 revision bumps and asserts exactly 5 renders plus the parked set still dispatching.
I verified the sole-writer assumption behind the ref (only the foundation declares these setters and only this pass consumes them), and independently reproduced the test's before/after: with the old functional-updater form it fails expected 10 to be 5; with the fix it passes. Parking semantics are unchanged because same-content sets were already skipped.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthrough
Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to The change suppresses redundant parking updates while preserving identified parking transitions. No actionable merge-blocking risk remains after normal checks. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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 |

Description
Removing the worktree you are looking at could crash the terminal area with "Minified React error #185" (Maximum update depth exceeded). The whole terminal workbench then showed its error fallback. One user hit this on 1.4.215 while deleting an active worktree that had 8–9 terminal panes and a running Claude session.
Mechanism. When a worktree is removed, the main process stops every terminal (PTY) in it. The renderer then closes those panes one at a time, and each close is its own synchronous React commit. After each commit, the terminal workbench's
useTerminalParkingPasseffect runs again and calls three state setters:setParkedTerminalWorktreeIds,setForceParkedTerminalWorktreeIdsandsetEvictionExemptTerminalTabIds. Their updaters return the same Set when nothing changed. React still queues a render for them anyway, because it skips its "same state, do nothing" shortcut while the component already has other work pending. So every commit in the burst leaves one more update behind. React counts these chained updates and never resets the count during the burst. It grows by about 1.7 per closed pane. Past about 30 panes it goes over React's limit of 50 and throws #185, right atsetParkedTerminalWorktreeIds. That is the exact statement in the user's crash frame (Terminal-M0kI6An6.js:2:103140in 1.4.215).Change (
src/renderer/src/components/use-terminal-parking-pass.ts). The hook now keeps a ref of the last three sets it dispatched. This effect is the only code that writes those three states. It calls a setter only when the new set actually differs (haveSameIdSet). An unchanged pass now dispatches nothing, so it queues no render and leaves nothing pending.Before / after for the user: before, deleting an active worktree with many terminal panes could crash the terminal area. After, deletion completes normally. Parking decisions (which hidden worktrees get parked) are unchanged.
Why this approach. It removes the source of the chained updates with a small, local change. The alternative was to batch the whole pty-exit teardown while a worktree is being deleted. That touches the pane manager and the tab-close paths, so it is riskier. It is noted below as possible follow-up.
Fix evidence
Unit regression test:
src/renderer/src/components/use-terminal-parking-pass.test.tsx. A host hook owns the three parking states plus a revision state. It bumps the revision 5 times on the same component, which reproduces the case where React skips its same-state shortcut. The test asserts exactly 5 renders and checks that the parked set is still dispatched.AssertionError: expected 10 to be 5. Every bump caused one extra no-op render.Tests 1 passed (1).Real Electron app, end to end. The app was built with
npx electron-vite build --mode e2eand run hidden withORCA_BACKGROUND_LAUNCH=1. The React bundle was patched with one read-only line that records the peak of React's own nested-update counter, the counter that throws #185 above 50. A local, uncommitted Playwright probe did the following:Minified React error #185 ... at Terminal-g_NrAwx8.js:2:104389(setParkedTerminalWorktreeIds),[terminal.workbench] render crash contained by boundary, test failedWebAssembly.instantiate(): Out of memory, which is the separate too-many-terminals issue tracked in #23499The crash in the "before" build matches the user's report:
d(e=>bo(e,n.nextParkedTerminalWorktreeIds)?e:...)here, andmo(...)in the 1.4.215 chunk extracted from the shipped app._i/mi/zs/Rs/Kc/kl/Ol) and the sameterminal.workbenchboundary.Other checks:
pnpm teston the new test plussrc/renderer/src/components/terminal-pane/: 4729 passed.terminal-hidden-view-parking,terminal-parked-close-retirement,terminal-parked-memoryandterminal-parked-cli-split, 9 passed.pnpm tc:web: OK.ELI5 of the fix
Every time a terminal closed, a helper said "update the parking list!" even when the list had not changed. React took each of those as real work. When you deleted a worktree with lots of terminals, dozens of "nothing changed" updates arrived in a row. React decided it was stuck in an infinite loop and crashed the terminal area. Now the helper remembers what it last said and stays quiet when the list is the same.
Trade-offs
react_commit_cascadetelemetry still cannot see this kind of chain, because it reads pending work before the passive effects run. That is unchanged here.Adversarial review
1 loop until clean.
pnpm tc:webpass. The single type assertion in the test has aSAFETYcomment.Linked crash reports
Visual Proof
N/A. This fixes a crash with no visual change. The evidence is the test and the e2e counter results above.
Testing
Agent skill upstream boundary
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)Additional merge-risk verification (2026-10-02)
Integrated current main. Initialized the parking-set mirror lazily so repeated renders do not allocate three unused Sets. Added changed-set and Strict Mode regression coverage; 81 tests passed across five parking/retention suites, renderer typecheck passed, and the changed-code quality gate passed for the two PR files. Existing unrelated untracked reproduction artifacts were excluded from that gate. The recorded 30-pane Electron reproduction establishes this crash class; the exact 8–9-pane field incident is still unconfirmed.