fix(ui): SessionPicker honors wallet currency instead of hardcoded ¥ (#312)#357
Merged
fix(ui): SessionPicker honors wallet currency instead of hardcoded ¥ (#312)#357
Conversation
…312) Same bug shape as the StatusRow / UsageCard / StatsPanel set that #272 already fixed — `SessionPicker` was still doing `¥${totalCostUsd * USD_TO_CNY}` so USD-wallet users saw ¥-formatted costs in the session list. - `SessionMeta` gains `balanceCurrency?: string`. App.tsx writes the live wallet currency alongside `totalCostUsd` on each turn save, so every persisted session knows what currency its cost is denominated in. - `SessionPicker` accepts a `walletCurrency` prop and falls back to each row's `meta.balanceCurrency`. Prop wins (live value > stored). In-app picker (`/sessions`) gets the live ref from App; pre-mount picker in `chat.tsx` doesn't have a balance fetched yet, so it relies on the stored per-session value. - Cost rendering routes through the shared `formatCost()` helper that the rest of the cost UI already uses. - Regression test asserts USD wallet → `$0.05`, CNY wallet → `¥0.36`, no-prop + stored-USD → `$0.05`, neither → unchanged `¥0.36`.
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.
Closes #312
Summary
Same bug shape as the StatusRow / UsageCard / StatsPanel set fixed under #272 — SessionPicker still hardcoded
¥and ran USD → CNY itself, so USD-wallet users saw¥X.XXin the session list picker.The wallet currency in this codebase isn't persisted in config — it comes from a live balance fetch. The pre-mount picker (
chat.tsx) doesn't have that yet. So the fix has two layers:SessionMetagainsbalanceCurrency?: string. Every turn's cost-save inApp.tsxwrites it alongsidetotalCostUsd. Rows fall back to their own stored currency when no live prop is in scope.SessionPickeracceptswalletCurrency. The in-app picker (/sessions) getswalletCurrencyRef.current. Prop wins over per-row stored value.Cost rendering routes through the shared
formatCost(usd, currency, digits)helper instead of the inline¥${...}.Test plan
tests/ui-session-picker-currency.test.tsx— 4 cases: USD prop, CNY prop, no-prop + USD meta, no-prop + no meta (legacy default ¥)npx vitest run— 165/165 test files, 2423 tests pass