Skip to content

fix(snapshots): repair theme, async, and layout bugs from visual audit - #6

Merged
wei18 merged 1 commit into
mainfrom
fix/snapshot-quality-sweep
May 19, 2026
Merged

wei18 merged 1 commit into
mainfrom
fix/snapshot-quality-sweep

Conversation

@wei18

@wei18 wei18 commented May 19, 2026

Copy link
Copy Markdown
Owner

Summary

Visual audit of the 25 SudokuUI snapshot baselines surfaced 10 quality issues. This sweep fixes 9 of them and re-records all 25 PNGs. Issue G (Japanese locale copy) is left alone per scope.

Root causes (grouped)

Cause Issues fixed Where
A Theme/colorScheme never propagated to NSHostingView 1, 8, 9 SnapshotConfig mirrors colorScheme onto host.appearance
B .task re-entered on mount, resetting pre-seeded state 4, 5 hasBootstrapped latch in Completion + DailyHub VMs
C BoardView iPhone clipping (title + grid + digit row) 3 host.sizingOptions = [] + frame(maxWidth: .infinity) on digit buttons
D/F horizontalSizeClass returned .regular on iPhone fixtures 2, 6 inject .compact in wrapper for iPhone
E Duplicate Difficulty label + system blue accent 7, 8 .labelsHidden() + .tint(theme.accent.primary)

Issue G (locale → JA copy) deferred: SudokuKit doesn't ship Localizable.xcstrings in its bundle; adding one was forbidden by sweep scope. _ja / _zhTW suffixes still render English copy but locale-driven date/number formatting applies.

Before / after (3 critical spot-checks)

View Before After
Board iPhone light empty Dark bg, title 'y' only, 9 key clipped Warm paper bg, 'Easy' full, grid contained, all 9 digits visible
HomeView iPhone light Dark bg, hyphenated 'Prac-tice' / 'Set-tings' Warm paper bg, single-column rows, full labels
Completion iPhone light loaded Spinner mid-screen Leaderboard rows: alice 3:48 / bob 3:55 / carol 4:02
DailyHub iPhone light unfinished Pure spinner Easy / Medium / Hard rows with mini-board skeletons

Verified

  • swift build: 0 warnings
  • xcodebuild iOS scheme: ** BUILD SUCCEEDED ** 0 warnings
  • swift test full suite: 335/335 in isolation
  • 25 baseline PNGs re-recorded (count unchanged)

Known issues NOT in this PR

  • Flaky test overThresholdDrawShowsShimmer — passes 3/3 when run alone, races under parallel load. Pre-existing, deferred (deterministic clock injection needed).
  • Issue G (Japanese locale strings) — needs SwiftPM-bundle Localizable.xcstrings, out of scope.
  • BoardView iPhone 16pt horizontal misalignment — board is square + fully contained but sits 16pt left of header padding. GeometryReader + aspectRatio macOS quirk; would require rewriting BoardView as a custom Layout. Original blocker (title truncation, cell overflow) gone.
  • macOS NavigationSplit sidebar white background — pre-existing, default macOS sidebar styling doesn't pick up theme.surface.background.

🤖 Generated with Claude Code

…al audit

Visual audit of the 25 SudokuUI snapshot baselines surfaced 10 issues; this
sweep fixes 9 of them and re-records all 25 PNGs. Issue G (locale → Japanese
copy) is left alone per scope (requires regenerating Localizable.xcstrings
into the SwiftPM bundle).

Root causes fixed:

A) Theme / colorScheme never propagated to NSHostingView in snapshot tests
   — SwiftUI .preferredColorScheme(.light) doesn't set NSAppearance on the
   host. Fix: mirror colorScheme onto host.appearance in SnapshotConfig.
   This fixes light/dark divergence everywhere AND lets theme.accent
   propagate to system controls (Picker tint, button tint).

B) CompletionView and DailyHubView re-entered .task on mount even when
   tests pre-seeded state, resetting to .loading (pure-spinner snapshots).
   Fix: add hasBootstrapped latch in both VMs; user 'Retry' routes through
   a new retry() that clears the latch.

C) BoardView iPhone title clipped, board overflowed viewport, digit row
   pushed past 393pt. Three contributing causes: NSHostingView.sizingOptions
   was .standardBounds (host grew past requested frame), digit buttons had
   fixed minWidth that didn't share parent width, and aspectRatio path
   relied on host honoring requested frame. Fix: sizingOptions = [],
   per-digit frame(maxWidth: .infinity).

D/F) HorizontalSizeClass returned .regular under NSHostingView for iPhone
   fixtures, so HomeView used 2-col grid and RootView used NavigationSplit
   sidebar (white rectangle bug). Fix: inject .compact in the wrapper for
   iPhone snapshots.

E) PracticeHub showed both a 'Difficulty' Text heading AND the Picker's
   own inline label. Fix: .labelsHidden() on Picker; .tint(theme accent)
   on Picker + 'Draw new puzzle' CTA so they render in sage instead of
   system blue.

Per-file:
- Tests/SudokuUITests/SnapshotConfig.swift            +30/-5   (host wrapper)
- Tests/SudokuUITests/{Root,Home,Board,Practice,Daily,Completion}ViewTests
                                                       +143/-126 (call sites)
- Sources/SudokuUI/Practice/PracticeHubView.swift     +5/-1   (label/tint)
- Sources/SudokuUI/Completion/CompletionView.swift    +1/-1   (retry wire)
- Sources/SudokuUI/Completion/CompletionViewModel    +15/-1   (latch+retry)
- Sources/SudokuUI/Daily/DailyHubViewModel.swift     +5/-0   (latch)
- Sources/SudokuUI/Board/DigitPadView.swift          +3/-2   (button width)
- Sources/SudokuUI/Board/BoardView.swift             +5/-2   (comment)
- 25 PNG baselines re-recorded (count unchanged)

Verified:
- swift build: 0 warnings
- xcodebuild iOS scheme: ** BUILD SUCCEEDED ** 0 warnings
- swift test full suite: 335/335 in isolation; PracticeHubView
  overThresholdDrawShowsShimmer remains the same pre-existing flake
  (passes 3/3 when run alone, races under parallel load)
- Spot-checked 3 critical PNGs visually: Board iPhone light shows warm
  paper + 'Easy' title fully visible + 9x9 grid contained + all 9 digits
  visible. HomeView iPhone shows single-column rows with full labels.
  Completion loaded shows alice/bob/carol leaderboard rows instead of
  spinner. DailyHub unfinished shows Easy/Medium/Hard rows instead of
  pure spinner.

Issue G (locale → Japanese copy) deferred: SudokuKit doesn't ship its own
Localizable.xcstrings; the app-level one is invisible to the package bundle.
Adding tables to the package was forbidden by sweep scope. _ja and _zhTW
snapshots still render English copy but locale-driven date/number formatting
applies correctly.
@wei18
wei18 merged commit 6bb4276 into main May 19, 2026
@wei18
wei18 deleted the fix/snapshot-quality-sweep branch May 19, 2026 17:36
wei18 added a commit that referenced this pull request May 20, 2026
)

Promote 'Running implementation notes log' from methodology.md §Backlog
to an established subagent dispatch convention.

What changes:

1. New project-local skill .claude/skills/agent-impl-notes-log/SKILL.md
   defining when to invoke, file layout, the 4-section format
   (設計決定 / 偏離 / 折衷 / 未決), status transitions, and the
   anti-patterns to avoid.

2. methodology.md §Sub-agent roster dispatch contract gains item #6:
   subagent must create meetings/{date}_{topic}.impl-notes.md at task
   start, update incrementally, mark COMPLETE before report. Leader
   reviews impl-notes before merging.

3. methodology.md skill matrix lists agent-impl-notes-log under the
   implementation phase.

4. Backlog entry removed from methodology.md §Backlog (now active).

