* fix(ssh): reconnect persisted PTYs after shutdown races * fix(ssh): harden shutdown reconnect-target derivation - exclude runtime-owned (ephemeral-VM) targets: a renderer-driven startup ssh.connect would dispose the runtime layer's live relay session - exclude explicitly disconnected / auth-failed targets so startup never dials a host the user chose to leave offline (sessions still restore on tab focus via the deferred flow) - avoid re-running buildTerminalSessionData via the default parameter when the remote-session map is legitimately empty (null sentinel) - recompute activeConnectionIdsAtShutdown alongside terminal-field patches so a crash between patches cannot strand a stale target - pin all of the above with tests, including the patch-writer path Co-authored-by: Orca <help@stably.ai> * fix(ssh): filter runtime-owned targets at startup reconnect consumption Main's windowless-promotion path can persist runtime-owned ids into activeConnectionIdsAtShutdown; renderer must never dial those. Co-authored-by: Orca <help@stably.ai> * test(ssh): pin runtime-owned exclusion independently of the status gate Give the runtime-owned fixture a transient status so the status gate alone cannot exclude it; verified by mutation (guard removal fails). Co-authored-by: Orca <help@stably.ai> * refactor(session): extract reconnect-target derivation to its own module workspace-session.ts crossed the max-lines budget; the derivation is a self-contained concern (session ids + live SSH state -> startup targets). Parameter is now required (null = none) since every caller has the terminal session data or must opt into the scan explicitly. Co-authored-by: Orca <help@stably.ai> * fix(ssh): exclude runtime-owned targets from the connected-states path too A pane-level optimistic write can stamp a runtime-owned connection state; the live 'connected' filter must apply the same exclusion as the session-id union (CodeRabbit review finding). Pinned in the test on both paths. Co-authored-by: Orca <help@stably.ai> --------- Co-authored-by: Neil <4138956+nwparker@users.noreply.github.com> Co-authored-by: Orca <help@stably.ai>