Repository navigation
perf(terminal): defer cold worktree activation tab mounts until first reveal - #8597
Conversation
… reveal Activating a worktree mounted a TerminalPane for every saved terminal tab in one render pass. Each mount replays scrollback through xterm, attaches a WebGL renderer, and issues a sync-IPC snapshot read, so a worktree with many agent-session tabs froze the renderer for tens of seconds (field trace: 200+ replay-guard stall releases inside one activation window, plus restore-marker feedback loops re-fetching snapshots at ~4/sec). Cold activations now mount only the tabs the user can see (active tab, each split group's active tab, activity-portal tabs, pending spawns) plus tabs that are already live or that parked byte watchers cannot cover. Every other tab defers like a cold-parked tab from birth: no view until first reveal, with the parked byte watchers owning bell/title/completion side effects meanwhile. The restriction reuses the targeted background mount mechanism and lifts once every tab has been revealed. Deferral only engages when more than four tabs would mount cold, and only while hidden-view parking is enabled, so small worktrees and the parking kill switch keep today's behavior.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughTerminal activation now defers selected tab mounts and reveals them as tabs become visible. Parked watchers provide coverage and optional title restoration for deferred tabs. PTY reconnect and exit handling now buffer live data, suppress duplicate exits, coordinate primary and sidecar callbacks, and avoid respawning sessions that exited before attachment. Watcher disposal, terminal close callbacks, pinned-tab confirmation queuing, worktree removal cleanup, SSH startup reconnect, host resolution, and registration cleanup were also updated. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 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
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/renderer/src/components/Terminal.tsx (1)
1070-1136: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick winInclude the deferral inputs in the watcher-sync deps.
groupsByWorktree,activeTabIdByWorktree, andpendingStartupByTabIdfeed the render-bodyimmediateTabIds/revealActivationDeferredTabspath, so leaving them out can delay legacy parking reconciliation until some unrelated dependency changes.src/renderer/src/components/Terminal.tsx:1122-1136
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 1a00c1a1-751e-4ec1-810f-3039814d9eed
📒 Files selected for processing (6)
src/renderer/src/components/Terminal.tsxsrc/renderer/src/components/terminal-pane/TerminalPaneOverlayLayer.tsxsrc/renderer/src/components/terminal-pane/use-terminal-tab-cold-parking.tssrc/renderer/src/components/terminal/background-terminal-worktree-mount.test.tssrc/renderer/src/components/terminal/background-terminal-worktree-mount.tssrc/renderer/src/runtime/sync-runtime-graph.ts
… past hydration's blanket spawn flag The new e2e (child worktree, 8 tabs, renderer reload against live daemon sessions) caught the deferral never engaging: session hydration marks every persisted tab pendingActivationSpawn, and treating that flag as must-mount-now put all tabs in the immediate set. Only explicit queued startups (pendingStartupByTabId) mount eagerly; a deferred tab's reveal consumes the hydration flag exactly like an activation mount would. Sleep/wake respawn flows go through targeted background mounts and are unaffected (terminal-sleep-wake-restore passes). The spec asserts the visible tab mounts, deferred tabs stay unmounted with parked byte-watcher coverage, and a revealed tab mounts on demand.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/renderer/src/components/terminal-pane/parked-terminal-byte-watcher.ts (1)
254-284: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
restoreTitleOnRegisteris skipped in byte-parser mode.src/renderer/src/components/terminal-pane/parked-terminal-byte-watcher.ts:265-284forwards this only throughregisterTerminalSideEffectFactConsumer(), so whenmainSideEffectAuthorityis off the flag does nothing. That leaves cold-started parked tabs without a title snapshot, and their title can stay blank/stale until fresh bytes arrive. Add a byte-parser fallback or gate the option to main-authority-only parks.
🧹 Nitpick comments (1)
tests/e2e/terminal-cold-activation-deferral.spec.ts (1)
62-79: 🧹 Nitpick | 🔵 TrivialConfirm child worktree cleanup after this test.
The test creates a new child worktree (
e2e-cold-defer-${Date.now()}) but the spec has no visible teardown removing it. If theorca-appfixture doesn't reset repo/worktree state between runs, repeated CI runs will accumulate orphaned worktrees on disk.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 3dabc3a7-484b-4f3a-88b2-10d05e34aa84
📒 Files selected for processing (8)
src/renderer/src/components/Terminal.tsxsrc/renderer/src/components/terminal-pane/parked-terminal-byte-watcher.test.tssrc/renderer/src/components/terminal-pane/parked-terminal-byte-watcher.tssrc/renderer/src/components/terminal-pane/terminal-parked-tab-watchers.test.tssrc/renderer/src/components/terminal-pane/terminal-parked-tab-watchers.tssrc/renderer/src/components/terminal-pane/terminal-side-effect-facts-handler.tssrc/renderer/src/components/terminal-pane/use-terminal-tab-cold-parking.tstests/e2e/terminal-cold-activation-deferral.spec.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- src/renderer/src/components/terminal-pane/use-terminal-tab-cold-parking.ts
- src/renderer/src/components/Terminal.tsx
|
Follow-up hardening fixes are pushed in commit What was fixed:
Validation on the pushed commit:
|
There was a problem hiding this comment.
🧹 Nitpick comments (4)
src/renderer/src/components/Terminal.tsx (1)
1062-1083: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winGuard the per-render coverage-check loop once deferral has fully resolved.
On every render of an already-active worktree with
coldActivationDeferralEnabled === true, the loop overworktreeTabscallingcanWatcherCoverParkedTerminalTabfor every tab (lines 1071-1075) runs unconditionally — even afterrevealActivationDeferredTabshas nothing left to do because the worktree's deferred entry was already cleared. Skipping the loop (and therevealActivationDeferredTabscall) whenactivationDeferredMountTabIdsByWorktreeRef.currenthas no entry forrenderedActiveWorktreeIdwould avoid repeated per-tab work in the common steady state.♻️ Suggested guard
} else { // Why: tabs added after activation never passed the original coverage // gate. Uncoverable/no-PTY tabs must mount now so they can spawn or keep // their non-snapshot-backed live transport. - for (const tab of worktreeTabs) { - if (!canWatcherCoverParkedTerminalTab(renderedActiveWorktreeId, tab)) { - immediateTabIds.add(tab.id) + if (activationDeferredMountTabIdsByWorktreeRef.current.has(renderedActiveWorktreeId)) { + for (const tab of worktreeTabs) { + if (!canWatcherCoverParkedTerminalTab(renderedActiveWorktreeId, tab)) { + immediateTabIds.add(tab.id) + } } + revealActivationDeferredTabs({ + restrictions: backgroundMountTabIdsByWorktreeRef.current, + deferredMountTabIdsByWorktree: activationDeferredMountTabIdsByWorktreeRef.current, + worktreeId: renderedActiveWorktreeId, + allTabIds: worktreeTabs.map((tab) => tab.id), + immediateTabIds + }) } - revealActivationDeferredTabs({ - restrictions: backgroundMountTabIdsByWorktreeRef.current, - deferredMountTabIdsByWorktree: activationDeferredMountTabIdsByWorktreeRef.current, - worktreeId: renderedActiveWorktreeId, - allTabIds: worktreeTabs.map((tab) => tab.id), - immediateTabIds - }) }src/renderer/src/components/terminal-pane/pty-exit-delivery.ts (1)
36-45: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winSilently dropped sidecar errors beyond the first.
for (const sidecar of delivery.sidecars) { try { sidecar(delivery.code, { hadPrimary: delivery.primary !== undefined }) } catch (error) { if (!hasError) { firstError = error hasError = true } } } Only the first error across primary+sidecars is ever surfaced; any second/third sidecar failure is discarded with no trace at all. If two exit observers regress simultaneously, one failure disappears silently instead of being logged (unlike the analogous cleanup-failure path in
pty-transport.ts'sregisterPtyExitHandler, which logs viaconsole.error).🔍 Proposed fix to log swallowed secondary errors
for (const sidecar of delivery.sidecars) { try { sidecar(delivery.code, { hadPrimary: delivery.primary !== undefined }) } catch (error) { if (!hasError) { firstError = error hasError = true + } else { + console.error('[pty] exit sidecar failed after a prior error', error) } } }src/renderer/src/components/terminal-pane/terminal-parked-tab-watchers.test.ts (1)
49-52: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRename the discard-spy to match what it actually tests.
const consumePreHandlerPtyState = vi.fn() vi.mock('./pty-pre-handler-buffer', () => ({ discardPreHandlerPtyState: (ptyId: string) => consumePreHandlerPtyState(ptyId) })) This spy is wired to
discardPreHandlerPtyState, not the realconsumePreHandlerPtyStateexport, yet every assertion in this file (e.g.expect(consumePreHandlerPtyState).toHaveBeenCalledWith(PTY_ID)) reads as if it verifies the latter. This is confusing when a test fails and someone traces the wrong production function.✏️ Proposed rename
-const consumePreHandlerPtyState = vi.fn() +const discardPreHandlerPtyStateSpy = vi.fn() vi.mock('./pty-pre-handler-buffer', () => ({ - discardPreHandlerPtyState: (ptyId: string) => consumePreHandlerPtyState(ptyId) + discardPreHandlerPtyState: (ptyId: string) => discardPreHandlerPtyStateSpy(ptyId) }))(and update every
expect(consumePreHandlerPtyState)call-site accordingly)src/renderer/src/components/terminal-pane/pty-connection.test.ts (1)
7872-7898: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winTest mocks around the real synchronous exit dispatch instead of exercising it.
This test's mock calls
callbacks.onData(...)then resolves{ id, exitedBeforeAttach: true }directly, bypassing the realcreateIpcPtyTransport+ pre-handler-buffer path that actually produces this result (seepty-transport.ts, which synchronously drains a buffered exit and invokesonPtyExit— i.e. this pane's ownonExit()— beforeconnect()resolves). Consolidated with the ordering concern raised inpty-connection.ts.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: b66da4b8-2f2b-419e-8a74-24365d2214d8
📒 Files selected for processing (25)
src/renderer/src/components/Terminal.tsxsrc/renderer/src/components/terminal-pane/TerminalPaneOverlayLayer.tsxsrc/renderer/src/components/terminal-pane/pty-connection.test.tssrc/renderer/src/components/terminal-pane/pty-connection.tssrc/renderer/src/components/terminal-pane/pty-dispatcher-pi-routing.test.tssrc/renderer/src/components/terminal-pane/pty-dispatcher.tssrc/renderer/src/components/terminal-pane/pty-exit-delivery.tssrc/renderer/src/components/terminal-pane/pty-pre-handler-buffer.test.tssrc/renderer/src/components/terminal-pane/pty-pre-handler-buffer.tssrc/renderer/src/components/terminal-pane/pty-transport-types.tssrc/renderer/src/components/terminal-pane/pty-transport.test.tssrc/renderer/src/components/terminal-pane/pty-transport.tssrc/renderer/src/components/terminal-pane/terminal-parked-tab-watchers.test.tssrc/renderer/src/components/terminal-pane/terminal-parked-tab-watchers.tssrc/renderer/src/components/terminal-pane/terminal-parked-watcher-registry.test.tssrc/renderer/src/components/terminal-pane/terminal-parked-watcher-registry.tssrc/renderer/src/components/terminal-pane/use-terminal-tab-cold-parking.tssrc/renderer/src/components/terminal/background-terminal-worktree-mount.test.tssrc/renderer/src/components/terminal/background-terminal-worktree-mount.tssrc/renderer/src/components/terminal/terminal-tab-actions.test.tssrc/renderer/src/components/terminal/terminal-tab-actions.tssrc/renderer/src/store/slices/pinned-tab-close-confirm.test.tssrc/renderer/src/store/slices/pinned-tab-close-confirm.tssrc/renderer/src/store/slices/worktrees.tstests/e2e/terminal-cold-activation-deferral.spec.ts
🚧 Files skipped from review as they are similar to previous changes (3)
- src/renderer/src/components/terminal-pane/use-terminal-tab-cold-parking.ts
- src/renderer/src/components/terminal/background-terminal-worktree-mount.test.ts
- tests/e2e/terminal-cold-activation-deferral.spec.ts
|
Merged current main, resolved the pty-connection conflict, and pushed the regression fixes in 4eb58df. Fixed:
Validation:
One Docker startup attempt hit an sshd readiness flake before the test began; the clean retry and final instrumentation-free run both passed. |
|
Follow-up: main advanced again after the first push, including terminal session retirement changes. I merged the new tip and resolved the three close-path conflicts in 838450d, preserving both pinned-close callbacks and the new PTY-exit retirement metadata. Revalidated on the final merged tree:
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 1db6a2cb-5105-4888-a083-c7d12fa89688
📒 Files selected for processing (17)
config/reliability-gates.jsoncsrc/renderer/src/App.tsxsrc/renderer/src/components/Terminal.tsxsrc/renderer/src/components/terminal-pane/pty-connection.tssrc/renderer/src/components/terminal-pane/pty-transport.test.tssrc/renderer/src/components/terminal-pane/pty-transport.tssrc/renderer/src/components/terminal-pane/terminal-parked-tab-watchers.test.tssrc/renderer/src/components/terminal-pane/terminal-parked-tab-watchers.tssrc/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.tssrc/renderer/src/components/terminal/background-terminal-worktree-mount.test.tssrc/renderer/src/components/terminal/background-terminal-worktree-mount.tssrc/renderer/src/lib/resolved-worktree-execution-host.test.tssrc/renderer/src/lib/resolved-worktree-execution-host.tssrc/renderer/src/runtime/sync-runtime-graph-scheduling.test.tssrc/renderer/src/runtime/sync-runtime-graph.tssrc/renderer/src/startup/ssh-startup-reconnect.test.tssrc/renderer/src/startup/ssh-startup-reconnect.ts
🚧 Files skipped from review as they are similar to previous changes (7)
- src/renderer/src/components/terminal/background-terminal-worktree-mount.test.ts
- src/renderer/src/components/terminal-pane/pty-connection.ts
- src/renderer/src/components/terminal-pane/pty-transport.ts
- src/renderer/src/components/terminal-pane/terminal-parked-tab-watchers.ts
- src/renderer/src/components/terminal-pane/terminal-parked-tab-watchers.test.ts
- src/renderer/src/components/terminal/background-terminal-worktree-mount.ts
- src/renderer/src/components/Terminal.tsx
… they don't render blank (STA-1840) (#8811) * fix(mobile): background-mount never-mounted terminals on subscribe so they don't render blank (STA-1840) A mobile terminal.subscribe to a tab the desktop never mounted this session — a workspace the desktop isn't currently showing, a cold-activation-deferred tab (#8597), or a cold-parked tab — has no attached PTY, so the runtime has no headless emulator and the initial snapshot is empty. The mobile terminal then renders blank (repro: on the phone, scroll to an old workspace whose terminals the desktop unmounted; they stay blank). When a mobile subscribe hits an empty snapshot (or resolves no PTY), the runtime now asks the renderer to background-mount that tab so the PTY attaches and the live data stream — already subscribed on that path — delivers its output. A never-mounted workspace has no renderer-graph leaf, so its terminals are surfaced to mobile via synthetic pty:<ptyId> handles that carry no real UI tabId. The runtime passes the ptyId through the mount request and the renderer resolves the owning tab from the persisted tab model (resolveTerminalTabIdForPtyId), falling back to a whole-worktree background mount if it cannot. The request is idempotent for already-mounted tabs and never unmounts a live pane, so the worst case is the same blank as before — no regression. Validated on an iOS simulator with a two-workspace desktop: opening the workspace the desktop was not showing rendered a fully blank terminal without the fix and the live shell prompt with it. Tests: runtime mount-request gating (real-tab / pty-form / no-ptyId / unknown), subscribe-handler empty-snapshot-vs-content, and the ptyId->tabId resolver; all 608 RPC method tests pass. * test(mobile): mock onRequestTerminalTabMount in useIpcEvents tests (fixes CI for #8811) * fix(mobile): harden blank terminal recovery mounts * perf(mobile): avoid redundant terminal recovery mounts * fix(mobile): ignore stale terminal mount requests * fix(mobile): skip recovery mounts for closed streams * fix(mobile): reject ambiguous terminal mount ownership * fix(mobile): preserve terminal handle through recovery mount * fix(mobile): recover legacy terminal history safely --------- Co-authored-by: Jinwoo-H <[email protected]>
… reveal (stablyai#8597) * perf(terminal): defer cold worktree activation tab mounts until first reveal Activating a worktree mounted a TerminalPane for every saved terminal tab in one render pass. Each mount replays scrollback through xterm, attaches a WebGL renderer, and issues a sync-IPC snapshot read, so a worktree with many agent-session tabs froze the renderer for tens of seconds (field trace: 200+ replay-guard stall releases inside one activation window, plus restore-marker feedback loops re-fetching snapshots at ~4/sec). Cold activations now mount only the tabs the user can see (active tab, each split group's active tab, activity-portal tabs, pending spawns) plus tabs that are already live or that parked byte watchers cannot cover. Every other tab defers like a cold-parked tab from birth: no view until first reveal, with the parked byte watchers owning bell/title/completion side effects meanwhile. The restriction reuses the targeted background mount mechanism and lifts once every tab has been revealed. Deferral only engages when more than four tabs would mount cold, and only while hidden-view parking is enabled, so small worktrees and the parking kill switch keep today's behavior. * test(terminal): prove cold-activation deferral end-to-end; unblock it past hydration's blanket spawn flag The new e2e (child worktree, 8 tabs, renderer reload against live daemon sessions) caught the deferral never engaging: session hydration marks every persisted tab pendingActivationSpawn, and treating that flag as must-mount-now put all tabs in the immediate set. Only explicit queued startups (pendingStartupByTabId) mount eagerly; a deferred tab's reveal consumes the hydration flag exactly like an activation mount would. Sleep/wake respawn flows go through targeted background mounts and are unaffected (terminal-sleep-wake-restore passes). The spec asserts the visible tab mounts, deferred tabs stay unmounted with parked byte-watcher coverage, and a revealed tab mounts on demand. * fix(terminal): harden deferred activation lifecycle * docs(reliability): correct SSH startup assertion evidence
… they don't render blank (STA-1840) (stablyai#8811) * fix(mobile): background-mount never-mounted terminals on subscribe so they don't render blank (STA-1840) A mobile terminal.subscribe to a tab the desktop never mounted this session — a workspace the desktop isn't currently showing, a cold-activation-deferred tab (stablyai#8597), or a cold-parked tab — has no attached PTY, so the runtime has no headless emulator and the initial snapshot is empty. The mobile terminal then renders blank (repro: on the phone, scroll to an old workspace whose terminals the desktop unmounted; they stay blank). When a mobile subscribe hits an empty snapshot (or resolves no PTY), the runtime now asks the renderer to background-mount that tab so the PTY attaches and the live data stream — already subscribed on that path — delivers its output. A never-mounted workspace has no renderer-graph leaf, so its terminals are surfaced to mobile via synthetic pty:<ptyId> handles that carry no real UI tabId. The runtime passes the ptyId through the mount request and the renderer resolves the owning tab from the persisted tab model (resolveTerminalTabIdForPtyId), falling back to a whole-worktree background mount if it cannot. The request is idempotent for already-mounted tabs and never unmounts a live pane, so the worst case is the same blank as before — no regression. Validated on an iOS simulator with a two-workspace desktop: opening the workspace the desktop was not showing rendered a fully blank terminal without the fix and the live shell prompt with it. Tests: runtime mount-request gating (real-tab / pty-form / no-ptyId / unknown), subscribe-handler empty-snapshot-vs-content, and the ptyId->tabId resolver; all 608 RPC method tests pass. * test(mobile): mock onRequestTerminalTabMount in useIpcEvents tests (fixes CI for stablyai#8811) * fix(mobile): harden blank terminal recovery mounts * perf(mobile): avoid redundant terminal recovery mounts * fix(mobile): ignore stale terminal mount requests * fix(mobile): skip recovery mounts for closed streams * fix(mobile): reject ambiguous terminal mount ownership * fix(mobile): preserve terminal handle through recovery mount * fix(mobile): recover legacy terminal history safely --------- Co-authored-by: Jinwoo-H <[email protected]>
Problem
Activating a worktree mounts a
TerminalPanefor every saved terminal tab in one render pass. Each mount replays scrollback through xterm, attaches a WebGL renderer, runs synchronous fit/reflow, and issues a sync-IPC scrollback read — so a worktree with many agent-session tabs freezes the renderer for tens of seconds.Field evidence from the trace log (
main.trace.ndjson): activating a 12-tab review worktree produced 222terminal_replay_guard_wedged_releasebreadcrumbs in one minute — replay-guard stall timers all firing ~20s late, the post-mortem signature of a renderer main thread pegged through the whole activation. The un-ACKed replays also trip the restore-marker feedback loop, which re-fetches and re-replays main-buffer snapshots at ~4/sec into panes that are still parsing, compounding the freeze. Bursts of ~100 simultaneous daemon PTY attaches accompany activations of the largest worktrees.ELI5
Before this change, opening a worktree with lots of saved terminal or agent tabs was like turning on every TV in a house at the same time. Even though only one tab was visible, Orca rebuilt every hidden terminal, replayed its scrollback, laid it out, and attached its renderer all at once. That burst could temporarily pin the renderer and appear as intermittent UI lag or a long freeze.
After this change, Orca starts only the terminal tabs that are visible or immediately required. The other eligible local terminals stay safely parked and load when first opened. Small worktrees behave as before, and remote or uncertain hosts still mount eagerly for safety. The first reveal of a deferred tab can still take its normal bounded restore cost, but the large all-tabs-at-once activation spike is removed.
Why this is the standard architectural fix rather than a hack:
We tested both the immediate and eventual reopen paths:
This directly addresses the reported intermittent lag when activating terminal-heavy worktrees. It does not claim to fix unrelated lag from other parts of the app.
Fix
Cold activations now mount only the tabs the user can see, plus tabs that must mount:
group.activeTabIdis a unified-tab id — mapped to the terminal entity id), activity-portal tabs, and tabs with a queued startup (pendingStartupByTabId);TerminalPanes are never narrowed);canWatcherCoverParkedTerminalTab) — deferring those would drop bell/title/completion side effects, so they mount eagerly.Every other tab defers like a cold-parked tab from birth: no view until first reveal. While deferred, the existing parked byte watchers own exit handling and side effects — wired in both hosts (the legacy watcher reconciliation effect and
useTerminalTabColdParkingvia a newdeferredMountTabIdsarg). The restriction reuses the targeted-background-mount mechanism (backgroundMountTabIdsByWorktreeRef), grows on each reveal, and lifts once every tab has been revealed.pendingActivationSpawnis deliberately not an immediate-mount trigger: session hydration blanket-marks every persisted tab with it, so honoring it would disable deferral for the exact scenario it targets (the new e2e caught this). A deferred tab's reveal consumes the flag exactly like an activation mount would — just later. Sleep/wake respawn flows go through targeted background mounts and are unaffected.Deferral only engages when more than 4 tabs would mount cold, and only while hidden-view parking is enabled — small worktrees and the parking kill switch keep today's behavior exactly.
Verification
terminal-cold-activation-deferral.spec.tsreproduces the field scenario: child worktree, 8 tabs with live daemon PTYs, renderer reload so persisted tabs hydrate cold. Asserts: only the visible tab mounts, deferred tabs stay unmounted (no late timer mounts), every deferred tab has parked byte-watcher coverage, and revealing a deferred tab mounts it on demand. This spec failed against two earlier iterations of the change (caught thependingActivationSpawnblanket flag and the primary-vs-child worktree coverage rule) before passing.terminal-sleep-wake-restore,terminal-hidden-view-parking,worktree-lifecycle,tab-close-navigationall pass.terminal/+terminal-pane/pass, including 7 new tests for the deferral policy.tsc,oxlint, and react-doctor clean on all touched files.Known limits
repoId::pathsession ids), so primary-worktree tabs are conservatively never deferred — same rule as per-tab parking.Tests
pnpm run typecheckpnpm run lint(existing unrelated warnings only; reliability/max-lines/localization gates passed)git diff --checkand merge-conflict checksmainmerged; GitHub reports the PR as mergeable