Skip to content

Add AppUpdateStore as the reference store, appVersion moves with it (#387, step 6) - #462

Merged
v0lumehi merged 4 commits into
mainfrom
v0lumehi/app-update-store
Nov 2, 2026
Merged

v0lumehi merged 4 commits into
mainfrom
v0lumehi/app-update-store

Conversation

@v0lumehi

@v0lumehi v0lumehi commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #460 (stack #459), retarget to main after the ones below merge.

Part of #387, step 6.

Fix or feature

  • Fix
  • Feature

This is a refactor with no change in behavior, so neither box fits.

What and why

Step 6 of #387: AppUpdateStore is the first store and the reference for the others. It owns the release check, the staged update, the update sheet, the uninstall plan and appVersion. It is @MainActor, an ObservableObject, and owns its own @Published state. It gets a ProcessRunner (from step 5), a ReleaseSource, the Localizer and the facts of its environment through init.

  • AppUpdateStore lives in NXModel. A check or a staging runs as a Task on the main actor, and the method that starts it returns the task, so a test awaits it. What needs AppKit reaches it as closures (terminate, relaunch) and the app calls appWillTerminate() from AppKit's quit notification.
  • AppUpdate in NXCore now holds the pure logic that was in BuildModel: release(fromJSON:), check(latest:current:) (found, up to date, no asset, unreachable), isNewer, assetNames, stage and StageFailure. The quarantine flag is cleared through a ProcessRunner, so AppUpdate no longer starts a Process for xattr. relaunch still starts its detached shell itself, and the store gets it as a closure.
  • ReleaseSource is the second service (a protocol, GitHubReleases is the real one): the latest release and the download.
  • Uninstall moves to NXCore, because the store holds its plan. The confirm button of the dialog is now confirmUninstall() in the store.
  • BuildModel creates the store and loses the whole self-update section. ContentView.swift shrinks from 2763 to 2494 lines and LauncherView.swift from 973 to 967. SourceSizeTests is lowered.
  • The views that show the update (the top bar icon, the activity line, the uninstall dialog, the Settings section and UpdateSheet) observe the store and not BuildModel.
  • frontend/ARCHITECTURE.md documents the store pattern (declaration, state, init, AppKit as closures, async work, tests, wiring) so the next store copies it.
  • Small differences in how it runs: the check and the download use URLSession's async API, and the quit observer is now registered when the store is created and not when the first update is staged. appWillTerminate() still does nothing without a staged update.

appVersion moved

static let appVersion moved from BuildModel in ContentView.swift to frontend/Sources/NXModel/AppUpdateStore.swift. I grepped the repository and followed every reader:

  • .github/workflows/build-mac-app.yml (the sed and its error message and comment)
  • .github/workflows/sync-upstream.yml (the sed for the experimental engine version)
  • tools/try-local (app_version) and tools/tests/test_try_local.py
  • RELEASING.md
  • Swift readers: UpdateSheet, EngineUpdateModel, Diagnostics and the dependency check text in BuildModel

The issue named lines 187, 191 and 9. They are lines 202, 191 and 10 now. I ran the workflow's sed against the new file and it gives 1.0.1. tools/try-local --print-version gives 1.0.1-local.

To keep a later move from breaking the release build, the new tools/tests/test_app_version.py checks that exactly one Swift file holds the line, that every reader names a file with it, and that a new reader has to be added to its list. It is part of the tools tests in tests.yml.

Tests

  • New NXModelTests target (links NXModel and NXCore, no SwiftUI) with AppUpdateStoreTests: 24 tests with a fake ProcessRunner and a fake ReleaseSource. They cover the check outcomes, staging (digest, no digest, network failure, not a released copy), install, relaunch and quit, waiting for a build, the automatic switch and its saved value, and the uninstall.
  • AppUpdateTests and UninstallTests moved to NXCoreTests. The two tests that used BuildModel became store tests.

@LNPANDY, this one changes how the launcher is built, not how it works or looks.

Checked

  • Tests: cd frontend && swift test in full, 768 tests (24 in NXModelTests, 98 in NXCoreTests, 646 in NX2AppleTests, 17 skipped as before). Four runs (three by hand and the pre-push hook run), all with 0 failures and no flaky test. python3 -m unittest discover tools/tests passes (148 tests, including test_app_version.py and test_try_local.py). I ran python3 tools/engine.py sync first.
  • Visual QA: not needed, no visible change. The existing capture tests that build the Settings page and the activity line with an update found and staged still pass on the store.
  • Run on a device or Mac: not run by hand. I did not start the app. The real download and install path (GitHubReleases, the relaunch and the quit hook) is not covered by a test, because it needs the network and the running app. The check, staging, install and relaunch logic is covered with fakes.

Screenshots

None, no visible change.

Scope

  • No engine file (dm/, scripts/, docs/, ref/) is added to the repository
  • No change to the engine or a game profile
  • A change to a launcher view has before and after screenshots above: not needed, nothing visible changes
  • No keys, game files or data extracted from a game in the change or the attachments

@v0lumehi v0lumehi added this to the v1.0.2 milestone Nov 1, 2026
@v0lumehi v0lumehi added launcher The NX2Apple launcher app mac Mac labels Nov 1, 2026
@github-actions github-actions Bot added documentation Improvements or additions to documentation ci Workflows and repository tooling labels Nov 1, 2026
@v0lumehi
v0lumehi added this pull request to stack #459 November 1, 2026 23:29
TitleID, GameInputs, BuildProgress and Toolchain (with Dep, Stage and StepState) are
value types and static functions in NXCore now. NXCoreTests tests them without SwiftUI.
ProcessRunner is the place that starts a process: capture, stream and start (with a process group). ProcessGroups moves the group tracking out of BuildModel. GitCheckout holds clone, fetch, pull, behind count, the automatic pull and the adoption of a ZIP copy, GitRules the pure decisions. BuildModel takes both in its initializer. Toolchain, Diagnostics, OlderTools, Uninstall and the update staging take a runner or a checkout as a parameter.
…387)

AppUpdateStore (NXModel) owns the release check, the staged update, the update sheet, the uninstall plan and appVersion. It is @mainactor, gets a ProcessRunner and a ReleaseSource through init, and has tests with fakes for both, without SwiftUI.

Release parsing, the version compare and the staging of a download move into AppUpdate (NXCore). ReleaseSource is the second service, Uninstall moves to NXCore, and the quarantine flag is cleared through the runner.

appVersion moves with the store to NXModel/AppUpdateStore.swift. build-mac-app.yml, sync-upstream.yml, tools/try-local, its test and RELEASING.md read it there, and tools/tests/test_app_version.py fails when a reader names a file without the line. ARCHITECTURE.md describes the store pattern.
@v0lumehi
v0lumehi force-pushed the v0lumehi/app-update-store branch from 32d6e35 to a96d6b3 Compare November 2, 2026 12:47
Base automatically changed from v0lumehi/process-runner to main November 2, 2026 15:31
@v0lumehi
v0lumehi merged commit 6b8ceb2 into main Nov 2, 2026
15 checks passed
@v0lumehi
v0lumehi deleted the v0lumehi/app-update-store branch November 2, 2026 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Workflows and repository tooling documentation Improvements or additions to documentation launcher The NX2Apple launcher app mac Mac

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant