Repository navigation
fix(ssh): Move to managed server keeps the host's terminal tabs - #26077
Merged
Merged
Conversation
Move stops the relay shells; their exits read as a user exit and closed the tabs before the conversion copied them to the server. Suppress those exits for the move, restart stopped shells on the relay when the host stays, re-home the open workspace onto the server, and report stopped shells to the runtime so terminal list stops calling them connected.
OrcaWin
marked this pull request as draft
October 7, 2026 05:18
The renderer-only exit suppression left main retiring the stopped tab from the saved SSH session before the conversion copied it, left other viewers unprotected, and swallowed real exits for the whole request. Register exactly the shells the move stops, from just before each shutdown, as a 'replaced' stop with their incarnation; main keeps the surface and labels the exit for every viewer, while a confirmed death stays 'exited'. Move now returns the shells it stopped, and a host that stays on the relay restarts only those tabs, discarding any buffered exit first.
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
When you move an SSH host to its managed Orca server, Orca warns that the host's open terminals will restart. They were supposed to come back. Instead most of them vanished: the host ended up with one terminal, or a new default one, and a leftover pane showed "SSH connection is not active…" until you clicked the workspace again. Now every terminal tab comes back on the managed server.
What Changed
Before (from the Phase 5 real-host test): the host had two relay terminals, Terminal 1 and Terminal 2. After Move to managed server, only Terminal 1 came back on the server. Terminal 2 was gone. The open workspace still showed the old Terminal 1 pane, now dead, with "SSH connection is not active…". The local
terminal liststill reported the stopped relay shell asconnected.After: all the host's terminal tabs stay open through the move. The conversion copies them to the server, which starts each one as a fresh shell with the same layout. The open workspace switches to the server copy as soon as the server's lists load, so no dead SSH pane is left behind.
terminal liststops calling a stopped relay shell connected.Mechanism:
exit. Both happened before the conversion copied the host's workspace session to the server, so only tabs whose exit happened to be lost made it across. (When a relay's last shell stops, the relay hangs up before it sends that exit. That is why one tab survived, and why another rerun saw 1 of 2.)replacedstop in main's existing intentional-stop register. That is the same register restarts use. Main then keeps the terminal in the saved session, and the exit reaches every viewer labeled as a restart, so mounted, parked and unmounted tabs all stay open. A death the relay confirms is still recorded asexited.exitstill closes its tab.setActiveWorktreea click uses. It does not change the current view, because Move is usually clicked from Settings.terminal listconnected.terminateSshTargetSessionsnow tells the runtime about each shell it stopped, unless the runtime already has a real exit for it. Because the lost exit never arrived, the runtime kept that recordconnected. The report uses the stop sentinel (-1), so the verdict readsunverifiable, never a certified death (docs/reference/ssh-execution-boundary.md). The relay accepting a kill is not an observed exit.Why
The move already promised a restart, and the conversion already carries the host's tabs to the server. The tabs were simply gone by the time it read them. Keeping them open at the source fixes the cause, using a suppression mechanism every exit path already honors.
Alternatives I rejected:
There is no wire change, so mixed client and server versions are unaffected.
Not in this PR: a migrated tab's title. The server publishes a live shell's title as "Terminal", so a restored "Terminal 1" shows as "Terminal". That is general server behavior for any restored tab, not specific to the move. Changing what the server publishes reaches old clients, so it belongs in its own change.
Linked Issue
Phase 5 real-host test findings P5-3 and P5-4 (rollout plan for the node runtime, Phase 3).
Visual Proof
N/A. I could not rerun the packaged two-version upgrade flow for this PR. The behavior is covered by the unit tests below, and the root cause comes from the test's saved profile. That profile's server session held only Terminal 1's id (as
web-terminal-<id>), and Terminal 2 was already missing from the SSH session.Testing
pnpm test src/main/ipc/ssh-managed-server-move-stop-retention.test.ts src/renderer/src/components/terminal-pane/terminal-parked-watcher-sleep-preserved-exit.test.ts src/renderer/src/ssh/ssh-managed-server-move-terminal-tabs.test.ts src/renderer/src/hooks/ipc-events/ssh-managed-server-converted-catalogs.test.ts src/renderer/src/hooks/ipc-events/ssh-managed-server-state-effects.test.ts src/main/ipc/ssh-terminate-sessions.test.ts src/main/ipc/ssh-terminate-sessions-previous-relay.test.ts src/main/ipc/ssh-managed-server-move.test.ts src/main/ipc/ssh-managed-server-move-conversion.test.tspasses.exited. A user exit before the stop closes its tab as always. I checked that this test fails without the register entry.pnpm tc,oxlint, andpnpm run check:code-quality:changedpass.I manually tested these changes locally
Automated tests added/updated, or explained why not below
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
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)