Skip to content

fix(sudoku): digit pad audit — badge contrast, exhausted-key affordance, a11y l10n, undo/redo disabled ink - #860

Merged
wei18 merged 1 commit into
mainfrom
fix/855-digitpad-audit
Jul 17, 2026
Merged

wei18 merged 1 commit into
mainfrom
fix/855-digitpad-audit

Conversation

@wei18

@wei18 wei18 commented Jul 17, 2026

Copy link
Copy Markdown
Owner

What

Closes #855 — all 8 design-audit findings on DigitPadView + the Leader-adjudicated extras.

  • F-1 armed badge → on-accent ink: 1.45:1/1.02:1 → 4.83:1/7.42:1 (reviewer recomputed independently; the remaining==1 accent-on-accent 1.0:1 case covered by the isArmed outer gate).
  • F-2 exhausted-but-enabled keys: whole-key 0.35 dim → full opacity + checkmark badge (≥6.6:1); digitButtonOpacity(isDisabled:) matrix deliberately re-pinned (5 cases).
  • F-3/F-8 a11y strings localized (String(localized:, bundle: .main) — the module carries no resources block, .main is the only correct bundle) + dynamic hints by hasSelection; 5 keys ×7 locales.
  • F-4/F-7 05-board.md 3×3/56pt reality + header comment; design-system.md gains the text.onAccent alias row + Mac remaining-badge won't-fix adjudication.
  • F-5 sim-CONFIRMED then fixed: disabled Undo/Redo rendered identical to always-enabled Erase (unconditional foregroundStyle footgun); now environment-aware — before/after/after-move screenshots verified by both implementer and reviewer. Mac layout never had the footgun (no explicit override) — correctly untouched.
  • F-6 token math verified already-AA (4.55:1/8.17:1) — no change.
  • Extra: exhausted-digit gate unified — pencilMode now permitted in the selected-cell path; structurally cannot reach placeDigit (routes to toggleNote), 4-quadrant test matrix.

Review

Dual CR, both APPROVE (mechanical 11/11). One pre-existing nit spun off: %lld remaining/%lld completed lack plural variations (es '1 restantes') — follow-up issue filed.

Verification

SudokuKit DigitPad|Board 74/74 + Settings 43/43 --no-parallel · scan:l10n green · swiftlint --strict clean · 8 iPhone-compact baselines re-recorded (badge/checkmark/undo-gray deltas), Mac/iPad justified-untouched.

🤖 Generated with Claude Code

…audit

