Repository navigation
Conversation
…er tab Closing one pane of a split terminal in a remote-server (paired Orca runtime) tab left a blank ghost pane behind, and closing again from that state killed the surviving terminal too, so the whole split was lost. The client sends `terminal.close` for the pane and drops the leaf from its layout, but the host still sees two live surfaces at that moment, so `rebaseLayout` refuses the membership change and republishes the two-leaf layout. The live-layout reconciler faithfully re-inserts a pane for the retired leaf. When the host's `onPtyExit` then retires the leaf and publishes a one-leaf layout, the store shrinks but the reconciler only planned insertions, so the pane stayed mounted with no PTY, no close control, and no way out. Its next close request resolved to the live sibling. Plan removals alongside insertions: a mounted pane whose leaf the host-authoritative layout no longer names, and whose transport has no PTY, is closed. The last pane is never removed, and a pane still bound to a PTY is left alone so a stale snapshot cannot tear down a live split. Reproduced against a headless `orca serve` on Ubuntu 24.04 paired over an SSH tunnel: before the change the DOM kept two `.pane` nodes while the store held one leaf and the host listed one terminal; after it, one pane, one leaf, one terminal, and the closed pane's process alone ended. The same steps over an "Add SSH host" connection were already correct on both v1.4.193 and main. Fixes stablyai#17770
|
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⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review. 📝 WalkthroughWalkthroughThe change persists retired leaf IDs across reconciliations. A host-dropped leaf remains pending while its pane still has a PTY. The reconciliation effect plans removal again after the PTY clears. It skips leaves that the host never named and preserves the final pane. Tests cover retirement tracking, PTY states, missing panes, and teardown ordering. Merge Risk: ⚪ Minimal · up to This change reconciles remotely retired terminal panes only after their PTY is gone, preserving the remaining terminal and preventing blank retired panes. No current merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Linked Issues checkExplanation The changes address issue Full details: Description checkExplanation The description is complete and relevant. It includes the required ELI5, change summary, rationale, linked issue, visual proof, testing details, AI disclosure, scope notes, and completed checklist items.
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
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: 10282a63-27de-4fce-a9a8-3aa2ad8b6429
📒 Files selected for processing (3)
src/renderer/src/components/terminal-pane/terminal-live-layout-reconciliation.test.tssrc/renderer/src/components/terminal-pane/terminal-live-layout-reconciliation.tssrc/renderer/src/components/terminal-pane/use-terminal-pane-reconciliation.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
There was a problem hiding this comment.
ℹ️ No critical issues — one coverage note and a minor reuse nit.
Reviewed changes
planTerminalLiveLayoutRemovals— new planner returning mounted leaves the host-authoritative layout no longer names.use-terminal-pane-reconciliation— the host-authoritative branch removes ghost panes after insertions, guarded on the pane owning no PTY and never removing the last pane.collectLeafIds— a Set-based tree walk feeding the new planner.- Tests — three cases for the planner covering a retired leaf, an all-mounted layout, and a null/empty layout.
ℹ️ Removal guards have no hook-level coverage
The bug being fixed lives in use-terminal-pane-reconciliation — the transport.getPtyId() === null and getPanes().length <= 1 guards are what keep a stale snapshot from tearing down a live split. The added tests only exercise the pure planner, so the two guards that actually decide whether to close a pane are unverified by automation. The planner tests are meaningful and would fail on a wrong set diff, but a regression in the guards (e.g. dropping the last-pane check, or the no-PTY check) would ship silently.
Technical details
# Cover the removal-path guards
## Affected sites
- src/renderer/src/components/terminal-pane/use-terminal-pane-reconciliation.ts:90-99 — closePane guard conditions
## Required outcome
- A test (or tests) that exercise the removal loop with a fake manager/transport, asserting: a pane whose transport reports a non-null ptyId is NOT closed; the last remaining pane is NOT closed; a PTY-less ghost among >1 panes IS closed.
## Open questions for the human
- Is a renderer hook harness for this reconciliation path already available, or would this need a new fixture? If the hook is impractical to unit-test, a comment stating the guards are covered by the live remote-server scenario (as done in the PR body) may suffice.DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
`manager.closePane` only tears down the pane and its transport. A pane retired by the host also owns a cache timer, an agent status, a terminal error slot and a restored-session banner, all keyed by the pane, which a bare close left behind. Route the removal through `executeClosePane`, the same path a user close takes. The selection rules move into `selectRetiredPaneIds` so they can be tested on their own: only a pane whose transport has no PTY is closed, a pane with no transport yet or still bound to a PTY is left alone, and the last pane on the tab is never removed.
…anner The planner grew its own recursive leaf walk; `collectLeafIds` in terminal-pane-layout-tree.ts already does this and handles an empty root.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: a018b44b-4ae4-4532-a146-ac6a08994345
📒 Files selected for processing (3)
src/renderer/src/components/terminal-pane/terminal-live-layout-reconciliation.test.tssrc/renderer/src/components/terminal-pane/terminal-live-layout-reconciliation.tssrc/renderer/src/components/terminal-pane/use-terminal-pane-reconciliation.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- src/renderer/src/components/terminal-pane/use-terminal-pane-reconciliation.ts
- src/renderer/src/components/terminal-pane/terminal-live-layout-reconciliation.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.
A transport reports no PTY both after its PTY ended and before its spawn has connected, so "mounted, unnamed by the host, no PTY" also describes a pane the client just split. A host snapshot landing in that window would have closed it. Remember the leaves of the last host-authoritative layout and plan a removal only for a leaf that set contained: the host can only retire a leaf it named. A leaf it has never named belongs to a pane still starting.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: f243f0b3-e437-4706-85e5-3982cdadc5b9
📒 Files selected for processing (3)
src/renderer/src/components/terminal-pane/terminal-live-layout-reconciliation.test.tssrc/renderer/src/components/terminal-pane/terminal-live-layout-reconciliation.tssrc/renderer/src/components/terminal-pane/use-terminal-pane-reconciliation.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- src/renderer/src/components/terminal-pane/terminal-live-layout-reconciliation.test.ts
- src/renderer/src/components/terminal-pane/terminal-live-layout-reconciliation.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.
…oved The host drops a leaf and ends its PTY in one step, but the two reach the client separately. When the layout arrives first, the pane still holds its PTY and the removal is rightly skipped; remembering only the previous layout's leaves then forgot the leaf, so the pane stayed mounted blank after the exit landed. Track retired leaves explicitly: a leaf the host named before and no longer names stays retired until its pane is gone or the host names it again. The exit rewrites the layout's pty bindings, which re-runs the reconciliation, and the pending leaf is removed then.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
selectRetiredPaneIds— extracted the removal-guard logic (no-PTY, never-last-pane, skip-unmounted-leaf) into a pure selector with four unit cases.- Full close cleanup — the host-authoritative reconciliation branch now closes retired panes through
executeClosePane, running the same cache-timer/agent-status/terminal-error/banner/pty-binding cleanup a user close performs. collectLeafIdsreuse — dropped the local Set-based leaf walk in favor of the sharedcollectLeafIdsfromterminal-pane-layout-tree.ts.
Both concerns from the prior review are addressed: the removal guards are now exercised directly, and the leaf-collector duplication is gone. The selectRetiredPaneIds tests assert exact results and would fail if either guard regressed.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
trackRetiredLeafIds— new pure tracker that retires a mounted leaf only when the host named it in a prior layout and then dropped it, and keeps it retired until its pane is gone or the host names it again.planTerminalLiveLayoutRemovals— now gates removals on the tracked retirement set, so a mounted leaf the host never named (a client split still spawning) is no longer mistaken for a ghost.- Reconciliation state — the hook carries
hostLayoutLeafIdsRef/retiredLeafIdsRefbetween runs so a host retirement that lands before the transport teardown is retried once the PTY clears.
This closes the "stale snapshot tears down a spawning pane" hole the previous iteration left open, and the added trackRetiredLeafIds and mid-spawn/pre-teardown race tests assert exact results.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
#19365) Adds the missing removal path to the host-authoritative layout reconciler, so a pane the host has retired is unmounted once its PTY has cleared. Fixes #17770. The removal planner, its retired-set gate, the null-PTY guard, the never-last-pane guard and their unit tests originate from #18387 by @ylcn91. This PR adds the recovery-state dependency that makes the deferred removal actually re-run, an e2e regression spec, and a hook-parity repin. Co-authored-by: ylcn91 <[email protected]>
|
Thank you for this — your diagnosis was correct and the design is yours. The removal planner, the retired-set gate, the null-PTY guard and the never-last-pane guard all landed essentially as you wrote them. We merged it in #19365 with you credited as co-author, because that branch had also picked up three things this needed: the That first one is worth explaining, since it's a real gap rather than a preference. Your comment says a deferred removal "is retried after the exit ... once the exit lands and rewrites the layout bindings" — we measured that the rewrite never happens: Also worth flagging for the future: this branch was latently CI-red on the hook-order parity test ( Closing in favour of #19365. Thanks again — this was a real bug and you found the right fix for it. |

