Skip to content

Move the repository out of BuildModel into a RepoStore (#387) - #466

Merged
v0lumehi merged 1 commit into
mainfrom
v0lumehi/repo-store
Nov 2, 2026
Merged

v0lumehi merged 1 commit into
mainfrom
v0lumehi/repo-store

Conversation

@v0lumehi

@v0lumehi v0lumehi commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

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

Part of #387, step 7 (repository).

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 repository: the path, the status line, the update check, the pull, the automatic update and the adoption of a ZIP copy. This PR moves them into RepoStore in NXModel, the second store after AppUpdateStore, and follows the pattern in frontend/ARCHITECTURE.md.

  • RepoStore is @MainActor, owns its @Published state (path, busy, status, behind, autoUpdate, autoPulled, autoAdopted) and takes GitCheckout, Localizer and UserDefaults through init. What reaches back into the model are four closures: whether a build runs, whether this is a release app, the build log, and didMove (the engine sync after a clone, a pull or an adoption).
  • Each action checks its own conditions and returns its Task, so a test awaits it. The git work blocks, so it runs off the main actor.
  • RepoLocation is the narrow protocol (path, isRepo, isGit) for stores that only need to know where the repository is. No store uses it yet.
  • NXCore gets what the store needs: RepoLayout (is it a repository, the tools a build needs, which checkout to use at start) and the file-system part of EngineLayout (marker, root, isCheckout, hasEngineTool). The stale check and the sync stay in the app target.
  • Settings "Tools", the library's activity line and the checks that follow a change of the repository observe the store, not BuildModel.
  • BuildModel lost its repository state and 230 lines. ContentView.swift is 2265 lines (was 2494), and its limit in SourceSizeTests is lowered. LauncherView.swift is 967, as before.

What stays in BuildModel and why

  • repoPath, repoOK and repoIsGit are forwarders to the store. The build code (start, archive, install, diagnostics, the engine switch of the release app) reads the path, and it is not a store yet.
  • BuildModel forwards the store's objectWillChange to its own. canBuild and the build views read the repository through the model, so they redraw as before. Both go with the build store.
  • syncEngine and its state read the path and pythonPath. They go to the engine sync store.
  • BuildModel is not @MainActor, so it reaches the store through MainActor.assumeIsolated, as it does for AppUpdateStore.

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), each 640 tests, 17 skipped as before, 0 failures. No flaky test seen. The new tests of RepoStoreTests run with a fake GitCheckout, without SwiftUI. RepoFlowFakeTests moved there. RepoAutoUpdateTests and RepoToolsTests still run the real git against local repositories, through the model.
  • 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 the documentation Improvements or additions to documentation label Nov 2, 2026
@v0lumehi
v0lumehi added this pull request to stack #459 November 2, 2026 00:21
@v0lumehi
v0lumehi force-pushed the v0lumehi/repo-store branch from 724ccbc to b296227 Compare November 2, 2026 12:47
Base automatically changed from v0lumehi/app-update-store to main November 2, 2026 16:00
RepoStore (NXModel) owns the repository path, its status line, the update check, the pull, the automatic update and the adoption of a ZIP copy. RepoLayout and the file-system part of EngineLayout move to NXCore. Settings, the library's activity line and the launcher observe the store. RepoLocation is the narrow protocol for other stores.
@v0lumehi
v0lumehi force-pushed the v0lumehi/repo-store branch from 69612fe to 8b2248f Compare November 2, 2026 16:00
@v0lumehi
v0lumehi merged commit d9ae970 into main Nov 2, 2026
14 checks passed
@v0lumehi
v0lumehi deleted the v0lumehi/repo-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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant