Skip to content

Fix cost currency display / 修复成本货币符号显示#4061

Merged
esengine merged 2 commits into
main-v2from
fix/cost-currency-display
Jun 12, 2026
Merged

Fix cost currency display / 修复成本货币符号显示#4061
esengine merged 2 commits into
main-v2from
fix/cost-currency-display

Conversation

@SivanCola

Copy link
Copy Markdown
Collaborator

Summary

  • Pair context-panel cost values with the currency from the same data source so panel telemetry cannot be overwritten by the default session currency.
  • Share frontend money formatting across the context panel and status bar, including normalization for common currency codes and symbols.
  • Normalize provider pricing currency symbols on the Go side so unexpected text cannot leak into UI cost values.
  • Add nowrap/ellipsis guards for compact metric values and restore command-palette hint ellipsis expectations.

Root cause

The context panel could select info.sessionCost while still preferring the global session currency, whose initial value defaults to yuan. Separately, unknown currency text was passed through directly, so bad or stale currency values could appear before the numeric cost.

Validation

  • npm --prefix desktop/frontend test
  • npm --prefix desktop/frontend run build
  • go test ./internal/provider
  • go test ./... from the desktop module

This change is display-only and does not modify provider request serialization, prompts, tool schemas, or other prompt-cache-sensitive paths.

@github-actions github-actions Bot added v2 Go rewrite (1.x) — main-v2 branch, active development desktop Wails desktop app (desktop/**) provider Model providers & selection (internal/provider) labels Jun 11, 2026
@SivanCola SivanCola marked this pull request as ready for review June 11, 2026 16:03
@SivanCola SivanCola requested a review from esengine as a code owner June 11, 2026 16:03
@SivanCola SivanCola enabled auto-merge June 11, 2026 16:03

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 666848e2dc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if (/^\p{Sc}$/u.test(value)) return value;
if (/^[a-z]{3}$/i.test(value)) return `${value.toUpperCase()} `;

return DEFAULT_CURRENCY_SYMBOL;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve configured multi-character currency symbols

When a provider/session supplies a compact multi-character symbol such as A$, CA$, HK$, or R$, this new formatter falls through to the yen default, so formatMoney(1, "A$") renders as ¥1.00 instead of preserving the configured currency. The old StatusBar/ContextPanel helpers passed unknown display symbols through, and Pricing.Currency is still described as accepting a display symbol, so existing non-USD/CNY configs using these common symbols will have their spend mislabeled; allow symbols containing a currency sign rather than defaulting them to yen.

Useful? React with 👍 / 👎.

The normalizer only passed through single-rune currency signs, so compact
symbols like A$, CA$, HK$, R$ fell back to ¥ and mislabeled non-USD/CNY
spend. Match on any embedded currency sign instead, on both the Go
(provider) and frontend (money.ts) sides.
@esengine

Copy link
Copy Markdown
Owner

Thanks @SivanCola — clean fix for the currency mislabeling, and good call sharing the formatter into lib/money.ts.

I pushed one follow-up commit before merging: the normalizer only passed through single-rune currency signs, so compact multi-character symbols (A$, CA$, HK$, R$) fell back to ¥ and would mislabel those configs. It now keeps any string that contains a currency sign, on both the Go (provider) and frontend (money.ts) sides, with tests covering it. Merging once CI is green.

@esengine esengine merged commit ea5f17d into main-v2 Jun 12, 2026
13 checks passed
@esengine esengine deleted the fix/cost-currency-display branch June 12, 2026 04:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

desktop Wails desktop app (desktop/**) provider Model providers & selection (internal/provider) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants