Skip to content

fix(terminal): keep unresolved snapshot-capability verdicts re-askable - #14676

Merged
brennanb2025 merged 8 commits into
mainfrom
brennanb2025/crash-terminal-capability-resettlement
Aug 16, 2026
Merged

brennanb2025 merged 8 commits into
mainfrom
brennanb2025/crash-terminal-capability-resettlement

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​801 $\color{#cf222e}{\Huge{\mathbf{−}}}$​14 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​787
Prod 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​183 $\color{#cf222e}{\Huge{\mathbf{−}}}$​25 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​158

ELI5

Orca saves memory by unloading terminal views that have been hidden for a while. It may only unload a pane when the terminal process can be reattached and a replay source will survive the unmount; otherwise the user loses scrollback and the shell can be orphaned.

When Orca could not determine that replay capability, it correctly kept the pane mounted—but after about 91 seconds of failed probes it stopped asking forever. One slow daemon startup could therefore make every local terminal permanently ineligible for eviction for the rest of the app session. This change keeps the conservative safety behavior and re-asks every five minutes, allowing a recovered daemon to make those panes safely evictable.

What changed

  1. The 1/2/4/8/16/30/30s unknown-capability ladder now decays to a bounded five-minute re-ask instead of synthesizing a permanent false verdict. Unknown remains eviction-exempt throughout.
  2. Superseded probe generations keep their caller's timer chain alive, and closed PTYs are pruned from retry state.
  3. The ongoing collector now covers tabs, pane-layout leaves, and pending reconnects just like startup refresh. Its sorted PTY-set key is memoized and JSON-encoded, so ordinary layout churn does not restart the loop and newline-bearing folder/workspace IDs cannot collide.
  4. Capability changes publish a small external-store revision consumed by the terminal parking effect. A quiet hidden worktree therefore re-evaluates parking when the daemon recovers; recovery is not dependent on unrelated React/store churn.
  5. The existing all-exempt force-park diagnostic now reports counts by route (fail-open, foreign-worktree, capability-unknown, split-pane) in a counts-only crash breadcrumb. No worktree IDs or filesystem paths enter the breadcrumb.

The broader terminal_parking_pass instrumentation was split into #14660 and is intentionally not part of this focused fix.

Why

This fixes a real latent defect, not a defect observed firing in the crash sweep. The retained field snapshot from the separately investigated leak showed the exemption system idle, and this change does not explain that leak or the renderer OOM cluster. The defect here is reproduced by focused unit/React gates.

The safety invariant remains: no pane may unmount unless both process reattachment and surviving replay are known. A failed, timed-out, missing, or null capability answer never becomes permission to evict.

Honest limitation

A stale cached authoritative true remains unchanged from main. If a provider later loses replay without invalidating that cached result, it remains the pre-existing route by which a pane could be unmounted without restorable scrollback. The five-minute re-ask applies only to unresolved answers and does not narrow that stale-true window; provider-generation/liveness invalidation is a separate follow-up.

Scope and compatibility

  • Renderer-only policy and state propagation; no RPC, stream opcode, daemon payload, or other remote-wire change.
  • Shared desktop path works for native, SSH, and folder workspaces; no platform-specific path or shortcut behavior.
  • Resolver-free/degraded surfaces perform at most one bounded unresolved batch per five-minute window and never gain permission to evict.
  • Steady-state healthy sessions resolve once and leave the retry set. The only continuing work is the bounded slow re-ask for unresolved PTYs.
  • Mobile is unaffected.

Testing

Focused post-rebase verification:

Gate Result
terminal-provider-snapshot-capability.test.ts 16 passed
terminal-provider-snapshot-capability-resettlement.test.ts 4 passed
use-terminal-provider-snapshot-capability.test.tsx 9 passed
terminal-retention-exempt-growth.test.ts 1 passed
terminal-cold-park-exempt-flip.react185.test.tsx 1 passed

The gates cover the full retry ladder and slow re-ask, same-array-identity timer refires, superseded generations, closed-PTY pruning, collector parity for split leaves and reconnects, newline-bearing PTY IDs, React invalidation, retention bounds after recovery, and repeated park-verdict flips without a React #185 loop. Targeted standard and type-aware lint also pass.

CI on the previous pushed head passed typecheck, package (macOS and Windows), cross-version wire compatibility, Git compatibility, shell contracts, and all 32 test shards. The sole static-analysis failure was an unused test suppression, removed in the next commit; final CI will rerun on the rebased head.

Adversarial review

Eight loops were run to clean:

  • Loop 1 found the split-leaf collector case and route classification unpinned, plus render-path collection work outside memoization; fixed and tested.
  • Loop 2 found incomplete memo dependencies and a generation-cancelled pass that could kill the degraded-startup timer chain; fixed and tested.
  • Loop 3 found the central same-identity re-ask mutation unpinned and a closed-PTY retry-state leak; fixed with non-vacuous gates.
  • Loop 4 independently re-applied the mutations and returned clean.
  • Merge-gate loop 5 found the missing React invalidation, newline-delimited key collision, non-exhaustive route switch, path-bearing diagnostic payload, and overstated stale-true claim; fixed and tested.
  • Merge-gate loop 6 re-derived the final behavior and returned clean after seven focused files / 94 tests.
  • Final-readiness loop 7 found a test-isolation leak: the prefetch renderHook stayed mounted, so a later capability publication logged a real assertion error even while Vitest reported green; fixed by explicitly unmounting the hook.
  • Final-readiness loop 8 re-audited pushed head b6cca5a26c and returned clean with no P0/P1/P2 findings.

Open-source precedent review supports the design: detach/unmount is safe only with process persistence plus replay, unknown capability stays mounted, and recovery is retried or event-driven instead of converting transient uncertainty into a durable verdict. The bounded re-ask and explicit React invalidation are conventional, focused mechanisms.

Visual proof

Electron QA ran through Playwright CDP on a dedicated dev instance at reviewed head cf11b9aeba (the final rebase adds only the lint-suppression cleanup and new base commits). The parking delay was reduced to 2 seconds for exerciseability; capability and replay behavior were production paths.

The passing rendered flow was park → terminate only the dedicated profile's daemon process → daemon recovery → reveal; the marker survived and was visible after scrolling to the top. Orca's explicit pty.management.restart() is intentionally destructive: it synthesized session exits and retired the parked tab, so reveal was impossible and that API cannot serve as session-preserving proof.

Live visual proof of “unknown capability stays mounted” remains blocked: the context-bridged capability IPC is immutable, and the dedicated daemon auto-respawned quickly enough that new PTYs resolved authoritative before force-park. This gap is stated rather than replaced with store inspection; the safety direction is covered by the focused unit/React gates.

Follow-ups

Checklist

  • Focused fix with regression coverage
  • Security/privacy, performance, cross-platform, SSH/remote, folder-workspace, and wire-compatibility reviewed
  • Automated tests added/updated
  • Final rebased focused verification and Electron evidence complete, with the live unknown-capability visual gap documented above
  • Final rebased CI complete

Author

  • X / Twitter: @BrennanKB5

@coderabbitai

coderabbitai Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Terminal provider capability tracking now retains unresolved states and retries them every five minutes. Capability revisions notify the hook and trigger terminal parking reevaluation. The hook collects PTYs from tabs, mappings, pending reconnects, and layouts. Retention logic classifies exemption routes and reports categorized counts in warnings and renderer crash breadcrumbs. Regression tests cover retry resettlement, route classification, retention growth, hook collection, and React 185 capability flips.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.09% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description is detailed and covers the change, rationale, testing, visual proof, scope, and follow-ups, but the required Linked Issue remains an empty Fixes # placeholder. Add the specific linked issue number after Fixes # before merging.
✅ Passed checks (3 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly and concisely describes the main fix: unresolved snapshot-capability verdicts can be re-asked.
✨ Finishing Touches 💡 1
📝 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.

@brennanb2025
brennanb2025 force-pushed the brennanb2025/crash-terminal-capability-resettlement branch from 31297d0 to cf11b9a Compare August 15, 2026 05:43

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/renderer/src/components/terminal-pane/terminal-hidden-worktree-retention.ts (1)

80-115: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Rename the splitPane bucket to match what it actually counts.

classifyEvictionExemptTerminalPty returns null for four different tabs: a tab with no ptyId, a remote-runtime pty, an SSH pty, and a same-worktree pty that already has an authoritative snapshot. countEvictionExemptTabRoutes files all four under splitPane.

Inside the all-exempt force-park branch in Terminal.tsx the split-pane inference usually holds, but the counter is exported and generic. A caller outside that branch reads clean, evictable tabs as split-pane exemptions, which misdirects the triage the breadcrumb exists for.

A name such as unclassifiedTab keeps the count useful in every context. Update the assertion in terminal-provider-snapshot-capability-resettlement.test.ts (lines 122-130) and formatEvictionExemptRouteCounts with it.

♻️ Proposed rename
 export type EvictionExemptRouteCounts = {
   failOpen: number
   foreignWorktree: number
   capabilityUnknown: number
-  /** Tab-level pty classifies clean, so the exemption came from a split pane's pty. */
-  splitPane: number
+  /** Tab-level pty classifies clean (absent, SSH, remote-runtime, or authoritative),
+   *  so in the all-exempt branch the exemption came from a split pane's pty. */
+  unclassifiedTab: number
 }

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a95dd16a-5e01-4bc1-814f-a47bb2cf6a4f

📥 Commits

Reviewing files that changed from the base of the PR and between e570cad and 31297d0c2a1a6aaafcc24c44793b49a50738be8b.

📒 Files selected for processing (9)
  • src/renderer/src/components/Terminal.tsx
  • src/renderer/src/components/terminal-pane/terminal-cold-park-exempt-flip.react185.test.tsx
  • src/renderer/src/components/terminal-pane/terminal-hidden-worktree-retention.ts
  • src/renderer/src/components/terminal-pane/terminal-retention-exempt-growth.test.ts
  • src/renderer/src/components/terminal/terminal-provider-snapshot-capability-resettlement.test.ts
  • src/renderer/src/components/terminal/terminal-provider-snapshot-capability.test.ts
  • src/renderer/src/components/terminal/terminal-provider-snapshot-capability.ts
  • src/renderer/src/components/terminal/use-terminal-provider-snapshot-capability.test.tsx
  • src/renderer/src/components/terminal/use-terminal-provider-snapshot-capability.ts

@brennanb2025

Copy link
Copy Markdown
Contributor Author

FINAL-HEAD Electron QA @ cf11b9aeba

Dedicated Playwright-CDP instance only (pr-14676-qa, CDP 9339 / renderer 5179, fresh profile). No computer-use. No edits.

Park → daemon process kill → reveal — scrollback survived

Marker QA14676-SCROLLBACK-MARKER-cf11b9ae / PARK-RESTART-REVEAL-PROOF was typed into a live pane, the tab was cold-parked behind decoys (__paneManagers unmounted), then only this profile’s daemon-entry.js was SIGTERM’d. Reveal remounted the same tab; after scroll-to-top the marker is visible on the real canvas.

Before park (marker visible):
01-before-park-marker-visible.png

Parked (target still in tab bar, decoy active):
04-parked-before-daemon-kill.png

Revealed immediately after daemon kill (viewport at bottom prompt):
06-revealed-after-daemon-kill.png

Same reveal after scroll-to-top — marker still in the pane:
07-revealed-scrolled-to-marker.png

pty.management.restart() retired the parked tab

Product restart API synthesized exits and removed Terminal 1 from the tab bar (Resource Manager 0 sessions). Reveal was not possible.

Parked with Terminal 1 still present:
02-parked-terminal1-unmounted.png

After management restart — Terminal 1 gone:
03-after-daemon-restart-tab-retired.png

Stay-mounted when no replay source — blocked as live visual proof

Could not hold a live local pty in capability-unknown long enough to show force-park leaving the pane mounted: contextBridge freezes getAuthoritativeBufferSnapshotCapabilities, and the daemon auto-respawns and answers authoritative: true. Ordinary tab park then unmounts restorable local tabs (expected when the daemon has already said yes). Unknown-exempt stay-mounted remains unit-covered, not visually proven here.

Full write-up: /tmp/orca-qa-14676/qa-14676-electron-final-head.md

@brennanb2025
brennanb2025 force-pushed the brennanb2025/crash-terminal-capability-resettlement branch 2 times, most recently from 9b24279 to b6cca5a Compare August 15, 2026 06:25
A daemon that could not answer the snapshot-capability probe within the
~91s startup ladder had its ptys settled 'no authoritative snapshot'
permanently: settled ids were excluded from every later synchronization,
and the only refresh callers run during renderer startup. Because the
eviction-exemption predicate treats absent/unknown capability as exempt,
one slow daemon start converted every local pty into a permanently
eviction-exempt tab — the hidden-worktree retention budget could free
nothing for the rest of the session (its own degenerate-case log:
'retention force-park freed no panes').

Three changes, none touching the safety direction (unknown still means
exempt, panes stay mounted):
- The retry ladder now decays to a slow 5-minute re-ask instead of a
  permanent verdict, so a recovered daemon is consulted again without any
  event wiring; the synchronization loop's existing timer carries it.
- The ongoing collector now gathers the same fields the startup refresh
  does (layouts, pending reconnect ids), keyed on the sorted id set —
  synchronization prunes cached verdicts outside its collected ids, so
  the narrower collector could evict valid split-leaf answers back into
  the exempt-by-default state.
- The degenerate-case log now carries per-route exemption counts
  (fail-open / foreign-worktree / capability-unknown / split-pane) and a
  matching crash breadcrumb, so field bundles can say which route
  dominates instead of a fourth investigation.

Guard: exemption flips are a pin-unreachable input to the rendered park
verdict, so capability verdicts must only change between commits — the
new react185 harness force-parks a worktree, lets pane mounts write
layouts/titles, flips capability repeatedly, and asserts every flip
settles far from React's nested-update limit.

Gates (previously red): a recovered resolver is re-consulted and the
exemption clears; retained mounted tabs stay bounded by the retention
limit as hidden worktrees accumulate after daemon recovery.

Scope honesty: this bounds an unbounded-by-design retention residual; it
is NOT the fix for the unexplained multi-GB field OOM cluster, whose
retainer remains unidentified (field sessions crash with <= 1 mounted
manager).
…oute buckets

Review found two unpinned pieces of the re-settlement fix: reverting the
ongoing collector to the narrow field set (dropping split-leaf layout and
pending-reconnect ptys, which the sync would then prune back to exempt
unknown) survived every existing test, and the force-park breadcrumb's
route counters had no coverage at all. Both mutations now fail.
…maps

The widened collector ran collect+sort+join on every Terminal render and
the memo-dep completeness was unpinned. Memoize the key on the four map
identities (behavior-identical; the string-keyed second memo still damps
layout-only churn) and pin the layouts dep with a staleness test — a
missing dep silently drops new split-leaf ptys from the sync.
Review loop 2: a synchronization pass cancelled by a newer generation
returned null, which ends the caller's timer chain — but the winner (the
startup refresh) ignores its own return value, so unknowns it leaves
behind had no scheduler left; recovery then waited on an id-set change.
Return 0 instead: the superseded chain re-checks immediately and the
early-outs collapse the re-check when nothing is pending.

Also pin the collect-key memo's remaining deps at runtime (pending
reconnect, tabs, pty ids) — exhaustive-deps is only a warn here, and
loop 1's staleness test covered the layouts dep alone.
…y prune

Review loop 3: mutation testing showed the chain's own re-ask path was
unpinned — collapsing the first early-out to identity-only (returning null
whenever the live-set reference is unchanged) passed every test, yet it
kills the timer chain after one backoff: the hook refires with the SAME
memoized array, so that mutation is the settled-forever bug in a worse
shape. Pin it at both levels: a module test drives two passes over one
array identity, and a hook test drives the real timer chain through a
backoff refire with no id churn.

Also pin the closed-pty retry prune (its removal survived the battery):
the empty-set pass must return null — a leaked entry keeps a phantom
5-minute timer for the session — and a reappeared id must restart the 1s
ladder rather than resume the decayed cadence.
@brennanb2025
brennanb2025 force-pushed the brennanb2025/crash-terminal-capability-resettlement branch from b6cca5a to 399b300 Compare August 16, 2026 18:44
@brennanb2025
brennanb2025 merged commit 0abbecb into main Aug 16, 2026
45 checks passed
AmethystLiang pushed a commit that referenced this pull request Aug 17, 2026
#14676)

* fix(terminal): keep unresolved snapshot-capability verdicts re-askable

A daemon that could not answer the snapshot-capability probe within the
~91s startup ladder had its ptys settled 'no authoritative snapshot'
permanently: settled ids were excluded from every later synchronization,
and the only refresh callers run during renderer startup. Because the
eviction-exemption predicate treats absent/unknown capability as exempt,
one slow daemon start converted every local pty into a permanently
eviction-exempt tab — the hidden-worktree retention budget could free
nothing for the rest of the session (its own degenerate-case log:
'retention force-park freed no panes').

Three changes, none touching the safety direction (unknown still means
exempt, panes stay mounted):
- The retry ladder now decays to a slow 5-minute re-ask instead of a
  permanent verdict, so a recovered daemon is consulted again without any
  event wiring; the synchronization loop's existing timer carries it.
- The ongoing collector now gathers the same fields the startup refresh
  does (layouts, pending reconnect ids), keyed on the sorted id set —
  synchronization prunes cached verdicts outside its collected ids, so
  the narrower collector could evict valid split-leaf answers back into
  the exempt-by-default state.
- The degenerate-case log now carries per-route exemption counts
  (fail-open / foreign-worktree / capability-unknown / split-pane) and a
  matching crash breadcrumb, so field bundles can say which route
  dominates instead of a fourth investigation.

Guard: exemption flips are a pin-unreachable input to the rendered park
verdict, so capability verdicts must only change between commits — the
new react185 harness force-parks a worktree, lets pane mounts write
layouts/titles, flips capability repeatedly, and asserts every flip
settles far from React's nested-update limit.

Gates (previously red): a recovered resolver is re-consulted and the
exemption clears; retained mounted tabs stay bounded by the retention
limit as hidden worktrees accumulate after daemon recovery.

Scope honesty: this bounds an unbounded-by-design retention residual; it
is NOT the fix for the unexplained multi-GB field OOM cluster, whose
retainer remains unidentified (field sessions crash with <= 1 mounted
manager).

* test(terminal): pin the widened capability collector and breadcrumb route buckets

Review found two unpinned pieces of the re-settlement fix: reverting the
ongoing collector to the narrow field set (dropping split-leaf layout and
pending-reconnect ptys, which the sync would then prune back to exempt
unknown) survived every existing test, and the force-park breadcrumb's
route counters had no coverage at all. Both mutations now fail.

* perf(terminal): memoize the capability collect key on its four store maps

The widened collector ran collect+sort+join on every Terminal render and
the memo-dep completeness was unpinned. Memoize the key on the four map
identities (behavior-identical; the string-keyed second memo still damps
layout-only churn) and pin the layouts dep with a staleness test — a
missing dep silently drops new split-leaf ptys from the sync.

* fix(terminal): keep a superseded capability pass's re-ask chain alive

Review loop 2: a synchronization pass cancelled by a newer generation
returned null, which ends the caller's timer chain — but the winner (the
startup refresh) ignores its own return value, so unknowns it leaves
behind had no scheduler left; recovery then waited on an id-set change.
Return 0 instead: the superseded chain re-checks immediately and the
early-outs collapse the re-check when nothing is pending.

