Repository navigation
fix(widgets): describe the Extra Usage widgets for Enterprise accounts too - #670
Open
eric-engberg wants to merge 7 commits into
Open
eric-engberg wants to merge 7 commits into
eric-engberg wants to merge 7 commits into
Conversation
On usage-based plans (Claude Enterprise) the usage API reports every
rate-limit window as null and no limits[] entries: there's no plan limit
to go over, and extra usage is the account's whole spend. The Extra
Usage widgets still called it overage ("Overage Used: $123.45"), and
their picker descriptions only mentioned pay-as-you-go overage, so
Enterprise users had no reason to think these widgets were theirs.
Searching the picker for "enterprise" or "spend" didn't find them.
The parser now flags a response that explicitly reports no plan limits
(`noPlanLimits`). The flag is kept in the usage cache and through the
merge with statusline rate_limits, and the three widgets label their
value "Spend Used", "Spend Left" and "Spend" when it's set. Only an
explicit null counts and any limits[] entry counts as a limit, so every
uncertain case keeps the "Overage" label. A cache written before this
change keeps the old label until its next refresh.
The widget descriptions now mention both Pro/Max overage and Enterprise
spend, which also makes the picker's search find them.
# Conflicts: # src/widgets/ExtraUsageRemaining.ts # src/widgets/ExtraUsageUsed.ts # src/widgets/ExtraUsageUtilization.ts
Upstream's label editor (sirmalloc#601) gives each widget one default label, while Extra Usage Used, Remaining and Utilization pick "Overage" or "Spend" by account. The editor offers the Overage label, since it has no usage data, and an edited label replaces whichever one the account would show.
With the label editor (sirmalloc#601) in main, anyone on a usage-based Enterprise plan can relabel the Extra Usage widgets' "Overage" to "Spend" in a few keys, so detecting those accounts from the usage API's response shape isn't worth its cache field and heuristics. What stays is the wording: the three widgets' descriptions say they cover Pro/Max overage and Enterprise spend, the docs say the same and point at the label editor, and picker searches for "enterprise" or "spend" list the three widgets first, which a new test checks.
The two widgets were the same class apart from how the amount is worked out, and their label, name, description and preview sample. They now extend ExtraUsageAmountWidget, the way the Tokens widgets share TokenCountWidget. Rendering is unchanged.
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.
I narrowed this after opening it: with the label editor (#601) in
main, anyone on an Enterprise plan can relabelOveragetoSpendthemselves, so detecting the account type isn't worth it. What's left is the wording.What
The three Extra Usage widgets' descriptions now say they cover both Pro/Max overage and Enterprise spend:
Searching the widget picker for "enterprise" or "spend" now lists these three first.
docs/USAGE.mdsays the same and points at the label editor for anyone who wants the label to readSpend.Why
On usage-based plans (Claude Enterprise) there is no plan limit to go over. The usage API reports every rate-limit window as
null, has nolimits[]entries, and reports all of the account's spend underextra_usage(amounts changed):{ "five_hour": null, "seven_day": null, "seven_day_sonnet": null, "seven_day_opus": null, "limits": [], "extra_usage": { "is_enabled": true, "monthly_limit": 50000, "used_credits": 12345.0, "utilization": 24.69, "currency": "USD" } }The widgets' descriptions only mentioned pay-as-you-go overage. An Enterprise user looking for their spend had no reason to think these were the widgets for it, and the picker's search didn't help: "enterprise" found Claude Session ID and Thinking Effort, and "spend" found nothing related.
How
getDescription()strings and one sentence indocs/USAGE.mdchange. The picker already searches descriptions, so no search code changes.ExtraUsageAmountWidget, the way the Tokens widgets shareTokenCountWidget, so each new description sits in a short subclass instead of in two copies of the same code.Demo
Searching the widget picker for "enterprise":
Powerline: before
Powerline: after
Plain: before
Plain: after
Testing
extra-usage-enterprise-wording.test.ts(5), written first: each widget's description mentions Pro/Max and Enterprise, and picker searches for "enterprise" and "spend" find the three among the widgets that mention the word, which rank ahead of loose fuzzy matches. All 5 fail onmain.main:bun testgives 2781 pass, 0 fail (Bun 1.4.2), andbun run lintis clean. Under Node 26 vitest, the new test file and the two widgets' tests pass (25).