Skip to content

fix(desktop): send provider currency in Meta to prevent session-start flip (#4546)#4548

Open
ashishexee wants to merge 1 commit into
esengine:main-v2from
ashishexee:fix/4546-currency-display-inconsistency
Open

fix(desktop): send provider currency in Meta to prevent session-start flip (#4546)#4548
ashishexee wants to merge 1 commit into
esengine:main-v2from
ashishexee:fix/4546-currency-display-inconsistency

Conversation

@ashishexee

Copy link
Copy Markdown
Contributor

Problem

#4546 reports that the status bar cost display shows inconsistent currencies:

  • Before session starts (home page): ¥0.0000 (CNY)
  • During session (after first usage event): $0.0000 (USD)

The root cause is two hardcoded defaults that disagree:

  • useController.ts:119sessionCurrency: "¥" (hardcoded CNY in frontend initial state)
  • config.go:1271 — DeepSeek pricing: Currency: "$" (USD)

The sessionCurrency field only updates when a usage event arrives from the backend (line 510). Before that, it stays at the hardcoded "¥" default.

Fix

Thread the provider's currency symbol from config through Controller to Meta, so the frontend knows the currency at session start — before any usage event.

Backend (Go):

  • internal/control/controller.go — Add currencySymbol field to Controller with CurrencySymbol() getter; add CurrencySymbol to Options struct
  • internal/boot/boot.go — Set CurrencySymbol: entry.Price.Symbol() in controller options (nil-safe: Pricing.Symbol() returns "¥" for nil/empty)
  • desktop/app.go — Add Currency string to Meta struct; populate in MetaForTab() with nil guard on tab.Ctrl

Frontend (TypeScript):

  • types.ts — Add currency?: string to Meta interface
  • useController.tscase "meta" sets sessionCurrency from meta.currency; case "reset" preserves sessionCurrency; sameMeta() includes currency in comparison

Verification

go vet ./internal/control/... ./internal/boot/...
(cd desktop && go vet ./...)
go test ./internal/control/... -count=1 -timeout 120s
go test ./internal/boot/... -count=1 -timeout 120s
(cd desktop && go test ./... -run "TestMeta|TestTab|TestWire" -count=1)
gofmt -l internal/control/controller.go internal/boot/boot.go desktop/app.go

Fixes #4546

@github-actions github-actions Bot added desktop Wails desktop app (desktop/**) agent Core agent loop (internal/agent, internal/control) config Configuration & setup (internal/config) v2 Go rewrite (1.x) — main-v2 branch, active development labels Jun 15, 2026
@ashishexee ashishexee force-pushed the fix/4546-currency-display-inconsistency branch from 2792bf4 to 60241d0 Compare June 15, 2026 20:49
… flip (esengine#4546)

The status bar cost display flipped from ¥ (CNY) to $ (USD) when the
first usage event arrived because sessionCurrency defaulted to ¥ in the
frontend initialState, while DeepSeek's pricing is configured in USD.

Now the Controller stores the provider's currency symbol (from
entry.Price.Symbol()) at build time, and MetaForTab() includes it in
the Meta event. The frontend reads meta.currency on session start and
initializes sessionCurrency immediately — before any usage event.

Fixes:
- case "meta" sets sessionCurrency from meta.currency
- case "reset" preserves sessionCurrency (was lost to initialState spread)
- MetaForTab() nil-guards tab.Ctrl
- sameMeta() includes currency in comparison
@ashishexee ashishexee force-pushed the fix/4546-currency-display-inconsistency branch from 60241d0 to e23081c Compare June 18, 2026 05:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent Core agent loop (internal/agent, internal/control) config Configuration & setup (internal/config) desktop Wails desktop app (desktop/**) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: 界面底部费用显示:会话前显示 CNY,会话中显示 USD,币种不一致

1 participant