Repository navigation
Add AppUpdateStore as the reference store, appVersion moves with it (#387, step 6) - #462
Merged
Merged
Conversation
3 of 6 tasks
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
force-pushed
the
v0lumehi/app-update-store
branch
from
November 2, 2026 12:47
32d6e35 to
a96d6b3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #460 (stack #459), retarget to main after the ones below merge.
Part of #387, step 6.
Fix or feature
This is a refactor with no change in behavior, so neither box fits.
What and why
Step 6 of #387:
AppUpdateStoreis the first store and the reference for the others. It owns the release check, the staged update, the update sheet, the uninstall plan andappVersion. It is@MainActor, anObservableObject, and owns its own@Publishedstate. It gets aProcessRunner(from step 5), aReleaseSource, theLocalizerand the facts of its environment throughinit.AppUpdateStorelives inNXModel. A check or a staging runs as aTaskon 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 callsappWillTerminate()from AppKit's quit notification.AppUpdateinNXCorenow holds the pure logic that was inBuildModel:release(fromJSON:),check(latest:current:)(found, up to date, no asset, unreachable),isNewer,assetNames,stageandStageFailure. The quarantine flag is cleared through aProcessRunner, soAppUpdateno longer starts aProcessfor xattr.relaunchstill starts its detached shell itself, and the store gets it as a closure.ReleaseSourceis the second service (a protocol,GitHubReleasesis the real one): the latest release and the download.Uninstallmoves toNXCore, because the store holds its plan. The confirm button of the dialog is nowconfirmUninstall()in the store.BuildModelcreates the store and loses the whole self-update section.ContentView.swiftshrinks from 2763 to 2494 lines andLauncherView.swiftfrom 973 to 967.SourceSizeTestsis lowered.UpdateSheet) observe the store and notBuildModel.frontend/ARCHITECTURE.mddocuments the store pattern (declaration, state,init, AppKit as closures, async work, tests, wiring) so the next store copies it.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.appVersionmovedstatic let appVersionmoved fromBuildModelinContentView.swifttofrontend/Sources/NXModel/AppUpdateStore.swift. I grepped the repository and followed every reader:.github/workflows/build-mac-app.yml(thesedand its error message and comment).github/workflows/sync-upstream.yml(thesedfor the experimental engine version)tools/try-local(app_version) andtools/tests/test_try_local.pyRELEASING.mdUpdateSheet,EngineUpdateModel,Diagnosticsand the dependency check text inBuildModelThe issue named lines 187, 191 and 9. They are lines 202, 191 and 10 now. I ran the workflow's
sedagainst the new file and it gives1.0.1.tools/try-local --print-versiongives1.0.1-local.To keep a later move from breaking the release build, the new
tools/tests/test_app_version.pychecks 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 intests.yml.Tests
NXModelTeststarget (linksNXModelandNXCore, no SwiftUI) withAppUpdateStoreTests: 24 tests with a fakeProcessRunnerand a fakeReleaseSource. 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.AppUpdateTestsandUninstallTestsmoved toNXCoreTests. The two tests that usedBuildModelbecame store tests.@LNPANDY, this one changes how the launcher is built, not how it works or looks.
Checked
cd frontend && swift testin full, 768 tests (24 inNXModelTests, 98 inNXCoreTests, 646 inNX2AppleTests, 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/testspasses (148 tests, includingtest_app_version.pyandtest_try_local.py). I ranpython3 tools/engine.py syncfirst.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
dm/,scripts/,docs/,ref/) is added to the repository