Skip to content

fix(desktop): keep checking for a newer build after a download - #207

Merged
nixuuu merged 1 commit into
devfrom
fix/desktop-update-newer-build
Nov 5, 2026
Merged

nixuuu merged 1 commit into
devfrom
fix/desktop-update-newer-build

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 5, 2026

Copy link
Copy Markdown
Member

The desktop app now keeps checking for updates after one has been downloaded. If a newer build appears, it downloads and replaces the staged one, so a restart installs the newest version.

Before: once an update was downloaded, the updater stopped looking:

  • the periodic timer stopped;
  • "Check now" in the popover skipped the app;
  • the desktop updater refused to check in the downloaded phase.

A downloaded nightly.70 therefore stayed the target even after newer nightlies came out.

What electron-updater 6.8.3 does on a second check (checked in the pinned source):

Platform Behaviour
macOS A newer ZIP replaces the cached ZIP and the proxy feed. With autoInstallOnAppQuit=false, Squirrel downloads, validates and stages it during quitAndInstall.
Windows / NSIS Installs from the current download helper's installer path.
Linux / AppImage Installs from the current helper's AppImage.
Linux / deb Updates stay disabled; the package manager owns installation.

The library clears its shared pending files when a replacement fails. The fix therefore downloads into alternating cache directories, so the older package stays installable.

Behaviour now

  • Checks: the popover, Settings → App updates and the periodic timer keep checking after a download. An unchanged feed keeps the staged version.
  • A newer download: the row shows the new target and its percentage. It turns "Ready" only once the download is complete and finalized.
  • Restart: still available; it waits for the current operation, then installs the newest complete package.
  • A failed newer download: the older version is Ready again, with "Update failed. Check again to retry."
  • Remote updates: a remote restart reports and records the version actually installed.
  • Unchanged: channel confirmation, downgrade and quit behaviour.

Tests: desktop updates tests with a fake updater:

  • a newer build replaces the staged one;
  • an unchanged feed keeps the staged one;
  • a failed replacement leaves the older one installable;
  • the timer keeps running after a download;
  • restart installs what is staged.

Remote-update integration passes, including a replacement while waiting for idle. Desktop tests: 74 passed. check:tmp: 1363 passed, 0 failed.

Copy audit (§8): separate Check and Restart actions, an explicit waiting explanation, and an error that ends with an action. Checked in light and dark, at desktop and phone width.

Not verified: a signed macOS build with Squirrel installation and native restart.

Related: #2

Keep manual and periodic checks running after an update is downloaded.
Use alternating download caches so a failed replacement preserves the
installable update, and wait for in-flight work before restarting.

Expose checks in both update views, preserve the remote restart target,
and document the pinned updater's behavior on each platform.

Related: #2
@nixuuu
nixuuu merged commit f65c90e into dev Nov 5, 2026
9 checks passed
@nixuuu
nixuuu deleted the fix/desktop-update-newer-build branch November 5, 2026 18:56
nixuuu added a commit that referenced this pull request Nov 14, 2026
…#743)

## Summary

Redesign of the sidebar **Updates** popover and the mobile Updates
sheet, following the approved audit. The goal: an immediate state on
every click, one summary, rows that never move.

