fix(desktop): use balance currency as session currency source, prevent ¥→$ flip after first turn / 修复成本符号显示不正确#4504
Closed
JesonChou wants to merge 1 commit into
Closed
Conversation
Closed
b0d4833 to
538bd59
Compare
…t \u00A5\u2192$ flip after first turn (esengine#4500)
538bd59 to
c2a03af
Compare
Collaborator
|
Thanks @JesonChou. We are closing this PR as superseded by #4329, which is now the canonical integration route for the cost/currency/status-bar work. Your contribution is recorded in #4329: you diagnosed the session currency flip from You are acknowledged in #4329 as a repository co-contributor for this work. |
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.
Problem
Fixes #4500.
Status bar session cost shows ¥ at startup, then flips to $ after the first conversation turn and never recovers.
Root cause:
sessionCurrencywas hardcoded to"¥"in initialState, but usage events from the backend carry"$"(DeepSeek pricing config hasCurrency: "$"). The reducer unconditionally replaced the value:A naive priority swap would freeze ¥ forever, breaking USD-billing users.
Solution
Three-tier fallback, with the balance endpoint as the source of truth. Once set,
sessionCurrencyis never overwritten:The balance endpoint already receives per-currency data from DeepSeek (
"CNY","USD"). A newCurrency()method exposes the raw symbol, piped throughBalanceInfoto the frontend.Scenario coverage
"¥""$"Files changed
internal/billing/balance.goCurrency()method +primaryInfohelperdesktop/app.goBalanceInfo.Currencyfielddesktop/frontend/src/lib/types.tsBalanceInfo.currencyfielddesktop/frontend/src/lib/useController.tsVerification
internal/billing+desktopcompile cleanly