Skip to content

Feat:usage display currency - #51429

Closed
Meinianda-L wants to merge 3 commits into
anomalyco:devfrom
Meinianda-L:feat/usage-display-currency
Closed

Meinianda-L wants to merge 3 commits into
anomalyco:devfrom
Meinianda-L:feat/usage-display-currency

Conversation

@Meinianda-L

@Meinianda-L Meinianda-L commented Sep 26, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #32485

Type of change

  • Bug fix

  • New feature

  • Refactor / code improvement

  • Documentation

    What does this PR do?

    Lets you choose the currency usage costs are shown in, instead of always USD. This continues feat: support configurable cost display currency #41208, which was closed
    after I deleted my fork.

    It adds display.currency and display.exchangeRates to the config:

    {
      "display": {
        "currency": "CNY",
        "exchangeRates": { "HKD": 7.8 }
      }
    }
    • Costs are still tracked in the provider's currency. They're only converted when shown: TUI sidebar, prompt footer,
      subagent footer, the app's context views, and ACP usage_update.
    • There are approximate built-in rates for the 7 most-traded currencies (USD, EUR, GBP, JPY, CNY, CAD, AUD). They're
      for display only, not billing. Any other currency can be added, and any built-in rate overridden, with
      display.exchangeRates (units per 1 USD).
    • If there's no rate for a currency, the original amount and currency are shown. It never relabels a number without
      converting it.
    • The first commit is from fix(acp): respect provider currency in usage_update instead of hardcoding USD #39425 (kagura-agent, authorship kept). It passes the provider's currency through, so
      providers that bill in CNY don't get converted twice. It also fixes ACP usage_update mislabels non-USD costs as USD #38667.

    Not changed: CLI stats and the run footer, because they add up costs across models without knowing each one's
    currency.

    How did you verify your code works?

    • bun test test/currency.test.ts in packages/core: 15 pass
    • bun test test/acp in packages/opencode: 146 pass
    • bun typecheck: 30/30 packages pass
    • Built a local binary, used it as my daily opencode, and checked the sidebar with a real DeepSeek session:
      • no config → $0.00 spent
      • CNY → CN¥0.03
      • JPY → ¥1
      • HKD + custom rate → HK$0.03
      • HKD without a rate → stays $0.00 (no relabel)

    Screenshots / recordings

Screenshot 2026-09-26 at 9 41 34 AM Screenshot 2026-09-26 at 9 43 35 AM Screenshot 2026-09-26 at 9 44 21 AM

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

kagura-chen and others added 3 commits September 26, 2026 09:25
…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]>
@github-actions

Copy link
Copy Markdown
Contributor

Hey! Your PR title Feat/usage display currency doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Sep 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@Meinianda-L Meinianda-L changed the title Feat/usage display currency Feat:usage display currency Sep 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Sep 26, 2026
@github-actions github-actions Bot closed this Sep 26, 2026
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs:compliance This means the issue will auto-close after 2 hours. needs:title

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ACP usage_update mislabels non-USD costs as USD [FEATURE]: Configure usage cost display currency

2 participants