Repository navigation
feat: support configurable cost display currency - #51631
Closed
Meinianda-L wants to merge 3 commits into
Closed
Meinianda-L wants to merge 3 commits into
Meinianda-L wants to merge 3 commits into
Conversation
…ding USD The usage_update ACP event hardcodes currency: "USD" regardless of the provider's actual currency configuration. This causes non-USD providers (e.g. EUR-priced custom providers) to report incorrect currency labels. Add an optional `currency` field to the ProviderCost schema (defaults to "USD" when omitted for backward compatibility). Thread the configured currency through to both usage_update call sites (usage.ts layer and service.ts ACP client) using a cached lookup pattern matching the existing contextLimit implementation. Fixes anomalyco#38667 Signed-off-by: kagura-agent <[email protected]>
Add a display.currency config option that converts usage costs to the user's preferred currency at presentation boundaries (ACP usage_update, TUI, and app). The provider/model currency remains the source currency: when no display currency is configured, costs are shown unchanged in the source currency, and amounts are never relabeled when conversion is impossible (unknown rate). - Add Currency core module: approximate USD-based display rate table, convert() with user rate overrides, and locale-aware format() - Add display.currency and display.rates to the config schema - Convert in both ACP usage_update paths (Effect layer and ACP client) - Replace hardcoded USD formatters in TUI (sidebar, prompt, subagent footer) and app (context usage, context tab) with the shared utility - Regenerate SDK types and document the new options Relates to anomalyco#32485. Supersedes the approach explored in anomalyco#32487 and builds on provider-currency propagation from anomalyco#39425.
…encies Other currencies can be added via display.exchangeRates. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
|
The following comment was made by an LLM, it may be inaccurate: |
Contributor
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
1 task done
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.
Issue for this PR
Closes #32485
Type of change
What does this PR do?
Usage cost is hardcoded to USD. This adds
display.currency(and optionaldisplay.exchangeRates) so it can be shown in another currency, e.g. CNY:{ "display": { "currency": "CNY" } }Costs are still tracked in the provider's currency and are only converted where they're displayed (TUI sidebar/footers, app context views, ACP
usage_update). There are approximate, display-only rates for the 7 most-traded currencies (USD, EUR, GBP, JPY, CNY, CAD, AUD); anything else can be added viaexchangeRates(units per 1 USD). If no rate exists, the original amount and currency are shown, never relabeled.The first commit is from #39425 (kagura-agent, authorship kept, fixes #38667): it passes the provider's
currencythrough so CNY-priced providers aren't double-converted.This continues #41208, which was auto-closed by the stale-PR bot.
How did you verify your code works?
bun test test/currency.test.ts(core): 15 passbun test test/acp(opencode): 146 passbun typecheck: 30/30script/build.ts --singleand used it as my own opencode against a real DeepSeek session: default →$0.00,CNY→CN¥0.03,EUR→€0.00,HKD+ custom rate →HK$0.03,HKDwithout a rate → stays$0.00.Screenshots / recordings
Before: the footer always shows
$.After,
"display": { "currency": "CNY" }(footer:CN¥0.03):After,
"display": { "currency": "EUR" }, same session (footer:€0.00; the cost is only about €0.004):Checklist
🤖 Generated with Claude Code