Also pin the collect-key memo's remaining deps at runtime (pending
reconnect, tabs, pty ids) — exhaustive-deps is only a warn here, and
loop 1's staleness test covered the layouts dep alone.

* test(terminal): pin the same-identity re-ask path and closed-pty retry prune

Review loop 3: mutation testing showed the chain's own re-ask path was
unpinned — collapsing the first early-out to identity-only (returning null
whenever the live-set reference is unchanged) passed every test, yet it
kills the timer chain after one backoff: the hook refires with the SAME
memoized array, so that mutation is the settled-forever bug in a worse
shape. Pin it at both levels: a module test drives two passes over one
array identity, and a hook test drives the real timer chain through a
backoff refire with no id churn.

Also pin the closed-pty retry prune (its removal survived the battery):
the empty-set pass must return null — a leaked entry keeps a phantom
5-minute timer for the session — and a reappeared id must restart the 1s
ladder rather than resume the decayed cadence.

* fix(terminal): apply recovered snapshot capabilities

* test(terminal): remove stale lint suppression

* test(terminal): clean up capability prefetch hook
kunsanglee added a commit to kunsanglee/orca that referenced this pull request Aug 21, 2026
stablyai#14676 replaced the exemption predicate with a route classifier so the
force-park breadcrumb can say WHY a force-park freed nothing. This branch adds a
reason that classifier did not have: a remote or SSH pty whose owner this
worktree cannot prove.

