Repository navigation
fix(terminal): keep the tab when a reattach finds its process gone - #28067
Conversation
Co-Authored-By: Claude <[email protected]>
Co-Authored-By: Claude <[email protected]>
|
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:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: 🔵 Low · up to The allowlist removal has no established new defect, but a rejected CDP command may still leave an e2e session attached. Merge with owner awareness of that open concern. Pre-merge checks ·
|
…ng writer Co-Authored-By: Claude <[email protected]>
Co-Authored-By: Claude <[email protected]>
…g fixture and stop docs Co-Authored-By: Claude <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
0563fe91-c314-4d1c-883c-306211b10e07
📒 Files selected for processing (6)
src/main/ipc/pty/pane/absent-pane-owner.tssrc/main/ipc/pty/pane/stable-pane-absence-respawn.test.tssrc/main/runtime/runtime-durable-store-fixture.tssrc/main/runtime/terminal-intentional-stops.tstests/e2e/helpers/paired-terminal-parking-oracle.tstests/e2e/paired-runtime-retention-metrics.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.
| await session.send('HeapProfiler.collectGarbage') | ||
| // Why not performance.memory: it is a cached, rounded figure that can predate the GC above. | ||
| const heapBytes = (await session.send('Runtime.getHeapUsage')).usedSize | ||
| await session.detach() |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
Detach the CDP session when sampling fails.
If either HeapProfiler.collectGarbage or Runtime.getHeapUsage rejects, execution skips session.detach(). The sampler then leaves its CDP session attached while the oracle handles the failure. Keep the error propagation, but move session.detach() into a finally block.
…-tab # Conflicts: # tests/e2e/workspace-layout-oracle-known-on-main.ts
ELI5
When Orca relaunches, the window reconnects each terminal pane to its old process. If that process is gone (the terminal service restarted, or the workspace was asleep), the window starts a fresh process in the same pane. Main also reacted to the missing process, but it did so by deleting the whole tab from its saved copy of the layout. The window kept showing the tab, so the two copies disagreed until the window happened to save again. Now main only forgets the dead process and keeps the tab.
What Changed
Before: relaunch after the terminal service was killed, or wake a slept workspace after a relaunch. The window shows the tabs, but main's saved layout has the terminal records with no tab bar entry and no group. Main then mints a new group with a new id, while paired clients (the phone, a second desktop) see the panes and group missing or under a different id. This lasts until the window saves its tab bar again.
After: main keeps the tab, its group and its pane, and only clears the dead process id from that pane. The fresh process the window starts then binds to the same pane, so every view keeps the same tab and group ids.
Mechanism: when the reconnect attempt hears from the process's host that the process no longer exists,
attachStablePaneOwnerused to:retirePersistedStablePaneOwner.The new
releaseAbsentPaneOwner(src/main/ipc/pty/pane/absent-pane-owner.ts) reuses two things that already exist:replacedkind, which tells the exit handler that a new process is taking the pane, so the surface stays;retireReplacedPaneBindinginpane-owner-replacement.ts, split out of the existingreleaseStoppedPaneBinding), which callsstore.retirePtyBindingto clear only that pane's process id. Going through that existing writer keeps the main-process layout-writer ratchet at its baseline.A unit test on main had pinned the old behaviour as "drops the tab ... leaving re-persistence to the renderer". It now asserts that the tab and pane stay and only the binding is cleared.
Why
A missing process is not a closed tab: the window is about to start a fresh process in that same pane. Deleting the tab made main's copy disagree with the window's. The tab then came back only through a later window save, and any reader in between (the phone, the CLI, the layout stream) saw it missing. Both pieces were already there. A planned replacement (terminal restart) uses
replacedtoday, andretirePtyBindingwas written for exactly "clear a stopped process's binding, keep the pane". So this adds no new mechanism and removes one path where main edited the tab bar on its own.The surface-wide retirement stays where it is correct, for example an agent session that exits during start.
Alternatives considered:
Linked Issue
Fixes #
Visual Proof
N/A: the window already drew the tabs correctly. What changes is main's saved layout and what paired clients are told, which the layout checker reads. Evidence is the e2e runs below.
Testing
I manually tested these changes locally (macOS, background dev Electron: the layout checker's
sleep-quit-resume,cold-daemon-restartandrestart-restorescenarios)Automated tests added/updated, or explained why not below
Updated
src/main/ipc/pty/pane/stable-pane-absence-respawn.test.ts. The shared durable-store test fixture gains the Store's binding-only retirement.Removed the known-on-main entries this fixes from
tests/e2e/workspace-layout-oracle-known-on-main.ts: allcold-daemon-restartentries (paired-client list empty, tab bar not saved after relaunch, group re-minted) and allsleep-quit-resumeentries (tab bar not saved after wake). With those entries gone, the scenarios pass in CI. Windowed and headless layout checker run, with the orcad scenarios running: 38306972065 (all 39 tests pass).Full e2e suite: 38306983931. Diffed against main at the same commit (38297736386), there are no failures that main does not also have. Shards 6, 7 and 12 hit the 30-minute job limit, as they do on main, and shard 11 did too here; every test in shard 11 finished with the same results as main. An earlier head's full run (38302215596) showed
manual-worktree-order-persistence(sidebar worktree drag order) failing once. It passed in three separate runs on this branch (38302237975, 38305925637, 38305935672) and on main (38305944547).pnpm tc,oxlintandcheck:code-quality:changedpass. The main, persistence, runtime and shared layout unit suites pass.AI Disclosure
Review
Agent skill upstream boundary
Notes
toSshExecutionHostId), as the old retirement did. A relay's "absent" answer still counts as proof of absence, as before.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)