Skip to content

The shell folder caches every game's framework, and Settings names it (#398) - #399

Merged
1 commit merged into
mainfrom
feat/shell-framework-mirror
Nov 1, 2026
Merged

1 commit merged into
mainfrom
feat/shell-framework-mirror

Conversation

@LNPANDY

@LNPANDY LNPANDY commented Nov 1, 2026

Copy link
Copy Markdown
Owner

Fix or feature

  • Feature

What and why

Implements #398. A game lived in the shell only as long as its build folder existed: dropMissing dropped it once the framework was gone, and the recovery was a full rebuild (hours for a big game, shader cache notwithstanding).

  • The build mirrors each framework into NX2Apple-shell/frameworks/ after it succeeds — a hard link when the build folder sits on the same volume (zero extra space), a copy otherwise. A rebuilt game re-mirrors over the old link.
  • dropMissing falls back to the mirror, and the next install re-embeds from it, rewriting the library entry's path — a deleted build folder no longer removes a game from the shell.
  • Settings → Build tools gains the cache row: the name (缓存文件 / Cache files), the folder path beneath it, an Open folder button at the right, and a caption saying what lives there and what deleting it costs — the wording the owner specified.
  • The banner question from the issue resolved while implementing: banners are already in two places (inside each framework and the Mac's ArtworkStore cache), so no re-scraping is ever needed.

Checked

  • Tests: new ShellMirrorTests (link → mirror exists → drop-fallback rewrites the path → without a mirror the game drops); the full suite passes; the language suites pass (the l10n tests caught my missing de/sv/fr entries for the new keys — added, German without a semicolon).
  • Visual QA: the cache row reads as specified; the mirror is filesystem-level.
  • Run on a device or Mac: built on this Mac; the recovery path needs a device test — delete a game's build folder, install another game, and the deleted game should stay in the shell and play from the mirrored framework.

…#398)

A game lived in the shell only as long as its build folder existed: dropMissing dropped it once the framework was gone, and the recovery was a full rebuild. The build now mirrors each framework into the shell folder (a hard link on one volume, a copy across), dropMissing falls back to the mirror, and the next install re-embeds from it — a deleted build folder no longer removes a game. Settings → Build tools gains the cache row the owner asked for: the name, the folder path, an Open folder button, and a caption saying what lives there and what deleting it costs. Hard-link and drop-fallback behaviours are tested (ShellMirrorTests).
@github-actions github-actions Bot added launcher The NX2Apple launcher app windows Windows (the Qt front end) labels Nov 1, 2026
@LNPANDY LNPANDY closed this pull request by merging all changes into main in 7293d52 Nov 1, 2026
@LNPANDY

LNPANDY commented Nov 1, 2026

Copy link
Copy Markdown
Owner Author

@v0lumehi two PRs for your design review when you are up, both from the owner's rc5 test:

The owner also asked for the shell's framework recovery from the device to be considered — the issue (#398) has the analysis; the mirror approach won because pulling GBs from a device is the worse experience.

@LNPANDY

LNPANDY commented Nov 1, 2026

Copy link
Copy Markdown
Owner Author

One interaction to settle with this: #232 (delete a game's build folder after a successful build, with a setting) and this mirror are the same storage decision seen from two sides. If #232's deletion runs while the mirror is the only other copy, the mirror becomes the single point of failure — and if #232 deletes before the mirror is written, a crashed build loses the framework entirely. Proposals:

  1. Order matters: mirror first, then (if the setting is on) delete the build folder.
  2. The delete setting should refuse to run when the mirror is missing or incomplete — it must never be the step that leaves a game with no framework anywhere.
  3. Direction for you to call: with the mirror in place, is Remove a game's build folder after a successful build, with a setting to keep it #232 even needed as a deletion? A build folder is mostly shader and extract caches; the mirror + a much smaller cleanup might make the whole setting obsolete.

Please also review #400 (the shell settings page, merged) — it touches the launcher/game priority chain your GameSettingsStore defines.

@v0lumehi

v0lumehi commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator

@LNPANDY I reviewed the mirror. The idea is right. Four changes before we build on it, and my answer to the two questions.

The mirror should be an APFS clone, not a hard link

A hard link shares the file with the build folder. A rebuild that writes the framework in place changes the mirror too, so a failed rebuild breaks both copies. FileManager.copyItem clones on APFS. It also costs no space, and later writes to the build folder do not reach it. I checked both on this Mac with a 300 MB file: the clone used 0 MB, a write into the original showed up in the hard link and not in the clone. On another volume copyItem makes a real copy, as now. So mirrorFramework becomes removeItem plus copyItem, and the linkItem branch goes away.

The mirror is the primary copy

Yes. shell.json should always point at NX2Apple-shell/frameworks/. The build folder is the build's work area. Then dropMissing checks one path, and the second loop in ShellInstaller that rewrites paths goes away.

The installer makes the mirror

Today only a new build mirrors, in the BuildModel callback. Games built before this change have no mirror, and deleting their build folder still drops them. If ShellInstaller mirrors every game whose framework it finds, before dropMissing, every game gets a mirror at the next install. The build callback then needs no mirror call.

A failed mirror is reported

try? ShellInstall.mirrorFramework(...) hides a full disk. The player then thinks the game is safe. The installer should log the failure and keep the game on its build folder path.

Smaller points

  • The mirror call computes the shell root from basePath only, while installShell uses outDir when it is set. resolveRoot saves the first answer, so for a new user the mirror call now decides where the shell folder lands. One helper for the root fixes that.
  • The English, Swedish and French texts of shellCache.note contain a semicolon. The German one is fine.

#232

#232 stays a deletion. The build folder holds gigabytes besides the framework (the extracted game, the intermediates), and the mirror makes deleting it safe. I will change #232 so it deletes only after the installer has a mirror of that game, and refuses to delete when the mirror is missing. Then the order you describe holds and a crash between build and mirror keeps the build folder.

@v0lumehi
v0lumehi deleted the feat/shell-framework-mirror 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

launcher The NX2Apple launcher app windows Windows (the Qt front end)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants