Documentation comes from this release commit, without inheriting newer content. Commit: 63ea8c2b3d.
Feature — Onboarding
A one-time 6-step intro carousel shown to new users. Completion is persisted in MMKV so returning users skip straight to sign-in.
Designs live in Figma file AuNNzmm0PbYXoZ0g3forCY, frames 27:13040 / 27:13048 / 27:13056 / 27:13061 / 27:13385 / 27:13437.
Files
Route: app/(onboarding)/index.tsx re-exports OnboardingScreen.
Slides
Visual stack
Film
The single onboarding screen opens on a film (OnboardingIntroFilm, played through the app's shared VideoPlayback, an expo-video VideoView; the ad backfill uses the same component). The video paywall (script 3) plays the same film through the same component; it only shows on the popular catalogue, so there it is always ShowOff. The pick is onboardingFilm, and useOnboardingVideoSource resolves it to the bundled file for both surfaces.
The films ship in the app only: there is no build switch and no Remote Config key for them. ShowOff was kept after the owner tried it against a RushE film as two TestFlight builds; the RushE film and the onboarding_video key (which could replace a film with a URL) are gone. A console that still serves onboarding_video is ignored like any unknown key.
Encoding. The shipped files are 1080², 30 fps, HEVC tagged hvc1 (the tag AVPlayer plays), 3.0 MB for the two. The films were shot in a dark room, so the encode carries a 1.25× gain on each colour channel (RGB, so blacks stay black and the foot still dissolves into the page without a seam); nothing is filtered at runtime. The masters (1080², 60 fps) are gitignored under src/assets/onboarding/Onboarding_video/; ShowOff's is the cut delivered on 22/10/2026 (HEVC, ~2.8 Mbps), the public-domain one H.264 at ~18 Mbps. Encode from them, never from a shipped file (a second HEVC pass costs quality):
After adding, removing or renaming a film, run bun run assets:sync (the asset manifest is generated and gitignored).
The film fills about two thirds of a phone, ~1,800 px tall on a 3x screen. The earlier 720², ~0.5 Mbps encode was stretched 2.5× and its text and badges smeared; H.264 at the new quality would weigh about twice as much. onboarding-film-assets.test.ts holds each file to hvc1 at 1080². Android support for HEVC varies by device: encode H.264 (-c:v libx264 -tune film -crf 23) if these files ship there.
Title segments
Slides mix solid-white runs with gradient runs on the same line. Modeled as
title: TitleLines = readonly (readonly TitleSegment[])[]:
OnboardingTitle flattens this into a column of <TextOutlineRun> lines —
each line renders all its segments into a single Skia canvas, side-by-side,
with per-segment gradients. Consolidating onto one canvas per line (rather
than one per segment) cuts the per-slide Skia surface count by ~3× without
changing the rendered output. See <TextOutlineRun> in
src/components/TextOutline.tsx.
State
MMKV key: onboarding. Only hasCompleted is persisted —
shouldShowPostOnboardingPaywall is intentionally in-memory only because it
exists solely to bridge the final onboarding tap to the post-onboarding
paywall. A cold relaunch starts fresh.
Flow
During FTUE, the tutorial gameplay song and the pick-song Get choice are permanently unlocked as "promo" library entitlements (no rewarded ad). See songs.md.
The onboarding_script variants shape the tutorial's run after the welcome (popular catalogue; a public build always plays Twinkle, then the picker).
From the welcome or the drills to the song (goToTutorialSong): script 4's welcome and scripts 1–3's training drills (finished or skipped) go straight to the choose screen on a choosing run, or to the song (tutorialSongRoute). A "Now you're ready to play your first masterpiece!" beat stood there for 1.5 s until the PO removed it (23/10/2026). The hand-off still sends its fn_tutorial_set, and waits for the run's MIDI as the beat's time let it, at most TUTORIAL_SONG_HANDOFF_MAX_WAIT_MS (1.5 s) — no wait once it has arrived, which on script 4 is long before the welcome is left.
The onboarding A/B test runs on onboarding_script and tutorial_song. The Firebase experiment sets both per group: the script (3 = the old training drills, 4 = the training merged into the first song) and the group's own tutorial_song (its three_songs; keep one_song, which builds on script 1 still read). Typical groups: baseline 3 with today's songs; var1–var3 4 with their songs. Script 4 is script 3 in everything else (the choose screen, the video paywall, the first-song paywall at the 4th song_end, onboardingScriptHasVideoPaywall).
- Default: an install the console names no script for walks
4. A value the app does not know (5,0) is dropped and the last one stands; the persisted config is the last-known-good, so a failed fetch keeps the console's last script. - Fixed per run: the run reads the script once (
getTutorialScript), so the welcome's training decision and the songs agree even if a fetch lands in between. - Reported: as the
onboarding_scriptuser property at launch. - Old builds: a build from before script 4 drops the value and walks its own default (script 1). Target the experiment at the new app version.
- Forced by the build:
EXPO_PUBLIC_RC_FORCE_ONBOARDING_SCRIPTmakes any build walk one script whatever the console says. No CI job sets it (ci-cd.md): TestFlight follows the experiment as the store build does, so a group's script and itstutorial_songalways arrive together. To keep a tester on one group, give their build number its own Remote Config condition above the experiment. In a development build,EXPO_PUBLIC_RC_ONBOARDING_SCRIPTin.env.localwins over both (dev-overrides.ts).
Every script reports its "get a song" step as fn_tutorial_get_song (song_id, song_name), so the scripts' funnels line up: script 1 on the picker's Get, scripts 2, 3 and 4 on the choose screen's Play, before the song starts (tutorialChoiceGetSongParams names the song by its catalog row, as the song's own events do).
No paywall reads Remote Config enableIAP: that flag only hides the one-off purchases (the No Ads package and single-song deals). Every script's paywalls — the one after the film, script 3's video paywall and its held-back first-song paywall — show whatever it says (paywalls-ignore-enable-iap.test.ts).
The choosing runs' result (TutorialSongResultScreen) is the Game Mode result (SessionResultOverlay, Play tab lit). It shows the excerpt's score, frozen at game over (tutorial-song-result.ts).
- Kept from Congrats:
song_result, the tracking prompt and script 3's video paywall. The last two happen on the run's first result only, after the reveal. - Not run here: interstitials, and the first-song and replay paywalls.
- No Replay: the action row has Song list and Next song only (
SessionResultOverlaywithoutonReplay); each tutorial song is played once. - Leaving: Song list and Next complete the tutorial. A suggestion rides out with the completion (
pendingPlay), andTutorialExitHostopens it once the app exists. A locked one plays its rewarded video first, as on the Game Mode result. A gameplay pick raises the rootPlayLaunchCoverfirst, so the Song List the app lands on (and the Game Mode result'sreplaceinto a next song / replay) never shows before gameplay:PlayScreenlowers it once its route has arrived (useScreenEntered), with a 4 s backstop. - Choosing the next song: the result's song cards carry no CTA. A tap selects one (the top card by default), and Next opens it — with the video glyph when it is ad-locked (songs.md).
- No Learn tab: Learn Mode opens after four finished songs, so a first-run player sees no toggle here — only the Play recommendations under "Recommended for You" (songs.md).
- Waits for tracking: every exit waits for the tracking answer.
- Relaunch: reaching the result ends the run for a relaunch. A player who quits the app on the result or under script 3's video paywall comes back to the song list, not the training. The result sets the tutorial store's persisted
reachedResult; the screen on view stays up, and the next cold start restores the tutorial as complete (restoreTutorialPersistedState).
On script 1 and public builds, a song's result is the Congrats celebration. The last song's celebration ends the run for a relaunch, as the choosing runs' result does: quitting there, or on the picker after it, comes back to the song list. It stays until the celebration has fully come in, then 1.5 s more (tutorialResultHoldMs). The choose screen has no close: the player picks one of its songs.
Song previews on both pickers. On "Choose your first song" and "New song available!" each cover is a preview button: a tap plays fifteen seconds of the song (the badge turns into the moving wave), and the songs also play one after another on their own, half a second after the cards are up, each fading in over half a second (TUTORIAL_PREVIEW_START_DELAY_MS). It is the result screens' queue (useSongPreviewQueue) without their 3 s wait and 2 s fade, which hold the music back for the score; here the songs are the screen. On the choose screen the queue repeats: after its last song it goes back to its first, in the same order, until the player taps Play (repeat: true; the picker and every other screen play their songs once). The card whose song is sounding moves with the music (TutorialPreviewRipple, rules in preview-beat-fx.pure.ts). Every note the preview plays (subscribeBeats) kicks the cover, feeds a soft purple halo that glows brighter the busier the music is, sends a glowing ring out of the cover's edge, each ring the next of cyan, purple and magenta (glow and line alike), (one per note, at most one every 110 ms, so a chord is one ring) that widens to 2.2× and fades as it grows. A fast passage fills the space; a slow one leaves a ring or two. Round it, a cyan → magenta comet arc (a sweep gradient with a blurred glow under a crisp line) orbits just clear of the cover at its own steady pace, one turn per 2.4 s (SPIN_LAP_MS): the one part that does not follow the notes. It is one Skia canvas behind the cover, larger than it, so the row never jumps; its blur, stroke and gradient programs are drawn at 1/255 when the screen arrives, so the first note does not stutter. With Reduce Motion on, nothing listens to the notes and only the halo shows, still. A choose-screen song is previewed by its catalog name (its game chart's busiest 15 s, never a recording), never by its tutorial chart (tutorial-song-preview.pure.ts). Play, Get and close stop the previews before leaving; the picker's tracking prompt counts as a screen cover, so nothing plays under it. No analytics event is sent. Rules: tutorial-song-choice.pure.ts, tutorial-song-result.ts, first-song.pure.ts.
Each tutorial_song entry can also set the difficulty tag its song shows on its tutorial result (the song intro, the choose screen's cards and the end picker's cards show no tag, PO 23/10/2026): "difficulty" takes the sheet's number (1–6) or the song list's label ("easy", "hard", any case) and replaces the catalog row's; "diff_tag": false hides the tag. Both are optional; an unreadable value is ignored, never the song. The tag is drawn bare, like the song list's. Analytics keep the catalog difficulty.
Which catalog song an entry is. The card (title, artist, cover, the preview it plays) and the song's analytics come from the bundled catalog row the entry names (catalogSongForEntry):
"song_id"(optional): the row'sidinsongs.json, thesong_idsong events send (dance-monkey,no-batidao,fur-elise,apt,twinkle-twinkle-little-star). It is matched exactly and wins overname. An id no row has plays the stand-in rather than whatevernamewould find, so a typo shows on the device."name"(required): withoutsong_id, the row whose file name, id or title it matches, ignoring case, accents, spaces and punctuation. Keep it besidesong_id: builds beforesong_idmatch bynamealone, and drop an entry without one.
Excerpts the app ships play with no download. An entry's midi is fetched while onboarding runs, unless its file name is one the app carries under src/assets/tutorial/: then the song plays that bundled chart, and nothing is downloaded or waited for (bundledTutorialExcerpt, prepareTutorialRun). The match is the file the URL ends in, exactly (case included), wherever it is hosted: …/Q4_Folder/tutorial_1stUA_package/APT_RoseBrunoMars_tutorial.mid plays the bundled APT_RoseBrunoMars_tutorial. The app ships the excerpts of the Instant songs:
The CDN keeps a copy of each, for builds that predate it and as the source of truth. A file whose notes change takes a new file name: the old name keeps playing the copy the app shipped with. Adding an excerpt to the app is committing its .mid under its CDN file name; charts:convert-tutorial turns it into a chart at build time.
The CTA never skips ahead — each tap advances by one slide; the final tap arms the post-onboarding paywall (see stepper.ts and its tests). Horizontal pan gestures advance / retreat the index with the same single-step semantics; vertical drags fail the gesture so child views (none today) keep working.
Training drills
Scripts 1–3 only. On those scripts the welcome's "Let's go!" opens the drills below (TutorialWelcomeScreen); script 4 goes on to the song (the choose screen first), and its first song teaches the tap and the hold instead (Guided first song). fn_training_set / fn_training_ready still come from the welcome; fn_training_start / fn_training_end are no longer sent.
tutorial_start (step: step_tap | step_hold) reports each lesson once the player has done it: on the drills (scripts 1–3) when the tap drill and the hold drill are passed; on the guided first song (script 4) when its first tap note is played and its first hold's head is played (it need not be held to its tail, PO 23/10/2026).
The drills' Skia sheets are baked before the turn to landscape. TutorialPracticePrewarm, mounted in app/(onboarding)/_layout.tsx (behind the splash and the film, with the judgement and song-keyboard prewarms) and in app/(tutorial)/_layout.tsx (a relaunch part-way), bakes the keyboard's key and overlay sheets and the lane's master atlas into their caches, one per idle slot, on runs that keep the drills. The drills' keyboard is the fixed C3–G4 window (twelve white keys, a song's narrowest is ten), so its sheets are not the song's: planTutorialPracticeKeyboardPrewarmGeometry cuts them, and tutorialPracticeBeamFloorPx is the one beam floor both TutorialGameplayCanvas and the pre-bake use, so they land on one master-atlas key. Measured on the simulator (Debug): the ~0.7 s JS stall at Start → Welcome is gone (86 / 139 ms), at the price of ~0.35 s more splash on a first launch; the practice mount drops from ~685 to ~530 ms of JS with all three caches hit. The rest is the surface's own mount, not a bake, and it is two commits now: TutorialGameplayStack mounts the lane canvas, and the keyboard two frames later (useStagedMount — frames, not an idle slot: the idle queue ran both stages back to back and the stall stayed one piece). The longest single stall is ~440 ms (the canvas, its layers and Skia views) and the keyboard's is ~140 ms; the UI thread's worst frame there is ~55 ms, under the loading card.
The practice screen's two drills (tap, then hold) move on only after a Perfect press
(PERFECT+ or PERFECT). A press is judged exactly as Game Mode judges one: classifyHit on the
live Timing-panel windows, the ones TimingZoneConfigOverlay draws
(judgeTutorialPracticePress).
A GOOD or EARLY press (the great / tooEarly judgements):
- pops its label, GOOD or EARLY, in PERFECT's look (white letters, the yellow outline and
glow;
tutorialJudgementLook), while the note closes in on its centre and fades out (TUTORIAL_RETRY_NOTE_FADE_MS). The key's light goes out with it, even with the finger still on the key: held, it stood in the lane as a golden column and read as the note stuck there; - once the label has played out (
TUTORIAL_RETRY_LABEL_MS, the label's own life), says "Tap Again!" — "Hold Again!" on the hold drill (tutorialRetryMessage) — forTUTORIAL_COACH_COPY_DWELL_MS, raised a tenth of the screen above the drill's other copy; - then drops the note again from the top.
A hold let go too soon. The hold drill also wants the key kept down until the long note's
tail reaches the line. Letting go more than TUTORIAL_HOLD_RELEASE_MARGIN_MS (0.3 s, the last
fifth of the 1.5 s hold — Game Mode allows only its ~25 ms Perfect-late window) before the tail
breaks the hold (tutorial-practice-hold-release.ts):
the ramp stops so the note freezes where the finger left it, EARLY pops (the tap drill's
own word, fire("tooEarly", 0): one label for a press too soon and a lift too soon), the note
closes in on the part still standing above the line and fades, then "Hold Again!" and a fresh
fall — the same retryLabel → retry → drill path a GOOD press takes (beginRetry). Game
Mode's own early release stays neutral; only the training says anything.
The label sits where Game Mode's does, top-centre of the canvas; only the drills draw it in
PERFECT's look, the tutorial song keeps Game Mode's colours. This is the
retryLabel → retry pair of phases in
tutorial-practice-flow.ts. A note resting
on the line takes any press on its key as PERFECT+. The drill's notes fall at Game Mode's lane speed (DEFAULT_LANE_PX_PER_SECOND), so its zones sit as far from the line as a song's. Other keys, and presses while the note is still
above the Too-early window, are ignored.
Tutorial song
The tutorial song is a Game Mode session (useTutorialSongSession over useMagicGameplay) that
waits on each note, drawn by Game Mode's own gameplay group (PlayScreenGameplayGroup, under
GameplayThemeTierProvider): the score (hidden through the 3-2-1, shown at GO), the x2–x5 badge,
the points over each lane, and the glow, smoke, stars and keyboard colours that climb with the
streak. Only the training drills keep the fixed tier-1 look. It draws Game Mode's song progress
rail (PlayScreenSongProgressRail) across the top. The rail stays hidden through the 3-2-1, shows at GO, and fills with the chart's tick up
to totalEndTicks, so it waits with the song
(TutorialSongGameplayPhase).
Before the song starts, TutorialGameplayScreen plays the song reveal: the cover rises with a
pulsing ring over the starry sky, then the title and artist fade in (no difficulty tag on a tutorial song). It is the shared
SongRevealShowcase (with
SongRevealCover, SongRevealMeta, song-reveal.model.ts and
StarryScaffold) in src/components/, because Learn
Mode plays it too — after the "Learn Mode unlocked!" popup's Claim opens Twinkle
(songs.md). The tutorial's result
celebration draws the same SongRevealCover.
A chosen tutorial song starts sooner than other songs
(tutorial-song-start.ts): its reveal
holds 0.7 s once settled instead of 2 s (holdMs, the 0.95 s motion unchanged). The song
mounts under the reveal once it settles — reported by the reveal on the UI thread
(onSettled), so the mount never lands on the entrance — and loads through that hold; its lane
atlas was already baked on the idle JS thread while the entrance played
(useTutorialSongPrebake), and its keyboard's sheets behind the splash (KeyboardAtlasPrewarm
in the onboarding and tutorial layouts — baked under the reveal, they stuttered it). Its 3-2-1 is Game Mode's 2 s pre-roll, armed when the reveal hands
over (piano.md). Learn Mode's reveal keeps the 2 s hold.
Guided first song
On script 4, the run's first song, the first time it is played (step.index === 0 && !tutorialRunUsesClassicTraining() in TutorialGameplayScreen), teaches what the training drills did, on two of its own notes (tutorial-song-guide.pure.ts, wired in useTutorialSongSession). Every later song plays as Game Mode.
- The first tap note. The song's first note that is not a hold, as the engine reads a hold (its tempo included: a short long note on a fast song is a tap). Either guided note may come first: No Batidão opens on three holds and taps after them, Fur Elise taps first and holds last. Twinkle has holds only, so only its first hold is guided.
- While it is the note to play, a press on its key (inside the note tolerance) that is not Perfect is ignored. It pops the label it earned, as Game Mode would (GOOD or EARLY — EARLY also for a press before the Early window while the note is on screen; before it shows, the key just sounds), and it sounds, but it scores nothing (no points over the lane) and the note goes on falling.
- The song waits for the note on the line, as Game Mode waits on every note (auto-pause). The moment it does, the training's spotlight (
TutorialPracticeSpotlightOverlay) comes in, dimming everything but the key's column, with "Tap the key when the note reaches the line" (TutorialSongGuideCopy, 50 pt above halfway down to the hit line). It comes in over 588 ms (TUTORIAL_SONG_GUIDE_SPOTLIGHT_ENTER_MS, 1.7× the drills' 1 s pace), and from the same frame the hand of the training drills (TutorialHandGuide) shows the tap gesture on its key. Playing the key clears all three. Every guided wait below brings them in the same way. All three are mounted once with the surface byTutorialSongGuideLayerand shown on the UI thread fromguideWaitKindSv(opacity + translate), so a wait starting or ending commits nothing to React; under the Get ready! card their Skia layers draw atTUTORIAL_SONG_GUIDE_PREWARM_OPACITYto warm the GPU pipelines. - A press there scores Perfect however long the wait. Game Mode turns such a press Late after 0.5 s and Miss after 1.2 s (fixed, not BPM-scaled); the guide lifts both limits through
useMagicJudgement'sgetAutoPausePerfectGraceMs(returningundefinedonce nothing is guided, so Game Mode's default grace applies). - A Perfect press while the note is still falling plays on.
- The first hold.
- Its press is guarded as the first tap note's is (PO, 24/10/2026): a press on its key before the line that is not Perfect pops the label it earned and sounds, but scores nothing, and the hold goes on falling to the line. A key held down through such a press does not start the hold on arrival; the player presses again.
- Waiting on the line for its press, it gets the spotlight with the training's hold line, "Hold the key when the long note reaches the line", and the hand (the long press), and its press scores Perfect however long the wait.
- From the press on it plays as Game Mode (PO, 23/10/2026: a hold scores like a tap, and its haptic already tells it from one). Let go early, it keeps its head's points without the completion bonus and the song goes on; held to its tail, it gets the bonus.
Skipping the FTUE (Remote Config onboarding_skip)
Remote Config key onboarding_skip (boolean, default true) controls the FTUE
skip affordances. Read it through
selectOnboardingSkipEnabled —
Firebase-only, with no __DEV__ override, so a dev build shows the same funnel
players get.
With the key set to false, none of the skip affordances render and the flow is
exactly the full funnel. The practice pill is additionally gated on
handler.isPlaying — the pre-roll done, the loading card faded out and the drill on
screen — so it never lands on top of the prepare loading card (the sampler can be ready
while the card is still held its minimum time or fading). Its 0.5 pt rim is the song list
Play pill's rim as it reads on that pill — light blue at half strength
(tutorialSkipBorder) — so it stays as quiet on the pill's near-black fill.
TutorialTrainingOverlay renders the pill only when a caller passes both
showSkip and onSkip, which is why the tutorial song screen (which passes
neither) has no skip.
The screen never navigates. The final CTA calls useOnboardingStore.finishWithPaywall(), which arms shouldShowPostOnboardingPaywall. Root-mounted PaywallHost opens the subscription modal in portrait; dismissing it calls complete(), which flips hasCompleted to true and the root app/_layout.tsx mounts (tutorial). See routing.md.
Post-onboarding paywall handoff
finishWithPaywall() flips shouldShowPostOnboardingPaywall on. <PaywallHost>
watches that flag, opens the global PaywallModal
with POST_ONBOARDING_PAYWALL_VARIANT in portrait, and immediately calls
dismissPostOnboardingPaywall() so a future re-mount can't re-arm the modal.
When the user dismisses or purchases, the host calls complete() (if onboarding
is not yet marked done), which swaps the root layout from (onboarding) to
(tutorial).
The real subscription / IAP plumbing isn't wired yet — the modal's CTAs both advance the flow (same as the in-app paywall flow), which is the seam where billing slots in later.
Why fade-only (no horizontal pager)?
Slides 1–4 share a hero region but the title block changes; slides 5–6 swap the entire layout. A FlatList pager would slide both slides side-by-side mid-swipe, exposing the layout change for a frame. Cross-fading instead — keyed Animated.View blocks with FadeIn / FadeOut layout animations — keeps each slide self-contained and removes the awkward "two layouts visible at once" interstitial.
Debugging
Profile screen exposes a "Reset onboarding flow" button that closes the paywall, resets onboarding and tutorial state, then signs out — re-running the full onboarding → paywall → tutorial sequence.