Repository navigation
fix(ssh): a user's Disconnect sticks until they connect the host again - #23487
brennanb2025 wants to merge 24 commits into
Conversation
… nobody clicked A user's Disconnect used to mean only "there is no connection object", so the next connect from anywhere redialed the host. Main now stores what the user asked for on the target row (desiredConnection), written only by the ssh:connect and ssh:disconnect handlers. Connects nobody clicked go through a separate ensureConnected entry point that is refused with ssh_disconnected_by_user while the Disconnect holds, before any authority rotation, registration or broadcast. Runtime-owned targets never record or enforce it. Every published state (broadcast, getState, paired clients) carries disconnectedBy: 'user' while it holds, including after a restart when no connection object exists. The runtime RPC takes an optional background flag; absent keeps meaning a user's Connect.
…ling a Disconnect A terminal pane's deferred attach, startup restore and automation dispatch now connect through ensureConnected. When it fails and the host publishes that the user's own Disconnect holds it down, the pane reports nothing, dials nothing more, and waits for the user's Connect; the same holds when a connect already in flight fails as a cancellation because of the Disconnect. An automation on such a host is skipped with a plain reason. Terminating or removing a target's sessions uses a cleanup connect that leaves the user's Disconnect in place.
… host down The shared host-connection signal derives unavailableReason: 'user-disconnected' from the published disconnectedBy, so the terminal overlay, the SSH-routed browser card and the editor's load-error view say "You disconnected <host>" and offer Connect, which is the user's own connect and lifts the Disconnect. A new terminal on such a host shows the same card instead of redialing. The overlay's and the sidebar card's Connect share one handler, and a ratchet test pins every renderer caller of the user's connect so a background path cannot start using it.
…verlay's Connect A Docker SSH spec disconnects the host with a terminal pane open, checks the published state stays disconnected, attributed to the user and on the same connection generation for six seconds, then connects from the overlay. The browser-routing spec's unavailable-host case now expects the card for a host the user disconnected, which offers Connect in place of Retry.
…ission and the automation skip
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (15)
💤 Files with no reviewable changes (5)
🚧 Files skipped from review as they are similar to previous changes (3)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review. 📝 WalkthroughWalkthroughThe change records user Connect and Disconnect intent for SSH targets and distinguishes user, background, and session-cleanup connection attempts. Background reconnection respects a user Disconnect. Renderer state and interfaces identify user-disconnected hosts and provide Connect actions. Terminal and automation workflows use background connection APIs, and E2E coverage checks that the disconnect state persists until a user reconnects. Priority: ➖ Normal Merge Risk: 🔵 Low · up to A Connect made just before Terminate Sessions may fail and need to be retried. This is a bounded concurrency risk rather than a general failure of disconnect or session cleanup. Security Architecture ReviewSecurity architecture risk: 🟡 Moderate · up to A Disconnect now controls future SSH connections, but an error while closing a temporary cleanup connection may leave that connection open despite the saved choice. The reviewed path does not establish what happens to the transport after such an error. Retained concerns
Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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 |
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: effd77ef-9f4d-4e4a-885f-76b6b20d805a
⛔ Files ignored due to path filters (1)
src/shared/rpc-contract/rpc-params-catalog.generated.tsis excluded by!**/*.generated.*
📒 Files selected for processing (78)
.github/workflows/e2e.ymlconfig/scripts/run-ssh-docker-e2e.mjssrc/main/ephemeral-vm-runtime-ssh.tssrc/main/ipc/ssh-connect-flow.tssrc/main/ipc/ssh-connection-handlers.tssrc/main/ipc/ssh-connection-intent.tssrc/main/ipc/ssh-renderer-broadcast.tssrc/main/ipc/ssh-target-crud-handlers.tssrc/main/ipc/ssh-target-registry.test.tssrc/main/ipc/ssh-user-disconnect-intent.test.tssrc/main/ipc/ssh.tssrc/main/runtime/rpc/errors.tssrc/main/runtime/rpc/methods/ssh.test.tssrc/main/runtime/rpc/methods/ssh.tssrc/main/ssh/ssh-connection-store.tssrc/main/ssh/ssh-target-registry.tssrc/preload/api/ssh-api.tssrc/preload/api/ssh-bridge.tssrc/renderer/src/components/browser-pane/assemble-chrome/ssh-routed-browser-page-gate.tsxsrc/renderer/src/components/browser-pane/assemble-chrome/ssh-routed-browser-page-gate.user-disconnected.test.tsxsrc/renderer/src/components/browser-pane/use-ssh-workspace-browser-route.host-connection.test.tsxsrc/renderer/src/components/editor/EditorConflictReviewSurface.tsxsrc/renderer/src/components/editor/EditorContent.tsxsrc/renderer/src/components/editor/EditorEditFileSurface.tsxsrc/renderer/src/components/editor/EditorFileLoadErrorView.tsxsrc/renderer/src/components/editor/EditorFileLoadErrorView.user-disconnected.test.tsxsrc/renderer/src/components/editor/local-host-test-fixture.tssrc/renderer/src/components/editor/useEditorPanelFileLoadRetry.host-connection.test.tsxsrc/renderer/src/components/settings/ssh-session-termination.tssrc/renderer/src/components/settings/ssh-target-remove.test.tssrc/renderer/src/components/settings/ssh-target-remove.tssrc/renderer/src/components/sidebar/WorktreeCardSshHostControl.tsxsrc/renderer/src/components/terminal-pane/TerminalPaneRuntimePortals.tsxsrc/renderer/src/components/terminal-pane/TerminalSshReconnectOverlay.test.tsxsrc/renderer/src/components/terminal-pane/TerminalSshReconnectOverlay.tsxsrc/renderer/src/components/terminal-pane/pty-connection-deferred-ssh-passphrase.test.tssrc/renderer/src/components/terminal-pane/pty-connection-deferred-ssh-user-disconnect.test.tssrc/renderer/src/components/terminal-pane/pty-connection-parked-ssh-snapshot.test.tssrc/renderer/src/components/terminal-pane/pty-connection-reattach-binding.test.tssrc/renderer/src/components/terminal-pane/pty-connection-remote-runtime-attach.test.tssrc/renderer/src/components/terminal-pane/pty-connection-runtime-owner-spawn-routing.test.tssrc/renderer/src/components/terminal-pane/pty-connection-test-environment.tssrc/renderer/src/components/terminal-pane/pty-connection/deferred-session-attach.tssrc/renderer/src/components/terminal-pane/pty-connection/ssh-session-connect.tssrc/renderer/src/components/terminal-pane/terminal-pane-host-state.test.tssrc/renderer/src/components/terminal-pane/terminal-pane-host-state.tssrc/renderer/src/components/terminal-pane/use-terminal-pane-foundation.tssrc/renderer/src/hooks/automation-dispatch-workspace.tssrc/renderer/src/hooks/automation-dispatch-workspace.user-disconnect.test.tssrc/renderer/src/hooks/useAutomationDispatchEvents.test.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/fr.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/lib/worktree-host-connection-phase.test.tssrc/renderer/src/lib/worktree-host-connection-phase.tssrc/renderer/src/ssh/ssh-user-connect-callers.test.tssrc/renderer/src/ssh/ssh-user-connect.tssrc/renderer/src/ssh/use-user-disconnected-host-connect.tssrc/renderer/src/startup/startup-ssh-connection-restore.test.tssrc/renderer/src/startup/startup-ssh-connection-restore.tssrc/renderer/src/store/slices/runtime-environment-ssh-selectors.tssrc/renderer/src/store/slices/runtime-environment-ssh.tssrc/renderer/src/store/slices/ssh-target-cleanup.tssrc/renderer/src/store/slices/ssh.test.tssrc/renderer/src/web/preload-api/web-terminal-api.tssrc/renderer/src/web/web-preload-api-ssh.test.tssrc/shared/execution-host.tssrc/shared/rpc-contract/ssh-params.tssrc/shared/ssh-disconnected-by-user.tssrc/shared/ssh-retained-payload-admission.test.tssrc/shared/ssh-retained-payload-admission.tssrc/shared/ssh-types.tstests/e2e/helpers/browser-pane-mount-census.tstests/e2e/local-ssh-browser-routing.spec.tstests/e2e/ssh-user-disconnect-sticks.spec.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
…y or a cleanup opens a transport
…h, whatever raced its refusal
There was a problem hiding this comment.
ℹ️ No critical issues — the user-disconnect flow is well covered end to end. The intent gate, though, is not quite the single choke point the PR describes: a few dial sites bypass it. Details below.
Reviewed changes
- Persisted per-target intent.
SshTarget.desiredConnection('connected' | 'disconnected', absent = connected) is written only byssh:disconnectand by a user connect, is stripped from renderer-authored target saves, and is preserved across restarts by the target-row normalizer. - Admission split.
connectTarget(targetId, admission)gains'user' | 'background' | 'session-cleanup';'background'is refused withssh_disconnected_by_userwhen the user's Disconnect holds the host. Newssh:ensureConnected/ssh:connectForSessionCleanupIPC and web-preload plumbing;ssh.connectgains an optionalbackgroundflag. - Published
disconnectedBy. Stamped at the single enrichment point, synthesized into adisconnectedstate when no connection object exists (restart), and carried through payload admission and store equality. - Renderer wait cards. Terminal overlay, browser gate and editor error view show "You disconnected
<host>" with a Connect button;connectPaneSshHostwaits instead of redialing; automation dispatch skips with a plain reason;unavailableReasonderives from the published field. - Ratchet + coverage. A test pins the renderer callers allowed to reach the user connect; owner tests (a–h), renderer tests, and a new Docker-SSH e2e cover the behavior.
ℹ️ The intent gate is not the only place an SSH transport opens
connectTarget is described as the one place that refuses a connect to a host the user disconnected, but two handlers dial connectionManager.connect directly without consulting isSshTargetDisconnectedByUser, and one admission can leave the host connected while intent still says disconnected. The core flow (pane attach, startup restore, automation, VM) is correctly gated and proven by the e2e; these are the remaining gaps.
Technical details
# Unguarded dial sites against a user-disconnected target
## Affected sites
- `src/main/ipc/ssh-connection-handlers.ts:60-67` — `doResetRelay` opens a fresh transport
(`connectionManager.connect(target)`) when none exists, with only the shutdown fence, no intent
check. Reachable from the settings "Reset relay" action, which the UI offers while the host is
`disconnected` (`src/renderer/src/components/settings/SshTargetDestructiveActions.tsx:143-148`).
It force-stops and disconnects again in `finally`, so the resurrection is transient, but it
broadcasts a mid-flight `{ status: 'connected', disconnectedBy: 'user' }` and rotates the
provider authority/generation the renderer keys panes on.
- `src/main/ipc/ssh-connection-handlers.ts:291-300` — `ssh:testConnection` likewise dials
`connectionManager.connect(target)` with no intent check (user "Test connection"; broadcasts are
suppressed via `testingTargets`, so silent and transient).
- `src/main/ipc/ssh-connection-handlers.ts:212-216` + `src/renderer/src/components/settings/ssh-session-termination.ts:18-19`
— the `session-cleanup` connect is allowed past the refusal by design ("the caller closes it
again"), but the only close is the teardown at `:216`, which `:214` skips by throwing when a
remote shutdown fails. The cleanup transport then stays live while `desiredConnection` is still
`'disconnected'`: background connects keep being refused and the UI shows the wait card on a
host that is actually connected, until the user clicks Connect.
## Required outcome
Decide explicitly whether Reset-relay and Test-connection are sanctioned exceptions (in which case
the invariant statement should say so) or should route through admission / record intent. For
`session-cleanup`, ensure the transport opened for cleanup cannot outlive a failed terminate while
intent is `'disconnected'` — e.g. tear the transport down on the error path, or leave intent
unchanged but force a publish that reflects the live transport.
## Open questions for the human
Is `session-cleanup` winning over a Disconnect intentional even when the terminate fails, or should
a failed terminate fall back to leaving the host down (refusing the cleanup connect)?ℹ️ Nitpicks
- Restart delivery currently rests on renderer initial hydration, not the startup reconnect flow:
restoreSshConnectionsForStartuponly logs a refusal (startup-ssh-connection-restore.ts:73-75) and republishes onlyconnectedstates, so the wait card after a restart depends ondirect-ssh-initial-state-hydration.tscallingssh.getState. The main-process(c)test pinsssh:getStateat the IPC boundary; a renderer test that a restarted pane lands on the wait card would lock the wiring in place.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
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: b8d599b8-49d2-440d-aadd-9ab65776e8bd
📒 Files selected for processing (5)
src/main/ipc/ssh-renderer-broadcast.tssrc/main/ipc/ssh-user-disconnect-intent.test.tssrc/renderer/src/components/terminal-pane/pty-connection-deferred-ssh-user-disconnect.test.tssrc/renderer/src/components/terminal-pane/pty-connection/ssh-session-connect.tssrc/shared/ssh-types.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
| /** | ||
| * Waits on a host the user's Disconnect holds down until the user's own Connect succeeds or | ||
| * fails. Only those, or the pane closing, end it: nothing else reattaches this pane once its | ||
| * connect gave up, so a Connect abandoned before it finished keeps the pane waiting. | ||
| */ | ||
| function waitForUserConnectOfHeldDownHost( | ||
| session: ConnectPanePtySession | ||
| ): Promise<UserInitiatedSshConnectOutcome> { | ||
| const entryState = useAppStore.getState().sshConnectionStates.get(session.connectionId) | ||
| return waitForPublishedSshOutcome(session, (state) => { | ||
| if (state?.disconnectedBy === 'user') { | ||
| return null | ||
| } | ||
| const outcome = sshPromptConnectOutcomeForStatus(state?.status, false) | ||
| // Why skip the entry state's failure: it was published before this pane waited, so it is | ||
| // not the outcome of the user's Connect (the refusal can beat the Disconnect's push). | ||
| return outcome === 'failed' && state === entryState ? null : outcome | ||
| }) | ||
| } |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '1,225p' src/renderer/src/components/terminal-pane/pty-connection/ssh-session-connect.ts
sed -n '80,155p' src/renderer/src/components/terminal-pane/pty-connection/deferred-session-attach.tsRepository: stablyai/orca
Length of output: 10659
🏁 Script executed:
#!/bin/bash
set -o pipefail
printf '%s\n' '--- relevant files ---'
git ls-files | rg 'ssh|pty-connection|terminal-pane' | head -200
printf '%s\n' '--- symbols and tests ---'
rg -n --glob '!node_modules' \
'waitForUserConnectOfHeldDownHost|connectPaneSshHost|waitForPublishedSshOutcome|ensureConnected|getState\(\{ targetId|disconnectedBy|sshConnectionStates|auth-failed|reconnection-failed' \
src/renderer src/shared src/main test tests 2>/dev/null | head -500
printf '%s\n' '--- changed-file diff summary and focused diff ---'
git diff --stat 433986fa3be37911a0f13f7ffd454b831b87a64c 7599fa8f0bbc7003795ae3fddfdcd8ab33676245 -- src/renderer/src/components/terminal-pane/pty-connection/ssh-session-connect.ts
git diff --unified=30 433986fa3be37911a0f13f7ffd454b831b87a64c 7599fa8f0bbc7003795ae3fddfdcd8ab33676245 -- src/renderer/src/components/terminal-pane/pty-connection/ssh-session-connect.tsRepository: stablyai/orca
Length of output: 42060
🏁 Script executed:
set -o pipefail
rg -n --glob '!node_modules' \
'waitForUserConnectOfHeldDownHost|connectPaneSshHost|waitForPublishedSshOutcome|ensureConnected|getState\(\{ targetId|disconnectedBy|sshConnectionStates|auth-failed|reconnection-failed' \
src/renderer src/shared src/main test tests 2>/dev/null | head -500
printf '%s\n' '--- focused diff ---'
git diff --unified=25 433986fa3be37911a0f13f7ffd454b831b87a64c 7599fa8f0bbc7003795ae3fddfdcd8ab33676245 -- src/renderer/src/components/terminal-pane/pty-connection/ssh-session-connect.tsRepository: stablyai/orca
Length of output: 41704
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- renderer SSH slice ---'
fd -i '^ssh(\.test)?\.(ts|tsx)$' src/renderer/src/store src/renderer/src 2>/dev/null | head -30
sed -n '1,130p' src/renderer/src/store/slices/ssh.ts
printf '%s\n' '--- IPC handlers and state publication ---'
sed -n '90,155p' src/main/ipc/ssh-connection-handlers.ts
sed -n '1,115p' src/main/ipc/ssh-renderer-broadcast.ts
printf '%s\n' '--- user disconnect/Connect contract tests ---'
sed -n '110,255p' src/main/ipc/ssh-user-disconnect-intent.test.ts
sed -n '295,375p' src/main/ipc/ssh-user-disconnect-intent.test.ts
printf '%s\n' '--- renderer Connect callers/tests ---'
cat -n src/renderer/src/ssh/ssh-user-connect-callers.test.ts
rg -n --glob '!node_modules' 'ssh-session-connect|connectPaneSshHost|waitForUserInitiatedSshConnect' src testsRepository: stablyai/orca
Length of output: 26955
Capture the entry state before the asynchronous hold check.
isSshHostHeldDownByUser can await ssh.getState. If the user's Connect publishes auth-failed during that await, the later entryState read captures that real failure. The waiter then suppresses it because state === entryState, so the pane can remain pending instead of returning the Connect error.
Suggested fix
function waitForUserConnectOfHeldDownHost(
- session: ConnectPanePtySession
+ session: ConnectPanePtySession,
+ entryState: SshConnectionState | undefined
): Promise<UserInitiatedSshConnectOutcome> {
- const entryState = useAppStore.getState().sshConnectionStates.get(session.connectionId)
return waitForPublishedSshOutcome(session, (state) => {
@@
if (result.connected || session.disposed) {
return result
}
+ const entryState = useAppStore.getState().sshConnectionStates.get(session.connectionId)
if (!(await isSshHostHeldDownByUser(session.connectionId))) {
return result
}
- const outcome = await waitForUserConnectOfHeldDownHost(session)
+ const outcome = await waitForUserConnectOfHeldDownHost(session, entryState)There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Since the prior pullfrog review (54c0bc0a), three commits close the gaps that review raised, and I found no new problems.
- A held-down host always publishes as disconnected.
withUserConnectionIntent(src/main/ipc/ssh-renderer-broadcast.ts:59-75) coerces every publication throughbroadcastSshStateandgetPublicSshStateto{ status: 'disconnected', error: null, reconnectAttempt: 0, disconnectedBy: 'user' }while the intent holds, so a transport opened for Reset Relay or a session cleanup can no longer present as the host coming back. - A failed terminate closes the cleanup transport it needed.
closeTransportHeldDownByUser(src/main/ipc/ssh-connection-handlers.ts:106-122) is wired to thessh:terminateSessionserror path and tears the transport/session down when the host is held down, so no live transport outlives a failed terminate. The nestedrunTargetLifecyclecannot deadlock: the queue entry is deleted infinallybefore the rejection reaches the.catch. - A held-down pane waits through the races.
waitForUserConnectOfHeldDownHost(.../pty-connection/ssh-session-connect.ts:143-156) is single-shot rather than looping, keeps waiting when a user Connect is abandoned at the passphrase prompt, and suppresses a stale pre-Disconnect failure via thestate === entryStateidentity guard. Disposal still resolves the wait. - Coverage. New owner tests pin both behaviours — every published state masked while
getStateis connected, and the failed-terminate teardown (connection undefined, lease leftdetached) — and two renderer tests cover the refusal-beats-the-push race and the abandoned Connect.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Since the prior pullfrog review (103dec31), the delta is one test-only commit that locks in the fix that review approved. No production code changed, and no new problems.
- A failed terminate must not cancel a user's Connect. New owner test
(h) a user's Connect during a failed terminate keeps the connection it asked for(src/main/ipc/ssh-user-disconnect-intent.test.ts:379) races a userssh:connectagainst an in-flightssh:terminateSessionsthat fails, on a host the user had disconnected, and asserts the connect still resolvesconnectedwith a live transport and intentconnected. It is genuine coverage: removing the!isSshTargetDisconnectedByUserguard fromcloseTransportHeldDownByUsermakes the test reject withSshConnectAttemptCancelledError, because the unguarded close reachesdisconnectRegisteredSshTargetand rotates the provider authority out from under the parked user connect.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
… host-side operation The renderer used to make two calls to end remote terminals on a detached host: a cleanup connect, then the terminate. A reload between them left a live transport, relay session and redial on a host the user had disconnected, and a Connect clicked between them joined the cleanup dial only for the terminate to tear it down. ssh:terminateSessions now owns the whole operation in the target's lifecycle queue: it dials the relay itself when the sessions need it, terminates, and closes the transport again when the user's Disconnect holds the host down. A user Connect made meanwhile waits for the operation and dials its own session. A relay that reaches ready while the Disconnect holds restores no port forwards and republishes no phone tabs. The ssh:connectForSessionCleanup channel is removed.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Since the prior pullfrog review (0336e20), one commit consolidates how a user's "end terminals" reaches a host: the host now dials and closes the relay in a single lifecycle operation, so the renderer no longer reconnects before terminating.
ssh:terminateSessionsowns both ends. The newterminateSshTargetSessions(src/main/ipc/ssh-terminate-sessions.ts) runs inside the target lifecycle queue, callsterminateReachableSessions, and onSSH_TERMINATE_RECONNECT_REQUIREDdials withconnectTarget(targetId, 'session-cleanup')and retries; itsfinallycloses the cleanup transport (detach, so a failed terminate keeps its leases for retry). A user Connect parked behind the operation therefore waits for it instead of joining the dial.ssh:connectForSessionCleanupis gone. The IPC handler, preload API, web stub andSshTargetRemoveApi.connectare removed; onlyterminateSshTargetSessionsmay pass thesession-cleanupadmission (RegisteredSshConnectAdmissionexcludes it from the registry/RPC), andconnectTargetskips the lifecycle wait for it so the in-operation dial cannot self-deadlock.- Renderer retry deleted.
terminateSshSessionsWithReconnectis removed;SshPanecallsterminateSessionsdirectly, andremoveSshTargetWithBestEffortCleanupdrops its reconnect/retry while preserving the #2626 guarantee that an unreachable host cannot block target removal. - Held-down publication. A session-cleanup relay that reaches ready on a user-disconnected host restores no port forwards and republishes no phone tabs (
ssh-relay-session-callbacks.ts). - Coverage. Five owner tests cover the single-dial success, the masked publication, the failed-terminate close, a user Connect during a failed cleanup, and a user Connect during the cleanup's dial; the existing terminate tests now assert the host dials itself. I ran these plus the touched renderer/preload tests (54 green) and
pnpm tc(clean).
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…cted host back End Terminals, Remove and Reset Relay used to reach a host with no live session by registering a full connection and relay session, then hiding it from readers. They now run over a maintenance channel: a bare connection (and, for terminate, a bare relay mux) that is never registered, publishes no state, rejects on any drop instead of reconnecting, is closed on every exit path, and is aborted and joined by the shutdown drain. This removes the session-cleanup connect admission and the relay-ready skip it needed; while the user's Disconnect holds, nothing registers a transport or session for the host.
…ay's ready effects
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Since the prior pullfrog review (6ef7fba), two commits replace the registered session-cleanup connection with a genuinely unregistered maintenance channel, and add relay-side proof that a stop from a client with no consumer session is honoured. I found no new problems and ran two focused specialist passes over the concurrency and teardown seams.
- Dropped the
session-cleanupadmission.SshConnectAdmissionis now only'user' | 'background';connectTargetalways waits the target lifecycle queue and re-asserts admission after it, so there is no admission that could bypass the queue or the refusal. - New maintenance channel.
withSshMaintenanceTransport/withSshMaintenanceRelay(src/main/ipc/ssh-maintenance-channel.ts) open a bareSshConnectionthat is never registered in the connection manager, a relay session or a provider registry, publishes no state and rotates no authority; it reuses the host relay over the same instance id and hands callers a raw multiplexer. ssh:terminateSessionsrewritten around it. A live provider still ends its own sessions; a target with no provider but owned leases now dials over the maintenance relay and issuespty.shutdownper relay pty id, while an unreachable host still surfacesSSH_TERMINATE_RECONNECT_REQUIREDso target removal is never blocked (#2626).ssh:resetRelayuses the maintenance channel when no connection is registered, so a Reset cannot bring a user-disconnected host back through the registry.- Shutdown drain owns the maintenance transports.
beginSshShutdownaborts and joins each operation, and the held-downsetOnReadyguard was reverted because no relay session can reach ready on a held-down host any more. - Coverage. Owner tests for the passphrase prompt/cancel, relay-deploy failure and drain join/abort; the terminate/reset intent tests now assert nothing is registered while the Disconnect holds; a new relay test pins
pty.shutdownfrom a no-consumer-session client and that an owner-fenced stop is still refused.
Two open questions I traced to a negative: the maintenance channel has no path that stays unsettled or leaks its transport (disconnect() settles an in-flight connect(); deploy and mux.request are each timeout-bounded), and a maintenance dial on a host whose session is mid-reconnect shares the incumbent relay rather than displacing it.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
One commit landed while the previous review was posting (7910b1a → 44fff19), and it is test-only. No production code changed.
- A queued Connect survives End Terminals. New owner test
(ii) a user's Connect while the terminate waits behind the Disconnect ends connectedraces a userssh:connectbehind an in-flightssh:disconnectand a queuedssh:terminateSessions, then asserts the Connect still resolvesconnected, the target's intent isconnected, the transport and session are live, and the relay-ready effects fired. It would fail if the maintenance terminate cancelled or tore down a Connect that waited behind it. - A relay reconnect on a connected host restores forwards. New owner test
(ii) after the user's Connect, a relay reconnect restores forwards and republishesdrops and recovers a transport after the user reconnects, then asserts the relay redeploys, the session returns toready,notifySshRelayReadyfires, and exactly one port forward is restored — locking in the callbacks that the held-downsetOnReadyguard used to skip. - Tighter rejection timing. The drop-mid-operation test now attaches its
.rejectshandler before awaiting the transport teardown, so the assertion is registered earlier without changing what it checks.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Since the prior pullfrog review (44fff19), the delta is one test-only commit that strengthens the owner test covering a user Connect parked behind End Terminals. No production code changed.
- The parked Connect restores its forwards. The
(ii) a user's Connect while the terminate waits behind the Disconnect ends connectedtest now clearsmockPortForwardManager.addForwardhistory before the held Disconnect is released and asserts it is called exactly once (src/main/ipc/ssh-user-disconnect-intent.test.ts:571,583). It is genuine coverage rather than a tautology: the assertion reddens if the user connect that waited behind the terminate stops restoring its persisted port forwards. I ran the file — 20 tests pass.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…explorer and editor Quitting with a user-disconnected host said the host "could not be reached"; the prompt now says the user disconnected it and its terminals keep running, and still names any other host that really went quiet. The file explorer showed a raw readDir error on that host; it now shows the same "You disconnected <host>" card and Connect as the other panes. The editor card drops its red error title and icon for that case. All three read the shared host-connection signal's user-disconnected reason.
…nnects The retry only counted this client's own SSH targets, so connecting a host a remote runtime owns (including from the new Connect card) left the tree on its read error. It now also follows the workspace's shared host-connection epoch.
…nnected "Terminals there keep running" is false for a host with a timeout after disconnect: its relay ends them once that runs out, whether or not Orca quits. The prompt now states only what closing does.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Since the prior pullfrog review (2867f14), one renderer commit extends the user-disconnect treatment to three more surfaces. I read the incremental and full diffs, ran the six touched renderer test files (32 tests), pnpm tc:web, and the localization extraction/catalog verifiers — all green; no new problems.
- File explorer shows the wait card.
FileExplorerTreeStatusnow takes aworktreeId, reads the shared host-connection signal, and renders "You disconnected<host>" with a Connect button when the failed tree read is on a user-disconnected host, in place of the rawreadDirerror.FileExplorerandFileExplorerFilesTreePanethreadactiveWorktreeIdthrough. - Editor card reads as neutral.
EditorFileLoadErrorViewdrops the red error title/icon for a user-disconnected host and splitseditor.fileLoad.userDisconnectedHostintouserDisconnectedTitleanduserDisconnectedDescription. - Quit prompt names the disconnected host.
WindowCloseRunningWorkgains auser-disconnectedkind and theunverifiablevariant carriesuserDisconnectedHostLabels;classifyUnobservedHostsmaps each unobserved remote pty back to its worktree and separates hosts the user disconnected from ones that genuinely went quiet. Prompt copy moves toterminal/window-close-dialog-copy.ts, anduse-terminal-editor-close-foundationnow stores the whole work object. - Coverage. New unit tests for the classification and the prompt copy, renderer tests for both new cards, and the connect-caller ratchet now permits
FileExplorerTreeStatus.tsx.
I traced the classification edge cases (all-unobserved-user-disconnected → user-disconnected; any non-user-disconnected unobserved host → unverifiable with the named labels; local probes still excluded on quit) and the null/local worktree paths through useWorktreeHostConnection, and found nothing to correct.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
… connects Clicking Connect on the "You disconnected" card moves the host to connecting, which is no longer user-disconnected, so the card fell back to the dropped connection's raw read error until the reload landed. A connecting host now shows the loading state instead.
…le the host connects Clicking Connect on the "You disconnected" card moves the host to connecting, which is no longer user-disconnected, so the card fell back to the dropped connection's raw read error until the reload landed. A failure the retry gate reloads on connect now shows the existing connecting message instead.
…nd Chinese copy "There" came across as a vague place (そこの, 那里的) rather than the hosts the user disconnected, and the Spanish sentence repeated termina/terminales.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Since the prior pullfrog review (0dac851), four renderer commits improve how the file explorer and quit prompt handle a host the user disconnected. No owner (main-process) code changed.
- Reload a failed file-explorer tree when its host connects.
use-file-explorer-tree-load-effectsnow watches the worktree'sconnectedEpoch(threaded fromuse-file-explorer-tree-pane-state.ts) in addition to this client's ownsshConnectedGeneration, so a failed tree on a target a remote runtime owns — whose connect movessshStateByEnvironment, not the local generation — reloads once the host is up. The epoch term is scoped to the same worktree, so switching workspaces is not read as a connect. - Hide the raw read error while the host connects.
FileExplorerTreeStatusrenders the loading spinner when there is a read error andhost.phase === 'connecting', since that error belongs to the connection being replaced; the tree reloads on its own once the connect lands. - Reword the quit prompt for a user-disconnected host. The copy changes from "Terminals there keep running." to "Closing the window does not end terminals there." in
window-close-dialog-copy.tsand all six locale catalogs. - Coverage. New host-connect tests for the reload/no-op/worktree-switch cases and a status test asserting the raw error and the wait card stay hidden while connecting.
I ran the four touched test files (13 tests, all green), pnpm tc:web, and the localization extraction/catalog verifiers — all clean. The reload logic is guarded by rootError, updated in one place per run, and cannot loop (epoch is stable per connection); the connecting-spinner is bounded because startup restoration always settles (startup-degraded-recovery.ts).
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…gate reloads The retry gate reloads only the panel's active edit or preview file, but conflict review rows share the load-error view, so a row read "retrying once the workspace is ready" while connecting and then fell back to its raw error with no reload.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Since the prior pullfrog review (9295ba4), two commits land. One replaces the stale editor read error with the connecting state while a host connects; the other corrects the Spanish, Japanese and Chinese quit-prompt copy.
- Replaced the stale editor error with the connecting state.
EditorFileLoadErrorViewnow swaps a connection-caused load failure for the transient "Connecting to the remote host…" message whenever the workspace's host is in theconnectingphase, so the card no longer shows a raw error the in-flight connect is about to replace. A failure the connection cannot fix (e.g.ENOENT) still renders as-is. - Shared the reload predicate. The condition the retry hook uses to reload a file once its host connects is extracted into
isReloadedWhenHostConnectsand reused by the view, so the two surfaces cannot drift. - Corrected quit-prompt copy. The
userDisconnectedHostsanduserDisconnectedAndUnreachableHostsstrings now name the host's terminals explicitly in the Spanish, Japanese and Chinese catalogs.
I ran the two touched editor test files (7 tests), pnpm tc:web, and both localization verifiers — all green. The new EditorFileLoadErrorView test is genuine coverage: without the shownMessage branch it would see the raw SSH connection is not available text instead of the connecting message. No owner (main-process) code changed.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Since the prior pullfrog review (30e8971), one commit narrows the editor connecting-state substitution to the files the retry gate actually reloads.
- Scoped the connecting-state promise to the retry gate's file.
EditorFileLoadErrorViewgainsreloadsWhenHostConnects(defaultfalse), and the stale-error substitution now requires it.EditorContent(markdown-preview) andEditorEditFileSurface(edit) pass it — the two modesuseEditorPanelFileLoadRetryreloads for the active file — whileEditorConflictReviewSurfacedoes not, so a conflict row keeps its truthful raw read error instead of showing a "Connecting…" message that would never be followed by a reload.
I ran the three touched editor test files (10 tests) and pnpm tc:web — all green. The added test is genuine coverage: it renders without the prop and fails if the guard is dropped, since the raw SSH connection is not available text would otherwise be replaced. No owner (main-process) code changed.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…ot a refused host The escape hatch is offered on the "You disconnected" card, so the spec keeps the user's Disconnect. The refused-host setup it picked up from main was there to stop a terminal redial from recovering the route; a held Disconnect admits no redial, so the host stays reachable and an unmoved connection generation now proves nothing redialed behind the card before the escape hatch is clicked. The helper that refused connections has no other caller and goes with it.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Since the prior pullfrog review (853925f), the delta is a merge of origin/main (upstream only, no PR-authored production change) plus one test-only commit that reworks the SSH browser-routing escape-hatch e2e.
- The escape hatch now proves a held Disconnect, not an unreachable host.
tests/e2e/local-ssh-browser-routing.spec.tsdrops the merged-inrefuseDockerSshRelayTargetConnectionsTCP refusal and keeps the user'sssh.disconnect, then asserts the pane shows the "You disconnected" card and thatssh:getStateis unchanged (status,connectionGeneration,providerEpoch) before "Browse from this device instead" is clicked. - Dead helper removed. The refusal helper in
tests/e2e/helpers/docker-ssh-relay-target.tsand the spec'sreadRendererSshStatushelper had no remaining callers and are deleted; the genericssh-unavailablegate card keeps unit coverage, so no e2e-only path is lost.
I confirmed no lingering references to the removed symbols, that ssh:getState synthesizes a disconnected state while the intent holds (so the new poll resolves), and that ssh:disconnect awaits teardown before resolving (so the captured baseline is stable). pnpm run typecheck:e2e reports no errors in the two changed files.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Thanks @brennanb2025. Since this was opened, the SSH relay was removed (#27214, #27215) and SSH hosts now reach Orca's managed remote server through a managed tunnel that resumes on its own. Runtime environments have an in-memory manual-disconnect flag ( |
|
Closing as superseded: a merged PR already covers this change. Merged #30130 (27cfee6, 10-17, another author) does the same thing: a Disconnect is recorded for the session and background dials refuse it until an explicit Connect (main src/main/ssh/ssh-user-disconnect.ts). #29918 (03be5bb) and #30245 (06618fd) also landed. 17 of this PR's files have since moved or been (Stale-PR cleanup 2026-10-20, approved by Brennan. Reopen if something here is still missing on main.) |

ELI5
When you click Disconnect on an SSH host, Orca now keeps it disconnected until you connect it again. Before, a terminal in that workspace quietly dialed the host again less than a second later, so Disconnect did nothing. A dropped network connection still reconnects by itself, because losing the network is not you asking to disconnect.
What Changed
Before: Disconnect closed the connection, but nothing remembered that you asked for it. "Disconnected" only meant "no connection right now". Any background caller that wanted the host (a terminal pane attaching, startup restore, a scheduled automation, a paired web client's panes) simply connected it again, typically about 0.4 s after the click.
After:
Mechanism:
desiredConnection?: 'connected' | 'disconnected'(absent means connected, which is how every existing target and older build behaves). Only thessh:disconnecthandler writes 'disconnected', and only a user connect writes 'connected'. Targets owned by a runtime (ephemeral VMs) never get an intent.ssh:connect, or the runtimessh.connectwithout a flag) records intent and connects. A background connect (ssh.ensureConnected, orssh.connectwithbackground: truefrom a paired web client) never records intent. It is refused with a typedssh_disconnected_by_userwhen you disconnected the host. The check runs inconnectTarget, before any connection attempt is registered or broadcast, and again after the per-target lifecycle wait.disconnectedBy: 'user', stamped in the one place every published state passes through. Panes decide from that published fact, not from the error, so a pane whose in-flight connect was cancelled by the Disconnect also shows the card rather than an error.unavailableReasonderived from it; the phase stays "unavailable".Why
A Disconnect that background work undoes 0.4 s later is meaningless. The fix models your intent once, at the connection owner, instead of adding a "don't reconnect" check to each caller. Connection status alone cannot answer the question: "disconnected" looks the same after you disconnect, after a failed connect, and for a host that was never dialed. So the intent has to be stored, and it is persisted so a restart does not undo it either.
Alternatives considered:
Differences from the common pattern
The common pattern stores a per-host desired-connection state at the connection owner, refuses background recovery while it is off, and publishes a distinct "suspended" state.
Linked Issue
Found while fixing the SSH browser-route e2e regression (#23465): after
ssh.disconnect, the workspace terminal's deferred attach redialed the host within about 0.4 s in every CI run.Visual Proof
TODO: screenshots of the terminal, browser and editor "You disconnected " cards from live QA.
Testing
Owner tests (main process):
reconnection-failedis allowed.disconnectedByis published, including when no connection object exists and after a restart.Renderer tests: the terminal attach waits (no error, no retry) and attaches exactly once after Connect; a cancelled in-flight connect lands on the same wait; the signal, the terminal overlay, the browser card and the editor card show the message and call the user connect; startup restore, automation dispatch and target removal use the right entry point; the ratchet test.
Each behaviour was removed in turn (23 ablations), and each removal reddens its tests.
New e2e (
ssh-user-disconnect-sticks.spec.ts, Docker SSH lane): with a terminal open, after Disconnect the status, generation anddisconnectedBystay unchanged for 6 s; then the overlay's Connect reconnects and the pane reattaches.pnpm tc, fulloxlint,pnpm lint(including the localization verifiers),check:code-quality:changedandcheck:react-doctor:changedare clean.I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
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
backgroundflag onssh.connectand thedisconnectedByfield are optional, so older clients ignore them. Caveat: a paired web tab running an older bundle sends plainssh.connectfrom its panes, which the host treats as a user connect. Such a tab keeps undoing a Disconnect until it reloads.orca terminal createdo not count as you acting on the host, including when you runorca terminal createyourself. They wait behind the card until you connect.orca ssh connectCLI command, and a Connect button on the phone's terminal view. Until then, a host disconnected on the desktop is reconnected from the desktop or from the phone's New Workspace flow.Author X handle: @BrennanKB5
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)