Skip to content

feat(gamecenter): shared Daily Rank screen (part of #983) - #989

Merged
wei18 merged 7 commits into
mainfrom
worktree-agent-ac7aecff23614a6d7
Aug 5, 2026
Merged

wei18 merged 7 commits into
mainfrom
worktree-agent-ac7aecff23614a6d7

Conversation

@wei18

@wei18 wei18 commented Aug 5, 2026

Copy link
Copy Markdown
Owner

Summary

Implements the shared Daily Rank screen (part of #983 — the approved spec at
#983 (comment)):

  • New GameAppKit.DailyRankView / DailyRankViewModel / DailyRankTab /
    DailyRankScope (Packages/GameAppKit/Sources/GameAppKit/DailyRank/) —
    World/Friends scope × per-difficulty tabs, all four spec states (not
    signed in, friends-not-authorized, populated-but-empty, populated), plus a
    network-error funnel, plus a persistent "Open Game Center" secondary CTA.
    One implementation, parameterized per game — GameShellKit stays zero-dep.
  • Both apps' Home Leaderboard card is now a real push route (.dailyRank)
    instead of a GameCenterDashboard.present() side-effect: HomeMode's
    trailing glyph is uniformly chevron.right now (was an outward-jump arrow
    signaling "leaves the app"); MS's card subtitle changes from "Best times"
    to "Global / friends" (Sudoku's already said this).
  • 16 new strings across 7 locales in both catalogs (en + zh-Hant
    hand-authored, fanned out to ja/zh-Hans/es/th/ko); tab labels
    reuse each app's EXISTING difficulty-name keys (no new strings there).
    mise run scan:l10n passes.
  • Snapshot baselines: populated (iPhone/Mac × light/dark) + one empty state,
    per app, all eyeballed. Re-recorded the Home-card baselines that
    legitimately shifted from the chevron/subtitle change (verified the diff
    is exactly that, nothing else).
  • Unit coverage: DailyRankViewModelTests (8 cases, all 4 spec states +
    retry/sign-in/friends-grant transitions) via FakeGameCenterClient — no
    live authenticateHandler anywhere (fix(gamecenter): authentication has no timeout — a hung callback silently kills resume-pill for the whole session #766). Rewired two stale Home
    interaction test files that asserted the old signed-out-alert/no-route
    contract for Leaderboard. Sentinel .dailyRank route-factory tests in
    both apps.

Design forks (spec didn't fully dictate these — noting per instructions)

  1. World-tab translation: the spec's own English copy says "World", but
    for the other 6 locales I reused the exact word the app ALREADY ships for
    "Global" in the Home card's "Global / friends" subtitle (e.g. ja
    グローバル, zh-Hant 全球) rather than translating "World" fresh — so the
    screen's toggle uses the same term the user just read on Home. en stays
    "World" per the spec's literal wording.
  2. Own-rank fetch strategy: "top slice + the local player's own rank/time"
    is implemented as: fetch the top-N slice; if the local player isn't in it,
    a second aroundLocalPlayer: true fetch resolves their own entry for a
    separate "Your Rank" row. Not specified in the spec at that level of detail.
  3. List → ScrollView { LazyVStack }: started with List/Section
    (closest built-in match to "top slice + your rank" as two grouped
    sections) but discovered while recording baselines that a bare
    NSHostingView renders every OTHER view on this screen but leaves List
    row content blank — the same class of gap windowSnapshotView already
    exists for Form/NavigationSplitView (documented in SnapshotConfig.swift),
    just not previously hit by List. Switched to ScrollView { LazyVStack }
    with a custom row/section-header, matching this codebase's convention
    everywhere except Settings (HomeScreen is ScrollView { LazyVGrid }) —
    arguably the better fit for a custom-styled leaderboard row regardless of
    the infra gap.
  4. Home-tap auth gating removed: GameHomeViewModel.select(.leaderboard)
    used to gate the tap itself (presentGameCenterOrAlert, alert-and-stop
    when signed out). Since .leaderboard now has a route, it pushes
    unconditionally like every other mode — the not-signed-in explainer lives
    INSIDE DailyRankView (state 1) instead. This is what the spec requires
    ("never a blank screen" for state 1), not really optional, but it's a
    visible behavior change from the pre-feat(gamecenter): friends leaderboard — surface the friendsAllTime slice in an app-owned view #983 alert, so flagging explicitly.

Out of scope (per dispatch, later phases)

TF builds/upload, screenshot-generator slot, review-notes/marketing copy,
any ASC write, and interactive sim verification with a signed-in simulator
(live GameKit) — recommended as a follow-up acceptance step before this
ships, since it can't be proven from swift test alone.

Test plan

  • swift test --package-path Packages/GameAppKit — 66/66 (incl. 8 new
    DailyRankViewModelTests)
  • swift test --package-path Packages/GameShellKit — 32/32
  • swift test --package-path Packages/SudokuKit — all green (one
    pre-existing timing flake outside this diff, BoardLeaveOrPauseStateTests,
    passes in isolation — documented local-env flake, not a regression)
  • swift test --package-path Packages/MinesweeperKit — 381/381
  • mise run lint:swift_strict on all 21 touched Swift files — clean
  • mise run scan:l10n — 2 catalogs, 0 placeholders, all 7 locales complete
  • Sim visual verification on a signed-in simulator (live GC), both apps
    — not run in this pass, recommended before ship

🤖 Generated with Claude Code

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

wei18 and others added 7 commits August 5, 2026 11:42
…part of #983)

Adds the GameAppKit-hosted DailyRankView/DailyRankViewModel (World/Friends
scope, per-difficulty tabs, the four spec states: not-signed-in, friends-
not-authorized, empty, populated) and wires Sudoku's Home Leaderboard card
to push it as a real route instead of a GameCenterDashboard side-effect.

Co-Authored-By: Claude Fable 5 <[email protected]>
…k route (part of #983)

Mirrors Sudoku's wiring: AppRoute.dailyRank, homeModes[.leaderboard] subtitle
"Global / friends" + route (was "Best times" side-effect), and a
LiveRouteFactory+DailyRank.swift extension (kept LiveRouteFactory.swift under
the 400-line file_length ceiling) building DailyRankView from
MinesweeperLeaderboardID + the existing Beginner/Intermediate/Expert display
names. Also fixes an orphaned-doc-comment SwiftLint warning in
DailyRankModels.swift from the prior commit.

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

16 new keys (nav title, World/Friends scope, sign-in/friends-grant/error
explainer copy, empty states, section headers, "You" badge) spliced into
both apps' Localizable.xcstrings, en+zh-Hant hand-authored then fanned out
to ja/zh-Hans/es/th/ko per the ai-translated-localization glossary (Game
Center stays untranslated; "friends"/"global" reuse the terms already
shipped in the "Global / friends" Home subtitle and "Invite Friends" row).
Regenerates the SudokuAppCompositionTests fixture byte-copy.

mise run scan:l10n passes: 2 catalogs, 0 placeholders, all 7 locales complete.

Co-Authored-By: Claude Fable 5 <[email protected]>
…/sign-in/friends-grant

Wires GameCenterTesting into GameAppKitTests and adds 8 Swift Testing cases
against FakeGameCenterClient: not-signed-in, friends-not-authorized, loaded
(local player in top slice), loaded-empty, network-failure retry, sign-in
transition, friends-access-grant transition, and tab/scope selection. No
live authenticateHandler anywhere (#766). Full GameAppKit suite: 66/66 pass.

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

DailyRankResultView used SwiftUI `List`/`Section`, which — like `Form`/
`NavigationSplitView` (the existing windowSnapshotView gap documented in
SnapshotConfig.swift) — needs the real-window layout pipeline a bare
NSHostingView doesn't run: rows recorded as a blank white area. Switched to
`ScrollView { LazyVStack }` (this codebase's convention everywhere except
Settings' Form) — matches app visual language, sidesteps the infra gap, and
is arguably the better fit for a custom-styled leaderboard row anyway.

Adds DailyRankViewTests.swift: populated iPhone/Mac x light/dark (4) + one
empty-friends-scope state, all eyeballed. Also re-records the 8 HomeView
baselines that legitimately shifted from #983's Leaderboard-card chevron
change (arrow.up.forward -> chevron.right) — verified the diff is exactly
that glyph and nothing else. Full SudokuKit suite: 1 pre-existing timing
flake unrelated to this change (BoardLeaveOrPauseStateTests, passes in
isolation), everything else green.

Co-Authored-By: Claude Fable 5 <[email protected]>
…board-tap tests

Adds MinesweeperKit/Tests/MinesweeperUITests/DailyRankViewTests.swift,
mirroring SudokuKit's suite (populated iPhone/Mac x light/dark + one
empty-friends state, all eyeballed, MS theme + Beginner/Intermediate/Expert
tabs). Updates the two Home interaction/snapshot suites whose fixtures still
hardcoded pre-#983 Leaderboard behavior:
- MinesweeperHomeViewModelTests / HomeViewModelInteractionTests (Sudoku)
  asserted the OLD `presentLeaderboard` side-effect contract (tap sets an
  alert, never pushes). #983 makes Leaderboard a real route like every other
  mode — `GameHomeViewModel.select` now pushes `.dailyRank` unconditionally,
  with the not-signed-in explainer living inside DailyRankView instead.
  Rewrote the assertions to match; both suites green.
- MinesweeperHomeSnapshotTests' local `minesweeperHomeModes` fixture updated
  to match Live.swift ("Best times"/no-route -> "Global / friends"/.dailyRank);
  re-recorded its 6 baselines and eyeballed one (chevron + new subtitle).

Full suites: MinesweeperKit 380/380, SudokuKit all green (one pre-existing
timing flake outside this diff's scope, passes in isolation).

Co-Authored-By: Claude Fable 5 <[email protected]>
…t of #983)

Cheap nav-assertion per app, matching each suite's existing per-route test
pattern: Sudoku's RouteFactoryTests asserts the AnyView dump contains
"DailyRankView"; Minesweeper's LiveRouteFactoryTests is a construct-without-
crashing sentinel (matches its stated scope — the default `LiveRouteFactory()`
has no gameCenter, so this exercises the nil-fallback branch).

SudokuAppCompositionTests: 62/62. MinesweeperKit full suite: 381/381.

Co-Authored-By: Claude Fable 5 <[email protected]>
@wei18
wei18 merged commit 7f43499 into main Aug 5, 2026
5 checks passed
@wei18
wei18 deleted the worktree-agent-ac7aecff23614a6d7 branch August 5, 2026 09:13
wei18 added a commit that referenced this pull request Aug 6, 2026
…996)

The DailyRankView marketing fixtures used "TestPlayer"/"TestSweeper" as
the local player's displayName, which reads as unshipped test data in
the App Store "02b-rank" screenshot slot. Renamed to the neutral
fictional name "Rin" in both apps' DailyRankViewTests.swift and
re-recorded the 6 affected snapshot baselines per app (the 3-entry
"populated" fixture and the 10-row "populatedFull" marketing fixture,
each iPhone/Mac x light/dark where applicable); the emptyFriends
baseline is unaffected since no entries render.

Also translates the approved 02b-rank en headline/subhead into the 6
non-en locales (zh-Hant/zh-Hans/ja/ko/es/th) for both apps, reusing
each locale's existing "World"/"Friends" tab-label translations from
Localizable.xcstrings so the caption and screenshot agree verbatim,
and drops ("sudoku"|"minesweeper", "02b-rank") from
PENDING_TRANSLATION_SLOTS now that the pass is complete.

Regenerated only the 02b-rank ASC marketing frames (42 files, 7
locales x 3 devices x 2 apps); an unrelated 01-home baseline drift
from the #989 chevron change (tracked separately as #995) was reverted
to keep this diff scoped to #983.

Part of #983.

Co-authored-by: Claude Fable 5 <[email protected]>
wei18 added a commit that referenced this pull request Aug 11, 2026
…ard change (#1000)

The mac `01-home` App Store frames were last generated in #986 (2026-08-04), one
day before #989 (2026-08-05) rewrote the Home leaderboard card. The portrait
frames picked the change up when #997 regenerated all 154 of them; the mac set
was never rebuilt, so it kept rendering the pre-#989 UI.

Regenerating with the unmodified `scripts/build-ascspec-screenshots.py` produces a
deterministic, locale-invariant delta in both apps:

- Sudoku (21x22 px at 1942,993 / 268 px): the Leaderboard row's trailing glyph
  changed from the outward-jump arrow to `chevron.right`. #989 turned that card
  from a Game-Center-modal side-effect into a real push route to the shared Daily
  Rank screen, so it now uses the same push chevron as every other row
  (`GameShellUI/Home/HomeScreen.swift:66-75`).
- Minesweeper (637x40 px at 1319,908 / 2020 px): the same glyph change plus the
  subtitle, which #989 moved from "Best times" to "Global / friends"
  (`MinesweeperAppComposition/Live.swift:141`).

The committed frames are the stale side: the snapshot baselines that feed the
generator changed in #989, after the frames were built. The regenerated frames
match the shipped app.

Verified: regeneration is byte-deterministic across runs; the delta is identical
in all 7 locales; every locale's PNG opened and inspected, with real Thai / CJK
glyphs and no caption reflow.

closes #998

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
wei18 added a commit that referenced this pull request Aug 12, 2026
…stale-response drop (#1008)

Closes the two test gaps #989's review flagged as verified only by code
inspection: the `aroundLocalPlayer: true` second-fetch path (dedupe against
the top slice + degrade to top-only when it fails) and the `commit(_:for:)`
selection-key guard that drops a fetch response for a tab/scope the user has
since switched away from.

- Extends `FakeGameCenterClient` with optional `ownRankSlice`/`ownRankError`
  overrides for the `aroundLocalPlayer: true` call only; unscripted (nil)
  behavior is unchanged, so every existing consumer is unaffected.
- Adds `GatedLeaderboardGameCenter`, a small continuation-gated local fake
  (matching the `StubGameCenter`/`MinimalGameCenter` precedent already used
  in this target) that suspends one leaderboard id's fetch until released,
  making the tab-switch race deterministic without sleeps.
- Extracted the new fake into its own file to keep DailyRankViewModelTests.swift
  under the 400-line SwiftLint cap.

Sanity-checked both new guard-dependent tests fail on a temporarily
un-guarded production build (guard deleted / `try?` → `try`), then restored
the production file unchanged.

part of #983

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
wei18 added a commit that referenced this pull request Aug 12, 2026
…ily Rank stub (#1009)

* refactor(gamecenter): remove the app-owned Daily Rank screen (part 1 of the native-GC revert)

Checkpoint commit — production code, routes and tests only. The screenshot
pipeline and review-note updates land in the follow-up commit on this branch.

Home's Leaderboard card goes back to presenting Apple's native Game Center
dashboard as a side-effect, reverting the UI direction of #989.

Root cause this removes: `LiveGameCenterClient.friendsAuthorizationStatus()`
was hardcoded to `.notDetermined` and `requestFriendsAuthorization()` hardcoded
to `throw .friendsAccessDenied` — never implemented against GameKit. The
ViewModel called the latter behind `try?`, swallowing the throw and re-rendering
the identical screen, so the "Allow Friends Access" button did nothing for every
user, always. Every test injected a fake client, so the logic tested green while
the only production conformer was inert.

The old path was dormant, not deleted: `presentLeaderboard:
{ GameCenterDashboard.present() }` was still wired in both apps and unreachable
only because every mode carried a `route`. Dropping `route: .dailyRank` restores
it, so this is a revert rather than a rewrite.

Removed: GameAppKit's DailyRank view/view-model/models/state-views, Minesweeper's
`LiveRouteFactory+DailyRank`, the `dailyRank` route case in both apps, and the
28 committed DailyRankViewTests snapshot baselines. `HomeMode.trailingSymbolName`
returns to the pre-#989 shape (`arrow.up.forward` for Leaderboard, chevron for
the rest, as at 439ee8d).

Home view-model tests were rewritten rather than deleted: the
authenticated/unauthenticated/unknown/restricted matrix is preserved, with the
expected outcome flipped from "pushes .dailyRank" back to "fires the
presentLeaderboard side-effect".

The subtitle stays "Global / friends" — it predates #983 and accurately
describes Apple's dashboard, which carries a global/friends toggle.

Deliberately NOT in scope: `fetchLeaderboardSlice`,
`friendsAuthorizationStatus`, `requestFriendsAuthorization`,
`LeaderboardSliceService` and `LeaderboardScope.friendsAllTime` remain. Removing
them is a protocol-shape change across 7+ conformers and lands separately.

part of #983

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* fix(store): drop the 02b-rank screenshot slot and its dead review-note copy (part 2 of the native-GC revert)

Follow-up to c297d11 (part 1, production code): the app-owned Daily Rank
screen it removed also fed a store-screenshot slot and two ASC review-note
sections that no longer describe anything the app does.

Screenshot pipeline (scripts/build-ascspec-screenshots.py):
- Delete the six 02b-rank Slot() rows (iphone-6.9/ipad-13/mac × sudoku/
  minesweeper), the two per-app COPY caption dicts, the IOS_GAP_TRIM/
  MAC_GAP_TRIM entries and their now-orphaned rationale comments, and
  02b-rank's membership in the crop_all_sides set.
- Delete all 42 committed docs/app-store/screenshots-ascspec/**/02b-rank.png
  baselines.
- Re-record the 8 Sudoku HomeViewTests + 6 Minesweeper
  MinesweeperHomeSnapshotTests baselines: c297d11's
  HomeMode.trailingSymbolName revert (arrow.up.forward for Leaderboard,
  chevron for everything else) changes every Home render, so all 14
  baselines that include the Leaderboard row were stale against `swift
  test` until re-recorded here.
- Regenerate all 168 ASC screenshot slots from the refreshed baselines;
  42 of the 168 `01-home.png` outputs changed pixels (the Leaderboard row's
  trailing glyph). `mise-tasks/scan/store_frame_drift` passes clean.

Docs:
- screenshot-strategy.md: remove the "Daily Rank slot — 02b-rank" section.
- Both v2.6 review-information.md files: rewrite "WHAT MAKES THIS APP
  DIFFERENT" and "GAME CENTER" to describe what the app actually does now
  — the Home Leaderboard card opens Apple's native Game Center dashboard
  (GKAccessPoint / GKGameCenterViewController) — instead of the removed
  app-owned Daily Rank screen (World/Friends toggle, "Your Rank" row,
  "Allow Friends Access" state). Both stay well under the 4000-char ASC
  cap (Sudoku 3068, Minesweeper 3528).

Deliberately NOT in scope (per c297d11): fetchLeaderboardSlice,
friendsAuthorizationStatus, requestFriendsAuthorization,
LeaderboardSliceService, LeaderboardScope.friendsAllTime.

part of #983

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* chore(gameappkit): drop the now-unused GameCenterTesting test dependency

Review finding on this branch. `GameAppKitTests` depended on the
`GameCenterTesting` product solely for `DailyRankViewModelTests` and
`GatedLeaderboardGameCenter`, both deleted by the Daily Rank removal. Zero
files in the target reference `FakeGameCenterClient` or `GameCenterTesting`
any more.

The comment was the sharper problem: it still read "FakeGameCenterClient — the
same fake seam SudokuUITests / MinesweeperUITests use", which describes those
other targets accurately but is false for this one, so it read as a justified
dependency. It had already misled one reader into reporting the dependency as
still needed.

`GameCenterClient` (the protocol) stays — GameRootViewModelTests,
GameRootViewModelLeaveTests, TerminalPersistJoinTests and
UITestSignedOutGameCenterClientTests all declare inline test doubles against
it. The replacement comment says which files need it and why the Testing
product went away, so the next reader does not have to re-derive it.

Verified: swift test --package-path Packages/GameAppKit -> 58/58 passed.

part of #983

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* docs(store): mark the two stale 02b-rank references in the #997 pass record

Review finding on this branch. The `## Daily Rank slot — 02b-rank` section was
removed cleanly, but the following section — the record of the #997 portrait
panel-fill pass — still named `02b-rank` twice as a live `crop_all_sides`
member, which it no longer is (membership is now `{"04-completion"}`).

Rewriting those two lines to omit the slot would have falsified the record:
`02b-rank` genuinely was in that set when the pass ran, and the measurements
quoted are the measurements that were taken. So they are annotated rather than
edited — the history stays true and the reader learns the slot is gone, which
is how the generator's own `IOS_GAP_TRIM` comment handles the same situation.

part of #983

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 5 (1M context) <[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.

1 participant