Repository navigation
Fix Windows terminal daemon death after workspace close - #8140
Conversation
📝 WalkthroughWalkthroughThe daemon protocol adds history seeding for recovered scrollback. Cold restore conditionally re-anchors history or suspends the session when seeding fails, with integration coverage for recovered output and restart persistence. Windows PTY teardown avoids duplicate ConPTY closure. A Windows named-pipe harness repeatedly tests concurrent workspace-close kills, and CI workflow tests and reliability-gate metadata cover its execution. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/daemon/pty-subprocess.ts (1)
1081-1112: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winMark the Windows SIGKILL path as issued before
dispose()runs
forceKill()should setnodePtyKillIssuedafter the successfulprocess.kill(proc.pid, 'SIGKILL')path too.forceKillAndDisposeSubprocess()callsdispose()immediately afterward on Windows, so leaving the flag unset still letsdestroy()run and double-close ConPTY.
🧹 Nitpick comments (1)
src/main/daemon/pty-subprocess.test.ts (1)
2375-2399: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winGood regression test — consider also covering the reverse ordering.
This locks in "graceful kill → forceKill → dispose" on Windows. Given the asymmetry noted in
pty-subprocess.ts(forceKill's primaryprocess.kill(pid, 'SIGKILL')success path doesn't setnodePtyKillIssued), consider adding a companion case whereforceKill()is called first (succeeding via the rawprocess.killpath) followed bykill(), to prove the second node-ptykill()/destroy()invocation is also prevented.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 7b6ff6c3-0295-469d-b7e3-16113bf6f698
📒 Files selected for processing (13)
.github/workflows/computer-e2e.ymlconfig/reliability-gates.jsoncconfig/scripts/computer-e2e-workflow.test.mjsconfig/scripts/windows-daemon-workspace-close-repro.mjssrc/main/daemon/daemon-pty-adapter.test.tssrc/main/daemon/daemon-pty-adapter.tssrc/main/daemon/daemon-server.tssrc/main/daemon/history-manager.tssrc/main/daemon/pty-subprocess.test.tssrc/main/daemon/pty-subprocess.tssrc/main/daemon/session.tssrc/main/daemon/terminal-host.tssrc/main/daemon/types.ts
|
Follow-up review findings addressed in 1710325. The two history concerns were valid and reproduced before the fix:
Recovery is now part of The Windows harness now also requires every victim session and OS PID to be reaped. The rebuilt daemon passed all 25 iterations while keeping the daemon PID and witness PTY alive. Validation: 294 focused daemon tests passed (12 platform skips), workflow contract 12/12, node typecheck, focused lint, reliability/max-lines checks, production build, and strengthened native harness. |
Summary
Fixes #8048.
Important
This PR bumps the daemon protocol from 18 to 19 because recovered history is now carried atomically in
createOrAttach. A parallel PR also bumps the daemon protocol, so the final merge order must reconcile this number and retain 18 in the previous-version list.Screenshots
No visual change. Electron validation screenshots were inspected locally and deliberately not committed.
Testing
pnpm lint— focused lint passed, but the repository-wide command stops on an unrelated existingja.jsoninterpolation mismatch forcomponents.native-chat.composer.uploadingAttachments; this PR does not touch localization files.pnpm typecheck—pnpm typecheck:nodepassed; CLI/web typechecks were not run because this change is main-process/daemon-only.pnpm test— focused daemon suite: 294 passed, 12 platform skips; workflow contract: 12 passed.pnpm build—pnpm build:electron-vitepassed.Additional validation:
node config/scripts/windows-daemon-workspace-close-repro.mjs: all 25 victim sessions and OS PIDs were reaped while the built daemon and witness PowerShell survived the concurrent graceful/immediate shutdown races.pnpm check:reliability-gates,pnpm check:max-lines-ratchet, focused oxlint, andgit diff --checkpassed.AI Review Report
Reviewed both reported symptoms independently. The daemon-death path was traced from renderer graceful shutdown plus main-process forced sweep to a second Windows node-pty close. The history path was traced through cold restore to the fresh daemon's first checkpoint overwriting the recovery source.
The review checked:
process.platform === 'win32'; filesystem paths use Node path APIs; no shortcuts, labels, or UI behavior changed. Shared daemon tests pass, but live macOS/Linux/SSH/WSL sessions were not exercised.A final review caught formatter expansion pushing
types.tsover the max-lines limit; the duplicated seed payload now reuses the existing write request shape, and focused lint/typecheck passed afterward.Follow-up review found and fixed three issues before merge:
historySeeded: false, so a later adapter cannot promote a fresh-only snapshot.Both history findings were reproduced as deterministic red tests before the redesign and pass afterward.
Security Audit
createOrAttachrequest and accepts history already read from Orca's local persistence directory.finally.Notes
createOrAttachwire change or allow an older daemon to accept the new client silently.