Bug: Reading Streak Resets to 0 If User Hasn't Read Today
Describe the bug
The reading streak always shows 0 if the user hasn't logged a session yet today, even if they've read every single day for weeks prior.
Root Cause
In apps/web/src/pages/Stats.jsx, the getReadingStreak() function (line 315) compares dates[i] against today - i days starting from offset 0. So if the user hasn't read today, the very first comparison fails and the loop breaks immediately — returning 0.
Steps to Reproduce
- Log reading sessions consistently for several days in a row
- On a new day, open the Stats page before logging any session
- The streak displays 0 despite the consecutive reading history
Expected Behavior
The streak should remain intact if the user read yesterday. A grace window counting streaks ending on either today or yesterday is the standard behavior (used by Duolingo, Streaks, etc.) and gives users until end-of-day to maintain their streak.
Suggested Fix
In getReadingStreak(), check whether the most recent reading date is today or yesterday before starting the loop, and adjust the offset accordingly:
const startOffset = dates[0] === new Date().toDateString() ? 0 : 1;
for (let i = 0; i < dates.length; i++) {
const expectedDate = new Date();
expectedDate.setDate(expectedDate.getDate() - (i + startOffset));
if (dates[i] === expectedDate.toDateString()) streak++;
else break;
}
File affected
apps/web/src/pages/Stats.jsx — getReadingStreak() around line 315
I am a GSSoC 2026 contributor and would love to work on this issue.
Bug: Reading Streak Resets to 0 If User Hasn't Read Today
Describe the bug
The reading streak always shows 0 if the user hasn't logged a session yet today, even if they've read every single day for weeks prior.
Root Cause
In
apps/web/src/pages/Stats.jsx, thegetReadingStreak()function (line 315) comparesdates[i]againsttoday - i daysstarting from offset 0. So if the user hasn't read today, the very first comparison fails and the loop breaks immediately — returning 0.Steps to Reproduce
Expected Behavior
The streak should remain intact if the user read yesterday. A grace window counting streaks ending on either today or yesterday is the standard behavior (used by Duolingo, Streaks, etc.) and gives users until end-of-day to maintain their streak.
Suggested Fix
In
getReadingStreak(), check whether the most recent reading date is today or yesterday before starting the loop, and adjust the offset accordingly:File affected
apps/web/src/pages/Stats.jsx—getReadingStreak()around line 315I am a GSSoC 2026 contributor and would love to work on this issue.