Cortex icon indicating copy to clipboard operation
Cortex copied to clipboard

Low: locale-formatted context window values with dot thousands separators clamp to 2048

Open dovvnloading opened this issue 3 weeks ago • 0 comments

Severity

Low / internationalization — the Context window numeric input displays grouping according to the browser locale, but parses only comma/space/underscore grouping. In locales that use a dot as the thousands separator, typing or pasting the displayed format can unexpectedly clamp the setting to the minimum.

Evidence

  • GenerationControls.tsx:75–110: Context window uses format={(tokens) => tokens.toLocaleString()} (the viewer locale) and the shared NumberInput with integer bounds 2,048 to 65,536.
  • NumberInput.tsx:20–29: integer parser strips [\\s,_] but not '.'; Number("8.192") yields 8.192, not 8192.
  • NumberInput.tsx:57–79: a value outside the valid range is not committed while typing, but is clamped on blur. Here the parsed value becomes 2048, silently changing what the user meant.
  • NumberInput.test.tsx covers comma-grouped integers (12,288), but not common German/Spanish/Dutch period-grouped integers.

Reproduction

  1. Use a browser locale such as de-DE; (8192).toLocaleString("de-DE") displays 8.192.
  2. In Context window, select all and type/paste 16.384 to request 16,384 tokens.
  3. Blur the input. Actual: parse("16.384", 0) returns the number 16.384; clamp() commits 2048, the minimum, instead of 16384.
  4. Expected: a locale-formatted integer is parsed consistently with its own display format, or the input consistently uses locale-neutral digits without grouping.

Suggested fix and tests

Prefer locale-aware Intl.NumberFormat(...).formatToParts grouping and decimal separator normalization, with strict integer syntax validation (avoiding accidental acceptance of 1.5 as a misleading count). Alternatively render all editable integer values without separators and keep grouping in noneditable labels. Test de-DE, en-US, fr-FR including NBSP/narrow NBSP, and blur/keyboard stepping.

Reviewed revision: e824fe2dcba0d1be127c9fff165f776186dc37e9. Deterministic parse/clamp logic; browser locale integration not executed.

dovvnloading avatar Nov 09 '26 15:11 dovvnloading