Skip to content

fix(updater): install macOS orca serve updates instead of waiting on Squirrel forever - #27466

Merged
OrcaWin merged 6 commits into
mainfrom
OrcaWin/copy-21433-mac-serve-squirrel
Oct 11, 2026
Merged

OrcaWin merged 6 commits into
mainfrom
OrcaWin/copy-21433-mac-serve-squirrel

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​262 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​260
Prod 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​177 $\color{#cf222e}{\Huge{\mathbf{−}}}$​61 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​116

This is a copy of #21433 by @jbamlee, rebased on current main so CI can run here. CI on the fork never started; its runs sat queued since September. The contributor's five commits are kept unchanged, with their authorship. One follow-up commit adapts the tests to main:

  • updater-mac-quit-guard.test.ts was added on main after this branch (fix(updater): keep macOS Orca open when background instances block updates #24952). It calls registerMacUpdaterEvents without the two staging callbacks this change adds, so it now passes commitStagedMacInstall and failMacStaging.
  • The new install test no longer builds its window with as never. A small helper with a stated reason replaces it.

main's install path changed underneath this branch (#24952's background-instance blocker check). The cherry-picks applied cleanly. The updater, serve and CLI-runtime suites pass on the rebased code: 58 files, 608 tests.

Co-authored-by: jbamlee [email protected]


ELI5

When Orca runs as a background server (orca serve under a launchd service), updates on macOS never install. Orca downloads the update, then waits for macOS's installer (Squirrel) to say it is ready. But in this mode Squirrel is only asked to get ready when the install starts, and the install will not start until Squirrel is ready, so each side waits for the other forever.

This PR lets the supervised server start the install without waiting first. It also treats "Squirrel has finished preparing the new app" as the moment the install becomes final.

What Changed

Before (macOS, updateInstallMode === 'supervised-headless-serve'):

  • The update downloads, but the status stays at downloading 100% (macos_waiting_for_squirrel) and never reaches downloaded.
  • A paired client's remote update is refused with remote_update_not_downloaded.
  • A local install request waits 15s for Squirrel (deferMacQuitUntilInstallerReady), logs macos_install_guard_timeout, and quits without installing. launchd then relaunches the old version.

After:

  • The download is reported as downloaded, so both local and remote installs can start.
  • The install goes straight to the handoff. quitAndInstall skips the Squirrel-readiness guard. It goes to the existing supervised handoff (requestServeUpdateHandoff), then to autoUpdater.quitAndInstall(true, false). That call is where electron-updater's MacUpdater asks Squirrel to fetch the bundle from its localhost proxy.
  • Nothing destructive happens until Squirrel reports the bundle staged (its native update-downloaded). At that point commitStagedMacInstall commits the install, arms the exit watchdog, and then kills in-process PTYs and removes close listeners.
    • Orca's native listener is registered at setup, so it runs before the listener MacUpdater adds to quit the app.
    • Commit happens first. A throwing cleanup is recorded as post_commit_cleanup_failed, the same way performQuitAndInstall already handles it, and cannot skip the watchdog or MacUpdater's quit.
  • While staging, only Squirrel's own native error fails the install. It goes through the existing pre-commit recovery: the handoff is marked failed, quit state is reset, the server keeps its sessions, and a retry is possible.
    • MacUpdater re-emits that native error as an updater error. Other updater errors (for example a background check) are ignored during staging, because MacUpdater's pending listener would still quit and install after Orca had abandoned the handoff.
  • If Squirrel is silent for 120s, the updater reports a non-retryable error status and records macos_deferred_staging_slow, but keeps the handoff live. It does not abandon the install, for the same reason: MacUpdater's listener would install anyway when Squirrel eventually finishes. A late staging therefore still commits and relaunches normally.

Mechanism. updater-setup.ts deliberately sets autoInstallOnAppQuit = false for serve modes, so that an ordinary service quit never installs implicitly. With that flag off, electron-updater 6.8.9's MacUpdater.doDownloadUpdate does not call nativeUpdater.checkForUpdates() after the download. It only calls it inside MacUpdater.quitAndInstall() (see node_modules/electron-updater/out/MacUpdater.js). Orca's macOS readiness wait assumed the eager path that autoInstallOnAppQuit = true gives interactive installs. isMacStagingDeferredToInstall() (darwin + supervised serve) names that difference, and both waits now consult it.

Unchanged:

  • Interactive mode, unsupported-headless-serve, and Linux/Windows supervised serve.
  • UpdaterHandlerContext moved verbatim into src/main/updater-handler-context.ts. The new context fields would otherwise push updater-events.ts past the 300-line limit.

Why

Alternatives considered:

  • Set autoInstallOnAppQuit = true for supervised serve. Squirrel would stage right after the download, so the existing wait would end. But Squirrel.Mac then installs a staged update on any app exit, so a plain launchctl stop or a crash would install without the supervisor handoff. That is what the comment in updater-setup.ts forbids.
  • Call nativeUpdater.checkForUpdates() ourselves after the download. Same install-on-any-exit problem, and it races electron-updater's own proxy and auth bookkeeping.
  • Abandon the install when staging is slow. MacUpdater's update-downloaded listener is registered with .on(), and Orca cannot remove it. A late staging would then quit and install under a failed handoff, and the supervisor would skip the replacement spawn. So the timeout only reports.

Deferring the commit point to Squirrel's native signal keeps the pre-commit recovery path meaningful. That is the property the existing comment ("macOS without Squirrel stays uncommitted so late native errors can still recover") protects.

Linked Issue

No separate issue was filed. The evidence and root cause are in this description.

Field evidence from a macOS arm64 host running orca serve under a user LaunchAgent with ORCA_SERVE_UPDATE_HANDOFF_PATH set:

  • 1.4.201, 1.4.203, 1.4.204 and 1.4.205 all stopped at update_downloaded {"macInstallerReady":false} → macos_waiting_for_squirrel.
  • The log has zero request lines for the Squirrel.Mac proxy (Proxy server for native Squirrel.Mac is listening, then nothing).
  • ~/Library/Caches/com.stablyai.orca.ShipIt was last touched by the one install that succeeded before the host moved to serve mode.
  • The shipped 1.4.205 bundle still has the same autoInstallOnAppQuit expression and wait.

Visual Proof

N/A. The change is in main-process updater state for the headless server; there is no renderer UI change. The visible effect is that the update card reaches the downloaded (install) state and the install completes, instead of staying at 100%. The end-to-end log excerpt under Testing is the evidence.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

End-to-end on real packaged builds (macOS arm64, launchd-supervised orca serve)

Setup:

  • Built this branch at 5128ea8 twice with electron-builder --mac dir --arm64: once as 1.4.205-e2e.2 (the running app) and once as 1.4.205-e2e.3 (the update target).
  • Signed both with the same throwaway self-signed identity, so Squirrel's designated-requirement check can pass between them.
  • Installed e2e.2 into a scratch directory and ran bin/orca serve --port 6771 --no-pairing under a user LaunchAgent (KeepAlive).
    • State was isolated with ORCA_E2E_USER_DATA_DIR, HOME and ORCA_CLI_INSTALL_PATH. The production install on the same machine was untouched.
  • Attached a desktop window by launching the app a second time, since the updater only initializes once a window is attached.
  • ⌥-clicked Check for Updates, chose the target's latest-mac.yml, then pressed the update card's download and install buttons.

Success path (serve stderr, trimmed):

[updater] update_downloaded {"version":"1.4.205-e2e.3","macInstallerReady":false}
[updater] quit_and_install_started {"version":"1.4.205-e2e.3","macInstallerReady":false}
[updater] quit_and_install_invoking_native {"version":"1.4.205-e2e.3"}
[autoUpdater] / requested
[autoUpdater] /<sha512>.zip requested by Squirrel.Mac, pipe …/orca-updater/pending/…
[autoUpdater] nativeUpdater.update-downloaded
[updater] macos_deferred_staging_committed {"version":"1.4.205-e2e.3"}
[updater] macos_installer_ready {"deferredInstallRequested":false,"hasNewerDownloadedVersion":true}
[updater] will-quit cleanup for update install; daemonTeardown=disconnect
ShipIt: Installation completed successfully

Result:

  • The bundle's CFBundleShortVersionString became 1.4.205-e2e.3.
  • The same supervisor process respawned the child: launchd runs = 1, so this was not a launchd restart.
  • The child reports appVersion 1.4.205-e2e.3 over RPC.
  • serve-update-handoff.json was cleared.

Failure path, on the same running build:

  • The GitHub check had also offered the published v1.4.205, which is Developer ID signed and so cannot satisfy the test identity.
  • Installing it twice gave the same result both times:
    1. Squirrel fetched from the proxy.
    2. Squirrel rejected the bundle: code failed to satisfy specified code requirement(s).
    3. The install ended with quit_and_install_failed_via_event.
    4. The handoff recorded failed with its reason.
    5. The serve child kept running with the same pid.

Before this change (field):

  • Four consecutive releases stopped at macos_waiting_for_squirrel, with no proxy request at all.

New tests in src/main/updater.headless-serve-install.test.ts:

  • They stub process.platform = 'darwin', so they also run on Linux CI.
  • They model electron-updater's MacUpdater with autoInstallOnAppQuit off:
    • each unstaged quitAndInstall adds a persistent native update-downloaded listener that calls app.quit();
    • native errors are re-emitted as updater errors first;
    • native listeners run in registration order.
  • They cover five behaviors:
    • The status reaches downloaded, and the install commits only after Squirrel stages it. Order: commit → session cleanup → MacUpdater quit.
    • A Squirrel failure keeps sessions intact and fails the handoff. The retry then completes, with one commit and both MacUpdater listeners quitting.
    • A throwing session cleanup still commits and still lets MacUpdater quit.
    • An unrelated updater error during staging does not abandon the install.
    • A silent Squirrel is reported after 120s without failing the handoff, and a late staging still commits.
  • All five fail when run against the base commit (5 failed, 9 existing passed): the status stays at downloading 100% and native quitAndInstall is never reached. The cleanup-throws test also fails on the previous revision of this branch, which cleaned up before committing.

Local runs (macOS arm64):

  • pnpm typecheck: pass.
  • pnpm lint: pass.
  • pnpm run check:code-quality:changed: pass.
  • oxfmt --check: clean.
  • Updater and serve-handoff suites: 35 files, 360 tests, all passing.
  • pnpm test (full), which on this machine shows two kinds of failure, both unrelated to this change:
    • During the full parallel run, the ssh/ipc module graph hits suite-level ENOENT errors in Vitest's SSR transform cache. Those files pass when re-run on their own.
    • The remaining 8 files fail identically on the base commit here: real Claude CLI binaries, browser viewport, relay PTY, skill-recipe shell, repo-icon autodetect, and relay region correction.

Contract test: src/main/electron-updater-mac-staging-contract.test.ts runs the installed MacUpdater.quitAndInstall and handleUpdateDownloaded. An electron-updater upgrade that changed staging-inside-quitAndInstall, or quit-without-relaunch, now fails CI instead of silently restoring the deadlock.

Not tested: a Developer ID signed release updating to another Developer ID signed release. That needs Stably's signing identity; the e2e above uses a self-signed pair instead.

AI Disclosure

Investigation, implementation and tests were done with Claude Code (Claude Opus 5). Before publishing, the change went through independent clean-context reviews:

  • one Claude Opus reviewer instance;
  • four Codex review rounds.

Each round's findings were verified against source and fixed in this branch (see Review).

Review

Each review ran in a clean context against an exact commit. Findings were checked against source before any change:

  • Claude Opus reviewer (first commit):
    • The updater error path failed the handoff for unrelated errors during staging.
    • Session cleanup ran before Squirrel staged.
    • Staging was unbounded.
    • Tests were synchronous.
    • All four were confirmed and fixed.
  • Codex round 1: found the same cleanup-order, unbounded-wait and test-fidelity issues. Fixed. That repair also found and fixed a missing darwin check in isMacStagingDeferredToInstall.
  • Codex round 2: abandoning the install on timeout let MacUpdater's retained listener install under a failed handoff. Changed to report-only.
  • Codex round 3:
    • A throwing cleanup inside Squirrel's event skipped the commit and MacUpdater's quit. The install now commits first.
    • Retries were not modeled with MacUpdater's persistent listeners. Tests now model them.
  • Codex round 4: CLEAN, no findings.
  • PR bots:
    • Pullfrog: the fix depends on electron-updater's MacUpdater behavior, which all updater tests mock. Added the contract test above.
    • CodeRabbit: no actionable comments.
      • Its docstring-coverage warning is not taken; AGENTS.md asks for brief non-obvious comments, and these methods follow the file's one-line Why: convention.
      • The linked-issue warning is covered under Linked Issue.

Review coverage:

  • Cross-platform: every new branch is gated on darwin plus supervised serve. Linux and Windows serve installs and interactive installs keep their existing paths.
  • SSH/remote/local: remote install now reaches the existing downloaded gate. No wire change; execution ownership is unchanged.
  • Agents/integrations: none touched.
  • Performance: one timer per install attempt.
  • UI: none.
  • Security: no change to signature verification. Squirrel still validates the bundle against the running app's designated requirement.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Cross-platform: every new branch requires darwin and supervised serve. Linux and Windows serve installs keep their immediate commit.
  • SSH/remote: fixes the remote install for macOS supervised servers. No wire or schema change.
  • Mobile: not affected.
  • Backwards compatibility: no persisted-state or IPC changes.
  • Performance: one timer per install attempt; no new work in hot paths.
  • Known residual: a Squirrel that never answers leaves the install pending until the service is restarted. It is reported after 120s, and the process keeps serving. Forcing an exit before staging would quit without installing, and abandoning the handoff would let a late staging install unsupervised.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ff5f2c60-9d2e-41dc-bf55-6a463d6352c0

📥 Commits

Reviewing files that changed from the base of the PR and between 6769bb1 and fa5c9a4.


You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f59a2485-b799-4cf7-832b-768fdec95d7b


📥 Commits

Reviewing files that changed from the base of the PR and between bdc0921 and 6769bb1.



📒 Files selected for processing (12)
  • src/main/electron-updater-mac-staging-contract.test.ts
  • src/main/updater-events.test.ts
  • src/main/updater-events.ts
  • src/main/updater-handler-context.ts
  • src/main/updater-mac-install.ts
  • src/main/updater-mac-quit-guard.test.ts
  • src/main/updater.headless-serve-install.test.ts
  • src/main/updater/updater-download-install.ts
  • src/main/updater/updater-install-execution.ts
  • src/main/updater/updater-install-support.ts
  • src/main/updater/updater-setup.ts
  • src/main/updater/updater-state.ts


Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.




📝 Walkthrough
📝 Walkthrough

Walkthrough

For supervised headless-serve installs on macOS, the updater now defers install commitment and session cleanup until Squirrel staging completes. It reports staging failures and a non-retryable error when staging exceeds the timeout, while keeping the handoff active. Updater event handling now routes staging completion and failure through dedicated callbacks. Tests cover the staging lifecycle and related updater behavior.



Priority: ⬆️ High

Merge Risk: ⚪ Minimal · up to 6769b

No merge-blocking issue is established for the supervised macOS update handoff. A Developer ID-to-Developer ID release update remains untested.

Pre-merge checks | Passed 3 | Failed 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check Warning The description is detailed and covers the change, motivation, testing, risks, and review history. However, the required Linked Issue section explicitly states that no issue was filed, and the checkli… Add an actual linked issue reference under Linked Issue. Also report the result of pnpm build, or state that CI will cover it.
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 12 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check Passed The title clearly identifies the main change: fixing macOS Orca serve updates that previously waited indefinitely on Squirrel.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.


Full details: Description check

Explanation

The description is detailed and covers the change, motivation, testing, risks, and review history. However, the required Linked Issue section explicitly states that no issue was filed, and the checklist does not confirm a successful build.




✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR



  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

jbamlee and others added 6 commits October 11, 2026 05:41
…ng install

Supervised `orca serve` keeps autoInstallOnAppQuit off, so electron-updater's
MacUpdater hands the download to Squirrel.Mac only inside quitAndInstall. The
updater, however, held the status at "downloading 100%" and gated quitAndInstall
on Squirrel having already staged the bundle. Neither could happen first, so
every macOS serve update stalled at macos_waiting_for_squirrel, remote installs
failed with remote_update_not_downloaded, and a local install request timed out
and quit without installing.

In supervised serve mode, report the download as installable and let the install
proceed to the handoff and native quitAndInstall. The install commits and arms
the exit watchdog when Squirrel signals it has staged the bundle; a staging
failure still recovers through the existing pre-commit error path.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
… serve bundle

The supervised macOS install now calls electron-updater's quitAndInstall before
Squirrel has staged anything, and that staging completes asynchronously. Three
consequences needed handling:

- PTY cleanup and close-listener removal ran before staging, so a Squirrel
  failure recovered the server with its in-process sessions already killed.
  They now run when Squirrel reports the bundle staged, together with the
  commit and exit watchdog.
- Any updater 'error' during staging (for example a background check) failed
  the handoff while MacUpdater's pending listener would still quit and install.
  While staging is awaited, only Squirrel's native error ends it.
- Nothing bounded a Squirrel that never answers. After two minutes the install
  recovers through the existing pre-commit failure path and the server keeps
  serving.

isMacStagingDeferredToInstall is now darwin-only, so Linux supervised installs
keep their immediate commit.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…e install

Recovering the install on the staging timeout reset Orca's state and failed the
supervisor handoff, but electron-updater's MacUpdater keeps its own completion
listener. A Squirrel that finished after the timeout still quit the app and
installed, now with a failed handoff, so the supervisor skipped the replacement
spawn.

The timeout now only reports a non-retryable error status and records the slow
staging; the handoff and in-flight install stay live so a late staging commits
and relaunches normally.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Squirrel's update-downloaded listeners run in registration order, and Orca's
runs before the one MacUpdater adds to quit the app. The staged-install commit
ran PTY cleanup first, so a throwing cleanup callback skipped the commit, the
exit watchdog, and MacUpdater's quit, leaving the install stuck in progress.

Commit and arm the watchdog first, then run cleanup under the same
post_commit_cleanup_failed handling performQuitAndInstall already uses.

The tests now register MacUpdater's persistent quit listener per unstaged
install, so a retried install is followed through completion.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…nstalls rely on

The supervised macOS serve install assumes electron-updater's MacUpdater starts
Squirrel staging only inside quitAndInstall when autoInstallOnAppQuit is off,
and quits the app once staged when autoRunAppAfterInstall is off. Every updater
suite mocks electron-updater, so run the installed MacUpdater methods directly;
an upgrade that changed either behavior now fails here instead of silently
restoring the deadlock.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Main's macOS quit-guard test predates the staging callbacks this change
adds, so it now passes them, and the new install test builds its window
without a type assertion.

Co-authored-by: jbamlee <[email protected]>
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.

2 participants