Skip to content

fix(desktop): pin 'en-US' in number/currency formatting so tests pass under non-en-US locales - #98850

Closed
kokhlo wants to merge 1 commit into
NousResearch:mainfrom
kokhlo:fix/desktop-locale-pinned-number-formatting
Closed

kokhlo wants to merge 1 commit into
NousResearch:mainfrom
kokhlo:fix/desktop-locale-pinned-number-formatting

Conversation

@kokhlo

@kokhlo kokhlo commented Aug 30, 2026

Copy link
Copy Markdown

Summary

Three desktop call sites format numbers/currency through the implicit system locale (bare .toLocaleString() / new Intl.NumberFormat(undefined, ...)), so the vitest suite fails on any machine running a non-en-US system locale (e.g. pl_PL.UTF-8 groups thousands with U+00A0 and renders USD as 10 USD with a non-breaking space, which also defeats @testing-library's whitespace-normalized getByText).

  • fallback-model/format.ts — omitted.toLocaleString() -> omitted.toLocaleString('en-US')
  • use-prompt-actions/utils.ts — pin 'en-US' on the four .toLocaleString() calls in the usage line
  • billing-amounts.ts — new Intl.NumberFormat(undefined, ...) -> new Intl.NumberFormat('en-US', ...)

This matches the existing pinned-locale pattern already used in use-billing-state.ts (credits.toLocaleString('en-US'), new Intl.NumberFormat('en-US', ...)), so it is consistency rather than a new convention.

Fixes #98849

Testing

Worktree from main (4f22543), apps/desktop, Node v26.7.0:

$ LANG=pl_PL.UTF-8 LC_ALL=pl_PL.UTF-8 npx vitest run         src/components/assistant-ui/tool/fallback-model.test.ts         src/app/session/hooks/use-prompt-actions/utils.test.ts         src/app/settings/billing/index.test.tsx --project ui
 Test Files  3 passed (3)
      Tests  118 passed (118)

RED check on unpatched main under the same env — exactly the four tests named in the issue fail:

 x formats calls / input / output / total with thousands separators   (use-prompt-actions/utils.test.ts)
 x truncates oversized payloads and reports the omitted count          (fallback-model.test.ts)
 x rejects auto-refill amounts outside the billing bounds              (billing/index.test.tsx)
 x disables buy controls while polling and renders the settled outcome (billing/index.test.tsx)
 Tests  4 failed | 114 passed (118)

Also green under en_US.UTF-8, plus tsc -p . --noEmit and eslint clean on the three touched files.

@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/desktop Electron desktop app (apps/desktop/*) area/i18n Localization, locales, translations area/billing Account usage, credit usage, billing (cross-cutting) labels Aug 30, 2026
@alt-glitch

Copy link
Copy Markdown

This was generated by AI during triage.

Related: open #71750 already changes these same three formatter paths and includes focused regression coverage. This PR is a narrower subset; maintainers can choose the preferred review unit.

@OutThisLife

Copy link
Copy Markdown

Superseded by #120267. The Polish failures reproduce on current main; the replacement fixes the test expectations and preserves non-breaking spaces in billing queries without changing localized production output. Thanks @kokhlo for the precise reproduction and currency-whitespace diagnosis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/billing Account usage, credit usage, billing (cross-cutting) area/i18n Localization, locales, translations comp/desktop Electron desktop app (apps/desktop/*) P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vitest suite fails under non-en-US system locale (bare .toLocaleString() / Intl.NumberFormat(undefined, ...))

3 participants