Repository navigation
fix(terminal): prevent reconnect from killing live daemon sessions - #9804
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (13)
🚧 Files skipped from review as they are similar to previous changes (9)
📝 WalkthroughWalkthroughAdds lifecycle-aware session-tab close RPCs with explicit reasons, publication epochs, terminal incarnation handles, and host-side liveness adjudication. Renderer close-intent tracking is scoped by environment and worktree, with replay and snapshot freshness handling. Daemon initialization supports isolated legacy history paths. New Windows-focused Playwright fixtures exercise multi-generation reconnect survival, bounded disposal failure, process liveness, and cleanup behavior. Reliability-gate documentation records the investigation, evidence, criteria, and validation gaps. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 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
🧹 Nitpick comments (1)
tests/e2e/daemon-generation-reconnect-safety.spec.ts (1)
25-34: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueOptional: guard against protocol-version overlap in the fixed generation list.
ALL_GENERATION_PROTOCOLShardcodes[21, 22, 23]and appendsPROTOCOL_VERSION - 1/PROTOCOL_VERSION. This is correct whilePROTOCOL_VERSIONstays at 25, but if it ever lands on 22–24 the list gains a duplicate protocol (and thus a colliding named-pipe socket path), surfacing only as a crypticL290set-size failure. Deduping the list would make the intent version-agnostic.♻️ Suggested dedupe
-const ALL_GENERATION_PROTOCOLS = [...GENERATION_PROTOCOLS, PROTOCOL_VERSION - 1, PROTOCOL_VERSION] +const ALL_GENERATION_PROTOCOLS = [ + ...new Set([...GENERATION_PROTOCOLS, PROTOCOL_VERSION - 1, PROTOCOL_VERSION]) +]
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 6890fdf2-892c-4471-8152-545618cacfc8
📒 Files selected for processing (40)
config/reliability-gates.jsoncdocs/reference/plans/2026-07-21-windows-daemon-generation-safety-investigation.mdmobile/app/h/[hostId]/session/[worktreeId].tsxsrc/main/daemon/daemon-init.test.tssrc/main/daemon/daemon-init.tssrc/main/runtime/orca-runtime.test.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/rpc/methods/session-tab-close-methods.tssrc/main/runtime/rpc/methods/session-tabs-schemas.test.tssrc/main/runtime/rpc/methods/session-tabs-schemas.tssrc/main/runtime/rpc/methods/session-tabs.test.tssrc/main/runtime/rpc/methods/session-tabs.tssrc/main/runtime/runtime-rpc.tssrc/renderer/src/components/Terminal.tsxsrc/renderer/src/components/tab-group/useTabGroupWorkspaceModel.tssrc/renderer/src/components/terminal-pane/terminal-parked-tab-watchers.test.tssrc/renderer/src/components/terminal-pane/terminal-parked-tab-watchers.tssrc/renderer/src/components/terminal/terminal-close-incarnation.test.tssrc/renderer/src/components/terminal/terminal-close-incarnation.tssrc/renderer/src/components/terminal/terminal-tab-actions.test.tssrc/renderer/src/components/terminal/terminal-tab-actions.tssrc/renderer/src/hooks/useIpcEvents.tssrc/renderer/src/runtime/close-mirrored-editor-tab.test.tssrc/renderer/src/runtime/close-mirrored-editor-tab.tssrc/renderer/src/runtime/web-runtime-session.test.tssrc/renderer/src/runtime/web-runtime-session.tssrc/renderer/src/runtime/web-session-close-intent.test.tssrc/renderer/src/runtime/web-session-close-intent.tssrc/renderer/src/runtime/web-session-tabs-sync.test.tssrc/renderer/src/runtime/web-session-tabs-sync.tssrc/shared/runtime-types.tstests/e2e/daemon-generation-reconnect-safety.spec.tstests/e2e/fixtures/daemon-generation-canary.cjstests/e2e/fixtures/daemon-generation-desktop-discovery.tstests/e2e/fixtures/daemon-generation-entry.tstests/e2e/fixtures/daemon-generation-reconnect-client.tstests/e2e/fixtures/daemon-generation-runtime-close.tstests/e2e/helpers/daemon-generation-processes.tstests/e2e/helpers/daemon-generation-runtime-fixture.tstests/e2e/helpers/daemon-generation-safety-fixtures.ts
…onment (#9836) #9804 added a leading `environmentId` parameter to recordWebSessionCloseIntent (and isWebSessionCloseIntentPending) and updated the web-runtime-session.ts callers, but missed the second caller in close-mirrored-editor-tab.ts, which still passed 3 args. This broke the web typecheck on main and, had it compiled, would have recorded the close intent under the wrong scope key (closeIntentScopeKey(environmentId, worktreeId)) — so the host snapshot could flash the just-closed mirrored tab back. Pass the already-validated runtimeEnvironmentId (the same value handed to closeWebRuntimeSessionTab immediately below) so the intent is scoped correctly. Update the test's isWebSessionCloseIntentPending assertion to the 4-arg form. Co-authored-by: Orca <help@stably.ai>
|
Related to #9952. |
…onment (stablyai#9836) stablyai#9804 added a leading `environmentId` parameter to recordWebSessionCloseIntent (and isWebSessionCloseIntentPending) and updated the web-runtime-session.ts callers, but missed the second caller in close-mirrored-editor-tab.ts, which still passed 3 args. This broke the web typecheck on main and, had it compiled, would have recorded the close intent under the wrong scope key (closeIntentScopeKey(environmentId, worktreeId)) — so the host snapshot could flash the just-closed mirrored tab back. Pass the already-validated runtimeEnvironmentId (the same value handed to closeWebRuntimeSessionTab immediately below) so the intent is scoped correctly. Update the test's isWebSessionCloseIntentPending assertion to the 4-arg form. Co-authored-by: Orca <help@stably.ai>
Summary
session.tabs.closeLifecycleRPC.shutdown-dispose-failedfencing.Addresses #9749. The complete issue/PR investigation and call-flow reconstruction are included in
docs/reference/plans/2026-07-21-windows-daemon-generation-safety-investigation.md.Screenshots
No visual change.
Testing
pnpm lint— changed-fileoxlintand code formatting pass; the repository-wide switch-exhaustiveness lane has pre-existing unmatched cases inskill-freshness-group.tsxoutside this diff.pnpm typecheckpnpm test— focused production/RPC/renderer coverage passes 948/949; the sole failure is the existing Windows/tmpversus\tmpbadgeColordedupe expectation in untouched code.pnpm build— fresh Electron Vite and paired web-client builds pass; the full native/package build was not run.Focused evidence:
session-killedevents occurred.oxfmt --check, changed-codeoxlint, andgit diff --checkpassed.AI Review Report
Three full-diff review rounds ran against merge base
937a2015e.Round 1 found and fixed four destructive-action safety issues: lifecycle retirement could still reach renderer/process teardown, unavailable PTY inventory was treated as death, close intent could cross runtime profiles, and the Windows harness allowed an unsafe PID-start tolerance. An elegance pass also removed a cached capability result that could outlive server replacement. Round 2 was clean. After strengthening the harness to call production desktop discovery, round 3 found and fixed a Windows socket-mock defect in scanner tests; the subsequent full-diff review was clean.
The review explicitly checked macOS, Linux, and Windows compatibility; legacy protocol behavior; Windows named pipes and process identity; SSH, WSL, remote-runtime, sleeping/reattachable sessions, and multi-client behavior; path handling; Electron lifecycle behavior; cleanup ownership; polling/listener/handle risks; and reconnect-storm performance. Platform-specific fixture behavior is runtime-gated, and production adds no PowerShell/CIM hot path, polling loop, listener, subprocess, or Job Object implementation.
Security Audit
The changed RPC is a destructive-action boundary. Lifecycle requests require typed provenance plus exact host publication and terminal-incarnation evidence, fail closed on missing/access-denied liveness, and never fall back to the legacy destructive method on an old server. Explicit user closes retain the existing destructive path.
Logging records client kind, connection/request identity, reason, publication, and allow/refusal decision without terminal contents, authentication tokens, pairing secrets, or environment data. No dependency, authentication primitive, shell-command, Git command, or production process-enumeration change was added. The Windows harness uses guarded temporary roots and exact PID/start identities, refuses cleanup outside its fixture namespace, and left no process, pipe, handle, or temp-directory residue.
Notes