Skip to content

Carry the download URL in the update-check payload instead of a hardcoded releases page - #3387

Merged
mstomar125 merged 3 commits into
mainfrom
issue-3319-update-download-url
Sep 30, 2026
Merged

mstomar125 merged 3 commits into
mainfrom
issue-3319-update-download-url

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

Closes #3319

The update banner's Download button always opened core's GitHub releases page, whatever source found the update. The update-check payload now carries the download location, the banner opens it, and Download is hidden when the source names none.

What changed

Rust (packages/desktop-app/app-lib/src/update_check.rs)

  • UpdateStatus gains download_url: Option<String> (serializes as download_url, null when absent).
  • New RELEASES_PAGE_URL for the public source, next to LATEST_RELEASE_URL.
  • New status_from(current, latest, download_url) holds the version comparison. An update carries the source's URL; no update carries None even when the source has one. no_update sets None.
  • check_for_update passes Some(RELEASES_PAGE_URL) on the public-source branch and None on the other. The branch itself stays (the follow-on issues move and then delete it).

Frontend

  • update-status.svelte.ts: RELEASES_URL and its comment are deleted. download_url: string | null on the payload interface, downloadUrl state set in apply() as status.download_url ?? null, a canDownload getter. download() opens downloadUrl; with none it logs a warning and opens nothing.
  • update-banner.svelte: Download renders only when canDownload; Later renders in every case.

