Repository navigation
fix(runtime): route a CLI close of a paired host's terminal to that host - #29455
Merged
Merged
Conversation
orca terminal list on a desktop lists terminals a paired runtime runs, but orca terminal close on one of those handles stopped the remote PTY id on this machine, which cannot own it, and answered terminal_stop_unverifiable while the process kept running on the host. closeTerminal and closeTerminalTab now send the close to the owning runtime first and return its receipt; when that host is unreachable the close fails and the terminal stays visible.
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 12 minutes. View limit details
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 |
… the owner's stale-handle answer Codex review: a pane rebound while the host call was pending had its new occupant retired, and an owner that no longer knows the handle answers terminal_handle_stale, which rejected instead of retiring the mirror.
…to close it Codex review: the renderer's pin guard runs at the local commit, after the host had already stopped the process.
6 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
On the desktop,
orca terminal listalso shows terminals that really run on a paired Orca server. Closing one of those withorca terminal closetried to stop the process on the desktop, where it doesn't exist. So the command failed and the process kept running on the server. Now the desktop asks the server that owns the terminal to close it, and reports what that server says.What Changed
Before:
orca terminal close --terminal <handle>on a handle whose terminal runs on a paired runtime (executionHostId: runtime:<env>interminal list) did three things:remote:<env>@@<handle>, which it can't own;terminal_stop_unverifiable("a follow-up stop was issued but its outcome could not be verified").The server never got a close from the CLI. Agent and CI cleanup scripts failed, and processes leaked on headless servers.
After: the desktop sends
terminal.close(orterminal.closeTabfor--tab) to the owning runtime first, using the host's own handle, which is encoded in the PTY id. The CLI gets that host's receipt: stopped, live, or unverifiable with its reason and pending-kill flag. Then the desktop retires its local mirror. If the owning host can't be reached, the command fails and the terminal stays visible, so you can retry. If the host says it has no such terminal (terminal_not_found), the local mirror is retired, because nothing runs there.Mechanism: a new
src/main/runtime/session-tabs/paired-host-terminal-close.tsreads the owner from the PTY id (parseRemoteRuntimePtyId), sends the call, and parses the receipt. The graph-leaf paths ofcloseTerminal/closeTerminalTabinexplicit-terminal-close-stops.tsuse it before any local stop. The call reuses the runtime's existing paired-environment transport (callOrchestrationWorkerServer, which already backs federated workers), so no new connection code is added.Why
The execution host owns the terminal, so only its answer can say whether the process stopped. The alternatives I considered:
--host/--environmentitself.--environmentrouting already exists, and that's the route that works when you start from the server's own listing (fix(runtime): a terminal close commits in the session partition that holds the tab #27119 fixed the server side). It doesn't help with a handle the desktop issued, because that handle means nothing on the server.Failing when the owner is unreachable follows the SSH boundary rule: losing contact is never evidence the process stopped. So nothing is hidden on a guess.
Wire compatibility: this only calls the existing
terminal.close/terminal.closeTabmethods on the host. Older hosts already answer both.Linked Issue
Fixes #21339 (Linear STA-7826). Supersedes #21351. That PR only lets
--host runtime:<id>pick the paired server forterminal close, which--environmentalready does. It doesn't route a desktop-issued handle to its owner.Visual Proof
N/A — this changes what a CLI/RPC close does. There's no UI change.
Testing
src/main/runtime/paired-host-terminal-close.test.tsbuilds a desktop runtime whose renderer graph has a leaf onruntime:env-1. All five tests fail onorigin/main:terminal.closewith its own handle, the CLI gets the host'sptyKilled: true, and the local PTY controller is never asked to stop the remote id.pendingKillRecordedpass through unchanged.terminal_not_foundfrom the host retires the mirror without a verdict.--tabsendsterminal.closeTabto the host.pnpm tc:nodeandpnpm run check:code-quality:changedpass.Agent skill upstream boundary
Notes
SSH/remote: this is the paired-host case. Verdicts stay live/unverifiable/exited, taken from the owner. Local and SSH PTYs on this machine are unchanged, because the new path only runs for
remote:<env>@@<handle>ids.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)