Skip to content

fix(settings): keep the daily-reminder primer model stable so its sheet survives first tap - #918

Merged
wei18 merged 1 commit into
mainfrom
fix/909-reminder-primer-sheet-stable
Jul 20, 2026
Merged

wei18 merged 1 commit into
mainfrom
fix/909-reminder-primer-sheet-stable

Conversation

@wei18

@wei18 wei18 commented Jul 20, 2026

Copy link
Copy Markdown
Owner

What

Settings → Reminders → Daily reminder: the primer sheet no longer dismisses itself on the first tap after a cold launch.

Root cause

The ReminderSettingsEntry (holding the ReminderSettingsModel whose isPrimerPresented drives the sheet) was minted fresh by a factory closure invoked inside LiveRouteFactory's .navigationDestination builder. On cold launch the concurrent Settings bootstraps re-render an ancestor → SwiftUI re-invokes the builder → a brand-new model (isPrimerPresented=false) replaces the just-flipped one → the sheet binding reads false → dismiss.

Fix

Build the entry once at composition (MakeGameApp), store it as a value on GameDeps.reminderSettings (was a () -> Entry closure); LiveRouteFactory reads the stored value so a destination re-invoke returns the same model instance. Shared layer, both apps mirror-identical. The eager build is inert (init only stores config; notification-permission work stays lazy in the leaf-view .task { onAppear() }, which still re-fires each Settings visit). @MainActor added to ReminderSettingsEntry.

Verification

  • GameAppKit 46 + SettingsKit 49 + SudokuAppCompositionTests 33 + MinesweeperUITests 320 pass; swiftlint --strict clean.
  • New ReminderSettingsIdentityTests in both apps assert view(for:.settings) returns the same model === across two renders (fails on the pre-fix closure) + a negative control.
  • Dual CR: APPROVE (confirmed no eager side-effects, no state-staleness) + APPROVE-with-cosmetic (Package.swift file_length, fixed).
  • Leader sim-verified on both apps (clean-DerivedData build): primer opens with correct app-specific copy and stays stable. The cold-launch race is covered by the identity tests — the sim can't reproduce the sub-second churn window deterministically.

Closes #909

🤖 Generated with Claude Code

…et survives first tap

Settings → Reminders → Daily reminder: on the first tap after a cold launch
the primer sheet appeared then immediately dismissed. Root cause: the
ReminderSettingsEntry (holding the ReminderSettingsModel whose
isPrimerPresented drives the sheet) was minted FRESH by a factory closure
invoked inside LiveRouteFactory's .navigationDestination builder. On cold
launch the concurrent Settings bootstraps (SettingsViewModel /
MonetizationStateController) re-render an ancestor → SwiftUI re-invokes the
destination builder → a brand-new model (isPrimerPresented back to false)
replaces the just-flipped one → the sheet binding reads false → dismiss.

Fix: build the ReminderSettingsEntry ONCE at composition (MakeGameApp) and
store it as a value on GameDeps.reminderSettings (was a
() -> ReminderSettingsEntry closure); LiveRouteFactory holds it as a stored
property and the .settings case reads that value, so a destination re-invoke
returns the SAME model instance and isPrimerPresented can't be reset out from
under the sheet. Shared layer (GameAppKit + SettingsKit), both apps mirror-
identical. The eager build is inert (ReminderSettingsModel.init only stores
config + local-store getters — no UNUserNotificationCenter work; permission
machinery still runs lazily in the leaf-view .task { onAppear() }, which
re-fires every Settings visit on the persisted model). @mainactor added to
ReminderSettingsEntry (now a stored non-Sendable model inside a Sendable
LiveRouteFactory).

Verified: GameAppKit 46 + SettingsKit 49 + SudokuAppCompositionTests 33 +
MinesweeperUITests 320 all pass; swiftlint --strict clean (incl. SudokuKit
Package.swift back under file_length 400). New ReminderSettingsIdentityTests
in BOTH apps assert view(for:.settings) returns the SAME model === across two
renders (fails on the pre-fix closure) with a negative control. Dual CR:
APPROVE (no eager side-effects, no state-staleness) + APPROVE-with-cosmetic
(Package.swift length, fixed). Leader sim-verified on both apps (clean
DerivedData build): primer opens with correct app-specific copy and stays
stable — the cold-launch race itself is covered by the identity tests (sim
can't reproduce the sub-second churn window deterministically).

Closes #909

Co-Authored-By: Claude Fable 5 <[email protected]>
@wei18
wei18 enabled auto-merge (squash) July 20, 2026 16:17
@wei18
wei18 merged commit be3eee7 into main Jul 20, 2026
5 checks passed
@wei18
wei18 deleted the fix/909-reminder-primer-sheet-stable branch July 20, 2026 16:18
wei18 added a commit that referenced this pull request Aug 26, 2026
…ME (#1020) (#1038)

* feat(nav): shared 3-tab sidebarAdaptable shell + per-tab paths, retire HOME (stage A of #1020)

Shared layer only (GameShellKit + GameAppKit); the per-app migrations follow
in the next commits on this branch.

GameShellKit (zero-dep):
- AppTab (today/practice/progress) + RootShellView rewritten as a
  sidebarAdaptable TabView with one NavigationStack path per tab;
  navigationDestination(for:) at each stack root.
- BoardModalOverlayHoist: the #1019-adopted shape — a board's Pause /
  Completion overlay renders as a ZStack sibling OUTSIDE the disabled
  TabView via BoardModalOverlayCoordinator, driven by the single
  `.boardModalOverlay(isActive:content:)` modifier that also emits
  BoardModalOverlayActivePreferenceKey (the #763 "same condition" invariant
  now holds by construction). iOS fullScreenCover boards keep rendering in
  place (no coordinator in that environment).
- NavigationStackHost / SidebarItem / HomeScreen deleted outright.

GameAppKit:
- GameRootViewModel: `selectedTab` (plain stored, no side effects — N-AB)
  + `paths[AppTab]` with `setPath(_:for:persistJoin:)` owning the shrink
  detection; design.md §3.6.2 quoted verbatim (C-34). Tests: shrink on a
  non-selected tab refreshes the resume pill; tab switching alone never does.
- GameConfig: drops sidebarItems/homeModes/presentLeaderboard/statsRoute/
  statsSubtitleKey/homeAvatarImage/makeHome/title; adds `makeTabRoot`,
  invoked exactly once per tab per launch (memoized — #918 lesson, tested).
- TodayTabHost: resume pill + themed banner slot; the ATT primer anchor moves
  here (C-33) with ATTPrimerCoordinator and its tests untouched. a11y id
  `game.today.root`.
- AchievementsRow (C-36): Progress-tab Game Center entry through
  presentGameCenterOrAlert; HOME's leaderboard card is gone with
  GameHomeView/GameHomeViewModel (C-35).
- UITestRouteModifier resolves to UITestLaunchTarget (.tab / .push) so
  `-uitest-route daily|practice` select a tab instead of pushing a route.
- No `.badge(` and no custom dot view: U-12 resolved "not possible" (see the
  issue), badge dropped per design.md §2.3.

Docs: v3 design.md U-12 closed, prototype.html B-4/U-12 re-tagged, v1
design.md §How.5.1 marked superseded. L10n: Today/Progress/Achievements added
to both App catalogs (7 locales).

part of #1014

Co-Authored-By: Claude Fable 5 <[email protected]>

* wip(nav): checkpoint stage B in-flight work for session handoff (#1020)

PM checkpoint of session/brazen-starling-u7qw's uncommitted working tree so a
successor session can continue from a pushed branch instead of a local-only
worktree. Content is mid-edit stage B (app-composition wiring + contract
re-anchoring); not reviewed, not expected to build clean. To be squashed by
the continuing session.

part of #1014

Co-Authored-By: Claude Fable 5 <[email protected]>

* feat(nav): migrate Sudoku onto the 3-tab shell, cut AppRoute to 3 cases (stage B of #1020)

- AppRoute: exactly board / completion / settings (design.md §2.2); daily,
  practice, stats are tab identities now, home is gone.
- Live+TabRoots.swift builds the three tab roots once per launch: Today =
  DailyHub (per-tab path binding), Practice = PracticeHub, Progress =
  StatsView with the shared AchievementsRow in a new gameCenterSection slot
  (C-36). LiveRouteFactory keeps only the three push arms.
- DailyHubViewModel: exhausted → Practice switches tab via an injected
  selectTab closure (design.md §3.1) instead of pushing a route; Cancel
  drops the block and stays on the Today root.
- BoardView adopts `.boardModalOverlay(isActive:content:)` (single
  condition drives rendering + the #763 preference).
- reminderTapRoute selects Today and pops it to root; -uitest-route
  daily/practice resolve to tabs, settings to a push.
- Tests: Home suites + baselines deleted; TodayTabViewTests replaces them
  and feeds the 01-home marketing slot (mise-tasks/store/screenshots
  re-pointed); StatsView .txt structure baselines follow the generic slot
  (images unchanged). E2E: game.home.root → game.today.root,
  assertLandedOnHome → assertLandedOnTodayRoot.

part of #1014

Co-Authored-By: Claude Fable 5 <[email protected]>

* feat(nav): shared Settings gear on every tab root (#1020)

HOME's Settings card was the only Settings entry point; design.md §2.1/§3.7
want a trailing gear on each tab that pushes `.settings` inside the
initiating tab. `TabRootChrome` (GameAppKit) applies it once for all three
tabs — `chromedTabRoots` returns the unerased
`ModifiedContent<AnyView, TabRootChrome<Route>>`, so no tab can skip it —
and `GameConfig` gains the required `settingsRoute`. Sudoku's Live config
passes `.settings`; Minesweeper follows in its migration commit.

part of #1014

Co-Authored-By: Claude Fable 5 <[email protected]>

* feat(nav): migrate Minesweeper onto the 3-tab shell, cut AppRoute to 5 cases (stage B of #1020)

Mirrors the Sudoku migration file-role by file-role:
- AppRoute: exactly board / replayDailyBoard / resumeBoard / completion /
  settings (design.md §2.2); daily, practice, stats are tab identities.
- Live+TabRoots.swift builds Today = daily hub, Practice = practice hub,
  Progress = MinesweeperStatsView + the shared AchievementsRow (C-36);
  LiveRouteFactory keeps the five push arms, +Stats folded into the
  tab-roots file. Live config passes settingsRoute: .settings for the
  shared tab-root gear.
- MinesweeperBoardView adopts `.boardModalOverlay(isActive:content:)`.
- reminderTapRoute selects Today + pops to root; -uitest-route keys resolve
  to UITestLaunchTarget (daily/practice → tabs, settings/resumeFail → push).
- Tests: Home suites + baselines deleted; MinesweeperTodayTabViewTests feeds
  the 01-home marketing slot (mise-tasks/store/screenshots re-pointed);
  MinesweeperStatsTests .txt structure baselines follow the generic slot.
- L10n: "Settings" key added to the Minesweeper catalog (7 locales) — the
  shared gear label had no entry there.

part of #1014

Co-Authored-By: Claude Fable 5 <[email protected]>

* docs: re-tag screen-contracts + game-factory skill for the 3-tab shell (#1020)

Code review found both still describing the retired HOME / sidebar types as
current. screen-contracts.md gets the same "superseded by 3.0" banner
docs/v1/design.md already carries; the game-factory-composition skill now
describes the root shell / makeTabRoot / TabRootChrome shape a new game
must plug into.

part of #1014

Co-Authored-By: Claude Fable 5 <[email protected]>

* chore(tests): drop dangling NavigationStackHost mentions from SettingsKit sentinel comments (#1020)

Acceptance pass caught two comment-only references to the type deleted in
this branch.

part of #1014

Co-Authored-By: Claude Fable 5 <[email protected]>

* docs(screen-contracts): re-anchor ATT-PRIMER entry point to the Today tab (C-33, #1020)

part of #1014

Co-Authored-By: Claude Fable 5 <[email protected]>

* fix(nav): single Today banner, C-33 host test, open-gate Today fixtures (#1020 review)

- Today no longer stacks two banners: the daily hub's own banner slot is
  dropped on the Today root in both apps; TodayTabHost's slot (the C-33
  ATT anchor) is the only one.
- TodayTabHostTests: first ad context offers the primer when ATT is
  undetermined, never when determined, and the hasOffered latch holds
  across two hosts sharing one coordinator; the slot's onAdContext body is
  the free function the test calls (no behavior change).
- TodayTabViewTests / MinesweeperTodayTabViewTests: one open-gate fixture
  each so the 01-home marketing baselines cover the banner region.
- SudokuE2ETests: exhausted-Cancel test renamed to its Today-root landing;
  SudokuKit Package.swift trimmed under the file_length ceiling.

part of #1014

Co-Authored-By: Claude Fable 5 <[email protected]>

* fix(nav): host the hoisted overlay in a leaf observer so macOS keeps the pushed board (#1020)

On macOS, clicking Pause on a board pushed inside a tab NavigationStack popped
the board back to its hub while the path binding stayed [.board]. Bisection
against the macOS XCUITest showed re-running RootShellView.body while a board
is pushed unmounts the sidebarAdaptable stack destination; three things did
that: .onPreferenceChange(BoardModalOverlayActivePreferenceKey), the
.disabled(...) toggle, and reading coordinator.content in the shell body.

- Drop BoardModalOverlayActivePreferenceKey and the shell .disabled(); the lock
  is the overlay scrim + .isModal trait (#1019 evidence), rendered by a new
  HoistedOverlayHost leaf — the ONLY observer of the coordinator.
- boardModalOverlay(presentation:) takes a BoardModalPresentation key instead of
  a Bool, so completion-over-pause / leave->pause switches re-register the
  hoisted snapshot; dismiss(id:) scopes teardown to the presentation a board
  installed (outgoing/incoming boards coexist during transitions).
- Both BoardViews expose modalOverlayPresentation (shared enum, mirror principle).
- Tests: hoist routing + identity-scoped dismiss; board presentation-key
  branches; retire NavigationPreferencePropagationTests (its assumption is no
  longer load-bearing); make GameRootViewModelTabPathTests.settle() sleep so
  the refresh Task lands under the parallel runner (was 1-in-3 flaky).
- macOS E2E: SudokuE2ETests+MacShell pins #763 on the 3-tab shell via
  window-anchored coordinate clicks (tabs inert / Resume live / Leave pops).

Co-Authored-By: Claude <[email protected]>

* test(shell): drive boardModalOverlay's onChange re-registration in place (#1020 review)

branchChangeReRegisters mounted two NSHostingViews, so only the onAppear path
was ever exercised. Host one view over an @observable presentation probe and
flip .pause -> .completion -> nil in place; mutation check: commenting out the
.onChange(of: presentation) line fails exactly this test.

Co-Authored-By: Claude <[email protected]>

* fix(store): re-point the 01-home ASC slots to the Today baselines, regenerate frames (#1020)

HOME is retired, so the six Slot("01-home", …) entries in
scripts/build-ascspec-screenshots.py pointed at deleted HomeViewTests /
MinesweeperHomeSnapshotTests baselines and the #1001 frame-drift gate failed.
Point them at TodayTabViewTests / MinesweeperTodayTabViewTests (iPhone, iPad,
Mac light) and regenerate: 168 slots, 42 PNGs changed (01-home × 3 devices ×
7 locales × 2 apps), every other slot byte-identical. Eyeballed sudoku/iphone
en, minesweeper/iphone en, sudoku/mac zh-Hant, minesweeper/ipad ja — the Today
hub sits in the same panel + copy layout the HOME card used.

Co-Authored-By: Claude <[email protected]>

* docs(nav): align B-4 status, hoist/lock wording, and uitest-route comments with the shipped shape (#1038 review)

- design.md + prototype.html B-4: iPad idb PASS (#1019 evidence 06-10); macOS
  XCUITest pending -> #1039 (never cite the spike as macOS proof).
- BoardModalOverlayHoist / GameRoot / RootShellView: no .disabled() anywhere;
  the #763 lock is scrim geometry + .isModal AX pruning, not by construction;
  hoisted evidence is 06-10, 01-04 is the naive failure.
- SudokuE2ETests+MacShell: -uitest-route drives macOS too since #1037; only
  the near-win hooks stay iOS-only.
- mise-tasks/ui/tour: default launch = Today tab; daily/practice keys select tabs.
- BoardView.handleKeyPress: ignore key presses while an overlay is up (#763).

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: Claude Fable 5 <[email protected]>
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.

fix(settings): daily-reminder primer sheet dismisses itself on first tap after launch

1 participant