Skip to content

Preserve live daemon PTYs across app updates - #4330

Merged
Jinwoo-H merged 2 commits into
mainfrom
Jinwoo-H/preserve-daemon-pty-sessions
Jun 1, 2026
Merged

Jinwoo-H merged 2 commits into
mainfrom
Jinwoo-H/preserve-daemon-pty-sessions

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented May 31, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Preserve an already-healthy daemon when app-path or packaged-bundle freshness checks want replacement but the daemon owns live PTY sessions
  • Treat unverifiable live-session state as preserve, matching the existing resolver-unhealthy safety behavior
  • Add regression coverage for app-path mismatch, unverifiable session state, and packaged-bundle staleness with live sessions

Root cause

The renderer only prints --- session restored --- when it has a saved PTY session id but the daemon creates a new process for it. The daemon launcher was allowed to replace a protocol-healthy daemon after app updates or app-path changes without checking whether that daemon still owned live PTYs. That killed the backing PTY process, so the next app start could only cold-restore from terminal history.

Validation

  • pnpm vitest run src/main/daemon/daemon-init.test.ts
  • pnpm exec oxlint src/main/daemon/daemon-init.ts src/main/daemon/daemon-init.test.ts
  • pnpm run typecheck:node

Notes

  • pnpm vitest run src/main/daemon currently has unrelated local failures in node-pty-fd-leak.test.ts and pty-subprocess.test.ts; the targeted daemon-init regression suite is passing.

Made with Orca 🐋

@Jinwoo-H

Copy link
Copy Markdown
Contributor Author

E2E verification update:

  • Added tests/e2e/daemon-live-session-preservation.spec.ts to exercise the real Electron restart path with an isolated userData dir.
  • Reproduced the bug on origin/main by spoofing the daemon pid file entryPath after first launch, then relaunching against the same profile. The test failed as expected because the daemon PID changed (Expected: 14455, Received: 16601), proving the live daemon was replaced.
  • Ran the same E2E on this branch and it passed: daemon PID stayed stable and terminal content did not include --- session restored ---.

Validation run on this branch:

  • npx playwright test tests/e2e/daemon-live-session-preservation.spec.ts --config tests/playwright.config.ts --project=electron-headless
  • pnpm vitest run src/main/daemon/daemon-init.test.ts
  • pnpm exec oxlint tests/e2e/daemon-live-session-preservation.spec.ts
  • pnpm run typecheck:node

@Jinwoo-H
Jinwoo-H merged commit 5bfa141 into main Jun 1, 2026
1 check passed
@Jinwoo-H
Jinwoo-H deleted the Jinwoo-H/preserve-daemon-pty-sessions branch June 1, 2026 00:21
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant