Skip to content

feat: add an Extra Usage Limit widget - #756

Merged
sirmalloc merged 2 commits into
sirmalloc:mainfrom
eric-engberg:feat/extra-usage-limit-widget
Oct 29, 2026
Merged

sirmalloc merged 2 commits into
sirmalloc:mainfrom
eric-engberg:feat/extra-usage-limit-widget

Conversation

@eric-engberg

Copy link
Copy Markdown
Contributor

What

A new Extra Usage Limit widget shows the monthly extra usage limit itself: Overage Limit: $50.00. It sits with the other Extra Usage widgets in the picker's Usage category.

Why

The Extra Usage widgets show the amount spent, what's left and the percentage used, but never the limit. A line could read Overage Used: $123.45 with no way to add "of $500"; Remaining and Utilization only imply it. The limit is already in the usage API response (extra_usage.monthly_limit, in cents) and in the usage cache, so showing it costs nothing extra.

How

  • Modeled on Extra Usage Used: the reported currency and the cost number format, raw value mode, a fixed Overage Limit: label like the other Extra Usage widgets (the label editor can change it), and the same disabled and no-data hide options.
  • States: extra usage off shows n/a. Extra usage on with no monthly limit shows none (once the API has reported extra usage as on, a missing limit means none is set; it's already treated as conclusive, Extra usage widgets show permanent [Timeout] when account has no monthly limit set #413). An unknown state with an error shows the usage error, like its siblings.
  • Fetch: it needs only the extra usage state and the limit, which come from the usage fetch the other Extra Usage widgets already make.
  • Preview: $4,000.00, consistent with the Used ($106) and Remaining ($3,894) samples.

Demo

Rendered from a fake usage cache (no login, no API call): an Enterprise account ($123.45 of a $500 limit), a Max account ($12.50 of $50), and a Max account with no monthly limit.

Powerline

Extra Usage Limit next to the other Extra Usage widgets, Powerline mode

Plain

Extra Usage Limit next to the other Extra Usage widgets, plain mode

Testing

  • New widget tests: the limit in USD and in the API's currency, the global cost style, none without a limit, n/a and the hidden disabled state, errors and the no-data state, the preview, and the hideable states. A prefetch test checks the widget triggers a fetch for exactly the extra usage state and the limit.
  • bun test: 2378 pass, 0 fail. bun run lint passes.
  • Under Node (Vitest): the new widget tests and the prefetch tests pass, 51 of 51.
  • Built CLI under Bun 1.4.2 and Node 26.10.0 with an Enterprise usage cache: all runtimes give identical output in plain and Powerline modes, differing from main only by the new widget. The TUI opens and exits cleanly under both.
  • Piped renders from fake caches: Overage Used: $12.50 | Overage Limit: $50.00, Overage Limit: none (no monthly limit), n/a with extra usage off.
  • Picker search: "limit", "enterprise" and "spend" list the four Extra Usage widgets first.
  • Rebuilt as one commit on today's main, after the Enterprise Spend wording it built on merged as fix(widgets): describe the Extra Usage widgets for Enterprise accounts too #670: bun test 3258 pass, 0 fail; bun run lint clean. Built CLI under Bun 1.4.2 and Node 26.10.0: all runtimes agree in plain and Powerline modes, and the TUI opens and exits cleanly under both.

The Extra Usage widgets show the amount spent, what's left and the
percentage used, but never the monthly limit itself, so a line could
read "Spend Used: $123.45" with no way to show "of $500". Remaining
and Utilization only imply it.

Extra Usage Limit shows the monthly limit from the usage API, in the
reported currency and the cost number format, labeled like the other
Extra Usage widgets ("Overage Limit", or "Spend Limit" on accounts
without plan limits). When extra usage is on without a monthly limit
it shows "none", and when it's off "n/a", with the same hide options as
its siblings. It needs only the extra usage state and the limit, which
come from the fetch the other Extra Usage widgets already make.
@sirmalloc
sirmalloc merged commit b9136d9 into sirmalloc:main Oct 29, 2026
3 checks passed
axisrow added a commit to axisrow/ccstatusline that referenced this pull request Oct 29, 2026
sirmalloc#755 live picker preview, sirmalloc#754 fast mode widget, sirmalloc#753 thinking-effort test stub, sirmalloc#752 transcript block fallback fixes, sirmalloc#751 editor keys no longer pause on global install lookup, sirmalloc#750 git cache TTL starts after the run, sirmalloc#749 npx cache skip, sirmalloc#747 Block Usage hides at 100% and swaps with Block Reset Timer)

Conflict policy: upstream infra wins, fork features ported on top. Joins:
sirmalloc#750 stamps the git cache after the run while keeping the fork's execGit
hardening/env snapshot and daemon prefetch bookkeeping; sirmalloc#752's
isApiErrorMessage guard lands in the fork's shared collectTimestampFromLine
(sync + async twins), upstream's duplicate getActivityTimestamp dropped;
sirmalloc#747 adds SESSION_AT_LIMIT alongside the fork's zero hide state
(BlockResetTimer keeps zero + under-limit via isAtSessionLimit, SessionUsage
is no-data/zero/at-limit); sirmalloc#755 replaces the fork's picker window + "Showing
X-Y of N" note with upstream's renderWindowedList/getPickerMaxVisible and
live preview (markers ↑/↓ N more cover the counts); sirmalloc#751's installationState
useMemo replaces the fork's inline lookups, the fork's mainMenuIndex helper
is kept.

Co-Authored-By: Claude Code <[email protected]>
pcvelz added a commit to pcvelz/ccstatusline-usage that referenced this pull request Oct 29, 2026
Upstream: Extra Usage Limit widget (sirmalloc#756), live widget preview while picking (sirmalloc#755), Fast Mode widget (sirmalloc#754), transcript block fallback fixes (sirmalloc#752), editor keys on a global install (sirmalloc#751), git cache TTL (sirmalloc#750), npx cached copy skip (sirmalloc#749), Block Usage hide at 100% (sirmalloc#747), Block Reset Timer hide until 100% (sirmalloc#697), fish-style branch abbreviation (sirmalloc#614), jj detached HEAD (sirmalloc#705), hooks save warning (sirmalloc#703), dev reload (sirmalloc#700), merge ends at a hidden widget (sirmalloc#698), Block Forecast and Block Limit Timer widgets (sirmalloc#699), contributor guide (sirmalloc#706), POSIX path case fix (sirmalloc#707), whitespace-distinct conflict filenames (sirmalloc#709), Quick Start reorder (sirmalloc#715), bunx launch guidance (sirmalloc#714), jj diff summary counts (sirmalloc#711), powerline manual separators (sirmalloc#713), keychain credential by account (sirmalloc#532), Keychain probe timeout (sirmalloc#760), usage cache scoped per CLAUDE_CONFIG_DIR (sirmalloc#266), test isolation (sirmalloc#717, sirmalloc#753), dev-dependency bumps (sirmalloc#745)

Conflicts resolved per the standard-resolution table; fork deletions re-applied.

Hand edits outside conflicts:
- src/utils/global-command-resolution.ts: fork-rename (ccstatusline@ -> ccstatusline-usage@ in upstream's new bunx pattern)
- src/utils/__tests__/global-package-manager.test.ts: fork-rename (package dir ccstatusline-usage in upstream's new tests)
- src/utils/usage-fetch.ts: compat fix - cacheUsageData gained a fetchedAtMs arg (upstream sirmalloc#266); adapted the fork-only fetchFreshUsageData call site
- src/utils/__tests__/usage-fetch.test.ts: compat fixes - cache/lock now hashed per CLAUDE_CONFIG_DIR (usageFilePath helper) in four fork tests; upstream fableUsage renamed to fork's weeklyFableUsage; seedUsageCache takes TokenHome
- src/utils/__tests__/usage-prefetch.test.ts: compat fix - mockFetchUsageData renamed to upstream's mockFetchUsage in cleanly-merged tests
- README.md: took upstream's Quick Start move (sirmalloc#715) and dropped the fork's old copy; fork-rename of its ccstatusline@ specifiers; links to fork-deleted docs (docs/USAGE.md, docs/WINDOWS.md) replaced with the fork's inline text
- CONTRIBUTING.md: links to the fork-deleted docs/DEVELOPMENT.md pointed at the README Development section
- docs/test-retirements.md: ledger entries for the 12 upstream test renames (sirmalloc#697, sirmalloc#698, sirmalloc#700, sirmalloc#705, sirmalloc#713, sirmalloc#760)
eric-engberg added a commit to eric-engberg/ccstatusline that referenced this pull request Oct 30, 2026
Brings in upstream main through #41, which now holds #33 as upstream
sirmalloc#756. Main adds Extra Usage Limit at the same places the #33 branch
merged here did, so the widget manifest, the usage prefetch's widget list
and requirements, and its prefetch test keep main's single entry. Daily
Cost Rate's billed-spend test stubs getUsageFetchedAtMs, which #36 now
reads in place of its own getUsageFetchedAt.

# Conflicts:
#	docs/USAGE.md
#	src/ccstatusline.ts
#	src/types/RenderContext.ts
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.

2 participants