Skip to content

fix(updater): back up unsaved editors before a remote-triggered desktop update - #51245

Merged
AmoabaKelvin merged 3 commits into
mainfrom
fix/remote-update-install-prep
Nov 27, 2026
Merged

AmoabaKelvin merged 3 commits into
mainfrom
fix/remote-update-install-prep

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

ELI5

When another device (a paired desktop today, the phone next) tells a desktop Orca to install an update, Orca now saves your unsaved editor work and window state first, exactly like when you click Update on that desktop. After the restart, the unsaved text is back.

Files Added Deleted Net
Test 0 0 0 0
Prod 27 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​81 $\color{#cf222e}{\Huge{\mathbf{−}}}$​65 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​16

What Changed

  • Before: updater.install over RPC restarted a desktop Orca without backing up dirty editors or checkpointing window state. The install also hit the window's unsaved-changes guard. Remote installs were only ever exercised on windowless orca serve, so nobody saw this.
  • After: a remote install runs the same renderer preparation as an automatic install (editor hot-exit backup, durable state checkpoint, close guards stood down, input held). The new version reopens with the unsaved buffer restored and still dirty.
  • Mechanism:
    • UpdateInstallTrigger gains 'remote', which installRemoteServerUpdate passes.
    • performQuitAndInstall already runs main-side preparation for every trigger except 'manual'. 'manual' is now documented as "the local window's preload already checkpointed itself".
    • quitAndInstall no longer has a default trigger, so each entry point names its own.
    • prepareAutomaticInstall is renamed prepareRendererForInstall, since it isn't automatic-only.
  • Fixed on the way (also affects automatic and team-required installs on macOS today):
    • After a main-prepared install, a window close waited on the update until the window was destroyed. Electron's macOS quitAndInstall closes windows before it quits, so shutdown deadlocked until the 20 s exit watchdog forced it.
    • Close now waits only for the renderer checkpoint. Measured on real packaged builds: install-to-new-version went from 32 s (watchdog fired) to 9.6 s.
  • Shared coordinator: the check → download → install → wait-for-restart coordinator moves from the renderer to src/shared/remote-runtime/host-updates/, along with restart-wait, the install-failure probe, polling and version skew, so the phone can drive the same flow.
    • The desktop's wording comes in through transport.describeError.
    • Updater errors keep their coded status (RemoteServerUpdaterStatusError), including install failures read back after a restart. A German desktop now sees the translated reason, not main's English.

Why

  • Root cause: the install entry point inferred "the renderer is already prepared" from the trigger name. 'manual' meant "the preload ran prepareAndInvokeUpdaterInstall", but the RPC install reused 'manual' without any renderer involvement.
  • History: remote installs (Update paired Orca servers from the active client #9839) were built for headless serve, where there is no window to prepare. Main-side preparation came later with automatic installs (Add opt-in automatic desktop updates #44541) and was keyed on trigger !== 'manual', so the RPC path silently stayed on the "preload did it" side.
  • Why a new trigger: it puts the decision where the fact lives. Only the IPC handler behind the window's own Update button can know the preload prepared.
  • Alternatives rejected:
    • Having callers prepare the renderer: a phone can't reach the desktop renderer.
    • Moving all preparation into main for every trigger: that rewrites the working local path and its abort relay for no user gain.
  • Remote installs now behave like automatic ones:
    • Windows NSIS runs silently. Nobody is at the desktop to click through it, and a non-silent installer can wait forever on its "app cannot be closed" retry.
    • The "automatic updates off" and "terminal busy" holds stay automatic-only, because a remote user explicitly asked.

Linked Issue

No GitHub issue; this is host groundwork for a phone "Update host" action (the phone UI is a later PR).

Visual Proof

Real macOS packaged builds, test bundle id and isolated profile. A script drove the moved shared coordinator over the app's local RPC socket (check → download → install → wait). The editor text was typed and not saved; notes.md on disk was unchanged throughout.

Before the remote install (v…local.3, unsaved line, dirty dot):

before-remote-update-dirty.png

After the restart into the new build (v…local.2, relaunched by ShipIt), the unsaved line restored. Closing the tab asks "notes.md has unsaved changes. Save?":

after-remote-update-restored.png

Coordinator log from the final run:

before { appVersion: '1.4.214-local.3.a2da9909045' }
progress checking-update
progress downloading 0%
progress downloading 100%
progress restarting        23:36:12.8
progress updated           23:36:22.4
final {"phase":"updated","currentVersion":"1.4.214-local.2.5da719e0b23","error":null}

Same run before the close fix: restarting 23:00:12.4 → updated 23:00:44.5, and the host log showed Shutdown did not finish within 20000ms of committing the update install; forcing exit.

Testing

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • Every added test fails without this change and avoids the test anti-patterns

  • macOS, real Squirrel/ShipIt installs: two packaged builds of this branch under a test bundle id, with home and profile isolated.

    • A remote install with a dirty editor backed it up and restarted. The new version restored it, still dirty.
    • A daemon terminal opened before the update was still connected afterwards, with the same pty id.
    • A local "Restart to update" (preload path) on the same setup still exits in ~1 s and restores, so it is unchanged.
  • Fake-transport run of the shared coordinator: the happy path reaches updated. A host checkpoint failure surfaces as the coded automaticInstallCheckpointFailed through the injected describeError.

  • Gate: pnpm check:changed passes, and typechecks pass for node and web.

  • Not run: Windows and Linux. Reviewed by code: electron-updater's NSIS/AppImage quitAndInstall quits in setImmediate, after the close listeners are already removed, so the close fix changes nothing there.

  • No automated test: the behaviour lives in Electron window/updater lifecycles that only a real packaged install exercises. That's what the run above did.

Performance

None, because the new work runs once per remote install. It is the same renderer checkpoint every local and automatic install already does. The moved coordinator keeps its existing polling cadence and adds no owners or timers.

Risk

Level: Medium

  • Riskiest part: the updater install path.
    • Remote installs on a desktop with windows now go through renderer preparation. If the renderer refuses (for example an unsaved Source Control AI prompt draft in Settings), the install stops with "Orca could not save the current window before restarting" instead of restarting. The remote client shows that reason.
    • The close-wait change affects automatic and team-required installs too. A close during the install is now answered once the checkpoint is durable, instead of being held until the window dies.
  • Follow-up: on macOS, if a team-deferred Squirrel staging takes more than 120 s and the user closes the window during it, the window can't be reopened until staging finishes. No data is at risk.
  • Back out: a plain revert. No saved data or wire format changes; older clients and hosts behave as before.

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

  • Mobile: nothing on the phone changes yet. updater.* is still off the phone allowlist; the phone "Update host" PR adds it with its UI.
  • Older hosts: a new client calling updater.install on an older desktop gets the old behaviour (no preparation). Older clients get the new preparation from a new host.

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)
  • I stated the risk: what could break, for whom, and how to back it out
  • 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)