ELI5
In a tab that runs on a paired remote Orca runtime, closing one half of a split terminal left an empty pane behind, and closing that empty pane killed the terminal that was still alive. Now the empty pane goes away on its own and the surviving terminal stays.
What Changed
terminal-live-layout-reconciliation.ts:trackRetiredLeafIdsremembers the leaves the host named and then dropped while their panes are still mounted (a leaf the host never named belongs to a pane the client is still starting; a retired leaf stays pending until its pane is gone, so a removal skipped while the transport still held its PTY is retried after the exit).planTerminalLiveLayoutRemovalsturns those into removals, andselectRetiredPaneIdsdecides which panes to close: only a pane whose transport has no PTY, never the last pane on the tab.use-terminal-pane-reconciliation.ts: the host-authoritative branch applies those removals after insertions, throughexecuteClosePane, so a retired pane gets the same cleanup a user close does (cache timer, agent status, terminal error, restored-session banner, pty binding).Why
The client sends
terminal.closefor the pane and drops the leaf from its layout, but the host still sees two live surfaces at that moment, sorebaseLayoutrefuses the membership change and republishes the two-leaf layout, and the live-layout reconciler faithfully re-inserts a pane for the retired leaf. When the host'sonPtyExitthen retires the leaf and publishes a one-leaf layout, the store shrinks, but the reconciler only planned insertions, so the pane stayed mounted with no PTY and no close control. Its next close request resolved to the live sibling.Planning removals alongside insertions closes that gap. Guarding on "transport has no PTY" and "never the last pane" keeps a stale snapshot from tearing down a live split.
Linked Issue
Fixes #17770
Visual Proof
Before, split then one pane closed: a blank ghost pane stays and the next close takes the live terminal with it.
After, same steps: the closed pane disappears and the other terminal keeps running.
Testing
Reproduced against a headless
orca serve(Linux AppImage) on Ubuntu 24.04, paired over an SSH tunnel ("Add remote server" with the printed pairing URL and the SSH-tunnel option); client on macOS..panenodes while the store held one leaf andorca terminal liston the host listed one terminal; closing the blank pane closed the surviving terminal too. After: one pane, one leaf, one terminal, and only the closed pane's process ended.vitestforterminal-live-layout-reconciliation.test.ts,pnpm tc:web,oxlint,oxfmt --checkandcheck:code-quality:changedpass; the CI workflow's lint, typecheck and test jobs were run locally on this branch. Platforms: macOS client, Linux remote runtime.AI Disclosure
Claude Code (Fable 5.1) drafted the diagnosis, the patch and the tests. I set up the remote runtime, reproduced the bug, reviewed the change and verified it live against the running app and the host.
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Only the remote-server (paired runtime) reconciliation path changes; local and "Add SSH host" tabs never take the host-authoritative branch with a retired leaf.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)