TokenStep 0.2.23: fix Claude quota showing 100% at 1% usage - #29
Merged
Merged
Conversation
The usage endpoint reports utilization on a 0–100 scale, but values at or below 1 were treated as a 0–1 fraction and scaled by 100. A weekly window at 1% right after its reset showed as 100% in the popover. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Release notes, CHANGELOG, README and the build default, via script/prepare_release.sh. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Problem
The popover showed Claude Code's 7-day quota as 100% (red) while the real usage was 1%.
The
/api/oauth/usageendpoint reportsutilizationon a 0–100 scale (e.g.seven_day.utilization = 1.0means 1%).ClaudeQuotaService.normalizedPercenttreated any value ≤ 1 as a 0–1 fraction and multiplied it by 100, so a window between 0% and 1% — common right after the weekly reset — displayed as 100%.Fix
Drop the fraction heuristic and only clamp the value to 0–100.
Verification
five_hour = 5.0,seven_day = 1.0, which matches Claude's own 5% / 1%.script/test_compact_popover.shpasses.Note: a stale
claude-quota-cache.jsonmay keep showing 100% for up to 4 minutes after upgrading, until the cache expires.🤖 Generated with Claude Code