Repository navigation
Use one number formatter for token counts and chart axes - #463
Open
officialasishkumar wants to merge 1 commit into
Open
officialasishkumar wants to merge 1 commit into
officialasishkumar wants to merge 1 commit into
Conversation
The area, combo and scatter chart cards each carried a divide-and-round compactNumber, and the agent-limits card and the subagent status had their own formatTokens. Rounding never moved a value into the next unit, so a 1,234,567 axis tick read "1234.6K" and 999,950 tokens read "1000.0k". compactNumber in utils/format.ts already formats with Intl's compact notation, which carries the rounding into the next unit. The chart cards now use it, and formatTokens moves next to it as the same number with a lowercase thousands mark. The agent-limits cards, the composer status bar and the subagent status import it from there; the pro stand-ins keep re-exporting it so their exports stay the same. The subagent status now reads "1.3k tokens" like every other token label instead of "1.3K tokens". The format tests pin 999, 1,500, 999,950 and 1,234,567 for both helpers. Closes useagenthq#257
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.
By opening this pull request you agree to the Contributor License Agreement. On your first pull request a bot asks you to sign it with a one-line comment.
Fixes #257
The chart cards and the token labels each had their own number shortener, and the copies broke at the edges: rounding never carried into the next unit, so a 1,234,567 axis tick read "1234.6K" and 999,950 tokens read "1000.0k".
What changed
compactNumberand use the one infrontend/utils/format.ts. That one already uses Intl's compact notation, which carries the rounding into the next unit: 1,234,567 reads "1.2M" and 999,950 reads "1M".formatTokensmoves intoutils/format.ts, next tocompactNumber. It is the same number with a lowercase thousands mark ("96k", "1.3M"). Its two copies are gone:application/agent-limits/agent-limits-card.tsxagent-ui/live-subagent-status.tsxutils/format.ts. The twocomponents/prostand-ins keep re-exportingformatTokens, so their exports still match the private edition's.Values under 1,000 now keep one decimal where the old chart copies rounded to a whole number, so a tick at 2.5 reads "2.5" rather than "3".
Tests
utils/format.test.tspins both helpers at 0, 314, 999, 1,000, 1,500, 96,000, 482,800, 999,950, 1,234,567 and 1,250,000.agent-ui.test.tsxnow expects "1.3k tokens".Checks run locally with Bun 1.3.14:
cd frontend && bun run test: 2061 pass, 0 failtsc --noEmitinfrontend: passesbiome linton the changed files: no findingsOpen in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.