orca icon indicating copy to clipboard operation
orca copied to clipboard

Defer updater installs while hosting orca serve

Open OrcaWin opened this issue 4 months ago • 1 comments

Summary

Prevents a process started as orca serve from downloading, staging, or installing an update after desktop promotion. Update checks remain available, but install attempts now emit a visible error and a deduplicated lifecycle warning before native quit, daemon disconnect, or PTY/session cleanup.

Fixes #9563.

Screenshots

No visual change.

Reproduction

The preserved deterministic lifecycle harness failed before the fix with:

nativeInstallCalls: 1
pairedClientDisconnects: 1
sessionCleanupStarts: 1
servingOwner: { version: "1.0.51", connectedClients: 0, verified: false }
replacementOwner: null
pendingInstaller: { version: "1.0.61", staged: true }
deferredStatusVisible: false

The harness uses fake timers and explicit Electron events without sleeps. It exercises the real updater available/downloaded/native-ready/quit-and-install transitions while narrowly faking installer, supervisor, quit, and cleanup boundaries.

Post-PR review added two further deterministic macOS red/green cases: without the early policy guard the installer-readiness timeout called app.quit() after 15 seconds, and without the mode-aware before-quit predicate an ordinary headless quit was intercepted as an install request.

Testing

  • [ ] pnpm lint — full repository command not run
  • [ ] pnpm typecheck — full repository command not run
  • [ ] pnpm test — full repository command not run
  • [ ] pnpm build — exact template command not run
  • [x] Added deterministic regression coverage
  • [x] pnpm run typecheck:node
  • [x] Touched-file oxlint and oxfmt --check
  • [x] Focused updater lifecycle suite: 5 files, 115 tests
  • [x] Serve/runtime reliability suite: 7 files, 808 tests
  • [x] pnpm run check:reliability-gates
  • [x] pnpm run check:max-lines-ratchet
  • [x] pnpm exec electron-vite build --mode e2e
  • [x] Headless serve desktop activation Electron journey: 1 passed
  • [x] git diff --check

AI Review Report

The implementation review and the requested post-PR internal-review-until-clean cycle were anchored to merge base bf7fbdd57bf07070fd47559d90c0e6d1772848b0. The post-PR cycle ran four adversarial rounds; rounds 3 and 4 were clean.

The reviews found and fixed:

  • a macOS native-ready continuation that could bypass a public-entrypoint-only guard;
  • a macOS-only test that needed a platform condition;
  • a fired install timer handle that needed clearing before deferral;
  • a macOS installer-readiness timeout that could quit the headless owner before the policy guard ran;
  • a macOS before-quit handler that could reinterpret an ordinary headless Cmd+Q as an install request.

The final review checked retry/deduplication behavior, cleanup ordering, promoted serve mode, native updater continuations, install-on-quit, ordinary quit, and macOS/Linux/Windows and local/daemon/SSH/remote/mobile implications. Linux and Windows share the unit-tested serve policy, but packaged installers were not live-tested.

Security Audit

No new command execution, path handling, auth, secrets, dependencies, or IPC endpoints are introduced. The change removes a destructive lifecycle transition in serve mode and adds only a bounded mode/phase/version diagnostic. Interactive desktop updater behavior is unchanged.

Performance

No polling, subprocesses, scans, startup awaits, provider calls, or hot-path work were added. Deferral is constant-time, the app-quit boundary adds one mode predicate, and diagnostic state is bounded to two phase/version slots.

Notes

  • A real packaged installer, launchd no-console session, Linux systemd update, Windows installer, and live SSH update were not executed.
  • PR #9602 remains wire-compatible because this change does not alter RuntimeStatus or updateInfo.
  • PR #9602 should separately model macOS LaunchAgent/headless restart ownership and avoid recommending the in-app updater for a headless Mac server.

OrcaWin avatar Jul 21 '26 01:07 OrcaWin

Review Change Stack

📝 Walkthrough

Walkthrough

Added interactive and headless-serve updater install modes. Headless serve now defers update downloads and installations, records lifecycle diagnostics, and emits error status messages. Main-process wiring passes the selected mode based on serve state, while auth-preservation cleanup remains part of update quitting. A persisted macOS handoff protocol and runtime supervisor manage replacement readiness, failures, and recovery. Tests and reliability-gate evidence were updated accordingly.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 3.13% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description is thorough, but it misses the required Screenshots, Security Audit, and Notes sections and lacks the explicit cross-platform review confirmation. Add Screenshots/No visual change, a Security Audit, Notes, and explicitly confirm macOS/Linux/Windows compatibility review in the AI Review Report.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes implement the supervised macOS headless update handoff, fail closed for unsupported paths, and preserve interactive behavior as #9563 requires.
Out of Scope Changes check ✅ Passed The added code, tests, and reliability-gate updates all support the macOS serve-update handoff work and do not appear unrelated.
Title check ✅ Passed The title is concise and accurately summarizes the main change: safer macOS orca serve relaunch after updates.
✨ Finishing Touches
📝 Generate docstrings
  • [ ] Create stacked PR
  • [ ] Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

coderabbitai[bot] avatar Jul 21 '26 01:07 coderabbitai[bot]