Repository navigation
fix(ssh): a Disconnect stays disconnected, and Settings and the status bar agree - #30130
Conversation
…s bar agree A user's Disconnect of an SSH host is now recorded for the session, and background dials (a managed server's tunnel and status checks, census, host-resume recovery, pane and automation restores) refuse it until an explicit Connect. Disconnecting a managed host from Settings also stops its server's status checks, and the status bar's Disconnect of a managed server also disconnects the SSH host it runs on, so both surfaces read the same verdict. Fixes #30086 Fixes #30085
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to
|
The journey called the store's bare closeTab, which sends only terminal.close and holds nothing; it passed only because the disconnected host used to be redialed in the background, which #30130 stopped. Click the tab's X instead, the path that holds and replays an undelivered close.
…sed; deflake the shared-home spec (#30146) * fix(ssh): a tab closed while a managed host is disconnected stays closed after Connect #30130 made a user's Disconnect mark the host's managed server manually disconnected, so the desktop now answers its calls itself with runtime_manually_disconnected. The tab close path read that as the host's answer and dropped the close instead of holding it for replay, so the tab came back on reconnect. Treat it as an undelivered close, and route the Disconnect sources to the managed-orcad Docker lane. * test(e2e): close the disconnected host's tab the way a user does The journey called the store's bare closeTab, which sends only terminal.close and holds nothing; it passed only because the disconnected host used to be redialed in the background, which #30130 stopped. Click the tab's X instead, the path that holds and replays an undelivered close. * test(e2e): the shared-home spec tells a host's own server from a PID that only collides Each Docker host has its own PID namespace, so the PID host A records in the login-home slot can belong to an unrelated live process on host B; kill -0 alone then read it as B running from A's slot. Count a recorded PID only when its process runs from that slot.
ELI5
When you press Disconnect on an SSH host, it now stays disconnected until you press Connect. And pressing Disconnect in Settings or in the status bar now does the same thing, so both places always say the same.
What Changed
Before
After
Mechanism
src/main/ssh/ssh-user-disconnect.ts: a per-session record of hosts the user disconnected, next to the existing "sign-in cancelled" record from fix(ssh): a password SSH host waits for you at launch instead of prompting #30025.SshConnectionManager.connectrefuses a dial to a recorded host before it reuses or opens a transport. A connection test passes{ probe: true }to bypass it. Automaticssh:connectcalls fail fast without publishing an error state.src/main/ipc/ssh-host-user-disconnect.tsties the SSH host to the servers reached through it (a managed server, or a paired server with SSH access).ssh:disconnectrecords the host and marks those servers manually disconnected, which already stops their status checks. The status bar'sruntimeEnvironments:disconnectof a managed server also disconnects its SSH host. An explicit SSH connect clears both and restarts the servers' status checks after the connect finishes. The teardown claims the host's lifecycle before its firstawait, so a Connect clicked right after Disconnect is not undone.ssh:connect,runtimeEnvironments:connect, or Test (Test only bypasses it). Internal teardowns that usedisconnectRegisteredSshTarget(conversion, ephemeral VMs) do not set it.Why
runtime-environment-status-owner→resolveManagedRuntimeEnvironment→ensureOrcadManagedTunnel→connectionManager.connectdialed the host again after a finished Disconnect.SshConnectionManager.connect, where fix(ssh): a password SSH host waits for you at launch instead of prompting #30025 put the sign-in block. Every background dial goes through that call, so one check covers all of them. Guarding each caller separately would miss the next one someone adds.Linked Issue
Fixes #30086
Fixes #30085
Visual Proof
Managed host on a real Linux machine (omarchy), isolated as described under Testing.
Settings Disconnect, then a server status read (#30086). Before: the host connects again by itself.


After: still Disconnected, and the status bar shows 0 hosts.
Status bar Disconnect, then open Settings (#30085). Before: the status bar shows 0 hosts but Settings shows Connected.


After: both show disconnected.
Testing
Verified live (macOS dev build with its own HOME and userData, launched in the background and driven over CDP; the SSH host was omarchy Linux through a user-level sshd on a free port with a throwaway remote HOME and a fresh test key, reached through a private
ssh -Ltunnel; a real managed orcad was deployed into that throwaway HOME):Only in tests: the sign-in-block interplay, automation restore, the terminal pane's automatic connect, and paired (non-managed) servers with SSH access.
Tests (each new test fails on main):
ssh-host-user-disconnect.test.ts(automatic connect refused, server status checks stopped, explicit Connect lifts both, Test leaves it disconnected, Disconnect immediately followed by Connect),runtime-environment-managed-host-disconnect.test.ts(status bar Disconnect also disconnects the managed host; Connect goes through the host's connect), andssh-connection-manager.test.ts(background dial refused before reuse; probe allowed). Local: the full static-analysis job steps,pnpm tc, andsrc/main/ipc,src/main/sshandsrc/main/runtime/rpc/methodsrun single-worker. The one failure,pty-launch-race-parity.test.ts, also fails on main.Review
Codex (
gpt-6.1-sol, high) found three real issues over three rounds, and all are fixed. (1) Disconnect cleanup could re-mark a server after a fast Connect, so the lifecycle is now claimed before any await. (2) A test's transport could be reused by a background dial, so the check now runs before reuse. (3) The status bar's Connect did not restore the managed verdict and port forwards, so it now goes through the host's connect. The final round found nothing.Agent skill upstream boundary
Notes
Cross-platform: main-process state only, with no paths or processes. SSH: the change is all about SSH hosts. A Disconnect is a user verdict, not a liveness claim, and nothing here reports a remote process as live or exited. Mobile and paired clients: nothing new on the wire.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)