Repository navigation
fix(desktop): join update checks and recover after sleep - #471
Merged
Merged
Conversation
nixuuu
force-pushed
the
fix/update-busy-after-sleep
branch
from
November 10, 2026 08:33
373a526 to
e0c10ec
Compare
Keep the normal Squirrel install path synchronous. Replay a displaced native feed without the metadata deadline, preserving real staging failures and safe retries. Related: #471
nixuuu
added a commit
that referenced
this pull request
Nov 10, 2026
## 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](https://github.com/electron-userland/electron-builder/blob/electron-updater%406.8.3/packages/electron-updater/src/AppUpdater.ts), [BaseUpdater](https://github.com/electron-userland/electron-builder/blob/electron-updater%406.8.3/packages/electron-updater/src/BaseUpdater.ts), and [NsisUpdater](https://github.com/electron-userland/electron-builder/blob/electron-updater%406.8.3/packages/electron-updater/src/NsisUpdater.ts): Windows receives `--updated /S --force-run`; metadata can select `elevate.exe`, and launch permission failures can also trigger elevation. - [NSIS documentation](https://github.com/electron-userland/electron-builder/blob/electron-builder%4026.18.0/website/docs/nsis.md), [assisted installer](https://github.com/electron-userland/electron-builder/blob/electron-builder%4026.18.0/packages/app-builder-lib/templates/nsis/assistedInstaller.nsh), and [multi-user macros](https://github.com/electron-userland/electron-builder/blob/electron-builder%4026.18.0/packages/app-builder-lib/templates/nsis/multiUser.nsh): silent updates select the previous install scope and read its `InstallLocation`, preserving a custom per-user directory. - [Installer](https://github.com/electron-userland/electron-builder/blob/electron-builder%4026.18.0/packages/app-builder-lib/templates/nsis/installer.nsi) and [install section](https://github.com/electron-userland/electron-builder/blob/electron-builder%4026.18.0/packages/app-builder-lib/templates/nsis/installSection.nsh): assisted silent updates can elevate for a previous machine installation; `/S --force-run` relaunches the installed app. - [Running-process check](https://github.com/electron-userland/electron-builder/blob/electron-builder%4026.18.0/packages/app-builder-lib/templates/nsis/include/allowOnlyOneInstallerInstance.nsh): `--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
nixuuu
added a commit
that referenced
this pull request
Nov 10, 2026
Users sharing a public IP can exhaust GitHub's unauthenticated 60-request/hour allowance. Update discovery then reports every computer as failed, even though nothing failed to install. Canopy now reads a static release index first and presents an exhausted REST fallback as **Checks paused**, with an automatic retry at the reset time. ## Changes - Publish `https://itsoltech.github.io/canopy/releases/v1.json` through the existing Pages workflow after `publish-desktop` has verified and published the release. Include tags, prerelease flags, publication dates, all asset names/URLs and release notes. Exclude drafts and incomplete uploads; require the release that triggered publication. One serialized Pages deployment replaces the whole site/index. Ordinary site deployments also preserve the index. Pages already uses the workflow source; no settings change is needed. - Share a metadata client across desktop windows/peer requests, gateway resolution, BFF notes and phone release notes. Use a 15-minute cache, ETags/304 and in-flight deduplication. Immutable manifests are cached by the resolver. Fall back to REST only when the index is unavailable or invalid; missing tags/channels in a valid index do not trigger REST lookups. - Honor `x-ratelimit-reset` and `Retry-After` for 403/429, sharing cooldowns across API repositories within each process. Manual, wake and remote checks cannot bypass the pause. Desktop/gateway automatic checks retry at reset; Never still disables desktop automatic retries. Linked computers carry the same neutral message through existing fields. Genuine installation/signature failures still show Failed, and staged installers remain usable. - Keep manifest, checksum, installer signature and pinned TLS verification in place. No client tokens, protobuf changes, tags, workflow dispatches or repository settings changes. ### Discovery choice Pages provides atomic snapshots, the existing deployment path, complete metadata and release notes. A rolling download asset would need an additional mutable release/tag and replacement protocol. Atom lacks the complete asset inventory and manifest-presence contract. Desktop and its local gateway remain separate readers: CDN discovery removes the quota dependency without adding a privileged gateway proxy. ## Calls per hour One desktop/local gateway, one linked desktop/gateway, and one browser using the local BFF. Five independent processes; one Canopy releases page, unchanged metadata, no process restarts. Scheduled trace: desktop checks hourly, gateways every 15 minutes, one browser notes read. Active trace: each reader is requested once/minute, with concurrent duplicate callers. Pre-change counts follow the original 60-second desktop/BFF cache and uncached gateway paths; post-change counts come from fake-clock/mock-fetch hour-long traces in `packages/updater/src/catalog.test.ts`. No live anonymous API traffic was used. | Workload | Before: REST requests/h | After: REST requests/h | After: CDN requests/h | After with index unavailable: REST requests/h | | --- | ---: | ---: | ---: | ---: | | Scheduled checks and one notes read | 11 | 0 | 11 | 11 | | Active checks and notes once/minute | 300 | 0 | 20 | 20 | Counts include conditional HTTP requests, including 304s; they do not assume anonymous 304s are quota-free. Five processes initially receive bodies; subsequent validations reuse them. Fallback also retries the unavailable index at most once/15 minutes per active process. More API history pages multiply fallback list requests; the CDN index stays one request. Concurrent duplicate callers add no new requests. Artifact downloads and provider notes are separate: Claude/Codex notes remain REST-backed, with the same shared 15-minute/ETag/origin-backoff policy in the BFF. Older installed clients continue using REST. Caches/backoff are process-local and reset on restart. ## Copy audit (§8) `Failed · Update failed. Check again to retry.` / `Release server returned HTTP 403` → `Checks paused` plus `GitHub is limiting update checks from this network. Next check at <localized time and zone>.` The new text names the confirmed condition and the next automatic action without implying installation failure. Each sentence stays within the copy limits; sentence case, plain words and `Intl` time formatting are used. There are no new glossary terms, buttons or confirmations. The neutral message is visible in computer rows, including touch layouts; it is not available only through a tooltip. Real errors retain their existing recovery actions. No humour or jargon was added. Layouts reuse the existing row/action columns and wrapping styles; visual browser/device verification remains unperformed. ## Validation - `bun install`; `bun run typecheck`; targeted gateway typecheck after extracting worker row projection to preserve the 400-line limit. - `bun run lint`; `bun run format:check`; actionlint on both changed workflows. - 53 focused updater/desktop/gateway/index tests, including fallback, pagination, ETag/304, reset/Retry-After, remote/mobile state mapping, preserved staged installs and the hourly traffic traces. Another 24 existing release/publication tests passed. - `git diff --check`; `proto/canopy/update/v1` unchanged. No E2E, native installers, builds or workflow runs were executed. CI remains the merge gate; the first normal Release/Pages run validates deployment after merge. Additional mobile Expo lint reports 38 errors and 3 warnings in existing mobile code (for example synchronous effect state updates in `AttachmentViewer.tsx` and ref reads in `ImageCanvas.tsx`). A targeted check of the four touched mobile files reports the existing `Updates.UpdateInfoType` namespace diagnostic on the unchanged version-extraction line in `PhoneReleaseNotes.tsx`; the other three files pass. This is separate from the passing repository oxlint/typecheck gates; this PR does not expand into unrelated mobile lint fixes. Related: #376, #471
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
This was referenced Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A remote app-update request could reach a desktop that was already checking or downloading automatically.
checkRemote()rejected that overlap, andRemoteAppUpdatepersisted it as a failed installation. Preparation, metadata checks and downloads also had no controller deadlines, so an unresolved request after sleep could retain the running lock indefinitely. The overlap guard originates in #70; #373's check-only command callscheck(), so it did not introduce that guard. Without logs from the affected Mac, whether its operation was still progressing or hung cannot be distinguished.Manual and remote checks now share the current operation and its actual checking/downloading progress. Channel changes queue behind it and retain downgrade confirmation. Preparation and metadata checks have 60-second deadlines; downloads have a 30-minute total limit and a 90-second stall limit based on increasing transferred bytes. Cancellation propagates to release-feed requests and downloads. Recovery replaces the updater and isolates its download directory, ignoring retired events and late responses. Previously staged updates retain their installable updater. On macOS, module-level commit tokens track the shared native feed: ordinary installs call Squirrel synchronously without replaying
task.done. Only a displaced feed is replayed, serialized behind any pending finalizer. Local ZIP replay has no controller deadline and propagates actual staging failures through installation error handling; a failed replay remains eligible for retry.Suspend pauses the automatic timer. Resume/unlock recovery is debounced for 5 seconds, restarts stale work through the original shared promise, and restores the schedule. If a timeout finishes before the wake handler, automatic checks retry once; Never suppresses that automatic retry. A persisted busy-only failure reports the live updater phase, while real installation failures remain Failed. Gateway mapping and protobuf contracts are unchanged, including the frozen update service. Updated the Polish operational docs.
Validation:
bun install,bun run gen:check,bun run typecheck,bun run lint,bun run format:check, andbun run --filter @canopy/web buildpassed for the initial change. After the native-feed revision, focused desktop tests, full typecheck, lint and format:check passed again, with a final focused desktop typecheck after the replay-retry refinement.check:tmprun. CI remains the full-suite gate. Signed macOS sleep/resume and installation were not exercised on this Linux machine; native-feed ownership and replay are covered with fakes, while actual Squirrel staging remains unverified on a real Mac. The web build completed with chunk-size warnings.Copy audit (
docs/copy.md§8):Wait for the current app update operation to finish, then retry.→ existing live checking/downloading/ready statuses. Overlap requires no user action and is no longer presented as a failure.Update timed out. Check the connection, then retry.Two short sentences identify the event and next action; no protocol names or internal jargon.Related: #70
Related: #373, #459