Repository navigation
fix(sudoku): digit pad audit — badge contrast, exhausted-key affordance, a11y l10n, undo/redo disabled ink - #860
Merged
Merged
Conversation
…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
enabled auto-merge (squash)
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Closes #855 — all 8 design-audit findings on DigitPadView + the Leader-adjudicated extras.
digitButtonOpacity(isDisabled:)matrix deliberately re-pinned (5 cases).String(localized:, bundle: .main)— the module carries no resources block, .main is the only correct bundle) + dynamic hints by hasSelection; 5 keys ×7 locales.Review
Dual CR, both APPROVE (mechanical 11/11). One pre-existing nit spun off:
%lld remaining/%lld completedlack 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