Repository navigation
fix(ssh): a tab closed while a managed host is disconnected stays closed; deflake the shared-home spec - #30146
Conversation
…sed 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.
📝 Walkthrough
Priority: ⬇️ Low Severity of issue fixed: Low Merge Risk: 🔵 Low · 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.
…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.
There was a problem hiding this comment.
🧹 Nitpick comments: 1
config/scripts/pr-e2e-route-contracts.test.mjs: 1
478-497: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd
src/main/ipc/ssh-session-teardown.tsto the route contract.The managed-SSH matcher routes this source to all three journey specs, but the contract test does not include it in
expectRouted. Removing the matcher branch would therefore leave this test passing while changes to session teardown could stop selecting the journeys.Suggested fix
// #30130's Disconnect sources merged with this lane skipped. 'src/main/ipc/ssh-host-user-disconnect.ts', + 'src/main/ipc/ssh-session-teardown.ts', 'src/main/ipc/ssh-connect-flow.ts',
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
4112bd77-45fd-4b9a-a44a-c05b56b6f9fb
📒 Files selected for processing: 1
tests/e2e/ssh-orcad-shared-home-machines.spec.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.
…callers' policy (#30246) Each list that decides delivered / undelivered / recoverable / definitive by code now has a test naming its codes, the message fragments it relies on, and nearby codes it must not treat the same. Includes the #30146 shape: a client-minted runtime_manually_disconnected keeps a user's close for replay. Tests only; no production change.
ELI5
If you disconnect an SSH machine, close a terminal tab, and connect again, the tab should stay closed. Since #30130 it came back. This puts it back to staying closed.
What Changed
Before: Disconnect an SSH host that runs a managed Orca server, close one of its terminal tabs, then Connect. The closed tab reappears.
After: The tab stays closed. Orca remembers the close and sends it to the host as soon as the host is reachable again, which is what it already did when a connection simply dropped.
Mechanism. This is a regression from #30130 ("a Disconnect stays disconnected"). That PR made a user's Disconnect also mark the host's managed server as manually disconnected, so the desktop now answers every call to that server itself with
runtime_manually_disconnected, without contacting the host. The tab close path (web-runtime-session-tab-lifecycle.ts) keeps a close it could not deliver and replays it after reconnect, but only for a fixed set of "never reached the host" error codes.runtime_manually_disconnectedwas not in that set, so the close was treated as an answer from the host: the close was thrown away, and the host's next snapshot after reconnect brought the tab back. The fix adds that code to the "undelivered" set.The journey spec.
ssh-orcad-terminal-journeys.spec.tsclosed the tab with the store's barecloseTab. That path only sendsterminal.closeand holds nothing, so it passed only because the disconnected host used to be redialed in the background, which is exactly what #30130 stopped (the CI log showsruntimeEnvironments:call: ... was disconnected. Connect to use it again.). The spec now clicks the tab's X, the path every user close goes through (closeTerminalTab→closeWebRuntimeSessionTab). That path still fails without the fix above, because it drops the close onruntime_manually_disconnected.CI path filter. The "ssh on managed orcad (Docker)" lane would have caught this, but it was skipped on #30130 because none of #30130's files were routed to it. The managed-journeys route in
config/scripts/pr-e2e-source-routing.mjsnow also covers the Connect/Disconnect sources (src/main/ipc/ssh-connect-flow.ts,ssh-connection-handlers.ts,ssh-host-user-disconnect.ts,ssh-session-teardown.ts,runtime-environment-connectivity-handlers.ts,runtime-environment-manual-disconnect.ts,src/main/ssh/ssh-connection-manager.ts,ssh-user-disconnect.ts) and the renderer close-intent/replay modules (web-session-close-*). The route contract test pins all of them.verify/ "PR checks passed" is unchanged.Second, separate cause: a flaky check in
ssh-orcad-shared-home-machines.spec.ts:47(test-only, folded in from #30147). The Docker 2/2 lane runs both specs, so neither fix can show a green lane alone. The two Docker SSH hosts share/root, but each has its own PID namespace. The spec's "B never launched into A's slots" check read the PID that A recorded in the login-home slot and rankill -0on B. That PID (229on both failing runs) can be a live, unrelated process on B. The spec now counts a recorded PID only when that process's command line names its slot directory. Every managed server starts asnohup <runtime> <slot dir>/<launcher> ..., so the check keeps its intent: a server B really launched from A's slot would still fail it. This is not a product regression: none of the PRs after299dcb86fc8atouch the managed deploy, and the spec passed on both bisect probes.Why
#30130's intent stays as it is: a Disconnect still stays disconnected, and nothing redials the host. The local refusal really does mean the close never reached the host, so treating it like any other undelivered close is accurate, and it reuses the existing hold-and-replay path (STA-6224) instead of adding a new one. I considered two alternatives. Exempting tab closes from the manual-disconnect refusal would redial the host, which is exactly the loop #30130 removed. Reverting #30130's server-side marking would bring back #30086/#30085.
Linked Issue
Regression from #30130. It fixes the failing
tests/e2e/ssh-orcad-terminal-journeys.spec.ts:119on main. It also fixes the flakyssh-orcad-shared-home-machines.spec.ts:47, which has a test-only cause and supersedes #30147.Visual Proof
N/A: no UI change. A closed tab now stays closed, and the e2e spec checks that.
Testing
New unit test
holds a user close made while the host is disconnectedinsrc/renderer/src/runtime/web-runtime-session-tab-activate-close.test.ts. It fails without the fix and passes with it.Route contract test extended (
config/scripts/pr-e2e-route-contracts.test.mjs).Bisect evidence: the Docker 2/2 lane fails
ssh-orcad-terminal-journeys.spec.ts:119at27cfee6f7ea2(main up to and including fix(ssh): a Disconnect stays disconnected, and Settings and the status bar agree #30130, probe ci: probe managed-orcad Docker e2e at 27cfee6f7ea2 (bisect) — do not merge #30139) and passes at7f4243ed1c3d(before the stack).End to end: the managed-orcad Docker lane on this PR runs the real journey (disconnect, close, reconnect, relaunch) against a Docker SSH host. Nothing beyond that and the unit tests was verified live.
Shared-home predicate: checked on a real Linux host (omarchy, isolated under
/tmp). A slot file holding a live PID whose process runs from another slot is excluded, and a process running from its own slot is still matched. The Docker lane on test(e2e): the shared-home spec tells a host's own server from a PID that only collides #30147 passed this spec, including the checks after line 81.Local: full static-analysis steps,
pnpm tc, unit folderssrc/renderer/src/runtime,hooks,lib,components/{automations,tab-group,terminal}, single worker.I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Review
Codex review (
gpt-6.1-sol, high): no findings.Agent skill upstream boundary
Notes
SSH: this is SSH-only behaviour. Wire compatibility is unaffected because nothing new goes over the wire. The same applies to a paired server the user disconnected from Settings: a close made while it is disconnected is replayed on Connect.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)