Folded in as a `remote-unowned` route rather than left out — a remote pty exempt
by ownership would otherwise bucket as `split-pane`, which is the one bucket
that means "the tab-level pty classified clean". The counts feed field triage,
so a silently mis-bucketed route sends it the wrong way.

The classifier and the tab-route counter now take the worktree owner, and
Terminal.tsx resolves it from the same owner state the exemption selector reads.

The two eviction-exemption describes moved to terminal-eviction-exempt-tabs.ts's
own test file: both sides appended to terminal-parked-tab-watchers.test.ts and
the merged file crossed the 800-line budget. They test a different module
anyway.
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
stablyai#14676)

* fix(terminal): keep unresolved snapshot-capability verdicts re-askable

A daemon that could not answer the snapshot-capability probe within the
~91s startup ladder had its ptys settled 'no authoritative snapshot'
permanently: settled ids were excluded from every later synchronization,
and the only refresh callers run during renderer startup. Because the
eviction-exemption predicate treats absent/unknown capability as exempt,
one slow daemon start converted every local pty into a permanently
eviction-exempt tab — the hidden-worktree retention budget could free
nothing for the rest of the session (its own degenerate-case log:
'retention force-park freed no panes').

Three changes, none touching the safety direction (unknown still means
exempt, panes stay mounted):
- The retry ladder now decays to a slow 5-minute re-ask instead of a
  permanent verdict, so a recovered daemon is consulted again without any
  event wiring; the synchronization loop's existing timer carries it.
- The ongoing collector now gathers the same fields the startup refresh
  does (layouts, pending reconnect ids), keyed on the sorted id set —
  synchronization prunes cached verdicts outside its collected ids, so
  the narrower collector could evict valid split-leaf answers back into
  the exempt-by-default state.
- The degenerate-case log now carries per-route exemption counts
  (fail-open / foreign-worktree / capability-unknown / split-pane) and a
  matching crash breadcrumb, so field bundles can say which route
  dominates instead of a fourth investigation.

Guard: exemption flips are a pin-unreachable input to the rendered park
verdict, so capability verdicts must only change between commits — the
new react185 harness force-parks a worktree, lets pane mounts write
layouts/titles, flips capability repeatedly, and asserts every flip
settles far from React's nested-update limit.

Gates (previously red): a recovered resolver is re-consulted and the
exemption clears; retained mounted tabs stay bounded by the retention
limit as hidden worktrees accumulate after daemon recovery.

Scope honesty: this bounds an unbounded-by-design retention residual; it
is NOT the fix for the unexplained multi-GB field OOM cluster, whose
retainer remains unidentified (field sessions crash with <= 1 mounted
manager).

* test(terminal): pin the widened capability collector and breadcrumb route buckets

Review found two unpinned pieces of the re-settlement fix: reverting the
ongoing collector to the narrow field set (dropping split-leaf layout and
pending-reconnect ptys, which the sync would then prune back to exempt
unknown) survived every existing test, and the force-park breadcrumb's
route counters had no coverage at all. Both mutations now fail.

