Skip to content

fix(widgets): describe the Extra Usage widgets for Enterprise accounts too - #670

Open
eric-engberg wants to merge 7 commits into
sirmalloc:mainfrom
eric-engberg:feat/extra-usage-spend-label
Open

eric-engberg wants to merge 7 commits into
sirmalloc:mainfrom
eric-engberg:feat/extra-usage-spend-label

Conversation

@eric-engberg

@eric-engberg eric-engberg commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

I narrowed this after opening it: with the label editor (#601) in main, anyone on an Enterprise plan can relabel Overage to Spend themselves, 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:

Widget Before After
Extra Usage Used Shows amount spent on extra usage (pay-as-you-go overage) Shows extra usage spent: overage beyond Pro/Max plan limits, or your spend on Enterprise
Extra Usage Remaining Shows the remaining amount of your monthly extra usage limit Shows what's left of your monthly extra usage limit (Pro/Max overage or Enterprise spend)
Extra Usage Utilization Shows extra usage (pay-as-you-go) utilization percentage Shows extra usage as a percentage of your monthly limit (Pro/Max overage or Enterprise spend)

Searching the widget picker for "enterprise" or "spend" now lists these three first. docs/USAGE.md says the same and points at the label editor for anyone who wants the label to read Spend.

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 no limits[] entries, and reports all of the account's spend under extra_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

  • The three getDescription() strings and one sentence in docs/USAGE.md change. The picker already searches descriptions, so no search code changes.
  • Extra Usage Used and Remaining were the same class apart from how the amount is worked out, and their label, name, description and preview sample. They now extend a shared ExtraUsageAmountWidget, the way the Tokens widgets share TokenCountWidget, so each new description sits in a short subclass instead of in two copies of the same code.
  • Labels, rendered output and the usage fetch are unchanged.

Demo

Searching the widget picker for "enterprise":

Powerline: before

Picker search for enterprise before the change, Powerline mode

Powerline: after

Picker search for enterprise listing the Extra Usage widgets after the change, Powerline mode

Plain: before

Picker search for enterprise before the change, plain mode

Plain: after

Picker search for enterprise listing the Extra Usage widgets after the change, plain mode

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 on main.
  • The refactor: the two widgets' existing tests pass unchanged, and their output before and after matched byte for byte across 142 renders (preview, raw value, a custom label, hidden states, a number format, and usage data that's missing, disabled, incomplete or an error).
  • On today's main: bun test gives 2781 pass, 0 fail (Bun 1.4.2), and bun run lint is clean. Under Node 26 vitest, the new test file and the two widgets' tests pass (25).

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.
@eric-engberg eric-engberg changed the title feat: label Extra Usage as spend on accounts without plan limits fix(widgets): describe the Extra Usage widgets for Enterprise accounts too Oct 6, 2026
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.
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