Repository navigation
fix: format extra usage in the currency reported by the usage API - #418
Merged
Merged
Conversation
The usage API reports the account's billing currency (extra_usage.currency, e.g. "EUR"), but ExtraUsageRemaining always formatted with a hardcoded dollar sign, showing non-USD budgets with the wrong symbol. Parse the currency field through the API response schema, file cache, and prefetch merge, and format the remaining budget with Intl-based currency formatting (falling back to USD when the field is absent or invalid, preserving current output for USD accounts). Fixes sirmalloc#415 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
mhriemers
added a commit
to mhriemers/ccstatusline
that referenced
this pull request
Jun 4, 2026
…sirmalloc#418 Once sirmalloc#418 teaches the parser about extra_usage.currency, a fixture carrying the field would add extraUsageCurrency to the parsed result and break this test's expectation depending on merge order. The field is irrelevant to what this test covers (monthly_limit: null handling). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This was referenced Jun 4, 2026
sirmalloc
added a commit
that referenced
this pull request
Jun 14, 2026
… is set (#416) * fix: treat enabled extra usage without a monthly limit as complete usage data Accounts with extra usage enabled but no monthly limit configured (monthly_limit: null) never receive extraUsageLimit/extraUsageUtilization from the usage API. hasRequiredUsageField treated those absent fields as incomplete data on every fetch - including successful ones - so cached data was never accepted, the fetch loop re-fetched each cycle, and the extra usage widgets surfaced the cached lock error as a permanent [Timeout]. Extend the existing extraUsageEnabled === false special case to any response where the extra usage state is known: once the API has told us whether extra usage is enabled, absent detail fields are conclusive and refetching cannot produce them. Fixes #413 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * test: drop currency from no-limit fixture to stay order-independent of #418 Once #418 teaches the parser about extra_usage.currency, a fixture carrying the field would add extraUsageCurrency to the parsed result and break this test's expectation depending on merge order. The field is irrelevant to what this test covers (monthly_limit: null handling). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> Co-authored-by: Matthew Breedlove <sirmalloc@gmail.com>
… pull-requests/pr418
Owner
|
Thanks for this, it'll be published in the next release. |
tahodev
pushed a commit
to tahodev/ccstatusline
that referenced
this pull request
Oct 20, 2026
… is set (sirmalloc#416) * fix: treat enabled extra usage without a monthly limit as complete usage data Accounts with extra usage enabled but no monthly limit configured (monthly_limit: null) never receive extraUsageLimit/extraUsageUtilization from the usage API. hasRequiredUsageField treated those absent fields as incomplete data on every fetch - including successful ones - so cached data was never accepted, the fetch loop re-fetched each cycle, and the extra usage widgets surfaced the cached lock error as a permanent [Timeout]. Extend the existing extraUsageEnabled === false special case to any response where the extra usage state is known: once the API has told us whether extra usage is enabled, absent detail fields are conclusive and refetching cannot produce them. Fixes sirmalloc#413 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * test: drop currency from no-limit fixture to stay order-independent of sirmalloc#418 Once sirmalloc#418 teaches the parser about extra_usage.currency, a fixture carrying the field would add extraUsageCurrency to the parsed result and break this test's expectation depending on merge order. The field is irrelevant to what this test covers (monthly_limit: null handling). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> Co-authored-by: Matthew Breedlove <sirmalloc@gmail.com>
tahodev
pushed a commit
to tahodev/ccstatusline
that referenced
this pull request
Oct 20, 2026
…rmalloc#418) The usage API reports the account's billing currency (extra_usage.currency, e.g. "EUR"), but ExtraUsageRemaining always formatted with a hardcoded dollar sign, showing non-USD budgets with the wrong symbol. Parse the currency field through the API response schema, file cache, and prefetch merge, and format the remaining budget with Intl-based currency formatting (falling back to USD when the field is absent or invalid, preserving current output for USD accounts). Fixes sirmalloc#415 Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> Co-authored-by: Matthew Breedlove <sirmalloc@gmail.com>
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.
Summary
Fixes #415 — the usage API reports the account's billing currency (
extra_usage.currency, e.g."EUR"), butExtraUsageRemainingalways formatted with a hardcoded$, so non-USD accounts see their budget with the wrong symbol.Changes
currencyadded toUsageApiResponseSchema,CachedUsageDataSchema, both parse functions,USAGE_DATA_FIELDS/pickDefinedUsageFieldsin the prefetch merge, and theUsageData/RenderUsageDatatypes (asextraUsageCurrency)src/widgets/shared/currency.ts:formatUsageCurrency()usesIntl-based currency formatting with theen-USlocale, falling back to USD when the code is absent or invalid — so output for USD accounts is byte-for-byte unchanged ($3,894.00)ExtraUsageRemainingformats with the reported currency: an EUR account now seesOverage Left: €3,894.00Testing
currency.test.ts(default, known codes, invalid-code fallback)ExtraUsageRemaining.test.tscurrency: 'EUR'added to the usage-fetch API fixture, asserting it parses through toextraUsageCurrencybun run lintcleanRelated to but distinct from #387 (cents/dollars math). Related: #413/#416, #414/#417.
🤖 Generated with Claude Code