Repository navigation
Conversation
Recommendation: preserve fresh cached credits; handle refunds consistentlyVerified: all 40 supplied checks pass. With synthetic endpoint data, the PR adds the expected credit percentage, money detail and countdown; baseline displays only the rate window. Finding 1: reopening the panel drops fresh credits
Impact: valid, recently fetched credit information disappears simply because the panel was reopened. This is not stale/error fallback behavior. Requested change: retain the complete successful response during the reuse interval. Add a fresh mixed rate/credit-cache regression test. Finding 2: refunds lose their money detailThe collector retains Impact: the row remains, but its monetary detail disappears. Requested change: display the valid signed amount, or define a clamped display explicitly, rather than dropping monetary metadata. Test scope: actual UI with synthetic account data. Live billing/schema behavior, large-number layouts and other display sizes were not verified. Bar-alarm exclusion was checked through helper tests and source, not a dedicated visual test. Automated AI review: Astra inspected the PR; Fable 5.1 and a separate Astra session produced independent initial assessments, then findings were checked against targeted tests and the running UI. |
c99ca6b to
8f4f7e4
Compare
|
Thanks, both fixed in 8f4f7e4.
|
8f4f7e4 to
d6ba89a
Compare
|
Rebased onto quattro ("Show the Claude usage-credit allowance in the agents panel"). #15110 estimates a token allowance from local use. This PR shows the monetary credit allowance Anthropic reports, so they don't overlap. Since the panel moved:
|
d6ba89a to
0aab099
Compare
[Medium impact] The PR appears safe to merge; no actionable defects were found. SummaryAdds Claude usage credits as a separate allowance row in the agents panel.
|
Anthropic's OAuth usage endpoint returns a `spend` object beside the rate
limit windows. It is the monetary credit allowance Claude Code's own
`/usage` screen draws, and it fills up the way a window does: a percentage
of a cap, refilled with the billing month. The collector already has that
payload in hand when it reads the windows and dropped the object, so an
account spending against its credits could sit at 97% of them with nothing
in the panel to say so.
Read it as one more window. The collector carries the amounts and the panel
formats them, the way the prepaid balance section already splits that work.
The window gets its own limit line, and hovering it reads:
Usage credits: 97% used · resets in 13d 13h
€487.15 / €500.00 spent
A refund can carry the spend below zero. The meter then reads empty and the
amount keeps its sign: "-€5.00 / €500.00 spent".
`spend` has no reset stamp of its own; credits refill monthly, so the window
resets on the first of the coming month, dated in the offset that day
carries rather than today's. A window past that reset drops its money with
its percentage, since the money belongs to the month that ended.
Ways this window is not a rate limit window:
- Nothing that answers "what stops the next prompt" counts it: not the bar
icon's alarm, not the account autoswitch, and not the faster limit
checks that run while an account nears its switch threshold. Running
credits down returns the account to its rate limit windows rather than
stopping anything, and a month-long window at 100% would hold the bar in
alarm, or an account over its threshold, for weeks over money already
spent.
- The limits cache is a fallback for it only while the cache is current.
A cached percentage of a 5-hour or 7-day window is at worst hours old; a
cached credit figure could misreport the account by weeks of spending.
After a failed probe or a lapsed sign-in, money measured within the last
15 minutes still comes back, the same span in which the panel counts
numbers as live, so a refused re-check does not hide the row. Older
money waits for a probe that reaches the endpoint.
- An amount it cannot read is no window rather than a guess. A missing
exponent is not assumed to mean cents, which would render a zero-decimal
currency a hundredfold short, and two amounts in different currencies
cannot be written as one line.
An account without credits gets no such window and is unchanged: a plan that
never had them carries no `spend` object, one with them switched off says so,
and a prepaid ledger names credits rather than a cap. None of those yield a
window, and none of them cost the account the rate limit windows it does have.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
0aab099 to
a564c4a
Compare



Anthropic's OAuth usage endpoint returns a
spendobject beside the rate limit windows. It is the monetary credit allowance Claude Code's own/usagescreen draws, and it fills up the way a window does: a percentage of a cap, refilled with the billing month. The Claude collector already has that payload in hand when it reads the windows and dropped the object, so an account spending against its credits could sit at 100% of them with nothing in the panel to say so.This reads it as one more window. The collector carries the amounts and the panel formats them, the way the prepaid balance section already splits that work.
spendcarries no reset stamp of its own; credits refill monthly, so the window resets on the first of the coming month, dated in the offset that day carries rather than today's.Three ways it is not a rate limit window
Accounts without credits are unchanged
A plan that never had credits carries no
spendobject, one with them switched off says so, and a prepaid ledger names credits rather than a money cap. None of those yield a window, and none of them cost the account the rate limit windows it does have.Testing
test/shell.d/agent-usage-claude-limits-test.shgoes from 12 assertions to 40. The new ones cover the allowance being read, its reset date across a month end, a year end and a daylight-saving change, spending past the cap clamping the meter at full, a refund emptying it rather than dropping the row, every payload shape that means "no credits", the cache refusing to replay a money figure, the bar binding to a rate limit window instead of the fuller credit window, and the row's detail line in all four combinations of money and countdown.Verification
test/shell.d/agent-usage-claude-limits-test.shpasses, as do the other agents suites:agents-panel,agent-usage-claude-scanner,agent-usage-update,agents-rename-migration,bar-widget-contract../test/all: 8 of 244 files fail. Seven of them fail the same way on a cleanquattrocheckout and are unrelated —bar-icon-geometry,config,locate,omarchy-kernel-migration,runtime-smoke,snapper,unowned-system-paths(three of those want anomarchy-pkgscheckout this machine does not have). The eighth,manifest-entrypoints, failed under the full run but passes standalone on this branch and onquattro.🤖 Generated with Claude Code