Skip to content

Move the engine selection, the engine sync and the engine failure into EngineSyncStore (#387) - #467

Merged
v0lumehi merged 3 commits into
v0lumehi/repo-storefrom
v0lumehi/engine-sync-store
Nov 2, 2026
Merged

v0lumehi merged 3 commits into
v0lumehi/repo-storefrom
v0lumehi/engine-sync-store

Conversation

@v0lumehi

@v0lumehi v0lumehi commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

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

Part of #387, step 7 (engine sync).

Fix or feature

  • Fix
  • Feature

It is a step of the plan @LNPANDY and I agreed in #387. No change of behavior.

What and why

BuildModel still owned the engine: the selection of channel and engine, the sync of a checkout's engine/, the engine failure row and the engine switch of the release app. This PR moves them into EngineSyncStore in NXModel, the third store after AppUpdateStore and RepoStore, and follows the pattern in frontend/ARCHITECTURE.md.

  • EngineSyncStore is @MainActor and owns its @Published state: selection, busy, status, available, confirmingChannel, syncing and failure. It takes the Localizer, a ProcessRunner, the repository as a RepoLocation, the interpreter as a PythonLocation, the engine store, the network (EngineTransport) and UserDefaults through init.
  • PythonLocation is a new narrow protocol with pythonPath. BuildModel provides it today and the dependency store takes it over.
  • What reaches back into the model are closures: where the build reads its tools from (an installed engine tree), whether a build runs, whether the automatic update is on, and the log.
  • The sync (syncEngine, retrySync) keeps its rules: calls during a run wait and one more run follows, a current engine/ runs nothing and clears the row. The release app's work (prepareEngine, checkForUpdate, installAvailable, the channel switch, an engine that waits for the running build) moved as it was. The methods that start work return their Task, so a test awaits it.
  • RepoStore.didMove now starts the store's sync.
  • NXCore gets what the store needs: the stale check, the stamp key and the sync run of EngineLayout (from Engine.swift), EngineUpdater.swift (EngineChannel, EngineSelection, EngineUpdate, EngineInstaller, EngineTransport), EngineLayout.shaderChain (the body of BuildFolder.currentChain, which now calls it) and BuildFailureKind with BuildFailure (the failure row). The classifier stays in the app target.
  • Settings "Tools" (the engine rows and the channel alert), the sync banner, the failure row's Try again and the launcher's checks after a sync observe the store, not BuildModel.
  • Removed from the app target: Engine.swift (95 lines), EngineUpdateModel.swift (151) and EngineUpdater.swift (362, now 374 in NXCore with package access). ContentView.swift is 2228 lines (was 2265), and its limit in SourceSizeTests is lowered. LauncherView.swift is 967, as before.
  • EngineSyncStoreTests (15 tests, no SwiftUI) cover the sync with a fake runner and the release app's rules. FakeProcessRunner can now stream lines. EngineLayoutTests still runs a real script through the model.
  • The Qt hint test reads the failure kinds from BuildFailureKind.swift too, because the kinds moved there.

What stays in BuildModel and why

  • BuildModel forwards the store's objectWillChange to its own, as it does for RepoStore. canBuild and the build views read the engine's paths through the model, so they redraw as before. Goes with the build store.
  • startBuild waits for the sync and Diagnostics reads the selection, both through MainActor.assumeIsolated. They go with the build store.
  • pythonPath and the dependency list stay until the dependency store.
  • BuildModel is not @MainActor, so it reaches the store through MainActor.assumeIsolated.
  • tools/engine.py still names Engine.swift in a docstring. I did not touch tools/ in this PR.

All of this is in frontend/ARCHITECTURE.md.

Checked

  • Tests: cd frontend && swift test, four full runs (three by hand, one by the pre-push hook), 803 tests per run over the three bundles (NXModelTests 68, NXCoreTests 98, NX2AppleTests 637, 17 skipped as before), 0 failures. The step before had 791. The 12 more are the new store tests less the model tests that moved. No flaky test seen. The frontend-qt tests pass too.
  • Visual QA: not run. No view changed.
  • Run on a device or Mac: not run. I did not launch the app.

Screenshots

None, no visible change.

Scope

  • No engine file (dm/, scripts/, docs/, ref/) is added to the repository: a change there is a patch in patches/ (a commit in engine/, then tools/engine.py export, and tools/engine.py check passes), with its Upstream-Status
  • A fix to the engine or a game profile also goes to seedds/nxnative as a PR in parallel: this PR's patch says forwarded seedds/nxnative#..., or pending until that PR is open
  • A change to a launcher view has before and after screenshots above
  • 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 2, 2026
@v0lumehi v0lumehi added enhancement New feature or request launcher The NX2Apple launcher app mac Mac labels Nov 2, 2026
@github-actions github-actions Bot added documentation Improvements or additions to documentation windows Windows (the Qt front end) labels Nov 2, 2026
@v0lumehi
v0lumehi added this pull request to stack #459 November 2, 2026 00:45
fayh77 pushed a commit to fayh77/NX2Apple that referenced this pull request Nov 2, 2026
The app was compiled by Xcode 26.6 on macos-latest while the tests ran with 27.2. A closure that 27.2 accepts failed only in the build job (LNPANDY#467). Both now use the same Xcode.
@v0lumehi
v0lumehi force-pushed the v0lumehi/engine-sync-store branch from 31ebd4e to 2f7305f Compare November 2, 2026 12:47
…6 compiles it (#387)

The closure expects Void and the single expression returned a Task. Xcode 27.2 accepts it, the Xcode of the build job reports conflicting arguments to generic parameter T.
@v0lumehi
v0lumehi force-pushed the v0lumehi/engine-sync-store branch from ee35f10 to 89cee41 Compare November 2, 2026 16:00
@v0lumehi
v0lumehi merged commit d9ae970 into main Nov 2, 2026
14 checks passed
@v0lumehi
v0lumehi deleted the v0lumehi/engine-sync-store branch November 2, 2026 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request launcher The NX2Apple launcher app mac Mac windows Windows (the Qt front end)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant