**Usage & cost always renders USD.** The spend panel hardcodes a dollar sign, so every… #3
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Reported from the pi-chat app.
Usage & cost always renders USD. The spend panel hardcodes a dollar sign, so every figure stays in US dollars even though the account's profile currency is GBP —
web/src/lib/profile.tsalready storescurrency: 'GBP'and feeds "Currency: GBP" into the agent's profile context, so the app knows the currency it is ignoring here.Where:
web/src/lib/components/UsagePanel.svelte,fmtCost():It is the only place in the app that formats a cost (grep
fmtCostin web/src returns just this file), so a currency change is a three-file job.Important: the values really are USD.
src/usage.tsrolls up the SDK's per-messagecost.total, priced in USD, so relabelling the number as £ would overstate spend by roughly a quarter. It needs a conversion, not a symbol swap — and a fixed rate drifts silently, so the panel should say which rate it used.What I patched locally on this install (uncommitted, so it will be lost on the next pull) to read my own spend in pounds:
src/usage.ts— addUsageCurrency { code, symbol, rate }toUsageReport;displayCurrency()returns{ code: 'GBP', symbol: '£', rate }where the rate comes fromPI_CHAT_USD_GBP_RATE(default 0.746, snapshot checked 2026-11-03);computeUsage()returns it alongside the existing fields.web/src/lib/types.ts— mirror the same shape.UsagePanel.svelte—fmtCostmultiplies byreport.currency.rateand prefixesreport.currency.symbol(falling back to$/1 when the field is absent), and the Total spend tooltip shows the raw USD figure and the rate used.Suggested upstream shape: take the symbol from the profile currency, get the rate from an env override or a small server-side daily FX fetch, and fall back to USD when the currency is unknown.
Aside — how this looked unfixed after a deploy. The new build was served and
/api/usagereturned the currency field, but an open tab went on rendering the previous bundle:web/static/sw.jsdeliberately keeps a long-lived page's route chunks in the unversionedpi-chat-assetscache, and the auto-reload only fires within 5 s of the tab regaining visibility (web/src/routes/+layout.svelte). That is defensible, but nothing in the UI says which build is running, so a stale client is indistinguishable from a failed deploy. A build id in the UI, or an "update ready" pill, would remove the ambiguity.What I expected
Spend and per-model/per-session costs should be shown in the profile currency (£ GBP for me), converted from the USD cost that the providers actually bill — not hard-coded to $.
Attachments, if any, are attached to this issue by the app.