Skip to content

feat(daily): filter stale dailies + mark late-completion (#228 e+b) - #230

Merged
wei18 merged 2 commits into
mainfrom
feat/daily-rollover-eb
Jun 1, 2026
Merged

wei18 merged 2 commits into
mainfrom
feat/daily-rollover-eb

Conversation

@wei18

@wei18 wei18 commented Jun 1, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #228 with user-confirmed direction option E + B.

  • E: `SavedGameStore.latestInProgress()` filters out in-progress daily saves whose embedded UTC day is earlier than today. Practice saves untouched. Stale records aren't deleted — just hidden from the resume candidate set so they no longer mask newer saves.
  • B: `GameViewModel.isLateCompletion` flags past-day dailies; `BoardView` header renders a small `clock.badge.exclamationmark` icon next to the difficulty label with accessibility text `"Late completion — won't score on leaderboard"`. No banner/modal — subtle marker only.

Files (5, +272/-3)

  • `Packages/PersistenceKit/Sources/Persistence/Live/SavedGameStore.swift` — filter + inline `extractDailyDay(from:)` helper
  • `Packages/SudokuKit/Sources/SudokuUI/Board/GameViewModel.swift` — injectable `clock` + `isLateCompletion` + matching helper
  • `Packages/SudokuKit/Sources/SudokuUI/Board/BoardView.swift` — header marker
  • `Packages/PersistenceKit/Tests/PersistenceTests/LatestInProgressFilterTests.swift` — 5 tests for E
  • `Packages/SudokuKit/Tests/SudokuUITests/GameViewModelLateCompletionTests.swift` — 4 tests for B

Behavior preserved

  • Today's daily resumes identically (no marker, no filter exclusion).
  • Practice saves resume identically.
  • `SubmitGuards` still drops Game Center submissions for past-day dailies (unchanged).
  • `markCompleted` still runs locally for stale dailies (filed as follow-up: stale-record cleanup + whether to skip local completion flip are separate concerns).

Verification

  • `swift test --filter LatestInProgressFilterTests` → 5/5 pass
  • `swift test --filter GameViewModelLateCompletionTests` → 4/4 pass
  • `swift build --package-path Packages/SudokuKit` → green
  • `tuist build Sudoku --platform iOS` → green
  • CI: lint:swift_strict, iOS + macOS test suites

Authorship

Senior Developer subagent fully diagnosed + spec'd the diff but was blocked from applying by tool permissions (same as #229). Leader applied the spec verbatim plus the test fixtures.

🤖 Generated with Claude Code

wei18 and others added 2 commits June 1, 2026 15:38
User-confirmed direction for issue #228: option E + B hybrid.

E — Resume pill filter
----------------------
`SavedGameStore.latestInProgress()` now drops in-progress daily saves
whose embedded UTC day is strictly earlier than today. Practice saves
are untouched (they never expire). Stale records themselves are NOT
deleted in this PR — just filtered out of the resume candidate set so
they no longer mask newer non-stale saves.

Implementation:
- Inline `extractDailyDay(from:)` helper duplicated from
  `GameCenterClient/SubmitGuards` rather than re-exported across the
  package boundary (foundations.md §2 forbids the upward arrow).
- Uses the same `UTCDay.string(from:)` helper SubmitGuards uses, so
  the two cross-day comparisons stay consistent.
- `SavedGameStore` already had injectable `clock` (used by save flow);
  the filter reuses it without ABI change.

B — Late-completion affordance
------------------------------
`GameViewModel.isLateCompletion` computes `true` iff this is a daily
puzzle whose embedded UTC day is earlier than `clock()`. `BoardView`'s
header renders a small `clock.badge.exclamationmark` icon next to the
difficulty label with accessibility text "Late completion — won't score
on leaderboard". No banner / modal — subtle marker only.

Injectable `clock: @sendable () -> Date` added to both `GameViewModel`
inits (live + snapshot) with `{ Date() }` default — fully source-compat
for existing call sites.

Behavior preserved
------------------
- Today's daily renders identically (no marker, no filter exclusion).
- Practice saves render and resume identically.
- `markCompleted` still runs locally for stale dailies (no submission to
  Game Center — that's SubmitGuards' job, unchanged). Filed as a
  follow-up note: cleanup of stale records + whether to skip the local
  completion flip are separate concerns.

Tests
-----
- `Packages/PersistenceKit/Tests/PersistenceTests/LatestInProgressFilterTests.swift`
  (5 tests): today's daily eligible, yesterday's daily filtered, stale
  daily doesn't mask fresh practice, practice never expires, newest
  non-stale wins over stale + older fresh.
- `Packages/SudokuKit/Tests/SudokuUITests/GameViewModelLateCompletionTests.swift`
  (4 tests): yesterday's daily is late, today's daily is not, future-
  dated daily is not, practice is never late.

Verified
--------
- swift test --filter LatestInProgressFilterTests → 5/5
- swift test --filter GameViewModelLateCompletionTests → 4/4
- swift build --package-path Packages/SudokuKit → green
- tuist build Sudoku --platform iOS → green

Sr Dev diagnosed + spec'd the diff; Leader applied verbatim plus tests.

Closes #228.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
…name)

Strict swiftlint flagged `vm` (under the 3-char minimum). Same class
of CR-after-CI fix as #221 — pre-existing rule applied to new code.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@wei18
wei18 merged commit 7d631b9 into main Jun 1, 2026
5 checks passed
@wei18
wei18 deleted the feat/daily-rollover-eb branch June 1, 2026 10:01
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.

design: resume-game behavior when daily puzzle has rolled to a new day

1 participant