F-1: armed key's remaining badge now takes the on-accent ink
(surface.primary, the #786/#797 pattern) instead of keeping
text.secondary/accent.primary on the solid accent fill — 1.45:1 light /
1.02:1 dark -> 4.83:1 / 7.42:1.

F-2: exhausted-but-enabled digit keys no longer whole-key dim to 0.35
(~2.2:1) — opacity now only fires for genuinely disabled keys;
"fully placed" is signaled by a checkmark badge at full-opacity ink
(>=6.6:1). digitButtonOpacity gained an isDisabled parameter.

F-3: "Off", "%lld remaining", "fully placed" accessibility strings
localized via String(localized:) x7 locales (Off, %lld remaining,
fully placed, plus the two F-8 hints below).

F-4: docs/designs/05-board.md's stale 1x9 wireframe/preview
skeleton/spec-table entries updated to the 3x3 56pt-key reality;
DigitPadView.swift's header comment corrected.

F-5 (sim-confirmed): Undo/Redo's unconditional foregroundStyle made a
disabled key render identical to the always-enabled Erase key (same
footgun class as #797). Ink now conditions on canUndo/canRedo, falling
back to text.tertiary (the doc's own disabled convention) when
disabled. Verified via idb screenshots on a fresh practice board
(canUndo=false) before/after.

F-6: verified via token math (accent.primary on surface.background:
4.55:1 light / 8.17:1 dark) — already clears AA; no code change,
folded into the F-1 ink work per triage.

F-7: design-system.md gains a text.onAccent alias row documenting the
on-accent-ink pattern; 05-board.md records the Mac remaining-badge
won't-fix adjudication (2026-07-17) alongside its Mac-layout rationale.

F-8: digit keys get a dynamic accessibilityHint by hasSelection
("Places the digit..." / "Arms the digit...") on both compact and Mac
layouts, localized x7.

Adjudicated extra: unifies the exhausted-digit gate — a selected cell
in pencil mode no longer disables an exhausted digit, matching the
no-selection arming path (notes don't care about remaining count).
Pinned by DigitPadViewExhaustedDigitGateTests.

DigitPadView.swift split into DigitPadView+Accessibility.swift (pure
static helpers) to stay under the 400-line file_length ceiling.

8 iPhone-compact Board/DigitPad snapshot baselines re-recorded to match
(armedDigit, pencilNotes, empty x2, inProgress x2, almostComplete x2);
Mac/iPad baselines untouched (Mac never shows the badge or the
Undo/Redo footgun's affected code path).

Closes #855

Co-Authored-By: Claude Fable 5 <[email protected]>
@wei18
wei18 enabled auto-merge (squash) July 17, 2026 08:53
@wei18
wei18 merged commit 127e7fa into main Jul 17, 2026
5 checks passed
@wei18
wei18 deleted the fix/855-digitpad-audit branch July 17, 2026 08:53
wei18 added a commit that referenced this pull request Jul 17, 2026
…oku (#868)

Sudoku's board toolbar always showed "Pause" (bars icon), even before any
digit was placed, even though tapping it only ever opened the "Leave Game?"
sheet — no real pause feature exists yet. Minesweeper's equivalent control
was already state-aware: "Leave" + X pre-first-reveal, "Pause" + bars once
playing. Per #849 adjudication, extract the shared state→label/icon mapping
into `BoardLeaveOrPauseState` / `BoardLeaveOrPauseButton` (GameShellUI, zero
deps) and have both board views derive their own Ready-state signal from it.

Sudoku has no `.idle` board render (`startOrResume()` fires during
`BoardLoaderView`, before the toolbar ever mounts), so its semantically
equivalent Ready signal is "no move made yet on a live session" —
`status == .playing && !canUndo` (`canUndo` mirrors the session's undo
stack, which only digit placement/erase populates, never pencil notes).
Both apps gained a small view-local `showReadyLeaveOverlay` /
`showIdleLeaveOverlay` flag so tapping Leave-ready opens the shared
"Leave Game?" sheet without an illegal pause transition; Resume just hides
the flag. Sheet behavior itself is unchanged.

No new localized strings: `leave.game.leave`, `Pause`, `Resume` already
carry all 7 locales in both catalogs.

Snapshot churn (17 baselines, all reviewed as legitimate):
- 7 fresh/no-move-yet boards now show Leave+X instead of Pause+bars (the
  intended #849 fix): BoardViewBannerTests ads-enabled iPhone light/dark,
  BoardViewTests empty iPhone light/dark-ja/Mac light/dark,
  BoardViewPencilNotesTests (notes-only boards have no digit-undo history).
- 10 fixtures with placed digits (InProgress ×5, AlmostComplete ×4,
  ArmedDigit ×1) needed their `canUndo` fixture value corrected to match
  their visible board content (previously always false regardless of
  placed digits) — toolbar itself is pixel-identical (stays Pause), the
  Undo/Redo buttons flip from incorrectly-disabled to correctly-enabled.

Rebased onto ecea204 (#859/#860/#862): #860's DigitPadView contrast/a11y
rewrite re-recorded 8 of the same iPhone-compact baselines this change
touches. Took upstream as the merge base for the 8 PNG conflicts, then
re-recorded on the fully rebased tree so each baseline reflects the union
of both changes (verified pixel-diffed, e.g. the empty-board banner fixture
now shows both this fix's Leave/X toolbar and #860's digit-pad ink fix in
one frame). No source conflicts — #862's `BoardView+Completion.swift` /
`BoardLoaderView.swift` changes didn't touch the lines this PR edits.

CR round 2 (3 findings, all addressed):

Finding 1 (clock-model honesty): the original comment claimed straight MS
parity, but Sudoku's clock starts at `GameSession.start()` — called by
`BoardLoaderView` before the toolbar ever mounts — while MS's clock starts
only on first reveal/flag. Empirically verified (`GameSessionElapsedTests
.startAtZero`, SudokuCoreKit, plus a new live-session test here) that
`elapsedSeconds == 0` IS the real state at the instant `startOrResume()`
returns, so the Ready window is reachable — just far narrower than MS's:
gated `.leaveReady` on `elapsedSeconds == 0 && !canUndo` (was `!canUndo`
alone), and rewrote the code comment to state the clock-model asymmetry
plainly instead of claiming parity. This also fixes the real bug the
finding flagged: a pencil-marking player (`toggleNote` never touches
`undoStack`) or anyone who's simply let a second tick by now correctly
sees Pause, not Leave, once the clock has genuinely started accruing time.
Verified pause-overlay shape parity separately: both apps mount the exact
same shared `PauseOverlayView` with identical default strings
(`leave.game.title` "Leave Game?" / `leave.game.leave` "Leave") for a
genuine pause AND the Ready-state Leave-confirm — this is pre-existing,
shared, cross-app behavior, not something #849 introduced, so no shape
change was needed.

Finding 2 (resume-mount race): `BoardLoaderView.mountLoaded` renders
`BoardView` (`state = .loaded(viewModel)`) before `await
viewModel.startOrResume()`'s resync lands, so a resumed mid-game
`GameViewModel` could momentarily read the constructor's default
`canUndo == false` and flash `.leaveReady` for one frame. Added
`initialCanUndo` to the live `GameViewModel` init and threaded
`!snapshot.undoMoves.isEmpty` through at construction in
`BoardLoaderView.mountLoaded` — no transient wrong label.

Finding 3 (fixture fidelity): `BoardViewTests.makeViewModel`'s `canUndo`
derivation (`!userCells.isEmpty || elapsedSeconds > 0`) couldn't express
the pencil-only/running-clock scenario Finding 1 fixes, and wasn't faithful
to production's `!undoStack.isEmpty`. Changed the default to
`!userCells.isEmpty` alone (elapsedSeconds decoupled), with an explicit
`canUndo` override where the two must diverge (the `almostCompleteClues`
fixtures encode their near-solved state as puzzle givens, not `userCells`).
Added test coverage in `BoardLeaveOrPauseStateTests` pinning: a running
clock with no move made (pencil-only) resolves to `.pause`; a running clock
with a move resolves to `.pause`; the live-session Ready window is
reachable; and a resumed construction with `initialCanUndo` has no
transient `.leaveReady`.

One additional legitimate re-record from this round: BoardViewPencilNotesTests
now correctly shows Pause (was incorrectly showing Leave under the old
canUndo-only gate, since a pencil-only board has real elapsed time but no
undo history — exactly Finding 1's motivating bug).

Closes #849

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(sudoku): digit pad design-audit findings — armed badge contrast collapse, VoiceOver l10n bypass, doc drift (8 findings)

1 participant