Skip to content

fix(sudoku): digit-first follow-ups — keyboard, VoiceOver armed state, exhausted+armed opacity - #799

Merged
wei18 merged 1 commit into
mainfrom
fix/790-digit-first-followups
Jul 13, 2026
Merged

wei18 merged 1 commit into
mainfrom
fix/790-digit-first-followups

Conversation

@wei18

@wei18 wei18 commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Summary

Re-audit 2026-07-13 (main@2609995) found three MAJOR gaps in #781's digit-first input, all fixed here:

  1. Keyboard bypasses digit-first entirely — handleKeyPress's digit branch called placeDigit(_:) directly (via the now-removed placeOrToggle), which silently no-ops with no selection. Mac keyboard users had no way to arm a digit at all. Now routes through the extracted dispatchKeyboardDigit(_:) → viewModel.keypadDigit(_:), the same arm/place/pencil-note dispatch the pointer-driven digit pad already uses.

  2. VoiceOver gets no signal that tap semantics changed while armed — an armed digit changes an empty cell's tap from select → place with zero a11y 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. Exhausted-but-armed keypad button mixed disabled/active visual language — an exhausted digit that's still armed (valid for notes use) dimmed to 0.35 opacity while rendering .borderedProminent — looked disabled while staying interactive. Extracted digitButtonOpacity(remaining:isArmed:) excludes armed digits from the dim. (macDigitButton has no such gate — confirmed no analogous fix needed there.)

dispatchKeyboardDigit, accessibilityLabel (BoardCellView), and armedAnnouncementMessage/digitButtonOpacity were widened from private specifically so the new tests exercise the REAL logic 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.

Closes #790

Test plan

  • swift test --package-path Packages/SudokuKit — 303 tests / 63 suites pass (12 new)
  • New tests confirmed red on pre-fix code (git stash of production files only, re-ran — compile-time red on the new APIs: dispatchKeyboardDigit, armedDigit param, armedAnnouncementMessage, digitButtonOpacity)
  • mise run lint:swift_strict — 0 violations on changed files
  • mise run scan:l10n — 2 catalogs, 7 locales complete
  • rg -n "TODO|FIXME|stub" on the diff — zero hits
  • Scope check — Sudoku-only; Minesweeper/GameShellKit untouched

🤖 Generated with Claude Code

…, exhausted+armed opacity (#790)

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]>
@wei18
wei18 merged commit 09ac395 into main Jul 13, 2026
4 checks passed
@wei18
wei18 deleted the fix/790-digit-first-followups branch July 13, 2026 09:18
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-first follow-ups — keyboard path bypasses armDigit, VoiceOver armed-state gap, exhausted+armed visual conflict

1 participant