Repository navigation
fix: the Claude usage calendar shows days it can't vouch for as unavailable, not zero - #1058
Merged
Merged
Conversation
…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.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
cleanupPeriodDays, capped at 30 because the setting may have been raised after files were deleted; none when it is 0).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.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
cleanupPeriodDayswas 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.