Skip to content

fix(levels): address whole-branch review findings - #24

Merged
tsenoner merged 1 commit into
mainfrom
fix/levels-review
Jun 22, 2026
Merged

fix(levels): address whole-branch review findings#24
tsenoner merged 1 commit into
mainfrom
fix/levels-review

Conversation

@tsenoner

Copy link
Copy Markdown
Owner

Post-merge whole-branch review of the Levels feature (#13, all 4 slices on main) ran 67 agents (7 finders → dual-lens verify → gap sweep). Verdict: no Critical, 1 Important, 25 Minor. This PR fixes the batch you approved, plus surfacing the previously dead-stored best Ao5 time.

🟠 Important

  • Un-awaited DB reset race in the 4 new Levels test files (useLevelTest, useSpeedChallenge, useUnlockedLevel, LevelsScreen). They called _resetDbForTests() + deleteDatabase() without awaiting — the exact race the helper's docstring warns about, and the asymmetry with useDaily.test.ts (which was migrated). Now both are awaited.

🟡 Surface best Ao5 (your call: "surface it")

  • speedBestAo5 was written to IndexedDB forever but never read — only the tier badge was shown. Consolidated useSpeedBestTieruseSpeedBest({ tier, bestMs, record }), which reads back both keys (monotonic: max tier, min time) and shows Speed challenge · best 4.21s 🥈 → on the Levels screen. onDone now carries the earned time so a just-finished run reflects immediately (no read-back race).

🟡 Minor fixes

  • Silent level test: now plays playFeedback(correct, { sound }) (chime/haptic) like QuickDrill/GuidedSolve — it graded silently before.
  • Recompute: the correct weekday is computed once and reused by both the feedback and the picker reveal (was recomputed each render).
  • DNF test hardened: asserts neither speedBestTier nor speedBestAo5 was persisted on a DNF.
  • tierForAo5: documented the type-mandated, unreachable ?? 0.
  • useDaily comments: corrected the stale frozen-day / "credited" wording left by the correct-only streak rewire (no logic change).

Deliberately not changed (noted in review)

  • First Practice problem draws at level 0 (ref resolves async) — one valid-but-narrower problem/session; clean fix needs a sync cache. Low value.
  • Heatmap counts challenge days while the rest of Progress is practice-scoped — consistent with the kept "challenges count toward the streak" decision.
  • recordPracticeDay backward-clock edge & accuracyByDimension guard — pre-existing / every caller pre-filters.

Verification

  • Gates: typecheck ✓ · lint --max-warnings 0 ✓ · 286 tests ✓ · build ✓
  • Adversarial re-review of this fix diff: 2 candidates raised, 0 survived verification.

🤖 Generated with Claude Code

Post-merge whole-branch review of the Levels feature (#13) surfaced one
Important test-race plus a cluster of Minors. This is the agreed fix batch:

- tests: await _resetDbForTests() then deleteDatabase in the 4 new Levels
  test files (was an un-awaited race the helper's own docstring warns
  against; now matches useDaily.test.ts)
- speed: surface the best Ao5 time — consolidate useSpeedBestTier into
  useSpeedBest({ tier, bestMs, record }), which reads back the previously
  dead-stored speedBestAo5 and shows "best 4.21s 🥈" on the Levels screen
- levels: the level test now plays a correctness chime/haptic (playFeedback,
  honoring soundEnabled) like QuickDrill/GuidedSolve — it was silent
- levels: compute the correct weekday once and reuse it for the feedback and
  the picker reveal (was recomputed each render)
- test: the DNF speed test now asserts no best tier/time was persisted
- levels: document the type-mandated `?? 0` in tierForAo5 (unreachable row)
- daily: fix stale comments left by the correct-only streak rewire

Gates green: typecheck, lint (--max-warnings 0), 286 tests, build.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
daycipher Ready Ready Preview, Comment Jun 22, 2026 4:25pm

@tsenoner tsenoner closed this Jun 22, 2026
@tsenoner
tsenoner deleted the fix/levels-review branch June 22, 2026 16:28
@tsenoner
tsenoner restored the fix/levels-review branch June 22, 2026 16:35
@tsenoner tsenoner reopened this Jun 22, 2026
@tsenoner
tsenoner merged commit 1e1a6ba into main Jun 22, 2026
4 checks passed
@tsenoner
tsenoner deleted the fix/levels-review branch June 22, 2026 16:47
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