From d4489f24a05911d1395e8473fe86c3442d9397ee Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 2 Feb 2026 12:22:03 +0000 Subject: fix(study): use date-based comparison with 3 AM boundary for due cards Instead of comparing due timestamps exactly (card.due <= now), compare against the next 3 AM boundary so all cards due within the current study day appear at once. This prevents new cards from trickling in throughout the day when FSRS fuzz spreads due times. https://claude.ai/code/session_01FeDztLcyGofd6nxh8ct7a3 --- src/client/db/repositories.test.ts | 3 ++- src/client/db/repositories.ts | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src/client/db') diff --git a/src/client/db/repositories.test.ts b/src/client/db/repositories.test.ts index 448cb9e..38cf3fb 100644 --- a/src/client/db/repositories.test.ts +++ b/src/client/db/repositories.test.ts @@ -299,7 +299,8 @@ describe("localCardRepository", () => { describe("findDueCards", () => { it("should return cards that are due", async () => { const pastDue = new Date(Date.now() - 60000); - const future = new Date(Date.now() + 60000); + // Use a date far enough in the future to be beyond the next 3 AM boundary + const future = new Date(Date.now() + 2 * 24 * 60 * 60 * 1000); const card1 = await localCardRepository.create({ deckId, diff --git a/src/client/db/repositories.ts b/src/client/db/repositories.ts index e01254e..5121bae 100644 --- a/src/client/db/repositories.ts +++ b/src/client/db/repositories.ts @@ -1,4 +1,5 @@ import { v4 as uuidv4 } from "uuid"; +import { getEndOfStudyDayBoundary } from "../../shared/date"; import { CardState, db, @@ -140,11 +141,11 @@ export const localCardRepository = { * Get due cards for a deck */ async findDueCards(deckId: string, limit?: number): Promise { - const now = new Date(); + const boundary = getEndOfStudyDayBoundary(); const query = db.cards .where("deckId") .equals(deckId) - .filter((card) => card.deletedAt === null && card.due <= now); + .filter((card) => card.deletedAt === null && card.due < boundary); const cards = await query.toArray(); // Sort by due date ascending -- cgit v1.3-1-g0d28