Skip to content

perf(updates): drive the update center by events - #459

Merged
nixuuu merged 1 commit into
perf/fetch-3-bots-connectorsfrom
perf/fetch-4-updates
Nov 9, 2026
Merged

nixuuu merged 1 commit into
perf/fetch-3-bots-connectorsfrom
perf/fetch-4-updates

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Part 4 of 5. The update center, capabilities and computer metadata are driven by events.

What changes

  • Gateway updates_changed (829). It covers updater state, checks and worker update reports, merged into one notice per 250 ms, and adds updates to feeds. When a linked computer announces a change, its snapshot here refreshes at once instead of waiting for the read cooldown, and the settled read notifies clients. The cooldown no longer limits progress freshness.
  • GetClientCapabilities reads the gateway name from its identity instead of building a full computers snapshot (routes, peers, notices) on every call.
  • Web: one update center per tab, shared by the sidebar indicator, Workers and App updates (each had its own 5 s poller). It reads after events, every 2 s only while something updates, once a minute for older gateways, and never while hidden. Capabilities renegotiate when the overview connection changes (restart, upgrade, revocation) and every 5 min, not every 5 s. The remote BFF reuses a negotiation for 60 s and renegotiates at once after an Unavailable, Unimplemented or Unauthenticated call; auth stays per RPC. Config notices and Computers share one GetComputers read without 3 s timers (one 60 s visible check; 2 s only while a pairing invitation is valid). Network access checks every 30 s and devices every 60 s, while visible.
  • Mobile: the updates provider follows the same events (it read every 15 s, and every 2.5 s with the panel open). Devices follow their events instead of a 15 s poll.

Measurements

Scenario Method before after
S1: sidebar idle (127 s) GetClientCapabilities 25 (84 KB) 0
GetUpdates 25 (42 KB) 0
S3: Workers open (127 s) GetUpdates 50 (85 KB) 0
GetNetworkAccess 50 8
S4: 9 Settings navigations (27 s) GetUpdates 8 0
GetClientCapabilities 5 0
GetNetworkAccess 6 4

Tests: tests/integration/update-center.test.ts (an idle stream gets no notices; update progress is pushed), plus the existing linked-updates, desktop-updates, updates and gateway-role suites.

How it was measured

  • Web (real browser, own stack). scripts/bench/client-stack.ts on private ports (dev BFF, server role, synthetic worker), base = dev at a423af85, after = top of this stack. Resource Timing counted /api/* requests per path in a visible tab. Scenarios: S1 sidebar idle 127 s; S2 Settings → Connectors open 126 s; S3 Settings → Workers open 127 s; S4 nine in-app Settings navigations in 27 s. The BFF routes are pass-throughs, so gateway call counts equal these.
  • Gateway and linked home. Two real desktop-role gateways linked over mTLS (tests/integration/support/linked-timeouts.ts), counting RPCs served by the linked home and linked reads started here.
  • Mobile. No device run: the phone's request sequence before and after was replayed from source against the linked test gateways. On-device profiling is still open (see the stack summary).
  • The stack is cumulative; each table lists only the methods this PR changes. Values for the top build apply to this PR because no later PR touches those methods.

Copy audit (docs/copy.md §8)

No UI text was added or changed. Existing messages ("Could not load bots.", "Could not load connectors.", "Could not load settings. Check the connection and retry.") moved to shared stores unchanged.

@nixuuu
nixuuu added this pull request to stack #461 November 9, 2026 21:00
@nixuuu
nixuuu marked this pull request as ready for review November 9, 2026 21:01
The gateway announces update center changes (OverviewUpdate.updates_changed:
updater state, checks and worker update reports, merged per 250 ms) and
advertises the "updates" feed. A linked computer's change refreshes its
snapshot here at once, past the read cooldown; the settled read notifies
clients. GetClientCapabilities reads the gateway name from its identity
instead of building a full computers snapshot.

Web: one update center per tab shared by the indicator and both panels;
it reads on events, every 2 s only while something updates, once a minute
for older gateways and never while hidden. Capabilities renegotiate on
overview connection changes and every 5 min instead of every 5 s; the
remote BFF reuses a negotiation for 60 s and renegotiates on failing
calls. Config notices and Computers share one computers read without 3 s
timers; network access and devices check at 30 s / 60 s while visible.

Mobile: the update provider follows the same events; devices follow
their events instead of a 15 s poll.
@nixuuu
nixuuu force-pushed the perf/fetch-4-updates branch from ab50d22 to 4aba0ae Compare November 9, 2026 21:11
@nixuuu
nixuuu merged commit 7173706 into dev Nov 9, 2026
9 checks passed
@nixuuu
nixuuu deleted the perf/fetch-4-updates branch November 9, 2026 21:45
nixuuu added a commit that referenced this pull request Nov 10, 2026
Share check promises, bound updater work, recover stale attempts on wake, and preserve staged updates. Report persisted overlap through the live updater state.

Related: #70

Related: #373, #459
nixuuu added a commit that referenced this pull request Nov 10, 2026
A remote app-update request could reach a desktop that was already
checking or downloading automatically. `checkRemote()` rejected that
overlap, and `RemoteAppUpdate` persisted 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 calls `check()`, 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`, and `bun run --filter @canopy/web build`
passed 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.
- 29 focused desktop tests passed: 12 controller/remote-coordinator
regressions, 13 existing updater/feed/staging tests, and 4 native-feed
tests using fakes. Coverage includes joining during checks/downloads,
hung prepare/metadata, stale resume, stalled and total download
deadlines, repeated progress, error cleanup, queued channels, retained
staged updates, Never, and persisted busy versus genuine failures. The
native-feed tests verify synchronous installation without re-staging,
replay after another commit, serialization behind an unfinished
replacement, and real failure propagation followed by a safe retry.
- No web UI tests, E2E, or full local `check:tmp` run. 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):
- Busy-only `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.
- Unbounded wait → `Update timed out. Check the connection, then retry.`
Two short sentences identify the event and next action; no protocol
names or internal jargon.
- Existing action names, genuine failure messages, confirmations, and
status layouts remain in use. No new terms, repeated facts, humor, or
color-only meaning. No UI templates changed;
name-length/responsive/browser review was not run for this
controller-only change.

Related: #70

Related: #373, #459
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