…d install

updater.install over RPC reused the local 'manual' trigger, which assumes the
window's preload already checkpointed the renderer. A remote caller never
does, so main now prepares the renderer like an automatic install. The
check/download/install/wait coordinator moves to src/shared so other clients
can drive the same flow.
…kpoint is saved

A main-prepared install (automatic, team-required, and now remote) left the
window's close waiting on the update until the window was destroyed. The
native installer closes windows first, so shutdown stalled until the 20s exit
watchdog forced it. Close now waits only for the checkpoint itself.
@coderabbitai

coderabbitai Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Updater installation now requires explicit triggers, including a new remote trigger. Renderer checkpoint preparation uses renamed callbacks, and close waiting resolves when checkpoint preparation finishes. Remote runtime update modules move to shared code. Polling and restart waits preserve typed updater error statuses, while the coordinator supports transport-provided error descriptions.

Merge Risk: Minimal · up to 05aba

Remote-triggered updates now prepare the renderer before installing, so unsaved editor contents can be restored after the restart. No concrete regression introduced by this change was found. A pre-existing gap in deferred macOS automatic installs is unchanged and out of scope. The change is ready to merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: remote-triggered desktop updates now back up unsaved editors before install. The PR adds a 'remote' install trigger that runs renderer preparation, so the title matche…
Description check Passed The description follows the template closely. It covers ELI5, What Changed, Why, Visual Proof with before and after images and a coordinator log, Testing with manual steps and platforms, Performance, …
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: Title check

