mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
* fix(P1-A): persist SSH consumer recovery without a sync store flush rememberPtyConsumerRecovery ran on the live establish/reconnect path and called flushOrThrow -> writeToDiskSync, parking the Electron main thread on the profile-directory write. On a stalled or slow profile mount that freezes the whole app during SSH recovery and reconnect. Add Store.flushAsync(): same debounce-cancel and write serialization as flushOrThrow, but awaits writeToDiskAsync instead of blocking. The consumer recovery upsert/remove pair is now async and awaits it, and the SSH callers await through to establish()/reconnect() so ownership is still durable before relay setup continues. In-memory state still mutates synchronously (before the first await), so no caller can observe a torn record and dispose() stays synchronous. * fix(P1-A): detach the SSH session when a connect attempt fails Both failure exits in doConnect dropped the session from activeSessions without calling detach(). claimSshPtyConsumerRecovery only reuses an existing in-memory entry when detached === true, so the next connect attempt fell through to minting a fresh clientInstanceId, discarding the remembered owner lease and its resume identity. Route both exits through abandonFailedSshSession(), which detaches (keeping PTY ownership, unlike dispose()) before removing the session, and tolerates a teardown throw so it can't mask the connect error being rethrown. * fix(P1-A): await async lease persistence in SSH relay teardown Failed connect attempts now wait for 'detached' leases to persist before throwing, preventing reconnects from claiming them before cleanup completes. Detach and dispose operations are now async and await store durability. * fix(ssh): make session detach lease writes retryable on failure Separate in-memory detach (identity recovery, provider cleanup) from lease write persistence so rejected writes can be re-issued without re-running provider teardown or re-minting the session identity. Introduce flushDurableStateOrThrowAsync to flush only SSH-recovery state on the live establish/reconnect path, avoiding snapshot writes of sidecars that belong to quit/startup. Use Promise.allSettled in test reset to prevent one rejected disposal from leaking state into the next test. * fix(ssh): dispose mux on failed establish and propagate sync errors - Dispose mux when session is disposed during establish to prevent resource leak - Propagate synchronous errors in teardown via the completion promise instead of leaving completion undefined - Add test coverage for terminated PTYs that exit mid-reattach and must stay dead