**Popover**
- One summary line in the header (`Starting update…`, `Updating · 2 of 5
done`, `1 update failed · 4 updated`, `All 5 updates finished`, `5
updates available`, `Up to date · Checked 5:39 PM`). The header divider
doubles as the run's 2 px progress bar.
- Removed from the popover: the progress block, the empty 3-line slot
(#700), the active-step list and "Update results". The step history
stays in Settings → Workers → Updates.
- One counter, `N of M done`. M counts every planned step, including
queued ones, so the old "Updating 1" next to "0/2" can't happen. `· K
failed` appears only when K > 0.
- Footer: a `Settings` link; `What's new` only when there are unseen
notes; one labelled primary action on the right: `Update all`, `Restart
to update`, `Retry failed`, or a disabled `Starting…` / `Updating…` with
a spinner.
- Sidebar trigger: `arrow-down-tray`, with a dot when something waits, a
progress ring while updating, and `exclamation-circle` on failure. No
more green check for "downloaded" and no spinning ⟳.

**Rows** (web `UpdateItem`, mobile `UpdateRow`)
- Always two lines. The badge sits in a fixed slot, the bar in the
bottom padding, and the action in a fixed column, so a state change only
swaps text (`t-swap`). Only an error expands, and only on click.
- One vocabulary from `@canopy/domain/release/update-status`: Up to date
(quiet text), Available, Downloaded (was "Ready"), Queued, Starting,
Updating, Waiting, Restarting, Updated (the only green, for 1 h, via
`UpdateStep.finished_at`) and Failed. Edge states keep their own words.
- Icon actions, one meaning each, with a tooltip and `aria-label`:

  | Icon | Action |
  |---|---|
  | `arrow-down-tray` | Update `<name>` |
  | `power` (new) | Restart to update |
  | `repeat` (new) | Retry |
  | `plus` | Install |
  | `information-circle` | Details |

`arrow-path` (⟳) is used only for **Check now**. There is no cancel
glyph, because the API has no cancel action.
- A feed check no longer turns every row into "Checking".

**Immediate states, root cause of the late statuses**
- Before, the UI rendered only server-confirmed state, `reload()` was
blocked while an action was pending, and rows read the targets' own
reports, not the run's steps.
- Now `UpdatesState` (web) and the mobile state apply an overlay as soon
as you click: every planned step shows `Queued` (`plannedUpdateRun`, the
same plan the gateway writes), a row action shows `Starting`, and Retry
failed marks its steps. The gateway's answer replaces the overlay; an
error reverts it.
- Reads keep running during an action. A row shows the further of its
run step and its own report, so it never goes back.
- Gateway: `UpdateCenter.begin()` plans, persists and launches the first
steps before answering, and the response reuses the planning snapshot.
The first answer to Update all already has `running` steps.

**Calm restarts**
- A computer that announced its own update restart shows `Restarting`
with "Restarting to update…".
- The gateway no longer sets "…is unavailable. Trying again
automatically." for it. Its workers and CLIs get "… is restarting to
update." instead.
- After 3 min the row turns amber: "Still restarting after N min. Check
that computer." The 35-min step timeout still ends in Failed with Retry.

**Gateway / contracts**
- `ManageUpdates.retry_failed` (action string; proto comment only):
re-queues every failed or blocked step of the stopped run in one durable
write, keeps successes and their versions, and needs `confirm_restart`
when this app is among them.
- Additive `UpdateStep.finished_at = 12`.
- `updatePlan` moved into the domain as `plannedUpdateRun`.
`computerUpdate()` moved from web to
`@canopy/domain/release/computer-update`, so web and mobile derive rows
the same way.

**Bug fix:** this app's "Restart to update" stayed enabled during Update
all (`CompactAppUpdate.svelte`, old line 89). A click restarted this
computer mid-run, before the linked computers finished. Row actions are
now disabled while a run is active or an action is pending. No `Fixes:`
link: the enable logic dates from #207, and Update all already included
this app before #700, so no recent PR introduced it.

**Mobile parity:** the same summary, rows, icons, overlay, footer and
trigger. JS/TS only. `bun.lock`, the mobile `package.json`, app config,
plugins and native folders are unchanged, so the runtime fingerprint is
unchanged and this ships OTA. No EAS was run.

## Tests

- `packages/domain/src/release/update-status.test.ts`: the shared
planner predicts the gateway's steps and their row keys (skipped steps
apart, this computer last); rows never go back; Updated stays an hour;
the single counter; restart grace.
- `tests/integration/update-concurrency.test.ts`: Update all answers
with its first steps already running, from the snapshot it planned with;
Retry failed re-queues every failed step at once, keeps successes,
rejects a stale run id and a second retry.
- Updated for the new vocabulary and module paths: `linked-updates`,
`paired-app-updates`, `updates-bundled`,
`apps/desktop/test/update-controller`.

## Checks

`bun install` · `bun run gen:check` · `bun run typecheck` · `bun run
lint` · `bun run format:check` · the focused tests above (all update
suites: `update-center`, `update-concurrency`, `updates-bundled`,
`stale-app-updates`, `update-all-computers`, `paired-app-updates`,
`linked-updates`, desktop `update-controller`, domain) · `bun run
--filter @canopy/web build` · `expo export` for Android and iOS.

## Copy audit (docs/copy.md §8)

