Skip to content

feat(dashboard): metric cards display human-readable numbers#3045

Merged
alx-xo merged 3 commits into
mainfrom
alexm/age-1887-feat-metric-cards-should-display-human-readable-numbers
May 27, 2026
Merged

feat(dashboard): metric cards display human-readable numbers#3045
alx-xo merged 3 commits into
mainfrom
alexm/age-1887-feat-metric-cards-should-display-human-readable-numbers

Conversation

@alx-xo
Copy link
Copy Markdown
Contributor

@alx-xo alx-xo commented May 27, 2026

Summary

  • Add formatCompact util in src/lib/format.ts using Intl.NumberFormat notation: "compact" — produces 1.5K, 2.3M, 1.1B; handles negatives and drops trailing zeros natively
  • Add "compact" as new MetricCard format variant; change default from "number" to "compact" so all metric cards abbreviate by default; "number" preserved as toLocaleString() escape hatch
  • Remove local formatTokens from InsightsAgents.tsx in favour of shared formatCompact; fix cost MetricCard that was incorrectly using format="number"format="currency"

Root cause

Metric cards passed large integers directly to toLocaleString(), producing unreadable values like 1,234,567. There was no shared abbreviation utility — InsightsAgents.tsx had its own formatTokens using a manual K/M chain with toFixed(1), which produced trailing zeros (1.0K) and missed billions.

Test plan

  • Metric cards on Insights > Agents show abbreviated token counts (e.g. 1.5M not 1,500,000)
  • Total Cost MetricCard shows currency format ($1.23), not compact
  • Security Overview metric cards (Events Scanned, Findings, Flagged Sessions, Active Policies) show compact numbers
  • Small values (< 1000) still show exact (42, not 42.0)
  • Round thousands drop trailing zero (1K not 1.0K)

Use Intl.NumberFormat compact notation (1.5K, 2.3M, 1.1B) instead of
raw toLocaleString across MetricCard and InsightsAgents. Extracts shared
formatCompact util; adds "compact" as MetricCard default format variant
while preserving "number" as a toLocaleString escape hatch.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@alx-xo alx-xo requested review from a team as code owners May 27, 2026 01:59
@alx-xo alx-xo added the enhancement New feature or request label May 27, 2026
@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 27, 2026

AGE-1887

Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 27, 2026

🦋 Changeset detected

Latest commit: 01c120a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
dashboard Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link
Copy Markdown

vercel Bot commented May 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
gram-docs-redirect Ready Ready Preview, Comment May 27, 2026 2:08am

Request Review

@alx-xo alx-xo changed the title feat(dashboard): metric cards display human-readable numbers (AGE-1887) feat(dashboard): metric cards display human-readable numbers May 27, 2026
…2.3M) instead of raw comma-separated values.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@alx-xo alx-xo added this pull request to the merge queue May 27, 2026
Merged via the queue into main with commit 7e4501e May 27, 2026
32 checks passed
@alx-xo alx-xo deleted the alexm/age-1887-feat-metric-cards-should-display-human-readable-numbers branch May 27, 2026 17:13
@github-actions github-actions Bot locked and limited conversation to collaborators May 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants