Repository navigation
fix(runtime): a terminal close commits in the session partition that holds the tab - #27119
Conversation
…holds the tab One worktree's tabs can be split across the local and runtime:<id> saved partitions. The host close searched only the routed partition, so a tab in the other one was reported tab_not_found (or recorded nowhere useful) and the next snapshot brought it back. The close now resolves every partition that holds that exact tab id and commits there. Fixes #18202
📝 Walkthrough
Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: 🟡 Moderate · up to Closing a terminal tab can remove a different tab copy in another session partition and kill its process. A rebound pane in a later partition can also be retired. Resolve both issues before merging. Pre-merge checks |
|
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:
de8243e8-bb31-4dd7-aeee-487cc5b0a4f4
📒 Files selected for processing (12)
src/main/persistence/terminal-topology/terminal-late-bind-layout-rules.test.tssrc/main/persistence/terminal-topology/terminal-leaf-move-concurrent-close.test.tssrc/main/persistence/terminal-topology/terminal-stale-pane-tree-client.test.tssrc/main/persistence/terminal-topology/terminal-topology-commit.test.tssrc/main/persistence/terminal-topology/terminal-topology-model.test.tssrc/main/runtime/orca-runtime-build-headless-mobile-session-browser-tabs.tssrc/main/runtime/orca-runtime-get-runtime-id.tssrc/main/runtime/orca-runtime-terminal-close-spill-partition.test.tssrc/main/runtime/orca-runtime-wait-for-mobile-terminal-surface.tssrc/main/runtime/runtime-workspace-session-controller.tssrc/main/runtime/terminal-surface-close.tssrc/shared/workspace-session-terminal-tab-close.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
…d since it was asked The owner fence checks only the first partition holding the tab, so a second legacy copy rebound before admission was retired and its PTY collected for kill. Owner-fenced closes now capture every holder and refuse with terminal_pane_owner_changed when a later copy is new or changed.
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:
2174776e-e85f-43b0-a3e1-dd969f574051
📒 Files selected for processing (4)
src/main/runtime/orca-runtime-build-headless-mobile-session-browser-tabs.tssrc/main/runtime/orca-runtime-terminal-close-spill-partition.test.tssrc/main/runtime/terminal-surface-close.tssrc/main/runtime/workspace-session-terminal-tab-retirement-identity.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
| target, | ||
| options, | ||
| requestedSession: this.getWorkspaceSessionForWorktree(worktreeId), | ||
| requestedSession: requested.values().next().value ?? null, |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Capture the pane incarnation from its holder.
If the first partition lists the tab but not the addressed leaf, Line 142 supplies no incarnation for that leaf. terminalSurfaceCloseMutation then uses the second partition’s current PTY binding without its requested incarnation. If that pane restarts before the durable mutation, the close can retire the replacement pane. Capture and check the requested incarnation separately for each partition that holds the leaf.
…ssions The binding writer mutates a session in place, so comparing a captured session reference with the current one compared a replacement with itself. Capture an immutable copy of each holder's row, bindings and incarnations when the close is asked.
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:
89ce03d3-2c56-4033-8fdf-6c3c4ccc95af
📒 Files selected for processing (5)
src/main/runtime/orca-runtime-build-headless-mobile-session-browser-tabs.tssrc/main/runtime/orca-runtime-get-runtime-id.tssrc/main/runtime/orca-runtime-terminal-close-spill-partition.test.tssrc/main/runtime/terminal-surface-close.tssrc/main/runtime/workspace-session-terminal-tab-retirement-identity.ts
🚧 Files skipped from review as they are similar to previous changes (3)
- src/main/runtime/orca-runtime-get-runtime-id.ts
- src/main/runtime/orca-runtime-terminal-close-spill-partition.test.ts
- src/main/runtime/terminal-surface-close.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
| target, | ||
| options, | ||
| requestedSession: this.getWorkspaceSessionForWorktree(worktreeId), | ||
| ...captureTerminalCloseRequest(worktreeId, target, hostIds(), store, fenced), |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
Refuse tab IDs with conflicting identities across partitions.
If two partitions contain the same tab ID with different persisted identities, this request closes both copies. Each captured copy is checked only against its own partition. The close can therefore remove and kill a different tab’s surface. Compare holder identities before mutation. Refuse the close without a write or PTY kill when the identities conflict. The linked issue explicitly requires refusal for an ambiguous match.
ELI5
Closing a terminal tab on a paired server sometimes didn't stick: the tab vanished, then came back a moment later, and
orca terminal closeansweredtab_not_found. The server was looking for the tab in the wrong saved section. Now it looks in the section that actually holds the tab.What Changed
tab_not_found, but the saved row stayed.RuntimeWorkspaceSessionController.getHostIdsForTab(worktreeId, tabId)returns the holding partitions, routed partition first, or the routed partition alone when none holds it. The close transaction (terminalSurfaceCloseMutation) takeshostIds()instead of a singlehostId(). The pane incarnation fence (requestedSession), the retirement-identity capture andresolvePtyTabCloseSurfaceAuthorityread the same partition.Why
repoId::pathrepeats across hosts, so a worktree-level fallback would adopt another host's same-named workspace. The controller already refuses that, and this keeps the rule.Linked Issue
Fixes #18202
Also fixes the server half of #17767 and #21339. Those issues stay open for their client-side and CLI-routing parts.
Visual Proof
N/A: server persistence change with no UI change. The new test reproduces the issue's saved state.
Testing
New
src/main/runtime/orca-runtime-terminal-close-spill-partition.test.ts. It closes by handle a tab saved only inruntime:<env>whilelocalholds an unrelated tab. It covers two copies of one tab, and the pin guard in the holding partition. Onorigin/mainthe first two fail: the spill row survives the close.Focused suites: every runtime close test,
src/main/persistence/terminal-topology/andorca-runtime.test.ts(1558 passed).pnpm tc, oxlint, andpnpm run check:code-quality:changed.I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Agent skill upstream boundary
Notes
Server-internal. No wire change. SSH: unchanged; a direct-SSH partition is only touched when it holds that exact tab id. Folder workspaces: the routed partition comes from the same controller. An unroutable folder record still closes nothing, as before.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)