Repository navigation
feat(sudoku): digit-first input — arm a keypad digit, tap cells to place - #781
Merged
Merged
Conversation
Owner UX proposal #722 (recorded default: implicit dual-mode, no settings toggle). Tapping a keypad digit with NO cell selected arms it: the button renders prominent, every placed instance of that digit lights up with the existing same-digit token, and consecutive taps on empty cells place it (or toggle its pencil note in notes mode) through the existing placeDigit/ toggleNote paths — mistake counting, error surfacing, undo, completion and persistence rules all apply unchanged. Selecting a cell first keeps today's cell-first flow untouched. Invariant: armedDigit != nil iff selection == nil, enforced at exactly two mutator sites in GameViewModel (select() disarms unconditionally — arrow- key selection included; armDigit() clears selection). Tapping a user- filled cell while armed falls back to select-and-disarm; given cells stay inert (no Button wrapper per #473), same as cell-first. - keypadDigit/tapCell dispatchers live in a new GameViewModel+DigitFirst extension (VM owns mutation decisions; directly unit-testable) - DigitPadView: armed digit renders .borderedProminent + .isSelected a11y trait (no new strings, no new theme tokens); the compact layout's remaining==0 disable now applies only when a selection exists, so an exhausted digit can still be armed for notes use - BoardView+Highlighting: isSameDigit target = selected cell's digit ?? armedDigit (mutually exclusive by invariant) Tests: 12 new VM tests (arm/disarm, placement-stays-armed, filled-cell fallback, selection/armed mutual exclusion, pencil composition, undo) + 1 armed-state iPhone snapshot (new suite file; BoardViewTests sits at the file_length ceiling). Existing snapshot baselines byte-identical. Verification: GameViewModel|BoardView filtered batches 63 tests / 12 suites pass (full-suite runs segfault locally on unmodified main, known); swift build clean; swiftlint --strict 0 violations; new snapshot PNG eyeballed (armed keypad prominent, board same-digit tint, no selection tint). Closes #722 Co-Authored-By: Claude Fable 5 <[email protected]>
wei18
enabled auto-merge (squash)
July 11, 2026 13:10
wei18
added a commit
that referenced
this pull request
Jul 11, 2026
…722) (#782) Timeline log for the five-issue wave: cross-app coordinate a11y l10n (#755/PR #776), Sudoku state-suffix l10n (#771/PR #777), the #716 premise refutation + pencil-notes snapshot regression lock (PR #778), MS practice personal bests via seed-derived ids (#705/PR #779), and Sudoku digit-first input (#722/PR #781). Records the three pre-push review catches, the seed-reuse design decision, and process notes (haiku numeric spot-checks, reviewer send-report instruction, filtered-batch verification). Co-authored-by: Claude Fable 5 <[email protected]>
wei18
added a commit
that referenced
this pull request
Jul 13, 2026
…, exhausted+armed opacity (#790) (#799) Re-audit 2026-07-13 found three MAJOR gaps in #781's digit-first input, all in BoardView/DigitPadView/BoardCellView: 1. `handleKeyPress`'s digit branch called `placeDigit(_:)` directly (via the now-removed `placeOrToggle`), which no-ops with no selection — Mac keyboard users had no way to arm a digit at all. Routes through the extracted `dispatchKeyboardDigit(_:)`, which calls `viewModel.keypadDigit(_:)` — the same arm/place/pencil-note dispatch the pointer-driven digit pad already uses. 2. An armed digit changes an empty cell's tap semantics (select → place) with zero VoiceOver signal — the cell's label still read only "Empty". `BoardCellView` now appends a localized "will place N" hint while armed, and `BoardView` posts an `AccessibilityNotification.Announcement` on arm/disarm. Three new catalog keys ("will place %lld", "Digit %lld armed", "Digit unarmed") across all 7 locales. 3. An exhausted-but-armed keypad digit dimmed to 0.35 opacity while still rendering `.borderedProminent` — looked disabled while staying interactive (armed digits are valid for notes use even when fully placed). Extracted `digitButtonOpacity(remaining: isArmed:)` excludes armed digits from the dim. `dispatchKeyboardDigit`, `accessibilityLabel` (BoardCellView), and `armedAnnouncementMessage`/`digitButtonOpacity` were widened from `private` specifically so the new tests exercise the REAL logic (confirmed red on pre-fix code via `git stash` + `swift test`) rather than a re-implementation that can't regress. SwiftUI's `KeyPress` has no public initializer (confirmed against Apple's Accessibility/ SwiftUI sample code), so `handleKeyPress` itself stays untested; `dispatchKeyboardDigit` is the closest testable seam. Verification: `swift test --package-path Packages/SudokuKit` — 303 tests / 63 suites pass (12 new); `mise run lint:swift_strict` 0 violations on changed files; `mise run scan:l10n` passes (2 catalogs, 7 locales complete). Sudoku-only — Minesweeper/GameShellKit untouched. Closes #790 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
Sudoku digit-first input (#722, owner UX proposal; recorded default = implicit dual-mode, no settings toggle). Tapping a keypad digit with no cell selected arms it — the button renders
.borderedProminentwith an.isSelecteda11y trait, every placed instance of the digit lights with the existing same-digit token, and consecutive taps on empty cells place it (pencil mode: toggles that digit's note) through the existingplaceDigit/toggleNotepaths, so mistake/error/undo/completion/persistence rules apply unchanged. Cell-first flow is untouched when a selection exists.Invariant
armedDigit != nil ⟺ selection == nil: enforced at two mutator sites (select()disarms unconditionally incl. arrow keys;armDigit()clears selection), asserted at construction and in the test seam (CR hardening), andarmedDigitis never persisted (verified — no snapshot field).GameViewModel+DigitFirst.swift:keypadDigit/tapCelldispatchers (VM owns mutation decisions, directly unit-tested)DigitPadView: armed visual via existing styles; compact layout'sremaining == 0disable now applies only with a live selection so exhausted digits can still be armed for notesBoardView+Highlighting: same-digit target = selected digit ?? armed digit (mutually exclusive)Verification
Closes #722
🤖 Generated with Claude Code