Skip to content

fix(desktop): install windows updates silently and relaunch - #479

Merged
nixuuu merged 1 commit into
devfrom
fix/windows-silent-update
Nov 10, 2026
Merged

nixuuu merged 1 commit into
devfrom
fix/windows-silent-update

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 10, 2026

Copy link
Copy Markdown
Member

Behavior

Windows updates currently launch the assisted NSIS installer and require someone at the computer. Windows now uses quitAndInstall(true, true) after service shutdown, so local Restart to update, gateway requests, and linked-computer requests install silently and relaunch Canopy.

The first-time installer stays assisted (oneClick: false, directory selection, per-user default). macOS keeps the conditional feed replay introduced by #471 and its existing flags; Linux keeps its existing flags.

Existing machine-wide installations can still require UAC even when update metadata describes a per-user installer. A preflight checks isAdminRightsRequired, the machine-wide NSIS registry entry, and installation-directory write access before shutdown. It refuses these updates with an actionable local message and a remote failed reason, releases the worker's drain barrier, and keeps services running. Update those installations manually with administrator approval, or replace them with a per-user installation.

The Windows main-process shutdown timeout now uses taskkill.exe /PID <owned-controller-pid> /T /F instead of terminating only the controller. The normal supervisor already closes sidecar stdin, stops PostgreSQL with pg_ctl stop -m fast, waits for child closure, and uses owned-PID tree cleanup on timeout. NSIS starts after the controller exits.

Pinned source verification

Checked the lockfile and installed sources for electron-updater 6.8.3 and electron-builder / app-builder-lib 26.18.0, plus their versioned upstream documentation and templates:

  • AppUpdater API, BaseUpdater, and NsisUpdater: Windows receives --updated /S --force-run; metadata can select elevate.exe, and launch permission failures can also trigger elevation.
  • NSIS documentation, assisted installer, and multi-user macros: silent updates select the previous install scope and read its InstallLocation, preserving a custom per-user directory.
  • Installer and install section: assisted silent updates can elevate for a previous machine installation; /S --force-run relaunches the installed app.
  • Running-process check: --updated allows time to exit, then attempts cleanup. Silent prompts use default responses and can cancel installation if processes cannot be stopped. Our shutdown must finish first.

Polish documentation in docs/updates.md and docs/desktop.md covers unattended updates, UAC refusal, shutdown, relaunch, and the rollout limitation: older clients still use their previous installer behavior for the first update that installs this fix.

Validation

  • bun install --frozen-lockfile — passed.
  • TMPDIR=/var/tmp bun test apps/desktop/test/updates.test.ts apps/desktop/test/update-install.test.ts apps/desktop/test/update-controller.test.ts apps/desktop/test/mac-update-feed.test.ts — 37 passed. Covers Windows silent/force-run flags, unchanged Darwin/Linux flags, both remote request sources, successful journal recovery at the target version, elevation refusal/retry, and the macOS conditional feed replay.
  • bun run typecheck — passed; Svelte reports 0 errors and 0 warnings.
  • bun run lint and bun run format:check — passed.

CI remains the merge gate. No E2E suite or packaged installation was run. Real Windows installation, UAC behavior, process-tree termination, and relaunch cannot be verified on this Linux machine. Signing, publishing, and release workflows are unchanged.

Windows tester checklist

Start with a Windows desktop build containing this change and offer a newer release on its selected channel.

  1. Run a local Restart to update and confirm the target version is installed.
  2. Request remote updates from both a linked computer and a gateway while nobody interacts with the Windows computer; confirm reconnect reports the same request as succeeded at the target version.
  3. Install per-user into a custom directory and confirm the update preserves that exact directory and install scope.
  4. Confirm no installer wizard, directory prompt, finish screen, or UAC prompt appears for the per-user update.
  5. Confirm Canopy relaunches automatically and gateway, worker, BFF, and PostgreSQL return. Check that old bundled bun.exe processes do not retain file locks; exercise normal shutdown and the forced cleanup path.

Also test a machine-wide installation (including a custom machine-wide directory): local and remote requests must show the administrator-approval reason before shutdown, with no installer/UAC prompt, and services must remain available. The initial installation must still show the assisted directory-selection flow.

Copy audit (§8)

Before: machine-wide silent-update limitations had no specific preflight message. After: “Update needs attention” and “This installation needs administrator approval to update. Install Canopy for your user account to enable unattended updates.” A separate probe failure says “Could not check installation permissions. Retry the update on this computer.” Generic preparation failures also provide a retry action.

Static audit passed: sentence case, short sentences, plain language, explicit next actions, no new glossary terms, no decorative copy, and no color-only cues. Existing native dialogs and error fields are reused; no buttons, confirmations, empty states, or layout changed. No browser or Windows dialog layout validation was performed on this Linux machine.

Related: #335
Related: #471

Use unattended NSIS updates for per-user Windows installations and reject updates that need administrator approval before stopping services. Keep the assisted first-time installer and other platforms unchanged.

Related: #335

Related: #471
@nixuuu
nixuuu merged commit e783cbd into dev Nov 10, 2026
15 of 17 checks passed
@nixuuu
nixuuu deleted the fix/windows-silent-update branch November 10, 2026 09:39
nixuuu added a commit that referenced this pull request Nov 11, 2026
A phone paired to a desktop gateway can see its linked computers' update
actions, but cannot update its own paired computer. Remote web clients
have the same gap.

Expose the home desktop app as an update target and send confirmed owner
UI requests through the existing LocalAppControl → RemoteAppUpdate path.
Keep the installer, durable journal/receipts, idle barrier, Windows
silent install and planned-departure/reconnect handling. The UI shows
real updater progress and refusal reasons. Older gateways/desktops show
a one-time manual-update instruction.

Home app installation requires explicit restart confirmation, lists
known running turns and checks unsent-work blockers before dispatch.
Update all continues to exclude the home app. Standalone gateway and
worker updaters keep their existing actions. Phone credentials cannot
open or report on the desktop control channel. Changes are additive in
canopy.ui.v1; canopy.update.v1 is untouched.

Validation:
- Paired-app gRPC integration: 7 passing tests / 55 assertions,
including owner refusal, confirmation, old/disconnected/disabled
desktop, rate limits/admin failures, receipts, idle barrier, gateway
replacement and recovery using the same paired token.
- Existing linked-updates (10), desktop-updates (8), gateway-departures
(3) and updates-bundled (2) tests pass, one file at a time.
- bun install, gen:check, typecheck, lint, format:check and web build
pass.
- Full check:tmp: passed once, sequentially: 2367 pass, 165 skip, 0 fail
across 440 files (29325 assertions); “nothing left in the temp dir”.
- Manual web fixture review in light/dark at 390, 768 and 1440 px: home
action, progress, older-desktop instructions, running turns, Cancel
focus, long names and blockers. The blocker was also checked again after
opening confirmation.
- EAS CLI 27.4.1 production fingerprints match on both platforms: iOS
6ddec9ef559ee0095ac33e94ff9418a942053b17; Android
5f6eae3ab278f1cd543e9ed763f923a319b65ec9. Mobile changes are JS/TS only.
- Native mobile visual QA is unverified: local device platforms are
unavailable, and the remote device host still reported “Could not
communicate with device support” after its suggested refresh. No native
install or Windows GUI installer was exercised; those paths are reused
unchanged.

Copy audit (§8):
- Before: the home app row had no usable update action. After: named
computer + “Update Canopy on {name}”; the confirmation repeats “Update”
and explains restart, automatic reconnection and the idle barrier.
- Before: the own app needed an update from its computer without a clear
route. After: “Update this computer from its own window once to enable
remote updates.” The dependency and next action stay visible.
- “Send or discard your drafts and files before updating this computer.”
gives a concrete action. Existing failure details remain expandable. New
text uses the glossary, sentence case, present tense, typographic quotes
and correct plurals; no new jargon, empty states or decorative copy.
- Reviewed typical/short and long names on desktop and phone widths.
Actions have accessible text labels; statuses and blocker explanations
do not depend on color. Native layout remains the visual-verification
gap above.

Related: #373
Related: #471
Related: #479
Related: #507
nixuuu added a commit that referenced this pull request Nov 16, 2026
## Change

Windows installations that need administrator approval currently leave
users guessing how to update. Local **Restart to update** now offers
**Show installer** with four steps: reveal the downloaded installer,
close Canopy, run the installer as administrator, and reopen Canopy
normally. The file comes from the accepted updater download; the
renderer cannot choose a path. Cancelling keeps Canopy running, and a
missing installer directs users to download it again.

When PostgreSQL explicitly refuses administrator privileges, startup
reports that cause and tells users to reopen Canopy without **Run as
administrator**, instead of waiting for a generic readiness timeout.
Other startup failures retain their existing diagnosis. Remote updates
still fail before service shutdown when elevation is needed.

Fixes: #479

## Verification

- 23 affected tests passed through `check:tmp`, including real
child-process stderr split across chunks, unrelated startup failures,
and remote elevation rejection without shutdown.
- Desktop package typecheck, lint on edited TypeScript files,
formatting, and diff checks passed.
- Startup screen inspected in a real browser with a mocked desktop
bridge: light/dark, 1080 px and 390 px widths; no horizontal overflow.
- Full repository verification remains with CI. Native Windows dialog
layout, Explorer selection, and the manual UAC installation flow were
not exercised on this Linux host.

## Copy audit

Before: administrator approval plus a reinstall recommendation, and a
generic startup timeout. After: concrete installer instructions and a
specific explanation when the database rejects administrator privileges.

Checked sentence lengths, active voice, glossary, action labels, error
recovery, repetition, dependency explanations, and text cues; no
humorous copy or new empty states. Audit §8 item 9 is covered for the
startup screen at desktop/phone widths; the native Windows dialog
remains a manual Windows check because this host runs Linux. The change
adds no user-provided names or variable-length labels.
nixuuu added a commit that referenced this pull request Nov 28, 2026
## Windows app updates

- Confirm the running app matches the per-user NSIS registration. A
separate machine-wide registration no longer blocks that installation.
Installer metadata, directory permissions, checksum and publisher checks
still apply.
- Start the verified installer in silent per-user mode after services
stop, then quit after Windows confirms process creation. If launch
fails, restart the current version. Local updates offer **Show
installer** for manual recovery.
- Give Windows users **Retry app update** or **Update manually** in the
error details. **Dismiss** acknowledges the previous failure. Add
regression coverage for install scope, spawn errors, and retrying a
missing staged installer.

Thanks to @marcinniewinski for reporting this.

Fixes: #479

## Verification

- Locally on Linux at `7524a9ab5`, formatting and lint passed for the 11
edited code files. All four focused updater unit tests passed. The diff
check passed.
- PR CI covers repository checks, affected client builds and desktop
regression tests. The signed Windows desktop packaging workflow covers
installer signatures and installation on protected `dev`. It does not
cover an in-app update between signed versions.
- Windows validation still needs an ordinary user to update an existing
signed per-user installation, including a custom directory and a
separate machine-wide registration. Check that Canopy returns on the new
version with its services running, that a blocked launch returns to the
current version, and that machine-wide installs offer manual recovery
without automatic elevation. The original reported error has not been
reproduced.

## Copy audit

The error disclosure previously offered **Dismiss** alongside a failed
app request. It now offers the action appropriate to the local state.
The labels use existing app update terms and start with verbs. The
native dialog explains the failure and how to find the installer. The
labels and error text carry meaning without color. The changed labels
are fixed strings and reuse the existing disclosure and button styles.
Responsive rendering and the native dialog layout still need a runtime
check.
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