fix(tui): avoid rendering "1000.0K" in compact number formatting#33948
Open
IbrahimKhan12 wants to merge 1 commit into
Open
fix(tui): avoid rendering "1000.0K" in compact number formatting#33948IbrahimKhan12 wants to merge 1 commit into
IbrahimKhan12 wants to merge 1 commit into
Conversation
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".
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #33947
Type of change
What does this PR do?
Locale.numberformats compact counts shown in the TUI context panel, the subagent footer, and the CLIrunsummary. The thousands branch returned(num / 1000).toFixed(1) + "K";toFixed(1)rounds 999,950-999,999 up to1000.0, so they rendered as1000.0Kinstead of rolling over to1.0M(a session near a 1M-token context window showed1000.0K (100%)).The fix promotes the value to the
Msuffix when the rounded thousands value is1000.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.tscovering 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.tspasses (4 tests); I confirmed it fails before the fix (1000.0K) and passes after (1.0M).bun run typecheck(tui) passes andoxlintis clean on the changed files.Screenshots / recordings
N/A - text formatting only, not a visual UI change.
Checklist