Skip to content

Use one number formatter for token counts and chart axes - #463

Open
officialasishkumar wants to merge 1 commit into
useagenthq:mainfrom
officialasishkumar:fix/one-number-formatter
Open

officialasishkumar wants to merge 1 commit into
useagenthq:mainfrom
officialasishkumar:fix/one-number-formatter

Conversation

@officialasishkumar

@officialasishkumar officialasishkumar commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Chart axes: the area, combo and scatter chart cards drop their local compactNumber and use the one in frontend/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".
  • Token labels: formatTokens moves into utils/format.ts, next to compactNumber. It is the same number with a lowercase thousands mark ("96k", "1.3M"). Its two copies are gone:
    • the divide-and-round copy in application/agent-limits/agent-limits-card.tsx
    • the local Intl copy in agent-ui/live-subagent-status.tsx
  • Callers: the agent-limits cards, the composer status bar and the subagent status import it from utils/format.ts. The two components/pro stand-ins keep re-exporting formatTokens, so their exports still match the private edition's.
  • Visible change: the subagent status now reads "1.3k tokens", like every other token label, instead of "1.3K tokens".

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.ts pins 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.tsx now expects "1.3k tokens".

Checks run locally with Bun 1.3.14:

  • cd frontend && bun run test: 2061 pass, 0 fail
  • tsc --noEmit in frontend: passes
  • biome lint on the changed files: no findings

See it in action
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

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
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.

Use one number formatter for token counts and chart axes

1 participant