Skip to content

fix(sudoku): sticky digit-first — armed digit survives taps on non-empty cells - #944

Merged
wei18 merged 3 commits into
mainfrom
fix/939-sticky-digit-first
Jul 22, 2026
Merged

wei18 merged 3 commits into
mainfrom
fix/939-sticky-digit-first

Conversation

@wei18

@wei18 wei18 commented Jul 22, 2026

Copy link
Copy Markdown
Owner

What

Sticky digit-first input (owner-approved spec in the issue): while a digit is armed, cell taps never disarm —

  • armed + empty cell → place / pencil-note toggle (unchanged)
  • armed + user-filled same digit → clear (pencil mode: note toggle)
  • armed + different digit or given → no-op with a light haptic (new haptic-only AudioEvent contract: empty soundKey short-circuits before the resolve/log path)
  • disarm only by re-tapping the armed digit on the keypad
  • invariant armedDigit != nil ⟺ selection == nil preserved

VoiceOver truthfulness: "will clear N" hint added for armed same-digit cells (incl. the conflict-cell branch), catalog key will clear %lld in all 7 locales + regenerated fixture.

Verification

  • 31 digit-first/a11y tests green (SudokuKit filtered, --no-parallel); GameAudioKit 18/18 green; mise run scan:l10n green; swiftlint --strict clean.
  • Dual code review, 2 rounds: 2 MAJORs (stale VoiceOver labels; empty-soundKey bundle rescan/log spam) + 1 MINOR (conflict-cell hint) found and fixed.
  • Fresh-context acceptance 5/5 PASS incl. full sim protocol: arm → 3 consecutive placements → given-cell mis-tap stays armed → same-digit clear stays armed → keypad re-tap disarms.

Sudoku-only (no shared input code with Minesweeper — verified).

Closes #939

🤖 Generated with Claude Code

wei18 and others added 3 commits July 22, 2026 23:42
Digit-first `tapCell` used to fall back to `select(...)`, which
unconditionally disarms, whenever an armed tap landed on any non-empty
cell — a fast sweep died the moment it mis-tapped a filled cell or a
given. Per the owner-approved sticky-armed decision: an armed tap now
only clears/no-ops without ever disarming.

- tapCell(row:column:): empty cell places/toggles-note (unchanged);
  a user-filled cell holding the armed digit clears it (toggle) in
  normal mode, or toggles the note in pencil mode; any other non-empty
  cell (different digit, or a given) is a no-op that stays armed and
  fires a light haptic via the existing GameAudio haptic seam
  (`sudokuArmedMismatch`, iOS-only, no new infrastructure).
- Re-tapping the armed digit on the keypad remains the only disarm —
  already worked via `armDigit`'s toggle, verified by existing tests.
- Updated doc comments for the `armedDigit != nil ⟺ selection == nil`
  invariant, which now holds because tapCell never calls select()
  while armed.

Co-Authored-By: Claude <[email protected]>
MAJOR 1 (stale VoiceOver semantics): a sticky-armed tap on a user-filled
cell holding the armed digit now CLEARS it (destructive), but the a11y
label never announced this, and the "no hint on filled cells" test
comment still described the pre-#939 select()-fallback rationale.
Thread `pencilMode` into BoardCellView (mirrors the #790 `armedDigit`
threading) and append a new "will clear N" hint when armed, non-given,
non-error, and non-pencil (pencil mode toggles a note on that same tap,
not a clear, so the hint is scoped off there). New catalog key "will
clear %lld" fanned out to all 7 locales, mirroring "will place %lld"'s
registration; regenerated the SudokuAppCompositionTests l10n fixture
via `mise run gen:l10n_fixture`. Rewrote the stale test + added cases
for same-digit/different-digit/given/pencil-mode.

MAJOR 2 (haptic-only event rescans + logs per tap): `sudokuArmedMismatch`
(soundKey: "") hit LiveSoundPlayer's uncached bundle-resolve path (and
its per-call missing-asset log) on every mismatch tap in exactly the
fast-sweep path #939 optimizes. `play(_:)` now short-circuits on an
empty soundKey right after the haptic block, before touching the
resolve path; documented the "haptic-only" contract on
`AudioEvent.soundKey`. Added a GameAudioKit test locking that the
haptic still fires despite the early return (the resolve-skip itself
has no unit-testable public signal — `sfxPlayers`/`resolveSFXPlayerLocked`
are `private`, unreachable even via `@testable import`).

Co-Authored-By: Claude <[email protected]>
`accessibilityLabel`'s `isError` branch returned before the new
"will clear" logic, so an armed tap on a CONFLICTING user-filled cell
holding the armed digit — which `tapCell` clears exactly like a
non-conflicting one — only announced "conflict N" with no hint that
the tap would clear it. Append the same "will clear \(digit)" suffix
(reusing the existing catalog key, no new string / l10n change) when
`armedDigit == digit && !isGiven && !pencilMode`, mirroring the
non-error branch's gate. Added matching + pencil-mode-unchanged test
cases for the error path.

Co-Authored-By: Claude <[email protected]>
@wei18
wei18 enabled auto-merge (squash) July 22, 2026 16:23
@wei18
wei18 merged commit f1aee21 into main Jul 22, 2026
5 checks passed
@wei18
wei18 deleted the fix/939-sticky-digit-first branch July 22, 2026 16:23
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): sticky digit-first — armed digit must survive taps on non-empty cells

1 participant