Concurrent log differs from existing post-hoc phase meeting log: phase
log is summative and written at session wrap; impl-notes is updated
*during* work to capture micro-decisions that would otherwise be lost
to the diff. The two artifacts pair — phase log can reference
impl-notes for the trail of mid-flight context.
wei18 added a commit that referenced this pull request May 30, 2026
…ibility (release-blocker #212) (#213)

* chore(ads): set AdGate.gracePeriodDays = 0 for TestFlight/dogfood visibility

Temporarily zero out the 7-day onboarding grace so banner placement can be
verified on TestFlight / Mac dogfood builds without waiting a week per
device install. Refactored the literal `7 * 86_400` into a named static
constant `AdGate.gracePeriodDays` so the revert is a single-line change.

The four AdGateLogicTests that assert the 7-day boundary
(`day0SuppressesDuringGrace`, `day6StillInGrace`, `day7BoundaryReleasesGrace`,
`justBeforeDay7BoundaryStillInGrace`) are `.disabled(...)`-traited with a
pointer to issue #212. Their bodies stay intact — re-enable by removing
the `.disabled(...)` trait, no other change needed.

**This MUST be reverted before the v2.5 App Store submission.**

Tracking: issue #212 (release-blocker label). `docs/v2/design.md` rule #6
documents the 7-day grace as a product commitment; this PR ships a
deviation from spec gated on a clear restore path.

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

* test(banner): switch Home/BoardView banner-tests' deny path to purchase state

XCC iOS+macOS Test failed on PR #213's first push because
`HomeViewBannerTests.gateDenies_slotRendersNothing` and
`BoardViewBannerTests.running_butGateDenies_bannerSlotCollapsesToEmpty`
both relied on `makeAdGate(allow: false)`, which previously denied via a
fresh grace-period `firstLaunchAt`. With `AdGate.gracePeriodDays = 0`
(this PR's whole point), that denial path collapses and the helper now
allows the banner — tests fail.

Switch the deny path to `hasPurchasedRemoveAds = true` (rule #1 in
`shouldShowBanner`). Purchase-driven denial is purely state-driven, so
these helpers stay correct whether grace returns to 7 (per #212 revert)
or stays at 0. Test intent ("slot collapses when gate denies") preserved
— we just deny via a different rule.

* ci(lint): scope swiftlint identifier_name disable in BoardViewBannerTests

---------

Co-authored-by: Claude Opus 4.7 <[email protected]>
wei18 added a commit that referenced this pull request Jun 2, 2026
…st launch (#256)

* spec(adgate): remove 7-day grace period — banner always shows from first launch (#212)

User spec change 2026-06-02: drop the original "first-7-days no ads"
onboarding rule entirely. Banner appears from first launch, capped at
1/day with dismissed-that-day skip and Remove-Ads-IAP override
unchanged.

Code:
- AdGate.gracePeriodDays stays at 0 (was being restored to 7 per
  pre-change #212 spec — that ask is now withdrawn)
- shouldShowBanner() arithmetic branch retained as 0-valued knob so
  re-introducing a grace is one constant flip
- 4 disabled grace-boundary tests removed (no longer policy);
  bannerAlwaysVisibleAfterFirstLaunch smoke test added

Docs (user-facing):
- docs/privacy-policy.md — short notice + en + zh-Hant body updated to
  "Ads appear from first launch" (release-critical legal claim — was
  promising "first 7 days no ads"; would mismatch shipped behaviour)

Docs (internal):
- docs/v2/design.md — rule #6/#7, AdGateOutcome enum comment, the
  inline pseudo-code grace branch, wall-clock-bypass rationale, and
  the §決策 origin table all updated to reflect 0-grace policy
- docs/v2/plan.md — v2.5.2 phase description updated
- docs/v2/v2.5-readiness.md — manual-test checklist trimmed
  (T+0 should show banner; +8-days step removed)
- AdGate.swift inline comments

Tests: 16/16 AdGateLogicTests pass on this branch.

Closes #212 (with the policy spec inverted from the original ask).

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

* fix(docs): repair stale link paths from App/ → Sudoku/ rename + AdMob manifest URL

Pre-existing broken links surfaced by lychee on this PR because the
two files were modified for the gracePeriodDays spec change. None
of these breakages were introduced here; just cleaned up while in
the same diff.

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

* fix(docs): drop unstable AdMob URL (was 404 in lychee)

---------

Co-authored-by: Claude Opus 4.7 <[email protected]>
wei18 added a commit that referenced this pull request Jun 3, 2026
…0) (#282)

* fix(minesweeper): scale board + add reveal/flag mode toggle (refs #278)

Tier-0 UX blockers from the Designer critique (#278), all in
MinesweeperBoardView. Three coupled fixes, one dispatch:

#1 Board scaling. The cell button was hardcoded frame(30,30) inside a
naked VStack/HStack with no GeometryReader, so Expert (16x30 ~ 960pt)
overflowed every iPhone and most Mac windows. The grid is now wrapped in
a GeometryReader that derives a single square cell side fitting the
NON-square board by its longer axis:
  cellSide = floor(min(availW/cols, availH/rows))
where availW/availH subtract the inter-cell spacing first. The cell
frame and the number/flag/mine glyph (font ~ cellSide * 0.55, replacing
the literal 16) both scale from it.

#2 Tap-target floor. minCellSide = 32pt. When the fitted side would drop
below the floor (e.g. Expert on iPhone fits ~10pt), cellSide is clamped
to 32 and the board scrolls (ScrollView([.horizontal,.vertical]))
instead of shrinking into an un-tappable grid. When it fits, the
ScrollView is inert.

#3 Discoverable reveal/flag toggle. Added an on-screen segmented Picker
(Reveal / Flag) above the board, modeled on Sudoku's pencil-mode toggle.
In Flag mode a tap flags; in Reveal mode a tap reveals. Long-press (iOS)
and right-click contextMenu (Mac) stay as flag accelerators in either
mode — Mac users no longer depend on an invisible right-click. Mode is
view-local @State (no engine semantics). Added .contentShape(Rectangle)
so the whole cell square is hit-testable.

Deferred: Tier-1 theme tokens, Tier-2 Mac side-rail (#6), win/lose
overlay (#7), VoiceOver (#10), .task loop cleanup (#9) — separate
dispatches.

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

* fix(minesweeper): address #278 Tier-0 CR — flag double-toggle + fit centering

CR REQUEST-CHANGES:
- iOS .flag-mode long-press double-toggle: in .flag mode the button tap +
  long-press both fired onToggleFlag, netting a no-op. Long-press now only
  flags in .reveal mode (redundant in .flag mode where tap already flags).
- Fitted board was pinned top-leading; now center the floored grid in the
  offered rect (mirrors Sudoku BoardView), only scrolling when clamped to floor.

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

---------

Co-authored-by: Claude Opus 4.8 <[email protected]>
wei18 added a commit that referenced this pull request Jun 4, 2026
* feat(minesweeper): Mac side-rail 2-column board layout (refs #298 #6)

Add a horizontalSizeClass == .regular branch to MinesweeperBoardView so
the Mac/iPad detail pane no longer renders the iPhone vertical stack.
Mirrors Sudoku's BoardView.macLayout: centered + size-capped board (600pt
square) on the left, a 260pt control rail on the right carrying the status
bar + Reveal/Flag toggle (MS has no digit pad). Outer width capped at
900pt and centered.

Compact (iPhone) layout extracted unchanged; spacing literal 12 preserved
verbatim so the recorded covered-board snapshots don't churn. New Mac
layout uses theme.spacing tokens.

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

* feat(minesweeper): reveal all mines on loss + clearer mine glyph (refs #298 #7 #8)

#7: on a loss, surface every mine, not just the detonated cell. No engine
accessor needed — the actor snapshot already carries the full cells array
with isMine populated once mines are placed, so the renderer paints still-
hidden mines from cell.isMine when status == .lost. Detonated cell keeps
the bold mineHit red; surfaced mines use the soft mine fill. Correctly-
flagged mines keep their flag glyph. The Completion overlay (#292) sits on
top via the outer overlay, so the revealed board shows behind it.

#8 (partial): swap the mine glyph burst.fill -> xmark.octagon.fill for a
clearer hazard read. The covered-vs-revealed contrast raise + raised-tile
bevel are deferred — they churn the covered-board snapshot baseline, which
the sandbox can't re-record (see impl-notes).

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

* feat(minesweeper): VoiceOver labels + flag action on board cells (refs #298 #10)

Mirror Sudoku's BoardCellView AX. Each cell collapses into one element with
a "Row R, Column C, <state>" label (1-based, state covers hidden/flagged/
N/empty/mine incl. the lost-mine surfacing), the .isButton trait, and a
named Flag/Unflag accessibilityAction so VoiceOver users can flag without
the long-press / right-click accelerators (which VO can't reach). Flag
action is inert on revealed cells and once the board is terminal.

Threads zero-based row/column into MinesweeperCellButton from the grid.

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

* refactor(minesweeper): replace TimelineView ticker with .task(id:) loop (refs #298 #9)

The status bar drove its 1 Hz elapsed refresh via a TimelineView whose
nested .task re-fired on every timeline tick (a .task re-fire footgun).
Replace with Sudoku BoardView's pattern: a single .task(id:) on the body
owning a `while !Task.isCancelled { if playing { refresh }; sleep(1) }`
loop, cancelled automatically on disappear, keyed on the VM identity so
Retry restarts it. Status bar is now a plain HStack reading the @observable
snapshot. Non-visible; correctness/perf only.

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

* refactor(minesweeper): board outer padding via theme spacing token (refs #298 #11)

Migrate MinesweeperBoardView's outer .padding() to theme.spacing.medium
(value-identical 16, no snapshot churn) and the new Mac layout to the
spacing scale. The compact VStack(spacing: 12) literal is deferred — it's
the only remaining spacing-scale literal and migrating it churns the
covered-board snapshot baseline (sandbox can't re-record). Grid geometry
constants (minCellSide, cellSpacing, cornerRadius) are tap-target/shape
values, left as literals. Also seals the #298 impl-notes.

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

---------

Co-authored-by: Claude Opus 4.8 <[email protected]>
@wei18 wei18 mentioned this pull request Jul 28, 2026
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