* perf(terminal): memoize the capability collect key on its four store maps

The widened collector ran collect+sort+join on every Terminal render and
the memo-dep completeness was unpinned. Memoize the key on the four map
identities (behavior-identical; the string-keyed second memo still damps
layout-only churn) and pin the layouts dep with a staleness test — a
missing dep silently drops new split-leaf ptys from the sync.

* fix(terminal): keep a superseded capability pass's re-ask chain alive

Review loop 2: a synchronization pass cancelled by a newer generation
returned null, which ends the caller's timer chain — but the winner (the
startup refresh) ignores its own return value, so unknowns it leaves
behind had no scheduler left; recovery then waited on an id-set change.
Return 0 instead: the superseded chain re-checks immediately and the
early-outs collapse the re-check when nothing is pending.

Also pin the collect-key memo's remaining deps at runtime (pending
reconnect, tabs, pty ids) — exhaustive-deps is only a warn here, and
loop 1's staleness test covered the layouts dep alone.

* test(terminal): pin the same-identity re-ask path and closed-pty retry prune

Review loop 3: mutation testing showed the chain's own re-ask path was
unpinned — collapsing the first early-out to identity-only (returning null
whenever the live-set reference is unchanged) passed every test, yet it
kills the timer chain after one backoff: the hook refires with the SAME
memoized array, so that mutation is the settled-forever bug in a worse
shape. Pin it at both levels: a module test drives two passes over one
array identity, and a hook test drives the real timer chain through a
backoff refire with no id churn.

Also pin the closed-pty retry prune (its removal survived the battery):
the empty-set pass must return null — a leaked entry keeps a phantom
5-minute timer for the session — and a reappeared id must restart the 1s
ladder rather than resume the decayed cadence.

* fix(terminal): apply recovered snapshot capabilities

* test(terminal): remove stale lint suppression

* test(terminal): clean up capability prefetch hook
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