| Before | After | Reason |
|---|---|---|
| `Updates in progress` (header) | `Updating · 2 of 5 done` | one
counted summary replaces 4 places (§2.12) |
| `Updating 1 · 0 done · 0 failed` | removed | merged into the header;
zero counts hidden (§5) |
| `Update results · 0/2` (popover) | removed | duplicate; stays in
Settings |
| `Mac-Studio… · Canopy app · Updating` | removed | the row says it |
| `Ready` | `Downloaded` | says what happened |
| `Updating…` (presence badge) | `Restarting` | one word for an expected
restart; no ellipsis in badges (§2.11) |
| `Waiting for idle` | `Waiting` + `Restarts after its current turns
end.` | slot width; no jargon (§2.8) |
| `{name} is unavailable. Trying again automatically.` (during its own
restart) | `Restarting to update…`, after 3 min `Still restarting after
N min. Check that computer.` | an expected restart isn't a failure; the
warning ends with an action (§2.6) |
| `This Canopy app` | `This computer` | rows are computers (§3 glossary)
|
| `Checked 5:39 PM` on every row | once: `Up to date · Checked 5:39 PM`
| §2.12 |
| `Show update progress` | removed (`Updating…` while disabled) | no-op
action |
| `Update details` / `App updates` | `Settings` | one link (§5) |
| `What's new` always | only with unseen notes | no empty actions (§5) |
| tooltip `Restart to update Canopy. This stops agents running on this
computer.` | `Restart to update. Agents running on this computer stop.`
| one idea per sentence, active voice |
| `Request update again on X` | `Retry` | verb first, 1–3 words (§4.1) |
| `Installing` (CLI) | `Updating` | one vocabulary |
| `Agent CLIs · Installing…` (mobile) | `Agent CLIs · 6 · Updating` |
count kept; shared word |
| — | `Starting update…`, `Starting…`, `Retry failed`, `1 update failed
· 4 updated`, `All 5 updates finished` | -ing + ellipsis for ongoing
actions (§4.6); counted results; no exclamation marks |

Glossary: computer, worker, agent CLI, update channel; no new terms. No
sentences with "soul". Live numbers use `tabular-nums` and sit at the
end of the line. Checked with short, typical and long names (the gallery
has "Build server in the rack room · linux-x64 · 64 GB" and "Sleeping
computer with a rather long name") at desktop and phone width, light and
dark.

## Browser review

On the review host: the `/dev/updates` gallery against a local gateway,
captured with Playwright, light + dark, desktop (1100 px) + phone (390
px), in every state. New gallery params: `state=quiet`,
`state=starting`, `restart=1|slow`.

States checked: all up to date, available, starting (immediate),
updating in parallel with a restarting computer, slow restart, one
failed, finished.

- Found and fixed (second commit): on phones the edge badge "Manual
update" was wider than the fixed slot and overlapped the name. The slot
is now a minimum width that fits every shared word, so state changes
still move nothing; a rare long edge word truncates the name instead.
- Fixture caveat: in "finished" the gallery leaves some versions
unchanged, so those rows correctly show Available again (a newer version
beats Updated).
- Not reviewed: the native mobile sheet on a device. It typechecks and
exports for both platforms; no build or EAS was run.
nixuuu added a commit that referenced this pull request Nov 24, 2026
…1240)

## Windows desktop updates

When Canopy downloads a newer build while an earlier installer is ready,
electron-updater looks for the differential base in the replacement
cache. A missing installer.exe there caused ENOENT and a full download.
The reported shutdown four seconds into a download remains unexplained.

Pair the previous staged installer with its blockmap. When that map is
unavailable, try the installed release's installer and map. Keep the
previous verified installer available if a replacement is cancelled.
Preserve full-download fallback and signature verification.

Record the download fallback, recognised error codes, quit requests and
updater state at shutdown in the local desktop log. After an interrupted
update request, show the last recorded phase.

Fixes: #207

## Verification

36 focused desktop tests passed on Linux, including range downloads with
the pinned NSIS updater, cancellation, cold-start recovery and
diagnostic filtering. Desktop typecheck and edited-file lint passed.
Native Windows x64 installation and Authenticode verification remain
unverified locally. Full repository checks run in CI.

## Copy audit

Replaced the generic interrupted-update message with the last recorded
step and the action “Retry the update.” The messages use short sentences
and existing update terminology. Existing error details display the
messages. No controls or layout changed. Responsive rendering of the new
strings was not checked locally.
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