Repository navigation
perf(updates): run independent targets concurrently - #700
Merged
Merged
Conversation
nixuuu
marked this pull request as ready for review
November 14, 2026 11:45
nixuuu
added a commit
that referenced
this pull request
Nov 14, 2026
The delayed-rejection test sometimes reads `expired` before the successful turn's account update runs, even though the turn is already committed. This is a test race: ingestion commits the turn, then awaits settling, broadcasts and agent-bus handling before calling `coreTurnLogin`. A database count therefore cannot establish that the success has entered `ProviderAccounts.afterTurn`; the test's no-op queue barrier can run ahead of it. Observe the real account-update enqueue, keep the rejected account read held until the success is queued, then wait for both real updates to finish before asserting `signed_in`. Waiting for both independently also catches a stale rejection when ordering is broken. Remove the database-count helper and the two-second sampling loop. Product ordering in `provider-accounts.ts` and `turn-logins.ts` stays unchanged. Related: #696, #700, #703 ### Verification - Stress: **171 passed, 29 failed out of 200 (14.5% failures)** before; **200 passed, 0 failed** after. Each repetition runs the focused file, including the earlier device-login scenario this case depends on; the target case executes once per repetition. The after run passed all **800/800** tests in **310.99 s**. No retries, sleeps or timeout increases were added. - The baseline used 48 completed direct repetitions, then 152 with the repository's shared-Postgres runner. The after run used `nice -n 10 bun run check:tmp <focused-file> --rerun-each=200`; its identical source was staged under a temporary test filename so the unchanged baseline could run alongside it. Both used a private `TMPDIR` under `/var/tmp`. - Mutation check: bypassing the real queue with `update()` makes the new test fail with `Expected: signed_in / Received: expired`. The mutation was confined to a temporary test copy and removed. - `bun install`, `bun run typecheck`, `bun run lint`, `bun run format:check`, and the final focused file: **passed**, all with `nice -n 10` and temp under `/var/tmp`. The shared-Postgres runner reported no test temp directories left behind. No UI, protocol or runtime behavior changes.
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 18, 2026
## Change Paired desktop apps in **Update all** previously waited for every binary worker and CLI update on their gateway. After the gateway update finishes, each desktop can now update alongside other workers once its control stream reconnects and its own CLI updates finish. The run still allows up to four active steps. Fixes: #700 ## Verification - All 22 tests passed via `bun run check:tmp ./tests/integration/update-concurrency.test.ts ./tests/integration/update-center.test.ts`. The tests cover concurrent worker and desktop updates, a desktop reconnecting after gateway restart, and a desktop waiting for its own CLI. - Scoped formatting, lint and `git diff --check` passed. - GitHub CI covers the full repository checks.
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.
Update all now runs independent computers, workers and different agent CLIs concurrently, with four global slots. A slow acknowledgement, failure or timeout no longer stalls unrelated targets. Equal npm prefixes, Bun global projects, pnpm global projects and Volta inventories serialize through installation, validation and rollback. Different prefixes and standalone installers overlap. Duplicate tools are deduplicated per worker; older workers without resource metadata retain their single installer slot.
This Canopy app restarts last. A standalone gateway drains independent peer work before restarting, then resumes protocol-dependent local workers from the durable run. Workers still target the running gateway version and must pass compatibility checks before their CLIs start. Linked apps execute on their own computers and are tracked until they return. The frozen UpdateService is unchanged; WorkerLink adds optional installer resource metadata without changing its protocol version.
Web and mobile share compact activity/success/failure counters. The web popover reserves three lines for active targets, so names and changing activity do not move the list below. Mobile remains a JS/TS change on the existing OTA path; no native modules, app configuration, dependencies or fingerprint inputs changed. OTA publication remains the release workflow's responsibility after merge.
Performance
Measured wall time for 4 fake workers × 2 CLIs, each with 25 ms synthetic service time:
This is a 3.85× speedup for the fake workload. It excludes production polling, network and real installer variability. Timing is informational; deterministic gates, rather than timing thresholds, assert overlap and caps.
Validation
138e0c6b171c82b4933e86808cdfef56da73b8c6; Android906dc944f94eb8333fa384ed9f198834fdd30d13. Native fingerprint sources, app configuration, dependency manifests and the lockfile are unchanged.Copy audit (§8)