Skip to content

Add an app update checker that surfaces newer NodeSpace releases - #1881

Merged
mstomar125 merged 1 commit into
mainfrom
issue-1321-update-checker
Aug 1, 2026
Merged

mstomar125 merged 1 commit into
mainfrom
issue-1321-update-checker

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

Summary

Detect-only app update checker (no auto-update): on startup the app checks whether a newer NodeSpace release exists and, if so, surfaces it non-blockingly. Closes the backend/detection half of the update-checker requirement.

  • update_check module (packages/desktop-app/src-tauri/src/update_check.rs): pure update_available (semver compare — 0.10.0 beats 0.9.0, which lexicographic would get wrong), parse_version (tolerates a leading v), and latest_tag_from_json — all unit-tested without the network — wrapped by check_for_update, a 5s-timeout GitHub releases/latest fetch that swallows every failure (offline, timeout, rate limit, malformed/missing tag) to a "no update known" result.
  • check_for_update_command Tauri command for on-demand checks (menu item / on mount).
  • Startup spawn (lib.rs): fire-and-forget on tauri::async_runtime::spawn so it can never delay startup; emits update://available (payload: current + latest version) only when a strictly-newer release exists — no event on up-to-date or on any failure, so the banner appears solely on a real update.

Decisions

  • Version source = GitHub Releases /latest of this repo (releases are the installable artifacts). The endpoint excludes drafts/prereleases — "what a user can install".
  • Running version from Tauri PackageInfo (the shipped tauri.conf.json version), not CARGO_PKG_VERSION — so a build that bumps tauri.conf.json without Cargo.toml can't report a stale version and nag against its own release. (Applied from review.)
  • semver crate for correctness; unparseable input fails safe (never a false "update available").
  • Deps added: reqwest (rustls-tls, no OpenSSL) + semver.

Tests

8 unit tests: semver-not-lexicographic, equal/older are not updates, leading-v tolerance both sides, prerelease < release, garbage never claims an update, tag_name parsed from release JSON, rate-limit/error JSON → none, no-update status shape. Full pre-push gate green (test:all + cargo build --bin nodespaced + test:e2e + cargo test -p nodespace-app), clippy -D warnings clean.

Deferred to on-device (Mac)

The non-blocking banner component that listens for update://available (register the listener on mount, or call check_for_update_command directly), and live validation against real GitHub releases. Note for the frontend: the startup emit is fire-once with no replay, so register the listener before/independently of relying on the startup event, or call the command on mount.

Co-Authored-By: Claude Opus 4.8 [email protected]

Detect-only (no auto-update): compare the running app version against the latest
published GitHub release with semver semantics, so 0.10.0 correctly beats 0.9.0.
The check is best-effort — offline, timeout, rate limit, or a malformed/missing
tag all resolve to "no update known", never an error, and it runs on a background
task so it can't delay startup.

- `update_check` module: pure version-compare + release-JSON parse helpers
  (unit-tested without the network) wrapped by a short-timeout GitHub fetch that
  swallows every failure.
- `check_for_update_command` Tauri command for on-demand checks.
- A startup spawn that emits `update://available` (with the current/latest
  versions) only when a strictly-newer release exists, so the frontend banner
  appears solely on a real update.

The running version comes from Tauri's `PackageInfo` (the shipped
`tauri.conf.json` version) rather than `CARGO_PKG_VERSION`, so a build that bumps
`tauri.conf.json` without `Cargo.toml` can't report a stale version and nag
against its own release.

Adds `reqwest` (rustls) + `semver` to the desktop app. The non-blocking banner UI
that listens for the event, and live validation against real releases, are the
frontend/on-device half.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@mstomar125

Copy link
Copy Markdown
Contributor Author

APPROVE

Adversarial review traced every path in update_check.rs + the lib.rs wiring against the acceptance criteria. Verdict: ship-worthy, no blockers/majors.

  • Startup safety: the check is fire-and-forget on tauri::async_runtime::spawn; nothing is awaited in setup(). Zero unwrap/expect/panic/bubbling-? — every fallible step (client build, send, non-2xx, body read, JSON parse, missing/empty tag, unparseable tag) funnels through .ok()?/Option guards to no_update, and the emit is if let Some(window) + let _ =. Startup can't be delayed or fail.
  • Semver: genuine semver::Version compare (not lexicographic); fail-safe direction is right (garbage → no false update); leading-v covered; prerelease handled and moot given /releases/latest excludes prereleases.
  • Fetch: required User-Agent present; correct tag_name from /releases/latest; 5s timeout covers the whole request; the event fires only on a strictly-newer release.

The one MINOR it raised — CARGO_PKG_VERSION (Cargo.toml) could drift from the shipped tauri.conf.json version and nag against its own build — is addressed: the running version now comes from app.package_info().version. Re-verified: 8 unit tests pass, clippy -D warnings clean, full pre-push gate green. Merging.

@mstomar125
mstomar125 merged commit d265d32 into main Aug 1, 2026
2 checks passed
@mstomar125
mstomar125 deleted the issue-1321-update-checker branch August 1, 2026 09:54
mstomar125 added a commit that referenced this pull request Aug 1, 2026
closes #1321, #1887)

Completes the app-update manager on the merged detection backend (#1881): a
non-blocking update banner, plus a consistent pre-migration database backup so a
new release can never lose the user's data.

Update prompt (#1321): update-status store subscribes to the startup
update://available event + runs one on-demand check_for_update_command; a
per-version-dismissible UpdateBanner (mounted in the app shell) offers Download
(opens the release page — the bundle is unsigned, no in-app installer) and Later.

Data safety — no data loss on update (#1887): before any pending migration runs
AND when the db holds data, snapshot it with SQLite's consistent hot-backup
(VACUUM INTO) to a backups/ sibling dir, pruned to 5. Wired into SqliteStore::new
(best-effort — logged, never blocks startup). Completes the three-layer guarantee:
data lives outside the app bundle; migrations are transactional (crash-safe); and
now a committed bad/destructive migration is recoverable from the snapshot.

Hardened after adversarial review:
- VACUUM INTO (not checkpoint+file-copy): a transactionally-consistent snapshot
  even if another connection holds the db or has un-checkpointed WAL — the
  previous copy could silently omit WAL data under daemon+CLI concurrency.
- Gate on real data (a populated node table), not user_version==0, so a
  pre-versioning db at version 0 with data is still protected and empty dbs skip.
- Nanosecond + pid in the backup filename so two processes can't collide.
- app-shell cleanup now calls updateStatus.stop() (no leaked listener).

Tests: 6 migration-backup unit tests (data preserved in the snapshot, populated
version-0, empty-skip, current-skip, brand-new-skip) + an end-to-end
SqliteStore::new wiring test; 7 update-store tests. Live-validated against a real
185-node v2 profile: the daemon snapshots (v2/185) then migrates the live db to v3.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
mstomar125 added a commit that referenced this pull request Aug 1, 2026
closes #1321, #1887) (#1889)

Completes the app-update manager on the merged detection backend (#1881): a
non-blocking update banner, plus a consistent pre-migration database backup so a
new release can never lose the user's data.

Update prompt (#1321): update-status store subscribes to the startup
update://available event + runs one on-demand check_for_update_command; a
per-version-dismissible UpdateBanner (mounted in the app shell) offers Download
(opens the release page — the bundle is unsigned, no in-app installer) and Later.

Data safety — no data loss on update (#1887): before any pending migration runs
AND when the db holds data, snapshot it with SQLite's consistent hot-backup
(VACUUM INTO) to a backups/ sibling dir, pruned to 5. Wired into SqliteStore::new
(best-effort — logged, never blocks startup). Completes the three-layer guarantee:
data lives outside the app bundle; migrations are transactional (crash-safe); and
now a committed bad/destructive migration is recoverable from the snapshot.

Hardened after adversarial review:
- VACUUM INTO (not checkpoint+file-copy): a transactionally-consistent snapshot
  even if another connection holds the db or has un-checkpointed WAL — the
  previous copy could silently omit WAL data under daemon+CLI concurrency.
- Gate on real data (a populated node table), not user_version==0, so a
  pre-versioning db at version 0 with data is still protected and empty dbs skip.
- Nanosecond + pid in the backup filename so two processes can't collide.
- app-shell cleanup now calls updateStatus.stop() (no leaked listener).

Tests: 6 migration-backup unit tests (data preserved in the snapshot, populated
version-0, empty-skip, current-skip, brand-new-skip) + an end-to-end
SqliteStore::new wiring test; 7 update-store tests. Live-validated against a real
185-node v2 profile: the daemon snapshots (v2/185) then migrates the live db to v3.

Co-authored-by: Claude Opus 4.8 <[email protected]>
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