Skip to content

Shorten update-check interval and add foreground/network triggers - #231

Merged
MaplumeX merged 1 commit into
mainfrom
chore/verify-auto-update-periodic-check
Oct 13, 2026
Merged

MaplumeX merged 1 commit into
mainfrom
chore/verify-auto-update-periodic-check

Conversation

@MaplumeX

Copy link
Copy Markdown
Owner

Summary

Update checks previously ran on a 24-hour wall-clock cadence, so a compatible hub upgrade could go unnoticed for a day, and server switches relied on the startup check plus the 426 trigger. This change tightens the cadence and wires the checks into the events that actually signal "something changed": server switches, returning to the foreground, and network recovery.

Changes

Scheduling (packages/api/src/updates/update-checker.ts)

  • Initial check still fires 10s after startup; the recurring tick now runs every hour instead of gating on a 24-hour window.
  • Added foreground/online triggers (visibilitychange → visible, focus, online), throttled to 5 minutes based on the most recent attempt or successful check. Failed attempts also count toward the throttle, so a flapping network can't produce request storms; manual checks bypass it.
  • Server switch triggers an immediate check and clears the previous server's verdict / ready version.
  • All automatic triggers respect the "auto check" setting; manual checks keep working when it is off.
  • initUpdateChecks() now returns a stop function that clears the timers, the sync-status subscription, the base-URL subscription, and all DOM/window listeners. Stopping also cancels checks waiting on a server switch.

Robustness across server switches

  • /health is requested with an explicit baseURL snapshot and a 15s timeout.
  • A generation counter plus a base-URL/shell identity check discards stale successes, failures, and download results from a previous server so they never publish an out-of-date prompt.
  • Installer preparation is serialized on switch: the in-flight prepare is awaited before querying the new server, avoiding two native downloads racing over the same pending-install slot.

Installer reuse

  • A version prepared by the current platform shell is reused for the rest of the run (preparedVersion); a version with no published package yet is retried on the next check. Registering a different shell resets the cache.

API client (packages/api/src/api/client.ts)

  • New onApiBaseUrlChange(listener) subscription. setApiBaseUrl now notifies only on an actual value change.

Docs

  • Updated spec.md and issue 03 to reflect the new cadence and triggers; added issue 07 documenting the delivered behavior and acceptance criteria.

Testing

update-checker.test.ts was extended from 12 to 211 lines of coverage, including the API-client subscription. All 55 update-check, verdict, and API-client tests pass, covering:

  • hourly checks and startup delay,
  • per-event throttling (focus, visibilitychange, online) and background events being ignored,
  • throttle-on-failure with manual retry,
  • disable/stop behavior and listener cleanup,
  • server switch clearing state, discarding stale results, and serialized prepare,
  • installer reuse and retry when a package is not yet published.

Real-device download and install acceptance remains tracked by issues 05 and 06.

@MaplumeX
MaplumeX merged commit 75cc258 into main Oct 13, 2026
4 checks passed
@MaplumeX
MaplumeX deleted the chore/verify-auto-update-periodic-check branch October 13, 2026 15:03
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