Repository navigation
Conversation
The Claude prober's /api/oauth/usage response carries Claude's extra usage (usage credits) next to the plan windows: a `spend` object (enabled, used and limit in minor units with an exponent) and an `extra_usage` object (the same in cents, plus spend_limit_reached). The reading now keeps it as Headroom.ExtraUsage, tri-state throughout (nil = Claude did not say, never 0 or off), preferring spend and falling back to extra_usage. Both are decoded apart from the limits, so an odd shape there never fails the reading. PaidCreditsAvailable follows the enabled flag. /api/providers/headroom serializes it as extra_usage, and the Overview gauge shows one line under the Claude dials: "Usage credits: on · $0.00 of $350.00 used this month", "off", or "limit reached" in amber; hidden when unknown. Display only. The endpoint reports no purchased balance (spend.balance is null) and no banked limit resets, so those are left out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1 Signed-off-by: Danathar <6772335+Danathar@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
UI render evidenceRender evidence captured. Built from
These are fixture renders, not live data: the page was built from the PR head and filled with synthetic data from |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
The Overview usage gauge now shows Claude's usage credits (extra usage) under the Claude dials: whether they're on, and how much of the monthly cap is spent. Andy asked 11-19 for provider budget credits on the gauge, "just claude at least". This targets v5; Andy forward-ports it to v6.
What you see
One line under the Claude dials:
Usage credits: on · $0.00 of $350.00 used this monthUsage credits: offUsage credits: limit reached · $350.00 of $350.00 …(amber)It's display only. Nothing is turned on, bought or redeemed.
Where the data comes from
It comes from the same
GET /api/oauth/usageresponse the Claude prober already reads; there's no new call. On a live read (11-19) that response carries, next tolimits:spendobject:enabled, plusused/limitas{amount_minor, currency, exponent}extra_usageobject:is_enabled,monthly_limit/used_creditsin cents,decimal_places,spend_limit_reachedThe reading keeps this as
Headroom.ExtraUsage. It prefersspendand falls back toextra_usage. Every field is tri-state: nil means Claude didn't say, and it's never shown as 0 or off. Both objects are decoded separately fromlimits, so an unexpected shape there can't fail the plan reading.PaidCreditsAvailablefollows the enabled flag./api/providers/headroomserializes it asextra_usage(Headroom's customMarshalJSONlists its fields, so it's added there).Not shown, because the endpoint doesn't expose them: the purchased credit balance (
spend.balanceis null, while claude.ai shows the purchased amount) and banked limit resets (no field). Getting those would mean claude.ai's own web API, which is out of scope.MCP parity: v5 has no admin MCP, so there's no MCP read to extend here. The v6 forward port should add
extra_usageto v6's provider-headroom MCP read alongside the dashboard.Tests
rotation_claude_extra_usage_test.go: a new fixture shaped like the live response (testdata/claude_oauth_usage_extra_usage.json; provenance intestdata/README.md) goes through the real HTTP path. Also covered: disabled, limit reached, absent/null/empty/wrong-typed objects (nil, and noextra_usagein the JSON), and theextra_usage-only fallback, including a malformedspend. The plan windows are unchanged in every case.subscription_gauge.test.js: the line for on, off, limit reached, not reported (hidden) and a non-USD currency. All 27 pass locally undernode --test.subscription_gauge_overview_test.go: the render wiring.dashboard.md(usage gauge) andapi-reference/cost-tokens-telemetry.md. Changelog:changelog.d/added-claude-usage-credits-gauge.md.🤖 Generated with Claude Code
https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1