Deviations from the issue text

  • Paths. The crate split has landed, so the Rust file is packages/desktop-app/app-lib/src/update_check.rs and the tests run with -p nodespace-app-lib (the issue says src-tauri / nodespace-app).
  • Extra tests. Beyond the four Rust tests the issue names, I added one serialization test (download_url_serializes_as_a_key_that_is_null_when_absent) so the wire shape the frontend reads is pinned. On the frontend, beyond the two store tests and the two banner assertions the issue names: a store test that a payload omitting download_url counts as none (the issue's "missing field is null" risk note), one that a later payload without a URL clears an earlier one, a banner click test that Download opens the named URL, and a banner test that nothing renders when no update is available.
  • One comment corrected. check_for_update said "the comparison and the surfaced banner are identical" for both sources. That is no longer true, so it now says only the download location differs. No Pro wording added.

Ratchet (scripts/check-pro-boundary.ts)

Rebased onto main with the ratchet in it. Change vs origin/main: proWording 294 -> 293 (-1, the deleted RELEASES_URL comment "both free and Pro releases are published here"). No other marker moves, and no added line carries a marker. I lowered BASELINES.proWording to 293. I did not touch cloudSyncHooks: the check reports it at 0 against a baseline of 4, but that drop comes from an earlier merge, not from this change, so tightening it here would only risk a merge-queue conflict with whichever PR does it. No raise class applies.

Verification

  • cargo clippy -p nodespace-app-lib --all-targets -- -D warnings -D clippy::unused-async: clean.
  • cargo test -p nodespace-app-lib --lib update_check: 14 passed.
  • bun run --cwd packages/desktop-app test src/tests/stores/update-status.test.ts src/tests/components/update-banner.test.ts: 14 passed.
  • bun run --cwd packages/desktop-app quality:fix (eslint, design tokens, svelte-check): 0 errors, 0 warnings.
  • bun run scripts/check-pro-boundary.ts: passes (proWording 293 / 293).
  • bun run test:changed (this diff against main): frontend 5363 passed, scripts 969 passed, browser 136 passed, Rust workspace 4100 passed plus 237 app-lib unit tests passed.
  • rg -n -F -e RELEASES_URL -e 'both free and Pro' packages/desktop-app/src: no matches.

Mutation checks (fix reverted, new test confirmed to fail)

Frontend: banner always renders Download (banner test fails); download() without the null guard (2 store tests fail); apply without ?? null (omitted-field test fails); apply never sets downloadUrl (3 store tests fail); download() opens a hard-coded URL (store test and banner click test fail); banner hides Later when there is no URL (banner test fails).
Rust (each fails the named tests, then the file is restored):

  • no-update arm keeps the source URL: no_update_carries_no_download_url_even_when_the_source_has_one
  • update arm drops the URL: an_update_carries_its_sources_download_url, download_url_serializes_as_a_key_that_is_null_when_absent
  • no_update sets a URL: no_update_status_is_current_only, no_update_carries_no_download_url_even_when_the_source_has_one, download_url_serializes_as_a_key_that_is_null_when_absent
  • serde skips a None URL: download_url_serializes_as_a_key_that_is_null_when_absent
  • update arm falls back to the releases page when the source names none: an_update_from_a_source_without_a_download_url_has_none
    Not unit-testable: which URL check_for_update passes on each branch. That is the thin network shell around status_from and is unchanged in shape.

Risks

  • Both ends of the payload change in this PR, and the store treats a missing field as null.
  • A build that takes the non-public branch loses its Download button until its source supplies a URL. That is intended by the issue.
  • Rollback: revert this PR.

🤖 Generated with Claude Code

@mstomar125

Copy link
Copy Markdown
Contributor Author

Pragmatic code review — Initial Review (medium effort)

Independent reviewer agent (read-only, ran only the two frontend test files; no cargo per shared-machine constraint). Reviewed at head 52cdbc8b.

Recommendation: APPROVE (no critical or important findings; four optional suggestions).

Requirements check (issue #3319)

  • ✅ UpdateStatus serializes download_url (no skip_serializing_if, so None is null); the URL is set only on the update_available arm of status_from; the startup event passes the whole struct through, so the field reaches the frontend.
  • ✅ Non-public branch returns download_url: null (check_for_update, inspection only: the network shell is not unit-testable).
  • ✅ rg -F -e RELEASES_URL -e 'both free and Pro' returns nothing; no stale reference, mock, e2e seam or in-repo doc left on the old payload shape.
  • ✅ Free app still opens github.com/NodeSpaceAI/nodespace-core/releases/latest (RELEASES_PAGE_URL is character-identical to the deleted constant; not pinned by a test, see suggestion 2).
  • ✅ New and updated tests pass (reviewer's run: 2 files, 14 tests). Clippy, svelte-check and cargo were not run by the reviewer; the author's results are in the PR description.
  • ✅ Ratchet: proWording 294 -> 293 recounted on the changed files at origin/main vs HEAD (only the deleted store comment moves); every other marker unchanged; no added line carries a marker or an issue reference. Lowering only proWording and leaving cloudSyncHooks (already 0 at origin/main, not caused by this PR) is sound: the one-comment-per-baseline layout exists so PRs touching different markers do not conflict.
  • ✅ All Scope bullets (Rust, store, banner, store tests, new banner test) present. Deviations (crate-split paths, additive tests, lowering only proWording) are justified and disclosed.

Findings

🔴 Critical: none.
🟡 Important: none.

🟢 Suggestions

  1. 📁 packages/desktop-app/src/lib/stores/update-status.svelte.ts:67-70, 114-120, packages/desktop-app/src/lib/components/update-banner.svelte:12-19. The URL is now backend data and openUrl throws on anything that is not http(s)://; onDownload has try/finally but no catch, so a malformed or empty URL becomes an unhandled promise rejection with no feedback (the button still resets because of the finally). Unreachable today (only producer is a hard-coded https:// constant), reachable once another source supplies the URL. Principle: validate at the trust boundary where the value stops being a constant. Not a vulnerability: openUrl already restricts the scheme.
  2. Nit: 📁 update_check.rs:146-150. The public-branch-to-RELEASES_PAGE_URL pairing and the constant's value are untested (disclosed in the PR); a later change to check_for_update_with makes it unit-testable.
  3. Nit: 📁 update-status.svelte.ts:67-70. canDownload is not gated on available. Rust guarantees download_url is Some only on an update, the banner renders Download only inside showBanner, and apply() overwrites downloadUrl on every payload, so no reachable state shows Download while download() no-ops. Optional one-line enforcement.
  4. Nit: 📁 update-banner.test.ts:70-78. "renders nothing when no update is available" asserts on role status; it pins pre-existing behavior, harmless.

Verified independently by the reviewer

  • Ran vitest on the two files: 14 passed (store 10, banner 4).
  • Read the full diff, the final store and banner, external-links.ts, the lib.rs emit path and emit_routed; confirmed serde behavior and that serde_json is a regular dependency of app-lib.
  • Recounted the ratchet on all changed files at origin/main vs HEAD; confirmed cloudSyncHooks is 0 at origin/main.
  • Repo-wide search for the old constant, the old comment, the payload names and the banner: nothing stale.
  • Observation: vitest mocks the Svelte runes, so the tests cannot prove $state reactivity of canDownload; it is a getter over $state used in the template exactly like the existing showBanner, so low risk.

@mstomar125 mstomar125 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated pragmatic-code-review: APPROVE (posted as a comment, since GitHub blocks self-approval). Full findings in the review comment above.

@mstomar125
mstomar125 force-pushed the issue-3319-update-download-url branch 2 times, most recently from b46be96 to 80257ff Compare September 30, 2026 11:22
@mstomar125

Copy link
Copy Markdown
Contributor Author

Address-review summary

Reviewed head was 52cdbc8b (APPROVE, no critical or important findings). Current head is 80257ff9.

Addressed (1 of 4)

  • Suggestion 1 (update-status.svelte.ts, download()): the download location is now data from the update source and openUrl throws on anything that is not http(s)://, so a bad location would have been an unhandled rejection from the Download click. download() now catches that and logs a warning, like the neighbouring dismiss() and init() do. New test: "download logs instead of throwing when the download location cannot be opened". Mutation check: removing the try/catch makes exactly that test fail; restored.

Skipped (3 of 4), with reasons

  • Suggestion 2 (constant and branch pairing untested in check_for_update): a test asserting a constant equals its own literal is a tautology, and the branch is the thin network shell. Revisit when a later change extracts check_for_update_with, which makes the pairing unit-testable.
  • Suggestion 3 (gate canDownload on available): Rust guarantees download_url is Some only on a real update, the banner renders Download only inside showBanner, and apply() overwrites downloadUrl on every payload, so no reachable state disagrees. Duplicating the invariant in the frontend adds a second place to keep in sync. Revisit if a second producer of this payload appears.
  • Suggestion 4 (banner test asserts on role status): pins pre-existing behavior and is harmless.

Other changes since the review

  • Two rebases onto main (AppExtensions, then the extension contribution contract). The second conflicted on the proWording line of BASELINES: main had lowered the ceiling to 282, so the resolution takes main's value and applies this PR's -1. Running bun run scripts/check-pro-boundary.ts on the merged tree reports proWording 281 against a ceiling of 282, so the baseline is now 281; check passes at 281 / 281.
  • Any other PR that lowers proWording will conflict on that one line. The resolution is mechanical: take main's ceiling, run the check, set the ceiling to the printed count.

Verification on the pre-conflict rebased head (b46be96c)

bun run test:changed passed: frontend 5364, scripts 969, browser 136, Rust workspace 4100, app-lib units 246 (all 14 update_check tests included). quality:fix clean. The re-run on the final head is in progress.

Re-Review Decision

Decision: NO RE-REVIEW NEEDED

Rationale: the only code change since the approved review is a four-line try/catch with a log call inside download(), plus one mutation-verified test. The rest is mechanical rebase work; the one conflict was a single ceiling number, resolved from the checker's own printed count.

mstomar125 and others added 3 commits September 30, 2026 13:40
The update banner's Download button opened a hard-coded releases page
whatever source found the update. The Rust UpdateStatus now carries
download_url, set by the source that found the update (null when there is
no update or the source names no location), and the banner opens that URL
and hides Download when there is none. RELEASES_URL is deleted.

- update_check.rs: RELEASES_PAGE_URL for the public source, download_url on
  UpdateStatus, status_from() holding the version comparison.
- update-status store: downloadUrl state, canDownload getter, download()
  is a no-op with a warning when there is no URL.
- update-banner: Download only when canDownload; Later always.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…pened

The download location is now data from the update source, and openUrl
throws on anything that is not http(s). download() catches that and logs a
warning, so a bad location no longer becomes an unhandled rejection from the
banner's Download click.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@mstomar125
mstomar125 force-pushed the issue-3319-update-download-url branch from 80257ff to 1b4f2b4 Compare September 30, 2026 11:40
@mstomar125
mstomar125 merged commit 1a0f437 into main Sep 30, 2026
@mstomar125
mstomar125 deleted the issue-3319-update-download-url branch September 30, 2026 11:40
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.

Carry the download URL in the update-check payload instead of a hardcoded releases page

1 participant