From d4489f24a05911d1395e8473fe86c3442d9397ee Mon Sep 17 00:00:00 2001
From: Claude <noreply@anthropic.com>
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/pages/DeckDetailPage.tsx | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

(limited to 'src/client/pages/DeckDetailPage.tsx')

diff --git a/src/client/pages/DeckDetailPage.tsx b/src/client/pages/DeckDetailPage.tsx
index be4dc90..97f8378 100644
--- a/src/client/pages/DeckDetailPage.tsx
+++ b/src/client/pages/DeckDetailPage.tsx
@@ -7,6 +7,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
 import { useAtomValue } from "jotai";
 import { Suspense } from "react";
 import { Link, useParams } from "wouter";
+import { getEndOfStudyDayBoundary } from "../../shared/date";
 import { cardsByDeckAtomFamily, deckByIdAtomFamily } from "../atoms";
 import { ErrorBoundary } from "../components/ErrorBoundary";
 import { LoadingSpinner } from "../components/LoadingSpinner";
@@ -27,9 +28,9 @@ function DeckHeader({ deckId }: { deckId: string }) {
 function DeckStats({ deckId }: { deckId: string }) {
 	const { data: cards } = useAtomValue(cardsByDeckAtomFamily(deckId));
 
-	// Count cards due today
-	const now = new Date();
-	const dueCards = cards.filter((card) => new Date(card.due) <= now);
+	// Count cards due today (study day boundary is 3:00 AM)
+	const boundary = getEndOfStudyDayBoundary();
+	const dueCards = cards.filter((card) => new Date(card.due) < boundary);
 
 	return (
 		<div className="bg-white rounded-xl border border-border/50 p-6 mb-6">
-- 
cgit v1.3-1-g0d28

