Skip to content

The launcher walks a new player through setup with the real detection and installs (guided first run) - #120

Merged
LNPANDY merged 8 commits into
LNPANDY:mainfrom
v0lumehi:onboarding
Oct 28, 2026
Merged

LNPANDY merged 8 commits into
LNPANDY:mainfrom
v0lumehi:onboarding

Conversation

@v0lumehi

@v0lumehi v0lumehi commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Builds on #119.

New players now get a guided first-run setup instead of the eight-row tool panel. It is the view from #119, driven by a real LiveOnboardingDriver over the launcher's own BuildModel and GameLibrary.

What a player sees:

  • On launch the setup appears when it is not marked done (onboarding.completed) and setup is incomplete (a tool missing, no keys known, or no games folder). A player whose setup is already complete never sees it and it is marked done silently.
  • Settings has a "Run setup again" row (English and Chinese).
  • Welcome shows the free space on the home volume against an estimated need (Xcode if missing, the Metal Toolchain, the iOS platform if chosen, tools and caches; the estimate is documented in neededGB).
  • Platform: the choice is stored. Only iPhone or both adds the iOS platform download. A Mac-only choice no longer requires the iOS SDK for Mac builds (the xcode row used to run xcrun --sdk iphoneos); with no stored choice, or builds aimed at an iPhone, the requirement is as before (BuildModel.needsIOSPlatform).
  • Xcode: when it is missing, "Get Xcode" opens macappstore://apps.apple.com/app/id497799835 and /Applications is polled every three seconds for an Xcode until the step is left. When Xcode needs setup ("Finish setup"), there is one administrator prompt, then the Metal Toolchain and (iPhone or both) the iOS platform download without it, with progress parsed from xcodebuild output. Failures become a short localized message with the command output under details. A cancelled prompt goes back to the button.
  • In the background, from the moment the platform is chosen: Python, .NET, then Homebrew and the formulas, through BuildModel.installDep, one at a time. Homebrew and the formulas wait until Xcode is ready.
  • Keys are searched in ~/.switch/prod.keys, ~/Downloads/prod.keys and the games folder, checked by KeyCheck, and only the path goes into the same keys slot as the Builds page. After the games are found, the keys are checked against the game and a mismatch sends the player back with the reason.
  • Games: the chosen folder fills the same slots and library folder as the main UI, using the existing scan and artwork.
  • "Set up later" stores the step and choices; the next launch resumes there and revalidates (back to Xcode if it no longer holds).

The administrator prompt runs one script (OnboardingAdmin.source, passed to osascript as an argument), with the path quoted by AppleScript's quoted form of:

do shell script "/usr/bin/xcode-select -s " & quoted form of "<Xcode.app>/Contents/Developer" & " && /usr/bin/xcodebuild -license accept && /usr/bin/xcodebuild -runFirstLaunch" with administrator privileges

Testing on a set-up Mac: NSPB_ONBOARDING_FORCE=1 shows the real flow with real detection. It writes nothing (completed flag, step, platform, build target) until the player finishes or picks Set up later, and installs nothing until an install action is pressed (documented in frontend/Onboarding.md).

Changes to existing code: the xcode row's iOS requirement and the shared Xcode download commands in ContentView.swift, updateSlot no longer private, the Settings row, ContentView's onRunSetup parameter, and the window's root view (RootView holds the model and library for both).

Tests: LiveOnboardingDriverTests (27) run over injected fakes, no xcodebuild, sudo or network: state mapping from the probe, the platform-dependent iOS requirement, resume and revalidation, a complete setup never shown, admin cancel back to needsSetup, one admin call then the downloads, queued installs and failures, keys and games slots. swift build -c release and swift test pass (202 tests).

Not verified on a fresh Mac: the real flow was not run (no admin prompt, xcode-select, App Store or installs). In particular unverified:

  • the App Store's partially downloaded Xcode folder against the poll (it waits for xcodebuild -version to exit 0; tested with stub tools only);
  • the exact xcodebuild -downloadComponent / -downloadPlatform progress output (the parser takes the last percentage, else the bar stays indeterminate);
  • the admin prompt itself: it runs /usr/bin/osascript -e <script> as a child process off the main thread, and the exit status and stderr map to ok, cancelled (-128) or failed (mapping tested);
  • on a Mac without Python 3.12, the Python step fails with its output under details (the existing venv install needs a base interpreter); bundling Python removes that.

Smoke test on a set-up Mac: the app launches and marks setup done without showing it.

Screenshots

Settings has the new "Run setup again" row (English; the Xcode step uses the same wording and layout as the preview in #119, so it is not repeated here):

@v0lumehi
v0lumehi force-pushed the onboarding branch 3 times, most recently from 2b91728 to 38a61e1 Compare October 28, 2026 12:27
v0lumehi added a commit to v0lumehi/NX2Apple that referenced this pull request Oct 28, 2026
…sk figures in the mock

The release workflow copies only the executable into the .app, so a resource bundle
would be missing there and Bundle.module would abort. The welcome icon is now the
app's own icon (a symbol under swift run), and the default Welcome state carries no
invented free/needed GB.
…ze across states

The welcome header with the icon and name is gone (with its helper and string). The two
Xcode cards are equally wide and share one fixed height for every state, scrolling inside
instead of growing; the background note uses the card's full width. The platform cards
align their titles, and the keys and games cards keep a minimum height between states.
… footer

The block sits in the middle of the space and starts at the top and scrolls when it is
taller than the window. The disk warning keeps its place on Welcome so the block does
not shift.
… and installs

The first-run flow now runs over BuildModel and GameLibrary through LiveOnboardingDriver:
Xcode (one administrator prompt, then the Metal Toolchain and, for iPhone, the iOS platform),
the tools queued behind it, the keys and the games folder. A player whose setup is complete
never sees it, Settings can run it again, and Set up later resumes where it stopped.
A Mac-only choice no longer requires the iOS SDK for Mac builds.
…and Xcode counts as installed only when xcodebuild works

NSAppleScript is not thread-safe, so the script now goes to /usr/bin/osascript as one
argument and its exit status and stderr give the result (-128 is a cancelled prompt).
The App Store creates Xcode.app while it is still downloading, so the poll waits for
xcodebuild -version to exit 0 and the step stays on downloading until then.
…leaving a trace

The forced run starts from Welcome with real detection, keeps its preference writes
(step, platform, target, completed) in memory until the player finishes or sets up later,
and installs nothing until an install action is pressed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants