Skip to content

feat: add an Extra Usage Daily Budget widget - #672

Merged
sirmalloc merged 4 commits into
sirmalloc:mainfrom
eric-engberg:feat/extra-usage-daily-budget
Oct 9, 2026
Merged

sirmalloc merged 4 commits into
sirmalloc:mainfrom
eric-engberg:feat/extra-usage-daily-budget

Conversation

@eric-engberg

Copy link
Copy Markdown
Contributor

What

A new Extra Usage Daily Budget widget shows how much of the monthly extra usage limit can be spent per day for the rest of the month: what's left of the limit divided by the days left, today included. With $376.55 left of a $500 limit on Monday 5 October 2026, it shows Daily Budget: $13.95 (27 days left), or $18.83 with weekdays only (20 weekdays left).

Why

With a monthly limit, the number that matters during the day is how much you can still spend per day without running out before the limit resets. The existing widgets give the pieces (spent, left, percent) but not the pace. It's especially useful on usage-based Enterprise plans, where the monthly limit is the only limit.

How

  • Days left: today through the last day of the month. Monthly limits reset at 00:00 UTC on the 1st (per Anthropic's Spend Limits docs), so days are UTC days: in US Central time the day, and the month, roll over at 7pm.
  • Weekdays only: a w keybind in the line editor toggles counting weekdays only (Saturday and Sunday in UTC are skipped). The editor row shows (weekdays) when it's on. Today always counts, even a weekend day, so working on a weekend still shows a budget and nothing ever divides by zero.
  • Edge cases: once the limit is used up it shows $0.00. Without a monthly limit it shows nothing, like Extra Usage Remaining. With extra usage off it shows n/a. The disabled and no-data hide options, raw value mode, the reported currency and the cost number format all work like the other Extra Usage widgets.
  • Data: the extra usage state, limit and amount spent, all from the fetch the other Extra Usage widgets already make. The day counting is a small pure helper (countBudgetDaysLeft) that takes the time as a parameter.
  • Preview: a fixed sample ($194.70, the Remaining sample over 20 days), so the preview doesn't change with the date.

Demo

Rendered from a fake usage cache (no login, no API call) on Monday 5 October 2026: $123.45 spent of a $500 limit. The third widget counts every day left ($376.55 ÷ 27), the fourth weekdays only (÷ 20).

Powerline

Extra Usage Daily Budget for all days and weekdays only, Powerline mode

Plain

Extra Usage Daily Budget for all days and weekdays only, plain mode

Toggling weekdays only with w in the line editor:

Powerline

Toggling weekdays only in the line editor, Powerline mode

Plain

Toggling weekdays only in the line editor, plain mode

Testing

  • Day counting, against hand-checked calendars: all days and weekdays only on a Monday, a weekend day with weekdays only, the last day of the month, the first instant of a new month in UTC, and a US Central Friday night that is already Saturday in UTC.
  • Widget tests with the clock fixed: the budget for all days and weekdays only, $0.00 past the limit, the reported currency, no limit, n/a and its hidden state, errors and no-data, the fixed preview, and the w toggle (keybind label, editor modifier, metadata). A prefetch test checks the widget fetches exactly the extra usage state, limit and spend.
  • On today's main (with docs: explain an empty status line in one folder (workspace trust) #606 and feat(git-is-fork): render forks as an editable glyph #617 merged in locally): bun test gives 2798 pass, 0 fail (Bun 1.4.2), and bun run lint passes.
  • Under Node (Vitest): the new and touched test files pass, 56 of 56.
  • Built CLI under Bun 1.4.2 and Node 26.10.0 with a fake usage cache: all runtimes give identical output in plain and Powerline modes; it differs from main only by the new widgets. The TUI opens and exits cleanly under both.

eric-engberg and others added 4 commits October 5, 2026 01:27
With a monthly extra usage limit, the useful number during a day is how
much can still be spent per day without running out before the limit
resets. Extra Usage Daily Budget shows what's left of the monthly limit
divided by the days left in the month, today included, so it rises on
light days and falls on heavy ones.

Monthly limits reset at 00:00 UTC on the 1st, so days are UTC days.
A `w` keybind switches to counting weekdays only (Saturday and Sunday
in UTC); today always counts, even a weekend day, so the budget never
divides by zero. Once the limit is used up it shows $0.00; without a
monthly limit it shows nothing, like Extra Usage Remaining.
@sirmalloc
sirmalloc merged commit 75c7a1d into sirmalloc:main Oct 9, 2026
3 checks passed
@eric-engberg
eric-engberg deleted the feat/extra-usage-daily-budget branch October 9, 2026 22:23
pcvelz added a commit to pcvelz/ccstatusline-usage that referenced this pull request Oct 11, 2026
Upstream: label prefixes editable with e (sirmalloc#601, sirmalloc#666), Session Cost Rate (sirmalloc#671) and Extra Usage Daily Budget (sirmalloc#672) widgets, own-lock-only usage lock clearing (sirmalloc#624), NO_PROXY and request deadlines, terminal control-sequence sanitizing, git hardening and linear-time parsing, shared searchable option editor (sirmalloc#649) and widget base classes (sirmalloc#646-sirmalloc#654), node: imports (sirmalloc#657), Number.* globals lint (sirmalloc#645), test waits on redraw instead of fixed delays (sirmalloc#652).

Hand edits outside conflicts:
- src/widgets/shared/searchable-option-editor.tsx: compat fix - ports the fork's ref-based input handling (Enter picks from what was just typed) into upstream's new shared editor
- src/utils/usage-fetch.ts: compat fix - fork's fetchFreshUsageData uses upstream's clearOwnUsageLock (sirmalloc#624) instead of the removed clearUsageLock
- src/widgets/ApiUsage.tsx, src/widgets/Battery.ts: compat fix - Number.isNaN/Number.parseInt for upstream's no-restricted-globals rule
- src/utils/__tests__/usage-prefetch.test.ts: compat fix - mock renamed to upstream's mockFetchUsage
- src/tui/components/__tests__/PowerlineSetup.test.ts, src/tui/components/__tests__/StatusLinePreview.test.ts, src/tui/components/__tests__/TerminalWidthMenu.test.ts: compat fix - drop the fork's flushInk import, unused after upstream's waitFor switch
- README.md: upstream notes linked docs/USAGE.md (deleted in the fork); inlined the proxy and workspace-trust text instead; upstream's own release-note entries not taken
- .fork-keep-deleted: src/widgets/FableWeeklyUsage.ts (upstream widget, unregistered in the fork, which ships WeeklyFableUsage.ts)
- src/widgets/WeeklyFableUsage.ts: compat fix - adopts upstream's shared getUsagePercentWidgetEditorDisplay, which carries the time-cursor modifier
- src/tui/__tests__/App.test.ts: fork deviation - one extra down-arrow for the fork's Off Hours main-menu row
- src/widgets/__tests__/CacheTimer.test.ts, src/widgets/CacheTimer.ts: compat fix - emoji toggle moved from e to o because upstream reserves e for edit-label
- src/widgets/AgentAddress.ts: split the session-title guard into its own if (same behaviour) so the .fork-invariants nameSource guard matches again
- docs/test-retirements.md: ledger for tests upstream renamed or replaced
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