Repository navigation
fix(usage): show Claude credit usage when a login has no rate-limit windows - #295
BigWebstas wants to merge 2 commits into
Conversation
…indows Logins billed per use get no five-hour or weekly window from the Claude usage endpoint, only an extra_usage block, so the parser returned nothing and the status bar stayed hidden. Parse extra_usage (and the newer spend block) into creditUsage and show it as "$used / $limit": inline in the bar when there are no windows, and in the popover. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
🔧 Needs changes – labelled Thanks for the PR! This lets the status bar show credit spend for Claude logins whose usage response carries only Should fix before merge
Nits
Questions
Automated review pass (Claude Code). Anything unclear or wrong – say so and I'll take a look. |
johannesjo
left a comment
There was a problem hiding this comment.
🔁 Superseded by main, so closing is the likely next step. No new code issues at 77e536a.
Thanks again for this fix. Since the last review, the same change has landed on main through #297 (97e6d3c0, "refactor(usage): adopt the creditUsage shape from fork/extras" and "fix(usage): draw the credit meter at 0% used"). This head only merges main from before that point (e9db9a7). The PR's own code has not changed since 901021a.
-
Already on main:
electron/ipc/claude-usage.ts,claude-usage.test.ts,src/components/usage-format.ts,usage-format.test.ts,src/store/usage.tsandusage.test.tsmatchorigin/mainbyte for byte.CreditUsageand thecreditUsagefields inshared-types.ts,src/ipc/types.ts,src/store/types.tsandsrc/store/core.tsare on main too. -
Merge conflicts:
git merge-tree origin/main HEADconflicts insrc/components/UsageStatusBar.tsxandUsageStatusBar.client.test.tsx. Main's version of both is a superset of this one. It has thepercent() !== nullfix for the 0% meter from the earlier review, a test for it, and the newResourcesPanel. Resolving the conflicts in main's favour leaves this PR with an empty diff. -
Still open, now on main rather than here (follow-ups, not blockers for this PR): these nits from the previous review still apply to main's copy:
formatCurrencyhardcodes'en-US', and itscatchfalls back to$for any currency code.- The
UsageStatusBardoc comments still describe only the rate-limit windows. - It's still unconfirmed where the
spend/decimal_placesresponse shapes come from.
A small follow-up PR against main, ideally with a captured and redacted
extra_usageresponse as a fixture, would be welcome.
Generated by Claude Code
|
Thanks a lot for this, @BigWebstas! 🙏 Your credit-usage work landed on Generated by Claude Code |
Description
Shows Claude credit usage in the status bar for logins that are billed per use instead of a Pro/Max subscription.
For those logins, the Claude usage endpoint returns no
five_hourorseven_daywindow, only anextra_usageblock with the spend and the monthly limit. The parser ignored that block, so it reported "no rate-limit windows" and the status bar stayed hidden even though the user had a dollar limit set.electron/ipc/claude-usage.ts): readsextra_usage, plus the newerspendblock, into a new optionalcreditUsagefield with used, limit, currency and percent used. Amounts arrive in minor units and are converted usingdecimal_placesor theexponentfield, which default to 2.Credits $12.34 / $50.00 (25%). The hover popover always lists them. The meter turns amber at the usual 80% threshold.creditUsageis carried throughUsageResultandUsageState, and cleared on logout along with the windows. Codex is unaffected.Issues Resolved
None filed.
Check List
🤖 Generated with Claude Code