Explanation

The title names the main change: remote-triggered desktop updates now back up unsaved editors before install. The PR adds a 'remote' install trigger that runs renderer preparation, so the title matches the primary objective. It follows the conventional commit style and stays under one line.

Full details: Description check

Explanation

The description follows the template closely. It covers ELI5, What Changed, Why, Visual Proof with before and after images and a coordinator log, Testing with manual steps and platforms, Performance, a Risk section with level and back-out plan, Notes, and a checklist. The Linked Issue section states no issue exists, which the template requires for outside contributors. The author is a maintainer, so that is acceptable. The AI Disclosure section is empty, and the template says to skip it only for StablyAI team members. The final pnpm checklist item is unchecked, and the Testing box for automated tests is checked while no tests were added. These gaps are minor.

  • 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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fddd8fd1-f07f-4f37-8d20-8b20f0a4bb92
Commits

Reviewing files that changed from the base of the PR and between 35eb7e7 and 05abaee.

Files selected for processing: 27

  • src/main/updater/lifecycle/updater-download-install.ts
  • src/main/updater/lifecycle/updater-install-execution.ts
  • src/main/updater/lifecycle/updater-install-support.ts
  • src/main/updater/lifecycle/updater-remote-status.ts
  • src/main/updater/lifecycle/updater-required-restart.ts
  • src/main/updater/lifecycle/updater-setup.ts
  • src/main/updater/lifecycle/updater-state.ts
  • src/main/updater/updater-service.ts
  • src/main/window/renderer-relays/native-unload-coordinator.ts
  • src/renderer/src/components/bots/BotComputerPicker.fixture.tsx
  • src/renderer/src/components/settings/runtime-environments/RuntimeServersSection.fixture.tsx
  • src/renderer/src/components/settings/runtime-environments/server-rows/runtime-server-list.tsx
  • src/renderer/src/components/settings/runtime-environments/server-rows/runtime-server-row-details.tsx
  • src/renderer/src/components/settings/runtime-environments/server-rows/runtime-server-row-meta.ts
  • src/renderer/src/components/settings/runtime-environments/server-rows/runtime-server-row-presentation.ts
  • src/renderer/src/components/settings/runtime-environments/server-rows/runtime-server-row.tsx
  • src/renderer/src/components/settings/runtime-environments/updates/RemoteServerUpdateDialog.tsx
  • src/renderer/src/components/settings/runtime-environments/updates/RemoteServerUpdateStatus.tsx
  • src/renderer/src/components/settings/updates/GeneralRemoteServerUpdates.tsx
  • src/renderer/src/runtime/hosts/updates/remote-server-update-batch.ts
  • src/renderer/src/runtime/hosts/updates/remote-server-update-errors.ts
  • src/renderer/src/store/slices/runtime-host-updates/remote-server-updates.ts
  • src/shared/remote-runtime/host-updates/remote-server-install-failure-probe.ts
  • src/shared/remote-runtime/host-updates/remote-server-restart-wait.ts
  • src/shared/remote-runtime/host-updates/remote-server-update-coordinator.ts
  • src/shared/remote-runtime/host-updates/remote-server-updater-polling.ts
  • src/shared/remote-runtime/host-updates/remote-server-version-skew.ts

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

@AmoabaKelvin
AmoabaKelvin merged commit 1ab2c50 into main Nov 27, 2026
56 checks passed
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