fix(usage): stop extra-usage credit pools from marking a provider out of limit - #321
Merged
Merged
Conversation
The ai-usage daemon reports Claude's extra-usage credit buffer as a `monthly` window. That buffer is only drawn from once the 5-hour and weekly plan windows are exhausted, so a drained (or switched-off) pool says nothing about whether Claude is usable right now — yet `usageMarkerForItem` treated any window at 100% as a hard block, painting the provider dot red and the tooltip "limit reached" while 5h sat at 18%. Markers, the outlook ring, and `worstUsagePercent` now only consider enforced windows: daemon-flagged `informational` pools, extra-usage / credit / on-demand buffers, and windows labelled `(off)` are context only. The tooltip renders those rows with a neutral bar instead of a red one. Money-denominated plan windows (opencode-go monthly $, cursor billing cycle) keep enforcing. Also picks up the daemon's `informational` and `limit` window fields in the contract.
patroza
marked this pull request as ready for review
August 4, 2026 18:04
patroza
enabled auto-merge (squash)
August 4, 2026 18:07
patroza
added a commit
that referenced
this pull request
Aug 5, 2026
… of limit (#321) * fix(usage): stop extra-usage pools from marking a provider out of limit The ai-usage daemon reports Claude's extra-usage credit buffer as a `monthly` window. That buffer is only drawn from once the 5-hour and weekly plan windows are exhausted, so a drained (or switched-off) pool says nothing about whether Claude is usable right now — yet `usageMarkerForItem` treated any window at 100% as a hard block, painting the provider dot red and the tooltip "limit reached" while 5h sat at 18%. Markers, the outlook ring, and `worstUsagePercent` now only consider enforced windows: daemon-flagged `informational` pools, extra-usage / credit / on-demand buffers, and windows labelled `(off)` are context only. The tooltip renders those rows with a neutral bar instead of a red one. Money-denominated plan windows (opencode-go monthly $, cursor billing cycle) keep enforcing. Also picks up the daemon's `informational` and `limit` window fields in the contract. * test(usage): assert the tooltip stays neutral for a drained extras pool --------- Co-authored-by: T3 Code PR Stack <41898282+github-actions[bot]@users.noreply.github.com>
patroza
added a commit
that referenced
this pull request
Aug 5, 2026
… of limit (#321) * fix(usage): stop extra-usage pools from marking a provider out of limit The ai-usage daemon reports Claude's extra-usage credit buffer as a `monthly` window. That buffer is only drawn from once the 5-hour and weekly plan windows are exhausted, so a drained (or switched-off) pool says nothing about whether Claude is usable right now — yet `usageMarkerForItem` treated any window at 100% as a hard block, painting the provider dot red and the tooltip "limit reached" while 5h sat at 18%. Markers, the outlook ring, and `worstUsagePercent` now only consider enforced windows: daemon-flagged `informational` pools, extra-usage / credit / on-demand buffers, and windows labelled `(off)` are context only. The tooltip renders those rows with a neutral bar instead of a red one. Money-denominated plan windows (opencode-go monthly $, cursor billing cycle) keep enforcing. Also picks up the daemon's `informational` and `limit` window fields in the contract. * test(usage): assert the tooltip stays neutral for a drained extras pool --------- Co-authored-by: T3 Code PR Stack <41898282+github-actions[bot]@users.noreply.github.com>
patroza
added a commit
that referenced
this pull request
Aug 5, 2026
… of limit (#321) * fix(usage): stop extra-usage pools from marking a provider out of limit The ai-usage daemon reports Claude's extra-usage credit buffer as a `monthly` window. That buffer is only drawn from once the 5-hour and weekly plan windows are exhausted, so a drained (or switched-off) pool says nothing about whether Claude is usable right now — yet `usageMarkerForItem` treated any window at 100% as a hard block, painting the provider dot red and the tooltip "limit reached" while 5h sat at 18%. Markers, the outlook ring, and `worstUsagePercent` now only consider enforced windows: daemon-flagged `informational` pools, extra-usage / credit / on-demand buffers, and windows labelled `(off)` are context only. The tooltip renders those rows with a neutral bar instead of a red one. Money-denominated plan windows (opencode-go monthly $, cursor billing cycle) keep enforcing. Also picks up the daemon's `informational` and `limit` window fields in the contract. * test(usage): assert the tooltip stays neutral for a drained extras pool --------- Co-authored-by: T3 Code PR Stack <41898282+github-actions[bot]@users.noreply.github.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
With Claude at 5h 18% / weekly 78%, the provider dot and usage tooltip still showed red / "limit reached" — because the
ai-usagedaemon reports the extra-usage credit buffer as amonthlywindow sitting at 100% (Extra usage (off), €47.89 of €45).That buffer is only drawn from once the plan windows are exhausted, so draining it (or having it switched off) says nothing about whether the provider is usable right now.
usageMarkerForItemtreated any window at 100% as a hard block. The DMS widget on the same feed renders that row as neutral context, which is the behaviour we want here.Change
isEnforcedUsageWindow()in the shared client-runtime presentation module: a window is context-only when the daemon flags itinformational: true, when its label is a spend buffer (extra usage,credit(s),overage,on-demand,pay as you go), or when it is switched off ((off)).worstUsagePercentnow consider enforced windows only. Money-denominated plan windows still enforce (opencode-go monthly$, cursor monthly billing cycle).informationalandlimitwindow fields.Tests
apps/web/src/aiUsageState.test.ts— the exact live claude/max feed shape (5h 18 / weekly 78 /Extra usage (off)100) is no longer critical, grok'sinformationallegacy$pool no longer arms the outlook ring, a maxed real window still goes critical alongside extras, cursor's monthly billing window still enforces, plus directisEnforcedUsageWindowcoverage.