Skip to content

fix(minesweeper): graceful offline degrade for Daily Hub + resume (#530 #515) - #532

Merged
wei18 merged 2 commits into
mainfrom
worktree-agent-a6d2b7d6d5e3123e8
Jun 16, 2026
Merged

wei18 merged 2 commits into
mainfrom
worktree-agent-a6d2b7d6d5e3123e8

Conversation

@wei18

@wei18 wei18 commented Jun 16, 2026

Copy link
Copy Markdown
Owner

Two Minesweeper iCloud-signed-out bugs, same gate family as #512/#526.

#530 — MS Daily Hub two-phase render

MinesweeperDailyHubViewModel.bootstrap() now renders the (local, synchronous) trio immediately (state = .loaded), then fills completed+failed overlays async/best-effort (guard case .loaded + per-fetch catch). Mirrors the shipped Sudoku #526 fix, so a hanging CloudKit fetch can't block the hub.

#515 — MS resume degrades offline

MinesweeperSavedGameStore.loadInProgress/latestInProgress now map an iCloud-signed-out fetch (UserFacingError.classify == .iCloudSignedOut) to nil (no resumable game) instead of throwing — the Home resume pill degrades gracefully offline. Schema-too-new + decode errors still propagate (the #463 contract) since they occur after the fetch, outside the catch.

Verification

swiftlint --strict clean (5 files); MinesweeperKit 179/179 (--no-parallel). New tests: hang-repro + fast-fail + happy-path (#530); notAuth→nil ×2 + schema-still-throws + decode-still-throws regression guards (#515).
Leader sim-verified (iPhone 17 Pro, no iCloud): MS Daily Hub renders 3 cards offline (Beginner/Intermediate/Expert, —).

Review

Sonnet CR: PASS — #515 classification correct (only iCloudSignedOut→nil; schema/decode rethrow; tests non-vacuous), #530 two-phase correct + hang test would fail pre-fix, Package.swift SudokuCoreKit dep is test-target-only (already transitive). No blocking findings.

🤖 Generated with Claude Code

wei18 and others added 2 commits June 16, 2026 15:08
Bootstrap now sets `state = .loaded(mergeCards(trio, [], []))` immediately
after the synchronous `provider.dailyTrio(date:)`, then fills completion
and failure overlays async in `fillCompletionAndFailureOverlay` (Phase 2).
A CloudKit hang (iCloud signed out) can no longer block the hub's initial
render — same gate class and fix shape as the shipped Sudoku fix (#526).

Added `guard case .loaded = state else { return }` defensive check at
Phase-2 entry and exit (Sonnet's #526 nit, now applied to MS too).

New test file `MinesweeperDailyHubViewModelOfflineTests.swift` adds three
tests mirroring `DailyHubViewModelOfflineTests`:
- `bootstrapReachesLoadedEvenWhenCompletedIdsFetchHangsForever`
- `bootstrapReachesLoadedWhenCompletedIdsFetchThrowsImmediately`
- `bootstrapMarksCompletedCardsWhenPersistenceReturnsIds` (happy-path guard)

Package.swift: added SudokuCoreKit as explicit dep of MinesweeperUITests
so offline-hub fakes can implement PersistenceProtocol (which uses
Mode/GameSessionSnapshot from SudokuCoreKit) under InternalImportsByDefault.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…eStore (#515)

`loadInProgress(recordName:)` and `latestInProgress()` now catch errors
classified as `.iCloudSignedOut` (CKError.notAuthenticated code 9, and
`PersistenceError.iCloudNotSignedIn`) and return `nil` instead of throwing.
This degrades the Home resume pill / resume flow gracefully when iCloud is
signed out, rather than dead-ending with a thrown error.

Schema and decode errors are NOT caught — `PersistenceError.schemaVersionTooNew`
and JSON decode failures still propagate, preserving the #463 contract that
lets callers hide or delete a broken candidate.

New tests in `MinesweeperSavedGameStoreTests.swift`:
- `loadInProgressReturnsNilOnICloudSignedOutError` — fetch throws CKError 9 -> nil
- `latestInProgressReturnsNilOnICloudSignedOutError` — query throws CKError 9 -> nil
- `loadInProgressStillThrowsOnSchemaVersionTooNew` — regression guard for #463
- `loadInProgressStillThrowsOnDecodeError` — regression guard for #463

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@wei18
wei18 merged commit 98217c1 into main Jun 16, 2026
4 checks passed
@wei18
wei18 deleted the worktree-agent-a6d2b7d6d5e3123e8 branch June 16, 2026 07:27
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.

1 participant