Repository navigation
fix(resume): stop offering finished/virgin games as resume candidates - #679
Merged
Merged
Conversation
…#675) Home kept showing "Resume Easy — 0:00" after finishing a Sudoku game. Two real layers (of three hypothesized): H2 — orphan virgin record: `SavedGameStore.loadOrCreate` eagerly best-effort-saved a fresh idle snapshot (status inProgress, elapsed 0) on EVERY first mount of a puzzle. A board mounted then closed before the first move — e.g. Play Again then immediate Close — left that 0:00 record behind forever as the newest inProgress save. Removed the eager seed-write: `GameViewModel` already persists on the first real mutation (`scheduleSave`) or pause (`flush`), so a never-touched session is now correctly represented by NO record. This also removes the `fetchFailed` special case (#512 CR) — no write on any path means no clobber risk. H3 — stale in-session pill: `GameRootViewModel.bootstrap()` fetches the resume candidate once per launch, so even a properly `markCompleted`'d game kept its pill until relaunch. Added game-agnostic `refreshResumeCandidate()` (re-runs the injected `fetchResume`, clears on nil, funnels errors) and wired it into both teardown paths: `dismissGame()` (iOS fullScreenCover) and the `path`-shrink setter in `GameRoot.shellContent` (macOS NavigationStack pop, which never goes through `dismissGame()` — Leave/Close pop `path` directly via `BoardView+Completion.exitToHub`). Both apps get this for free via GameAppKit. H1 — completed record stuck inProgress: NOT reproducible on current main; `GameViewModel.markCompletedIfNeeded` (#610 fix *3) already flips the record on the playing→completed edge, and the debounced save is scheduled before the flip lands so the final write order is safe (markCompleted rewrites status after any racing autosave of the terminal snapshot would also carry "completed" via `SavedGameMapper`). Minesweeper: not affected by either layer — its store has no eager seed-write (`MinesweeperGameViewModel.persistCurrentState` guards `status != .idle`) and terminal reveals persist won/lost immediately (wireStatus maps them off "inProgress"); the H3 refresh applies to MS automatically through the shared GameRoot/GameRootViewModel. Tests: PersistenceKit CRUD tests now pin loadOrCreate-writes-nothing; GameAppKit gains refreshResumeCandidate clear/pickup tests and a dismissGame-triggers-refresh test. Suites green: PersistenceKit 74, GameAppKit 26, SudokuKit 261, MinesweeperKit 173. Co-Authored-By: Claude Fable 5 <[email protected]>
This was referenced Jul 5, 2026
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.
Fixes #675 (owner device report: 'Resume Easy — 0:00' after finishing a game).
Root-cause investigation (3 hypotheses, all adjudicated with evidence):
GameViewModel.markCompletedIfNeeded+ the mapper's.completed → "completed"; the issue's 2026-06-24 premise was stale. No second terminal write added.SavedGameStore.loadOrCreateeagerly persisted a virgin idle record (status inProgress, elapsed 0) on EVERY board mount — open-then-close left it as the permanentlatestInProgress. Fix: eager seed-write removed; first real mutation/pause (existingscheduleSave/flush) is the persistence trigger.GameRootViewModel.refreshResumeCandidate()hooked atdismissGame()(iOS modal) and path-shrink detection (macOS push pop) — Minesweeper inherits both via the shared typealias, zero MS code.Tests: PersistenceKit 74 · GameAppKit 26 (3 new, incl. a mutable fetch stub proving genuine re-fetch) · SudokuKit 261 · MinesweeperKit 173 — all green. Dual CR APPROVE ×2 (H1/H2/H3 citations + MS immunity independently verified; full suites re-run by reviewer).
Note for the owner: historical 0:00 orphan records already in CloudKit are not purged by this fix — a stale pill from OLD data disappears once that puzzle's board is touched again (or a one-off cleanup can be filed if it bothers you). Device check: finish a practice game → Home → no pill; play one move → leave → pill appears.
🤖 Generated with Claude Code