Skip to content

fix(tui): avoid rendering "1000.0K" in compact number formatting#33948

Open
IbrahimKhan12 wants to merge 1 commit into
anomalyco:devfrom
IbrahimKhan12:locale-number-rounding
Open

fix(tui): avoid rendering "1000.0K" in compact number formatting#33948
IbrahimKhan12 wants to merge 1 commit into
anomalyco:devfrom
IbrahimKhan12:locale-number-rounding

Conversation

@IbrahimKhan12

@IbrahimKhan12 IbrahimKhan12 commented Jun 25, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #33947

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Locale.number formats compact counts shown in the TUI context panel, the subagent footer, and the CLI run summary. The thousands branch returned (num / 1000).toFixed(1) + "K"; toFixed(1) rounds 999,950-999,999 up to 1000.0, so they rendered as 1000.0K instead of rolling over to 1.0M (a session near a 1M-token context window showed 1000.0K (100%)).

The fix promotes the value to the M suffix when the rounded thousands value is 1000.0. Only the thousands branch changes; every other output is unchanged.

How did you verify your code works?

Added packages/tui/test/util/locale.test.ts covering the K/M boundaries (999,949 -> 999.9K; 999,950 and 999,999 -> 1.0M; 1,000,000 -> 1.0M). bun test test/util/locale.test.ts passes (4 tests); I confirmed it fails before the fix (1000.0K) and passes after (1.0M). bun run typecheck (tui) passes and oxlint is clean on the changed files.

Screenshots / recordings

N/A - text formatting only, not a visual UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Locale.number rounds the thousands value with toFixed(1), so 999,950-999,999
rendered as "1000.0K" instead of rolling over to "1.0M". Promote to the M
suffix whenever the thousands value rounds up to "1000.0".
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Jun 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compact number formatter shows "1000.0K" instead of "1.0M" near 1M

1 participant