Skip to content

fix: the Claude usage calendar shows days it can't vouch for as unavailable, not zero - #1058

Merged
badcuban merged 1 commit into
mainfrom
fix/claude-calendar-unknown-days
Nov 23, 2026
Merged

badcuban merged 1 commit into
mainfrom
fix/claude-calendar-unknown-days

Conversation

@badcuban

Copy link
Copy Markdown
Collaborator

On a fresh install, the Claude "Local token activity" calendar showed "0 tokens" for every day of the past year, including days whose transcripts Claude Code had already deleted. Whenever the transcript scan finished, the reader claimed the whole year as covered.

Coverage now comes only from days a reading saw in full:

  • The days Claude Code still keeps transcripts for (cleanupPeriodDays, capped at 30 because the setting may have been raised after files were deleted; none when it is 0).
  • The saved history (providerTokenUsageStore.ts) records that range in its file and grows it while each read covers the previous read's last day again. It builds back toward a year, and starts over after a gap long enough for files to have gone.
  • Claude's stats cache no longer counts as proof of a quiet day, because Claude Code may have built it after transcripts were gone.
  • A partial scan claims nothing new. A transcript folder that can't be listed now makes the scan partial instead of silently skipping it.

The saved history also keeps days later than a reading's own "today" (a read that started before midnight, or a clock set back), and joins the range a failed save left in memory with the one on disk.

On the calendar, a day with recorded usage still shows before the known range, and a week with an unknown past day isn't reported as quiet.

Known limit: if cleanupPeriodDays was lowered and then raised again before Threadlines' first read, the files deleted in between can't be detected.

Tested with new store tests (midnight race, a read that no longer sees the last day), a reader test (30-day limit with the setting at 365, the range across restarts and after a gap, the range saved to disk), and a browser test (a quiet day before the range says "Usage unavailable", a usage day there still shows). Format, lint and typecheck pass, and the full browser suite passes.

…ilable, not zero

On a fresh install the Local token activity calendar showed "0 tokens"
for every day of the past year, including days whose transcripts Claude
Code had already deleted. Whenever the transcript scan finished, the
reader claimed the whole year as covered.

Coverage now comes only from days a reading saw in full: the days Claude
Code still keeps transcripts for (cleanupPeriodDays, capped at 30 since
the setting may have been raised after files were deleted; none when it
is 0). The saved history records that range and grows it while each read
re-covers the previous read's last day, so it builds back toward a year
and starts over after a gap long enough for files to have gone. Claude's
stats cache no longer counts as proof of a quiet day, a partial scan
claims nothing new, and an unreadable transcript folder makes the scan
partial.

The saved history keeps days later than a reading's own "today" (a read
that started before midnight, or a clock set back) and joins the range a
failed save left in memory with the one on disk.

On the calendar, a day with recorded usage still shows before the known
range, and a week with an unknown past day isn't reported as quiet.
@vercel

vercel Bot commented Nov 23, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated
threadlines Skipped Skipped Nov 23, 2026 4:42pm UTC

Request Review

@badcuban
badcuban added this pull request to the merge queue Nov 23, 2026
Merged via the queue into main with commit a0aacc6 Nov 23, 2026
23 checks passed
@badcuban
badcuban deleted the fix/claude-calendar-unknown-days branch November 23, 2026 16:53

This branch was previously deployed

1 inactive deployment
Preview — a0e32e3c Deployed Nov 23, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant