diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js
index a8a15ce34..e4df5dc26 100644
--- a/internal/gui/assets/app.js
+++ b/internal/gui/assets/app.js
@@ -8127,8 +8127,10 @@ function ledContentBox(c) {
// tab draws the same from the same answer.
// a count as a short number: 1.33 亿, 68.1 万 in Chinese, 133M in English
+// and in Chinese with Settings' K/M/B units (westernUnits)
+let westernUnits = false;
function ledShort(n) {
- if (locale !== "zh") return fmtN(n);
+ if (locale !== "zh" || westernUnits) return fmtN(n);
if (n >= 1e8) return +(n / 1e8).toFixed(2) + " 亿";
if (n >= 1e4) return +(n / 1e4).toFixed(1) + " 万";
return String(n);
@@ -10080,6 +10082,10 @@ function applyPrefs(s, rate) {
currency = s.currency || "usd";
if (applyPrefs.painted) renderCosts();
}
+ if (westernUnits !== !!s.westernUnits) {
+ westernUnits = !!s.westernUnits;
+ if (applyPrefs.painted) { renderCosts(); if (mode === "panel" && panelTab === "stats") renderPanelUse(); }
+ }
applyPrefs.painted = true;
if (!prefsBusy && (s.textSize || 100) !== textSize) { textSize = s.textSize || 100; applyZoom(textSize); }
const was = locale;
@@ -10602,6 +10608,10 @@ function renderTrayUsage(s, keep) {
$("#quotaLeftSegs").replaceChildren(segs([[false, t("Used")], [true, t("Left")]], !!s.quotaLeft,
(on) => { if (on !== quotaLeft) setQuotaLeft(on); }));
$("#currencySegs").replaceChildren(segs(CURRENCIES.map(([id, name]) => [id, t(name)]), s.currency || "usd", (v) => savePrefs({ ...keep, currency: v })));
+ // 万 and 亿 are Chinese's alone: in English a count is always K, M and B
+ $("#unitsRow").hidden = locale !== "zh";
+ $("#unitsSegs").replaceChildren(segs([[false, t("万 / 亿")], [true, t("K / M / B")]], !!s.westernUnits,
+ (v) => savePrefs({ ...keep, westernUnits: v })));
renderAlerts(s, keep);
// the agents' lists name a model with its provider's after it, or alone
// (#335): set on its own, so the agents are told
@@ -11188,7 +11198,7 @@ function prefsKeep(s) {
claudeWarmup: s.claudeWarmup || "", codexWarmAt: s.codexWarmAt || "", claudeWarmAt: s.claudeWarmAt || "", workbuddyCheckin: !!s.workbuddyCheckin, noStats: !!s.noStats,
noUpdatePill: !!s.noUpdatePill,
trayUsage: s.trayUsage || "", trayUsageEvery: s.trayUsageEvery || 3, trayNoLogos: !!s.trayNoLogos, vision: s.vision || "", imageGen: s.imageGen || "", currency: s.currency || "usd",
- usageAlert: s.usageAlert || 0, balanceAlert: s.balanceAlert || 0 };
+ westernUnits: !!s.westernUnits, usageAlert: s.usageAlert || 0, balanceAlert: s.balanceAlert || 0 };
}
// savePrefs sends what the page was drawn with (prefsBase) and the choice
diff --git a/internal/gui/assets/i18n.js b/internal/gui/assets/i18n.js
index 129220648..1d42f8dc8 100644
--- a/internal/gui/assets/i18n.js
+++ b/internal/gui/assets/i18n.js
@@ -192,6 +192,10 @@ const I18N = {
"Usage shows": "用量显示",
"How much of each window is used, or how much is left, on the Usage page, the panel and the menu bar": "每个窗口显示已用多少或剩余多少,用量页、面板和菜单栏一致",
"Currency": "货币",
+ "Number units": "数字单位",
+ "How a large count of tokens or requests is shortened on the Usage page and the panel": "用量页和面板上较大的 token 数、请求数用什么单位缩写",
+ "万 / 亿": "中文(万 / 亿)",
+ "K / M / B": "英文(K / M / B)",
"Usage alert": "用量提醒",
"Low balance alert": "余额提醒",
"A notification when a 5-hour, weekly or monthly window reaches this share used, once each time it runs": "5 小时、每周或每月窗口用到这个比例时发一条系统通知,每个周期只提醒一次",
diff --git a/internal/gui/assets/index.html b/internal/gui/assets/index.html
index 50dce850b..aff1c116b 100644
--- a/internal/gui/assets/index.html
+++ b/internal/gui/assets/index.html
@@ -253,6 +253,10 @@
diff --git a/internal/gui/tests/README.md b/internal/gui/tests/README.md
index 3e21224df..5ba323d1c 100644
--- a/internal/gui/tests/README.md
+++ b/internal/gui/tests/README.md
@@ -515,6 +515,14 @@ card's padding, as far in as the tabs above it, ends before the plot, and
nothing runs past the card or scrolls the page sideways; Chromium and WebKit,
English and Chinese.
+`number-units.test.cjs` checks Settings' Number units (John on Discord): in
+Chinese the Requests tab says a large count in 万 and 亿 ("15.4 亿", an axis's
+"8000 万") by default; picking K / M / B saves westernUnits, moves nothing on
+the settings page, and the totals and chart axis then say "1.54B" and "80M"
+while the page stays Chinese, after a reload and in the tray panel too, each
+label still ending before the plot. In English the row is hidden and counts are
+K / M / B anyway; Chromium and WebKit.
+
`panel-usage.test.cjs` opens the tray panel's Usage tab: the totals, a small
chart and a ranking of five at most for today, seven or thirty days, the
metric switch, and a click on a provider (or the picker) that switches to it —
@@ -968,7 +976,7 @@ reads shows none of it. English and Chinese, Chromium and WebKit, with
With Node.js and Playwright available:
```sh
-node --test internal/gui/tests/menu-scroll.test.cjs internal/gui/tests/click-scroll.test.cjs internal/gui/tests/panel-fold.test.cjs internal/gui/tests/rollup-short.test.cjs internal/gui/tests/panel-routing.test.cjs internal/gui/tests/gateway-fold.test.cjs internal/gui/tests/routing-kind.test.cjs internal/gui/tests/balance-fix.test.cjs internal/gui/tests/cli-update.test.cjs internal/gui/tests/login-import.test.cjs internal/gui/tests/agy-launch.test.cjs internal/gui/tests/currency.test.cjs internal/gui/tests/usage-ledger.test.cjs internal/gui/tests/update-check.test.cjs internal/gui/tests/omarchy.test.cjs internal/gui/tests/brand.test.cjs internal/gui/tests/library-loading.test.cjs internal/gui/tests/provider-typed.test.cjs node --test internal/gui/tests/signin-callback.test.cjs internal/gui/tests/routing-steady.test.cjs internal/gui/tests/old-webkit.test.cjs internal/gui/tests/session-terminal.test.cjs internal/gui/tests/text-size.test.cjs internal/gui/tests/zcode-site.test.cjs internal/gui/tests/rail-tip.test.cjs internal/gui/tests/sync-update.test.cjs internal/gui/tests/plugin-signin.test.cjs internal/gui/tests/plugin-market.test.cjs internal/gui/tests/s3-sync.test.cjs internal/gui/tests/routing-wb-refused.test.cjs internal/gui/tests/routing-blocked.test.cjs internal/gui/tests/routing-zcode-blocked.test.cjs internal/gui/tests/routing-shape.test.cjs internal/gui/tests/market-have.test.cjs internal/gui/tests/sessions-today.test.cjs internal/gui/tests/routing-side-calls.test.cjs internal/gui/tests/import-all-skills.test.cjs internal/gui/tests/routing-flood.test.cjs internal/gui/tests/routing-busy.test.cjs internal/gui/tests/own-skill.test.cjs internal/gui/tests/routing-manual.test.cjs internal/gui/tests/tray-usages.test.cjs internal/gui/tests/provider-remove.test.cjs internal/gui/tests/signin-link.test.cjs internal/gui/tests/tray-inuse.test.cjs internal/gui/tests/codex-auto-reset.test.cjs internal/gui/tests/routing-auto-reset.test.cjs internal/gui/tests/claude-usage-asked.test.cjs internal/gui/tests/claude-risk.test.cjs internal/gui/tests/library-toggle-status.test.cjs internal/gui/tests/library-all.test.cjs internal/gui/tests/routing-reroute-title.test.cjs internal/gui/tests/plain-names.test.cjs internal/gui/tests/panel-effort.test.cjs internal/gui/tests/agent-models-all-hidden.test.cjs internal/gui/tests/omp-roles.test.cjs internal/gui/tests/claude-effort.test.cjs internal/gui/tests/remote-magpie.test.cjs internal/gui/tests/qoder-cn-tile.test.cjs internal/gui/tests/provider-levels-scroll.test.cjs internal/gui/tests/signin-paste-codex.test.cjs internal/gui/tests/signin-paste-key.test.cjs internal/gui/tests/usage-alert.test.cjs internal/gui/tests/quota-families.test.cjs internal/gui/tests/provider-search.test.cjs internal/gui/tests/webdav-settings-refresh.test.cjs internal/gui/tests/lan-docker.test.cjs internal/gui/tests/plugin-key-hint.test.cjs internal/gui/tests/update-hide.test.cjs internal/gui/tests/tray-logos.test.cjs internal/gui/tests/routing-proxy.test.cjs internal/gui/tests/sse-body.test.cjs internal/gui/tests/remote-group-served.test.cjs internal/gui/tests/plugin-move-overflow.test.cjs internal/gui/tests/routing-time.test.cjs internal/gui/tests/unlisted-models.test.cjs internal/gui/tests/plugin-updates.test.cjs internal/gui/tests/request-archive.test.cjs internal/gui/tests/group-member-fast.test.cjs internal/gui/tests/providers-off-fold.test.cjs internal/gui/tests/account-return.test.cjs internal/gui/tests/usage-ledger-detail.test.cjs internal/gui/tests/usage-ledger-chart.test.cjs internal/gui/tests/usage-chart-axis.test.cjs internal/gui/tests/panel-usage.test.cjs internal/gui/tests/usage-refresh.test.cjs internal/gui/tests/usage-ledger-content.test.cjs internal/gui/tests/claude-direct.test.cjs internal/gui/tests/signin-again.test.cjs internal/gui/tests/sessions-calendar-fill.test.cjs internal/gui/tests/editor-short-window.test.cjs internal/gui/tests/group-from-model-add.test.cjs internal/gui/tests/sync-other-kind.test.cjs internal/gui/tests/web-page.test.cjs internal/gui/tests/balance-parts.test.cjs internal/gui/tests/search-api.test.cjs internal/gui/tests/provider-file-error.test.cjs internal/gui/tests/sessions-manage.test.cjs
+node --test internal/gui/tests/menu-scroll.test.cjs internal/gui/tests/click-scroll.test.cjs internal/gui/tests/panel-fold.test.cjs internal/gui/tests/rollup-short.test.cjs internal/gui/tests/panel-routing.test.cjs internal/gui/tests/gateway-fold.test.cjs internal/gui/tests/routing-kind.test.cjs internal/gui/tests/balance-fix.test.cjs internal/gui/tests/cli-update.test.cjs internal/gui/tests/login-import.test.cjs internal/gui/tests/agy-launch.test.cjs internal/gui/tests/currency.test.cjs internal/gui/tests/usage-ledger.test.cjs internal/gui/tests/update-check.test.cjs internal/gui/tests/omarchy.test.cjs internal/gui/tests/brand.test.cjs internal/gui/tests/library-loading.test.cjs internal/gui/tests/provider-typed.test.cjs node --test internal/gui/tests/signin-callback.test.cjs internal/gui/tests/routing-steady.test.cjs internal/gui/tests/old-webkit.test.cjs internal/gui/tests/session-terminal.test.cjs internal/gui/tests/text-size.test.cjs internal/gui/tests/zcode-site.test.cjs internal/gui/tests/rail-tip.test.cjs internal/gui/tests/sync-update.test.cjs internal/gui/tests/plugin-signin.test.cjs internal/gui/tests/plugin-market.test.cjs internal/gui/tests/s3-sync.test.cjs internal/gui/tests/routing-wb-refused.test.cjs internal/gui/tests/routing-blocked.test.cjs internal/gui/tests/routing-zcode-blocked.test.cjs internal/gui/tests/routing-shape.test.cjs internal/gui/tests/market-have.test.cjs internal/gui/tests/sessions-today.test.cjs internal/gui/tests/routing-side-calls.test.cjs internal/gui/tests/import-all-skills.test.cjs internal/gui/tests/routing-flood.test.cjs internal/gui/tests/routing-busy.test.cjs internal/gui/tests/own-skill.test.cjs internal/gui/tests/routing-manual.test.cjs internal/gui/tests/tray-usages.test.cjs internal/gui/tests/provider-remove.test.cjs internal/gui/tests/signin-link.test.cjs internal/gui/tests/tray-inuse.test.cjs internal/gui/tests/codex-auto-reset.test.cjs internal/gui/tests/routing-auto-reset.test.cjs internal/gui/tests/claude-usage-asked.test.cjs internal/gui/tests/claude-risk.test.cjs internal/gui/tests/library-toggle-status.test.cjs internal/gui/tests/library-all.test.cjs internal/gui/tests/routing-reroute-title.test.cjs internal/gui/tests/plain-names.test.cjs internal/gui/tests/panel-effort.test.cjs internal/gui/tests/agent-models-all-hidden.test.cjs internal/gui/tests/omp-roles.test.cjs internal/gui/tests/claude-effort.test.cjs internal/gui/tests/remote-magpie.test.cjs internal/gui/tests/qoder-cn-tile.test.cjs internal/gui/tests/provider-levels-scroll.test.cjs internal/gui/tests/signin-paste-codex.test.cjs internal/gui/tests/signin-paste-key.test.cjs internal/gui/tests/usage-alert.test.cjs internal/gui/tests/quota-families.test.cjs internal/gui/tests/provider-search.test.cjs internal/gui/tests/webdav-settings-refresh.test.cjs internal/gui/tests/lan-docker.test.cjs internal/gui/tests/plugin-key-hint.test.cjs internal/gui/tests/update-hide.test.cjs internal/gui/tests/tray-logos.test.cjs internal/gui/tests/routing-proxy.test.cjs internal/gui/tests/sse-body.test.cjs internal/gui/tests/remote-group-served.test.cjs internal/gui/tests/plugin-move-overflow.test.cjs internal/gui/tests/routing-time.test.cjs internal/gui/tests/unlisted-models.test.cjs internal/gui/tests/plugin-updates.test.cjs internal/gui/tests/request-archive.test.cjs internal/gui/tests/group-member-fast.test.cjs internal/gui/tests/providers-off-fold.test.cjs internal/gui/tests/account-return.test.cjs internal/gui/tests/usage-ledger-detail.test.cjs internal/gui/tests/usage-ledger-chart.test.cjs internal/gui/tests/usage-chart-axis.test.cjs internal/gui/tests/panel-usage.test.cjs internal/gui/tests/usage-refresh.test.cjs internal/gui/tests/usage-ledger-content.test.cjs internal/gui/tests/claude-direct.test.cjs internal/gui/tests/signin-again.test.cjs internal/gui/tests/sessions-calendar-fill.test.cjs internal/gui/tests/editor-short-window.test.cjs internal/gui/tests/group-from-model-add.test.cjs internal/gui/tests/sync-other-kind.test.cjs internal/gui/tests/web-page.test.cjs internal/gui/tests/balance-parts.test.cjs internal/gui/tests/search-api.test.cjs internal/gui/tests/provider-file-error.test.cjs internal/gui/tests/sessions-manage.test.cjs internal/gui/tests/number-units.test.cjs
```
If Playwright is installed outside the repository, set `NODE_PATH` to the
diff --git a/internal/gui/tests/number-units.test.cjs b/internal/gui/tests/number-units.test.cjs
new file mode 100644
index 000000000..79d5eb3da
--- /dev/null
+++ b/internal/gui/tests/number-units.test.cjs
@@ -0,0 +1,173 @@
+// Run with Node's test runner and Playwright on the module path; see README.md.
+// Number units (John on Discord): in Chinese a large count is said in 万 and
+// 亿 ("15.4 亿", an axis's "8000 万") unless Settings' Number units picks K /
+// M / B, which shortens it as English does ("1.54B", "80M") while the rest
+// stays Chinese — the Requests tab's totals and chart axis, and the tray
+// panel's, whose labels still end before the plot starts. The row is
+// Chinese's alone: in English it is hidden and counts are K / M / B anyway.
+// Picking it saves westernUnits, never scrolls the settings page, and holds
+// after a reload. Chromium and WebKit; no backend, the API is faked.
+const assert = require("node:assert/strict");
+const fs = require("node:fs/promises");
+const path = require("node:path");
+const { test } = require("node:test");
+const { chromium, webkit } = require("playwright");
+
+const assets = path.resolve(__dirname, "../assets");
+const midnight = new Date();
+midnight.setHours(0, 0, 0, 0);
+
+// a day by the hour of one provider: 7000 万 (70M) tokens an hour, from 2am
+function ledger() {
+ const series = Array.from({ length: 24 }, (_, h) => {
+ const on = h >= 2 ? 1 : 0;
+ const part = { calls: 900 * on, tokens: 7e7 * on, cost: 1.2 * on };
+ const by = { provider: { zcode: part }, agent: { claude: part }, model: { "glm-5": part } };
+ return { label: String(h), time: new Date(midnight.getTime() + h * 3600e3).toISOString(), calls: part.calls, errors: 0,
+ input: part.tokens * 0.01, output: part.tokens * 0.005, cache_write: part.tokens * 0.05, cache_read: part.tokens * 0.935, cost: part.cost, by };
+ });
+ const sum = (k) => series.reduce((a, p) => a + p[k], 0);
+ const tot = { calls: sum("calls"), errors: 0, input: sum("input"), output: sum("output"), cache_write: sum("cache_write"), cache_read: sum("cache_read"), reasoning: 0, cost: sum("cost"), unpriced: 0 };
+ const share = (id, name, icon) => ({ id, name, icon, ...tot });
+ return {
+ period: "today", rows: [], offset: 0, total: 1, ...tot, bucket: "hour", series,
+ by: { provider: [share("zcode", "ZCode", "generic")], agent: [share("claude", "Claude Code", "claudecode-color")], model: [share("glm-5", "glm-5", "")] },
+ agents: [{ id: "claude", name: "Claude Code", icon: "claudecode-color" }], providers: [{ id: "zcode", name: "ZCode", icon: "generic" }],
+ };
+}
+
+// the settings live here, across reloads of one context
+function serve(lang, store, web) {
+ return async (route) => {
+ const req = route.request(), url = new URL(req.url());
+ const json = (data) => route.fulfill({ json: data });
+ if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:${web}};` });
+ if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
+ if (url.pathname === "/api/state") return json({ agents: [], profiles: [], settings: store.cur });
+ if (url.pathname === "/api/settings") {
+ if (req.method() === "POST") { store.posts.push(req.postDataJSON()); store.cur = { ...store.cur, ...req.postDataJSON() }; }
+ return json(store.cur);
+ }
+ if (url.pathname === "/api/usage/requests") return json(ledger());
+ if (url.pathname === "/api/usage/quotas") return json([]);
+ if (url.pathname === "/api/usage") return json({ calls: 1, errors: 0, input: 1, output: 1, cache_read: 0, cache_write: 0, reasoning: 0, unpriced: 0, cost: 1, bucket: "day", series: [], agents: [], models: [] });
+ if (url.pathname === "/api/sessions") return json({ sessions: [], dirs: [] });
+ if (url.pathname === "/api/sessions/stats") return json({ from: "", to: "", days: [], agents: {} });
+ if (url.pathname === "/api/groups") return json({ groups: [], models: [] });
+ if (url.pathname === "/api/plugins") return json({ plugins: [] });
+ if (url.pathname === "/api/gateway/trace") return json({ mine: true, now: new Date().toISOString(), seq: 0, totals: { requests: 0, rerouted: 0, errors: 0 }, routes: [] });
+ if (url.pathname === "/api/gateway/history") return json({ cut: false, days: [], routes: [] });
+ if (url.pathname === "/api/providers") return json({ providers: [], gateway: { running: true, window: true } });
+ if (url.pathname.startsWith("/api/")) return json({});
+ const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname);
+ const contentType = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)];
+ await route.fulfill({ body: await fs.readFile(file), contentType });
+ };
+}
+
+// the chart's side labels, and whether each ends before the plot starts
+async function axis(p, card) {
+ return p.locator(card).first().evaluate((c) => {
+ const svg = c.querySelector(".led-chart svg");
+ const grid = Math.min(...[...svg.querySelectorAll(".grid")].map((g) => g.getBoundingClientRect().left));
+ return [...svg.querySelectorAll("text.axis[text-anchor=end]")].map((x) => {
+ const b = x.getBoundingClientRect();
+ return { text: x.textContent.trim(), fits: b.width > 0 && b.right <= grid + 0.5 };
+ });
+ });
+}
+const kpi = async (p, card) => (await p.locator(card + " .blk .v").first().textContent()).trim();
+
+async function check(p, card, western, what) {
+ const labs = await axis(p, card);
+ assert.equal(labs.length, 5, what + ": five side labels");
+ for (const l of labs) assert(l.fits, `${what}: "${l.text}" runs into the plot`);
+ const texts = labs.map((l) => l.text);
+ if (western) {
+ assert(!texts.some((x) => /[万亿]/.test(x)), `${what}: K/M/B axis, got ${texts}`);
+ assert(texts.includes("80M"), `${what}: 80M on the axis, got ${texts}`);
+ } else {
+ assert(texts.includes("8000 万"), `${what}: 8000 万 on the axis, got ${texts}`);
+ }
+}
+
+const settingsView = (p) => p.locator("#view-settings").evaluate((v) => v.scrollTop);
+
+for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
+ test(engine + ": Chinese counts in 万/亿 or, picked in Settings, K/M/B", async (t) => {
+ const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
+ t.after(() => browser.close());
+
+ for (const lang of ["en", "zh"]) {
+ await t.test(lang, async () => {
+ const store = { cur: { lang, theme: "light", currency: "usd", tray: "panel" }, posts: [] };
+ const ctx = await browser.newContext({ viewport: { width: 1000, height: 480 }, reducedMotion: "reduce" });
+ const p = await ctx.newPage();
+ const errors = [];
+ p.setDefaultTimeout(5000);
+ p.on("pageerror", (e) => errors.push(e.message));
+ await p.route("**/*", serve(lang, store, false));
+ const requests = async () => {
+ await p.locator('[data-view="usage"]').first().click();
+ await p.locator("#usageTab .opt").nth(1).click();
+ await p.locator("#ledChart svg").waitFor();
+ };
+
+ // by default Chinese says 万 and 亿, English K/M/B
+ await p.goto("http://magpie.test/");
+ await requests();
+ await check(p, ".led-trend", lang === "en", lang + " default");
+ assert.equal(await kpi(p, "#ledKpi"), lang === "en" ? "1.54B" : "15.4 亿");
+
+ await p.locator("#prefs").click();
+ await p.locator("#currencySegs .opt").first().waitFor();
+ if (lang === "en") {
+ assert.equal(await p.locator("#unitsRow").isHidden(), true, "no Number units row in English");
+ } else {
+ const segs = p.locator("#unitsSegs .opt");
+ assert.equal(await p.locator("#unitsRow .name").textContent(), "数字单位");
+ assert.deepEqual((await segs.allTextContents()).map((x) => x.trim()), ["中文(万 / 亿)", "英文(K / M / B)"]);
+ assert.equal(await segs.nth(0).evaluate((b) => b.classList.contains("on")), true, "万/亿 starts picked");
+ // scrolled down by a real wheel, a pick moves nothing
+ await p.locator("#currencySegs").hover();
+ for (let i = 0; i < 20 && !(await settingsView(p)); i++) { await p.mouse.wheel(0, 200); await p.waitForTimeout(20); }
+ const before = await settingsView(p);
+ assert(before > 0, "the settings list must be long enough to scroll");
+ await segs.nth(1).click();
+ await p.locator("#unitsSegs .opt.on", { hasText: "K / M / B" }).waitFor();
+ await p.waitForTimeout(300);
+ assert.equal(await settingsView(p), before, "picking units must not scroll the settings page");
+ assert.equal(store.posts.at(-1).westernUnits, true, "saved as westernUnits");
+ assert.equal(store.posts.at(-1).currency, "usd", "the rest of the settings sent as they were");
+
+ // the Requests tab now says K/M/B, still in Chinese
+ await requests();
+ await check(p, ".led-trend", true, "zh western");
+ assert.equal(await kpi(p, "#ledKpi"), "1.54B");
+ assert.equal((await p.locator("#ledKpi .blk .k").nth(1).textContent()).trim(), "请求", "the page stays Chinese");
+
+ // and after a reload, from the settings magpie keeps
+ await p.reload();
+ await requests();
+ await check(p, ".led-trend", true, "zh western, reloaded");
+ }
+ assert.deepEqual(errors, []);
+ await ctx.close();
+
+ // the tray panel's Usage tab, with what was saved
+ const pctx = await browser.newContext({ viewport: { width: 380, height: 560 }, reducedMotion: "reduce" });
+ const pp = await pctx.newPage();
+ pp.setDefaultTimeout(5000);
+ pp.on("pageerror", (e) => errors.push(e.message));
+ await pp.route("**/*", serve(lang, store, true));
+ await pp.goto("http://magpie.test/?mode=panel");
+ await pp.locator('[data-ptab="stats"]').click();
+ await pp.locator("#panelUsage .pu-card .led-chart svg").waitFor();
+ await check(pp, "#panelUsage .pu-card", true, lang + " panel");
+ assert.equal((await pp.locator("#panelUsage .pu-tot .blk .v").first().textContent()).trim(), "1.54B");
+ assert.deepEqual(errors, []);
+ await pctx.close();
+ });
+ }
+ });
+}
diff --git a/internal/settings/settings.go b/internal/settings/settings.go
index c5864f5bb..f30dc0c89 100644
--- a/internal/settings/settings.go
+++ b/internal/settings/settings.go
@@ -38,6 +38,10 @@ type Settings struct {
// rate (see internal/fx). A vendor's own balance, already in its own
// currency (a Chinese relay's ¥), is never touched by this.
Currency string `json:"currency,omitempty"`
+ // WesternUnits shortens a large count in K, M and B even when magpie
+ // speaks Chinese, which otherwise says it in 万 and 亿 (8000 万
+ // rather than 80M). It means nothing in English.
+ WesternUnits bool `json:"westernUnits,omitempty"`
// Dock keeps magpie in the Mac's Dock as well as the menu bar, for a
// menu bar too full to show its icon.
Dock bool `json:"dock,omitempty"`