Skip to content

fix(usage): stop extra-usage credit pools from marking a provider out of limit - #321

Merged
patroza merged 2 commits into
fork/changesfrom
t3code/fix-extra-usage-status
Aug 4, 2026
Merged

fix(usage): stop extra-usage credit pools from marking a provider out of limit#321
patroza merged 2 commits into
fork/changesfrom
t3code/fix-extra-usage-status

Conversation

@patroza

@patroza patroza commented Aug 4, 2026

Copy link
Copy Markdown
Owner

Problem

With Claude at 5h 18% / weekly 78%, the provider dot and usage tooltip still showed red / "limit reached" — because the ai-usage daemon reports the extra-usage credit buffer as a monthly window 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. usageMarkerForItem treated 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 it informational: 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)).
  • Marker fill, the outlook ring, the immediate-window pick, and worstUsagePercent now consider enforced windows only. Money-denominated plan windows still enforce (opencode-go monthly $, cursor monthly billing cycle).
  • Web tooltip renders non-enforced rows with a neutral bar and muted value instead of a red bar; the red "limit reached" line no longer fires for them. Mobile picks this up automatically via the shared marker.
  • Contract picks up the daemon's existing informational and limit window 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's informational legacy $ pool no longer arms the outlook ring, a maxed real window still goes critical alongside extras, cursor's monthly billing window still enforces, plus direct isEnforcedUsageWindow coverage.

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
patroza marked this pull request as ready for review August 4, 2026 18:04
@patroza
patroza enabled auto-merge (squash) August 4, 2026 18:07
@patroza
patroza merged commit 243fcbf into fork/changes Aug 4, 2026
11 checks passed
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant