Repository navigation
fix(board): start gamesession after load so timer ticks + digit pad lands (#227) - #229
Merged
Merged
Conversation
…ands (#227) Root cause: `BoardLoaderView.load()` constructed a `GameSession` and left it in `.idle`. Every digit-pad tap then failed the `.playing` gate inside the actor and was silently absorbed by `runSession` (M10 error funnel), so the user saw a dead board + a frozen 0:00 timer. The bug shipped on iOS too — PR #211's new macOS 2-column layout (260pt control rail) just made the frozen timer impossible to miss because the user's eye sits on it while contemplating the board. Fix (per Sr Dev's diagnosis on this issue) ------------------------------------------ 1. `GameViewModel.startOrResume()` — idempotent transition that maps `.idle → start()`, `.paused → resume()`, and no-ops otherwise. Both live and snapshot paths handled. 2. `BoardLoaderView.load()` calls `startOrResume()` immediately after `state = .loaded(viewModel)`, so users never sit on an idle session. 3. `BoardView` adds a 1-Hz `.task` ticker that calls `GameViewModel.refreshElapsed()` while `status == .playing`. Without this the timer label only advanced after mutations (via `resyncFromSession`), leaving long contemplation gaps frozen. Regression net -------------- New `GameViewModelStartTests` suite (4 tests) constructs `GameViewModel` via the LIVE init path with a real `GameSession` in `.idle` — exactly what users hit. `BoardViewTests` could not catch this class of bug because its `makeViewModel` uses the snapshot init seam with `status: .playing`, bypassing the actor entirely. Sr Dev diagnosed the bug end-to-end (file:line citations to the actor gate, the silent absorption, and the missing `.start()` call) but was blocked from applying the edit by tool permissions. Leader applied the spec'd diff verbatim plus the regression test. Verified -------- - swift build --package-path Packages/SudokuKit → green - swift test --filter GameViewModelStartTests → 4/4 pass - swift test --filter BoardViewTests → 17/17 pass (existing tests unaffected) - tuist build Sudoku --platform iOS → green Closes #227. Co-Authored-By: Claude Opus 4.7 <[email protected]>
4 of 5 tasks
4 of 5 tasks
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.
Summary
Fixes #227 — macOS Sudoku board had a stuck `0:00` timer and unresponsive digit pad. Sr Dev diagnosed the root cause as: `BoardLoaderView.load()` constructed a `GameSession` and left it in `.idle`. Every digit-pad tap then failed the `.playing` gate inside the actor and was silently absorbed by `runSession`. The bug shipped on iOS too — PR #211's macOS 2-column layout just made the frozen timer impossible to miss.
Fix (Sr Dev's spec, applied verbatim)
Diff: 4 files, +143 LOC. No platform-branch conditionals — fix applies to both iOS and macOS.
Regression net
New `GameViewModelStartTests` suite (4 tests) constructs `GameViewModel` via the LIVE init path with a real `GameSession` in `.idle`:
The existing `BoardViewTests.makeViewModel` uses the snapshot init seam with `status: .playing`, bypassing the actor — this is why the regression slipped through.
Verified
Authorship note
Senior Developer subagent diagnosed the bug end-to-end (root cause with file:line citations to the actor gate, the silent absorption pattern, and the missing `.start()` call) but was blocked from applying the edit by tool permissions. Leader applied the spec'd diff verbatim and added the regression test. Both the diff and the test follow the Developer's specification.
Closes #227.
🤖 Generated with Claude Code