Skip to content

feat(terminal): breadcrumb the worktree parking pass verdicts and manager census - #14660

Closed
brennanb2025 wants to merge 3 commits into
mainfrom
brennanb2025/crash-parking-pass-telemetry
Closed

brennanb2025 wants to merge 3 commits into
mainfrom
brennanb2025/crash-parking-pass-telemetry

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​242 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​242
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​201 $\color{#cf222e}{\Huge{\mathbf{−}}}$​8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​193

ELI5

Orca already decides on every terminal parking pass whether hidden worktrees are old enough to unload and which rule, if any, vetoes that decision. Production currently throws that explanation away, so a crash bundle with many live terminal managers cannot distinguish a clock that keeps resetting from an aged worktree that is repeatedly vetoed.

This PR records one compact latest-state census: hidden-worktree age cohorts, veto counts for the cohort already past the parking delay, the global parking/retention gates, ordinary/forced parking outcomes, and the post-commit live manager/pane counts. It changes no parking verdict or mount behavior.

What Changed

  • Summarize the parking verdict array without worktree IDs or filesystem paths.
  • Queue the census until after React commits the parking pass, then sample the live pane registry.
  • Send every pass through the existing renderer breadcrumb IPC path as terminal_parking_pass.
  • Coalesce that process-wide stream by name for 30 seconds so bursts update the latest payload and suppression count without filling the breadcrumb ring.
  • Cancel queued renderer work when the Terminal surface unmounts.

This branch intentionally does not change crash-breadcrumb-store retention policy.

Why

This is instrumentation, not a crash fix. The next field bundle can distinguish:

  1. A resetting clock: hiddenTracked remains high while the 30-second, 5-minute, and 15-minute cohorts remain near zero.
  2. A decision-time veto: worktrees reach the aged cohort while pending spawn work, cooldown, measuring, coverage, or a global gate explains why they stay mounted.

The payload contains aggregate counts only; worktree IDs are excluded because they embed paths.

Durability

The retained-slot policy landed independently in #14867 and is now part of main. This PR uses that existing durability behavior but does not change its budget or retention rules.

The telemetry remains logically independent: emission and coalescing produce valid census data, while the already-landed store policy determines how long it survives unrelated ring pressure.

Trade-offs

  • It observes; it does not fix the resetting clock or a sticky veto.
  • Aggregates distinguish the two failure shapes but do not identify a specific worktree.
  • Each event-driven parking pass adds one summary fold, one coalesced zero-delay post-commit task, and one compact IPC payload; there is no polling.
  • Name-scoped coalescing keeps only the latest payload during a burst; the existing retained slot protects that census from later unrelated breadcrumbs.

Visual Proof

N/A — this adds crash-reporting instrumentation and changes no rendered UI or interaction.

Testing

All #14660 targeted tests pass after rebasing onto current origin/main (7 files, 95/95 tests):

Suite Result
terminal-worktree-parking-telemetry.test.ts 6/6
crash-reporting-renderer-breadcrumbs.test.ts 19/19
active-terminal-repair-loop.react185.test.tsx 11/11
use-terminal-tab-cold-parking.test.ts 11/11
terminal-cold-park-verdict-loop.test.tsx 2/2
force-park-buffer-capture.test.ts 3/3
terminal-hidden-view-parking.test.ts 43/43

Current origin/main includes the independently landed retention and coalescing changes; the counts above are from this rebased PR head.

Compatibility and Scope

  • Cross-platform: shared renderer/main logic; no platform-specific paths or shortcuts.
  • SSH and folder workspaces: aggregate observation follows the existing parking pass and assumes neither local execution nor a Git worktree.
  • Remote wire compatibility: no new RPC params, stream opcodes, or persisted schema.
  • Security/privacy: no worktree IDs, paths, tokens, or per-worktree rows.
  • Mobile: not affected; this is the desktop terminal parking path.

Linked Issue

No tracked GitHub issue exists for this work. It comes from the 2026-08-13/14 crash-field sweep and instruments the open question behind a renderer-memory investigation.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • Visual proof is N/A because there is no UI change
  • Targeted tests pass locally
  • Cross-platform, SSH/remote, privacy, and compatibility impact considered
  • Full lint, typecheck, test, and build are left to CI

Author

  • X / Twitter: @BrennanKB5

@coderabbitai

coderabbitai Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

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: a5d43976-6898-4932-b8f4-4cfc375fec37

📥 Commits

Reviewing files that changed from the base of the PR and between 8e0dad8 and 65303bc.

📒 Files selected for processing (5)
  • src/main/ipc/crash-reporting-renderer-breadcrumbs.test.ts
  • src/main/ipc/crash-reporting-renderer-breadcrumbs.ts
  • src/renderer/src/components/Terminal.tsx
  • src/renderer/src/components/terminal-pane/terminal-worktree-parking-telemetry.test.ts
  • src/renderer/src/components/terminal-pane/terminal-worktree-parking-telemetry.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • src/main/ipc/crash-reporting-renderer-breadcrumbs.ts
  • src/renderer/src/components/terminal-pane/terminal-worktree-parking-telemetry.test.ts
  • src/main/ipc/crash-reporting-renderer-breadcrumbs.test.ts
  • src/renderer/src/components/Terminal.tsx
  • src/renderer/src/components/terminal-pane/terminal-worktree-parking-telemetry.ts

Included review availability: Your plan includes up to 10 reviews per rolling hour; 5 remain after this review.


📝 Walkthrough

Walkthrough

The renderer now summarizes terminal worktree parking decisions, queues telemetry until pane unmounts are committed, samples live pane census data, and suppresses unchanged summaries. Cleanup cancels pending telemetry. The main process coalesces terminal_parking_pass breadcrumbs by name with a 30-second interval while retaining the latest payload. Tests cover summary construction, veto categorization, census sampling, reset behavior, duplicate suppression, and breadcrumb coalescing.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% 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 explains the change, rationale, testing, compatibility, privacy, and visual impact, but it omits the required linked issue and several template sections. Add a valid Linked Issue and complete or explicitly mark the required Review, Agent skill upstream boundary, and Notes sections.
✅ 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 identifies the main change: adding breadcrumbs for terminal worktree parking verdicts and manager census data.
✨ 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.

@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.

Actionable comments posted: 1

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

1-10: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Shorten the module comment.

Keep the non-obvious reason. Remove the implementation walkthrough.

As per coding guidelines: “Comments must be concise, non-obvious, and brief—prefer one line; do not explain obvious behavior or walk through code.”

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6529e964-55be-4f35-90a1-94b9c2a3cad6

📥 Commits

Reviewing files that changed from the base of the PR and between 8b31910 and 93d1e213800420717dbb220335e2a61a0af77157.

📒 Files selected for processing (7)
  • src/main/crash-reporting/crash-breadcrumb-store.test.ts
  • src/main/crash-reporting/crash-breadcrumb-store.ts
  • src/main/ipc/crash-reporting-renderer-breadcrumbs.test.ts
  • src/main/ipc/crash-reporting.ts
  • src/renderer/src/components/Terminal.tsx
  • src/renderer/src/components/terminal-pane/terminal-worktree-parking-telemetry.test.ts
  • src/renderer/src/components/terminal-pane/terminal-worktree-parking-telemetry.ts

@brennanb2025
brennanb2025 force-pushed the brennanb2025/crash-parking-pass-telemetry branch 2 times, most recently from 9f1eb02 to faa64e4 Compare August 15, 2026 06:02
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Electron QA evidence (terminal_parking_pass) @ faa64e439d

Isolated $electron CDP session on this worktree only (Orca QA 14660, CDP 9334 / renderer 5177). Real sidebar cycling of three worktrees (main → qa-park-a → qa-park-b). No source edits, no screenshots committed.

Observed

  • terminal_parking_pass fired (4 renderer.breadcrumb traces in the QA profile).
  • Immediate second cycle produced no extra trace (30s name-only coalesce). After the 30s cold-park deadline emit (suppressedSinceLast: 4), 15s of unchanged UI produced no additional traces (4 → 4).
  • Payload is a fixed primitive-only census (int/bool keys only). No worktree ids, paths, or user identity.
  • Visible workspace/terminal chrome has no regression.

02-after-relaunch-main-active.png
03-cycled-qa-park-a.png
04-cycled-qa-park-b.png
05-steady-qa-park-b.png

Limitation: window.api is contextBridge-frozen, so suppressed renderer IPC cannot be counted in-page; coalescing is evidenced by traces + suppressedSinceLast.

@brennanb2025
brennanb2025 force-pushed the brennanb2025/crash-parking-pass-telemetry branch 2 times, most recently from 5d1a389 to 25c7dbd Compare August 16, 2026 07:58
@coderabbitai

coderabbitai Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

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.

@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-worktree-parking-telemetry.test.ts (1)

134-159: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Test replacement before the queued flush.

The test flushes the first sample before it queues the second sample. It does not cover the flushTimer !== null path, where queueTerminalWorktreeParkingPass must replace the pending summary. Add two queue calls before advancing timers. Assert that one breadcrumb contains the second sample.

Proposed regression test
+  it('keeps the latest sample before the queued flush', () => {
+    queueTerminalWorktreeParkingPass({
+      verdicts: [verdict({ worktreeId: 'a', hiddenSinceMs: 0 })],
+      ordinaryParkedCount: 0,
+      parkingEnabled: true,
+      retentionBudgetEnabled: true,
+      nowMs: 60_000
+    })
+    queueTerminalWorktreeParkingPass({
+      verdicts: [
+        verdict({
+          worktreeId: 'a',
+          hiddenSinceMs: 0,
+          hasPendingSpawnWork: true
+        })
+      ],
+      ordinaryParkedCount: 0,
+      parkingEnabled: true,
+      retentionBudgetEnabled: true,
+      nowMs: 61_000
+    })
+
+    vi.runOnlyPendingTimers()
+
+    expect(harness.crumbs).toHaveLength(1)
+    expect(harness.crumbs[0]?.data?.sampledAtMs).toBe(61_000)
+    expect(harness.crumbs[0]?.data?.pastParkDelayPendingSpawnWork).toBe(1)
+  })

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: bde614d5-5456-449d-99a5-226aef433362

📥 Commits

Reviewing files that changed from the base of the PR and between c066a55 and 25c7dbd93a8d088e250c15c711e9c4263007424d.

📒 Files selected for processing (7)
  • src/main/crash-reporting/crash-breadcrumb-store.test.ts
  • src/main/crash-reporting/crash-breadcrumb-store.ts
  • src/main/ipc/crash-reporting-renderer-breadcrumbs.test.ts
  • src/main/ipc/crash-reporting-renderer-breadcrumbs.ts
  • src/renderer/src/components/Terminal.tsx
  • src/renderer/src/components/terminal-pane/terminal-worktree-parking-telemetry.test.ts
  • src/renderer/src/components/terminal-pane/terminal-worktree-parking-telemetry.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/main/crash-reporting/crash-breadcrumb-store.ts
  • src/main/ipc/crash-reporting-renderer-breadcrumbs.test.ts
  • src/renderer/src/components/Terminal.tsx
  • src/renderer/src/components/terminal-pane/terminal-worktree-parking-telemetry.ts

Included review availability: Your plan includes up to 10 reviews per rolling hour; 6 remain after this review.

@coderabbitai

coderabbitai Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

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.

…ager census

The parking pass computes a per-worktree verdict on every run and, outside
e2e, throws it away — so when a field session mounts 49 managers with the
park/retention system idle, the bundle cannot say WHY: a hiddenSince clock
that keeps resetting under worktree cycling is indistinguishable from a
decision-time veto (pending spawn work, cooldown, coverage, measure,
portal).

Record a change-damped terminal_parking_pass breadcrumb per verdict shift:
deadline-cohort counts (hidden past the 30s park delay / 5min hot-retain /
15min retention TTL — a resetting clock keeps all three at zero), the veto
counts, ordinary/force park results, and the live manager+pane census the
same bundles used to infer from crumb multiplicity. Keyed on the counts,
never on raw ages, with a 30s emission floor, so steady state emits
nothing. No worktree ids in the payload (ids embed paths).

With this, the next bundle showing unbounded mounted managers answers
clock-reset vs veto directly instead of a fourth investigation.
@brennanb2025
brennanb2025 force-pushed the brennanb2025/crash-parking-pass-telemetry branch from 65303bc to 62808d2 Compare August 17, 2026 01:34
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Closing this — the question it was built to answer has since been answered, and the answer is negative.

Why it was opened

This PR was instrumentation only, deliberately split out from the fix (#14653) so the two could be judged separately. It never claimed to fix a crash.

A cluster of React #185 crashes at boundary terminal.workbench had been attributed to cold-park/reveal verdict oscillation — the parking pass flipping its verdict, feeding back through a render-time predicate into a remount storm that saturates React's nested-update limit. The circumstantial case looked strong:

  • the Windows crash landed 32s after a worktree switch, matching the 30 000 ms cold-park deadline
  • report 996b4cc2 showed mountedManagers 72 → 73 → 0 in 1.5s
  • withholdUnparkableTerminalTabs damping shipped in both crashing releases and never emitted a single terminal_park_verdict_churn breadcrumb

That last point was the actual motivation: the existing breadcrumbs only fired when damping engaged, so the case we cared about was precisely the one that left no trace. This PR breadcrumbed every parking-pass verdict plus a manager census so the next field bundle could answer whether verdicts churn in production.

Why it can be closed

1. The field data answered it without this instrumentation. Across the crash corpus, park churn appears in 0 of 16 React #185 reports versus 3 of 336 non-#185 reports — not merely absent but anti-correlated. The one report that did show heavy churn (60d84e6d: 38 flips, 30 remounts) did not crash.

2. The fix this was paired with was disproved. #14653 closed at zero diff on two independent grounds: its reproduction mocked pane coverage as "no watcher entry exists for this tab", but canWatcherCoverParkedTerminalTab never reads watcher ownership (it tests pane count, per-pane ptyId, leaf-id validity, restore policy); and independently, Terminal excludes activation-deferred ids from backgroundMountTabIds while TerminalPaneOverlayLayer applies that mount filter before the parked-set check, so a flipped verdict can never mount the deferred pane and the loop cannot close.

3. The cluster was mis-scoped. React #185 is not a terminal parking bug. The 16 reports span five boundaries — terminal.workbench 11, page.settings 2, app.workspace-shell 1, overlay.status-bar 1, page.activity 1. Five fired with no terminal subtree in the blamed tree at all; the terminal majority is base-rate. The blamed component stacks are bystanders, as 4543bb6826 already established: nestedUpdateCount is a module-level global keyed on the root, so the throw lands on whichever fiber calls setState next.

4. Most of the cluster was already fixed. 12 of 16 reports map onto six shipped fixes (f01bfd937f, 7a422712b1, 17617b1a6c, 4543bb6826, 36cc8495ef, 5f187e0836), two of which cite crash IDs by name. None of the six was a parking bug — they were a radix/react ref loop, an unstable fallback prop, a fresh {} literal in layout-effect state, an Activity portal readiness oscillation, and a store action reallocating state on a no-op.

5. It cannot address the one cluster still open. The renderer memory leak is untracked heap; this PR emits manager and pane counts. Count-based instrumentation is the same instrument class that has already returned clean on this leak repeatedly.

Follow-up

#14867 shipped a retained singleton breadcrumb slot for terminal_parking_pass in anticipation of this emitter. With this closed, that name now appears on main only in the retention set and its tests, with no production emitter — so that reservation should be reverted rather than left as retention config for a breadcrumb that never exists.

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