Skip to content

feat: add tooltip with full precision values to chart card totals and consolidate number formatting utilities - #3501

Merged
akshaydeo merged 1 commit into
devfrom
05-14-refactor_remove_duplicate_number_formatting_functions_and_use_a_centralized_function
May 14, 2026
Merged

feat: add tooltip with full precision values to chart card totals and consolidate number formatting utilities#3501
akshaydeo merged 1 commit into
devfrom
05-14-refactor_remove_duplicate_number_formatting_functions_and_use_a_centralized_function

Conversation

@impoiler

@impoiler impoiler commented May 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Consolidates number formatting utilities across the dashboard and logs UI, and adds tooltip support to chart card totals so users can see the full unrounded value on hover.

Changes

  • Added a totalTooltip prop to ChartCard (and its internal TotalChip/Header components) that, when provided, wraps the total chip in a Tooltip so hovering reveals the precise value. All chart tabs (Overview, MCP, Provider Usage, Model Rankings) now pass full-precision tooltips for token counts, costs, and latency averages.
  • Removed the local formatTokens function from chartUtils.ts and replaced all usages across chart components (tokenUsageChart, modelUsageChart, logVolumeChart, mcpVolumeChart, mcpTopToolsChart, providerTokenChart) with the shared formatCompactNumber from lib/utils/numbers.
  • Added formatCurrencyNumber to lib/utils/numbers and replaced the ad-hoc formatCost calls used as Y-axis tick formatters in costChart and providerCostChart with it.
  • Removed the duplicate formatCompactNumber implementation from lib/utils/governance.ts, replacing it with a re-export from lib/utils/numbers. Updated rateLimitDisplay and modelRankingsTab to import from the canonical location.
  • Fixed a missing $0 case in formatCost for zero values.
  • Token display in the logs table columns and log detail view now uses formatCompactNumber instead of the removed formatTokens.

Type of change

  • Bug fix
  • Feature
  • Refactor
  • Documentation
  • Chore/CI

Affected areas

  • Core (Go)
  • Transports (HTTP)
  • Providers/Integrations
  • Plugins
  • UI (React)
  • Docs

How to test

cd ui
pnpm i || npm i
pnpm test || npm test
pnpm build || npm run build
  1. Open the dashboard and navigate to the Overview, MCP, Provider Usage, and Model Rankings tabs.
  2. Hover over any chart card's total chip (e.g. "Total 1.2M") — a tooltip should appear showing the full unrounded number (e.g. "1,234,567").
  3. For cost totals, the tooltip should show the full currency value with up to 6 decimal places.
  4. For latency averages, the tooltip should show the value in milliseconds with up to 6 decimal places.
  5. Verify Y-axis tick labels on token and cost charts render correctly.
  6. Verify token counts in the logs table and log detail sheet display correctly.

Screenshots/Recordings

Before: Chart card totals show compact numbers with no way to see the exact value.
After: Hovering the total chip reveals a tooltip with the full-precision number.

Breaking changes

  • No

Related issues

Security considerations

None.

Checklist

  • I read docs/contributing/README.md and followed the guidelines
  • I added/updated tests where appropriate
  • I updated documentation where needed
  • I verified builds succeed (Go and UI)
  • I verified the CI pipeline passes locally if applicable

@coderabbitai

coderabbitai Bot commented May 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: aa69550b-7ddb-46aa-b26a-3d070e421f5a

📥 Commits

Reviewing files that changed from the base of the PR and between 4f68e70 and dcafd06.

📒 Files selected for processing (20)
  • ui/app/workspace/dashboard/components/charts/chartCard.tsx
  • ui/app/workspace/dashboard/components/charts/costChart.tsx
  • ui/app/workspace/dashboard/components/charts/externalCacheTokenMeterChart.tsx
  • ui/app/workspace/dashboard/components/charts/logVolumeChart.tsx
  • ui/app/workspace/dashboard/components/charts/mcpTopToolsChart.tsx
  • ui/app/workspace/dashboard/components/charts/mcpVolumeChart.tsx
  • ui/app/workspace/dashboard/components/charts/modelUsageChart.tsx
  • ui/app/workspace/dashboard/components/charts/providerCostChart.tsx
  • ui/app/workspace/dashboard/components/charts/providerTokenChart.tsx
  • ui/app/workspace/dashboard/components/charts/tokenUsageChart.tsx
  • ui/app/workspace/dashboard/components/mcpTab.tsx
  • ui/app/workspace/dashboard/components/modelRankingsTab.tsx
  • ui/app/workspace/dashboard/components/overviewTab.tsx
  • ui/app/workspace/dashboard/components/providerUsageTab.tsx
  • ui/app/workspace/dashboard/utils/chartUtils.ts
  • ui/app/workspace/logs/sheets/logDetailView.tsx
  • ui/app/workspace/logs/views/columns.tsx
  • ui/components/rateLimitDisplay.tsx
  • ui/lib/utils/governance.ts
  • ui/lib/utils/numbers.ts

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Dashboard charts now show optional total-value tooltips for quick reference.
  • Improvements

    • Standardized compact number formatting across charts, logs, and lists (e.g., 1.2K, 1.5M).
    • Improved USD currency display and small-value handling for cost values.
    • Consistent token/count formatting in charts, logs, and detail views.

Walkthrough

Centralizes compact and currency number formatters, updates charts and logs to use them, and adds an optional totalTooltip prop so ChartCard totals can render inside tooltips across dashboard tabs.

Changes

Number Formatting and ChartCard Tooltips

Layer / File(s) Summary
Number formatting utilities consolidation
ui/lib/utils/governance.ts, ui/lib/utils/numbers.ts, ui/components/rateLimitDisplay.tsx
Consolidates formatCompactNumber into numbers.ts, adds formatCurrencyNumber(value, maximumFractionDigits), and updates imports to use the centralized formatter.
ChartCard component tooltip support
ui/app/workspace/dashboard/components/charts/chartCard.tsx
Adds optional totalTooltip prop to ChartCard/Header/TotalChip, conditionally wraps the total chip in a Tooltip when provided, and forwards the prop in both loading and non-loading render paths.
Cost chart Y-axis formatter migration
ui/app/workspace/dashboard/components/charts/costChart.tsx, ui/app/workspace/dashboard/components/charts/providerCostChart.tsx
Switches Y-axis tick formatting from formatCost to formatCurrencyNumber for bar and area chart variants.
Token and volume chart Y-axis formatter migration
ui/app/workspace/dashboard/components/charts/logVolumeChart.tsx, mcpVolumeChart.tsx, mcpTopToolsChart.tsx, modelUsageChart.tsx, providerTokenChart.tsx, tokenUsageChart.tsx, externalCacheTokenMeterChart.tsx
Replaces local/older token formatters with formatCompactNumber for axis ticks and tooltip/token displays; removes local token-format helpers where present.
Dashboard tabs tooltip integration
ui/app/workspace/dashboard/components/overviewTab.tsx, providerUsageTab.tsx, mcpTab.tsx, modelRankingsTab.tsx
Supplies totalTooltip props to ChartCard instances across overview, provider usage, MCP, and model rankings tabs, formatting totals/averages (locale and currency formatting used where appropriate).
Log display & columns formatter updates
ui/app/workspace/logs/sheets/logDetailView.tsx, ui/app/workspace/logs/views/columns.tsx
Updates token displays to use formatCompactNumber and adjusts sub/secondary text to optionally include reasoning token breakdowns.

Sequence Diagram

sequenceDiagram
  participant Dashboard as DashboardTabs
  participant ChartCard
  participant Header
  participant TotalChip
  participant Tooltip
  Dashboard->>ChartCard: mount with totalTooltip?
  ChartCard->>Header: pass totalTooltip
  Header->>TotalChip: forward totalTooltip when total present
  alt totalTooltip present
    TotalChip->>Tooltip: wrap chip, render TooltipContent(totalTooltip)
  else no tooltip
    TotalChip-->>Header: render plain chip
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • maximhq/bifrost#3499: Related changes to ChartCard header/TotalChip behavior and chart header total presentation.

Suggested reviewers

  • akshaydeo

Poem

🐰 Numbers hop into neat lines and rows,
Chip tooltips peek where the total glows,
Compact coins and counts now sing in tune,
From logs to charts beneath the moon,
A rabbit cheers — the UI hums, hooray! 🥕✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main changes: adding tooltips to chart card totals and consolidating number formatting utilities.
Description check ✅ Passed The description comprehensively covers the PR objectives, changes made, testing instructions, and follows the template structure with all key sections completed.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 05-14-refactor_remove_duplicate_number_formatting_functions_and_use_a_centralized_function

Comment @coderabbitai help to get the list of available commands and usage tips.

impoiler commented May 14, 2026

Copy link
Copy Markdown
Contributor Author

@impoiler
impoiler force-pushed the 05-14-refactor_remove_duplicate_number_formatting_functions_and_use_a_centralized_function branch 2 times, most recently from 03ef5bf to 594893c Compare May 14, 2026 13:08
@impoiler impoiler self-assigned this May 14, 2026
@impoiler impoiler changed the title refactor: remove duplicate number formatting functions and use a centralized function feat: add tooltip with full precision values to chart card totals and consolidate number formatting utilities May 14, 2026
@impoiler
impoiler marked this pull request as ready for review May 14, 2026 13:15
@impoiler
impoiler force-pushed the 05-14-feat_adds_total_count_in_the_dashboard_charts_for_quick_overview branch from 9e677b6 to cb00051 Compare May 14, 2026 13:16
@impoiler
impoiler force-pushed the 05-14-refactor_remove_duplicate_number_formatting_functions_and_use_a_centralized_function branch from 594893c to 228b3ed Compare May 14, 2026 13:16
@greptile-apps

greptile-apps Bot commented May 14, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

Safe to merge — the changes are confined to UI formatting and a new optional prop, with no logic paths altered.

All external callers of the removed formatCompactNumber export from governance were migrated, confirmed by grep. The new formatCurrencyNumber correctly guards sub-cent values with a 4-decimal fallback, and formatCompactNumber guards non-finite inputs. The tooltip feature is purely additive and requires no provider changes since TooltipProvider is already global. No data, auth, or API-contract paths are touched.

No files require special attention. governance.ts has a mid-file import and numbers.ts is missing a trailing newline, but both were already flagged in earlier review threads.

Important Files Changed

Filename Overview
ui/app/workspace/dashboard/components/charts/chartCard.tsx Adds optional totalTooltip prop threaded through Header→TotalChip; chip conditionally wrapped in a Tooltip with a focusable trigger span. Implementation is clean.
ui/lib/utils/numbers.ts Adds formatCurrencyNumber alongside existing formatCompactNumber; handles sub-cent values with 4-decimal fallback and guards non-finite inputs. File lacks a trailing newline (already flagged).
ui/lib/utils/governance.ts Removes the local formatCompactNumber export and replaces it with a mid-file import from ./numbers used internally by formatRateLimitLines. Import is not re-exported (already flagged in thread), but all external callers were migrated so there is no broken reference.
ui/app/workspace/dashboard/components/charts/costChart.tsx Replaces formatCost Y-axis tick formatter with formatCurrencyNumber; compact notation now renders values ≥ $1K as e.g. "$1K" instead of "$1,000.00", which is a cleaner axis label.
ui/app/workspace/dashboard/utils/chartUtils.ts Removes formatTokens (migrated to shared formatCompactNumber) and adds the missing $0 guard to formatCost.
ui/app/workspace/dashboard/components/overviewTab.tsx Adds totalTooltip for all five chart cards; cost/latency tooltips use locale-formatted strings with full precision. Existing Tooltip/TooltipTrigger imports are preserved.
ui/app/workspace/logs/views/columns.tsx Swaps formatTokens for formatCompactNumber in the log table token column renderer; behavior is equivalent for all practical token count magnitudes.
ui/app/workspace/logs/sheets/logDetailView.tsx Replaces formatTokens with formatCompactNumber for prompt/completion/total/reasoning token display in the log detail sheet.
ui/components/rateLimitDisplay.tsx One-line import migration from governance to numbers; no logic change.
ui/app/workspace/dashboard/components/modelRankingsTab.tsx Migrates formatCompactNumber import from governance to numbers and adds totalTooltip to the top-models chart card.

Reviews (4): Last reviewed commit: "refactor: remove duplicate number format..." | Re-trigger Greptile

Comment thread ui/lib/utils/governance.ts
Comment thread ui/lib/utils/numbers.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ui/app/workspace/dashboard/components/charts/providerCostChart.tsx`:
- Line 142: The Y-axis uses different formatters depending on chart type (bar
uses formatCurrencyNumber while area uses formatCost), causing inconsistent axis
formatting when toggling; update the component (providerCostChart) to compute a
single y-axis formatter (e.g., const yAxisFormatter = formatCost or a chosen
unified formatter) and use that same function for tickFormatter everywhere
(replace tickFormatter={(v) => formatCurrencyNumber(v)} and the area chart
tickFormatter usage to reference yAxisFormatter) so both chart types render
identical number formatting.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fbee6981-4582-4db8-bbf4-d6a50c6fad6a

📥 Commits

Reviewing files that changed from the base of the PR and between cb00051 and 228b3ed.

📒 Files selected for processing (19)
  • ui/app/workspace/dashboard/components/charts/chartCard.tsx
  • ui/app/workspace/dashboard/components/charts/costChart.tsx
  • ui/app/workspace/dashboard/components/charts/logVolumeChart.tsx
  • ui/app/workspace/dashboard/components/charts/mcpTopToolsChart.tsx
  • ui/app/workspace/dashboard/components/charts/mcpVolumeChart.tsx
  • ui/app/workspace/dashboard/components/charts/modelUsageChart.tsx
  • ui/app/workspace/dashboard/components/charts/providerCostChart.tsx
  • ui/app/workspace/dashboard/components/charts/providerTokenChart.tsx
  • ui/app/workspace/dashboard/components/charts/tokenUsageChart.tsx
  • ui/app/workspace/dashboard/components/mcpTab.tsx
  • ui/app/workspace/dashboard/components/modelRankingsTab.tsx
  • ui/app/workspace/dashboard/components/overviewTab.tsx
  • ui/app/workspace/dashboard/components/providerUsageTab.tsx
  • ui/app/workspace/dashboard/utils/chartUtils.ts
  • ui/app/workspace/logs/sheets/logDetailView.tsx
  • ui/app/workspace/logs/views/columns.tsx
  • ui/components/rateLimitDisplay.tsx
  • ui/lib/utils/governance.ts
  • ui/lib/utils/numbers.ts

Comment thread ui/app/workspace/dashboard/components/charts/providerCostChart.tsx
@impoiler
impoiler force-pushed the 05-14-refactor_remove_duplicate_number_formatting_functions_and_use_a_centralized_function branch 2 times, most recently from fa99222 to 0c119ab Compare May 14, 2026 14:09
coderabbitai[bot]
coderabbitai Bot previously approved these changes May 14, 2026
Comment thread ui/lib/utils/numbers.ts
@impoiler
impoiler force-pushed the 05-14-refactor_remove_duplicate_number_formatting_functions_and_use_a_centralized_function branch from 0c119ab to 4f68e70 Compare May 14, 2026 14:15
akshaydeo
akshaydeo previously approved these changes May 14, 2026

akshaydeo commented May 14, 2026

Copy link
Copy Markdown
Contributor

Merge activity

  • May 14, 2:27 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • May 14, 2:29 PM UTC: Graphite rebased this pull request as part of a merge.
  • May 14, 2:31 PM UTC: Graphite couldn't merge this PR because it was not satisfying all requirements (PR does not have required approvals).
  • May 14, 2:31 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • May 14, 2:32 PM UTC: @akshaydeo merged this pull request with Graphite.

@akshaydeo
akshaydeo changed the base branch from 05-14-feat_adds_total_count_in_the_dashboard_charts_for_quick_overview to graphite-base/3501 May 14, 2026 14:27
@akshaydeo
akshaydeo changed the base branch from graphite-base/3501 to dev May 14, 2026 14:27
@akshaydeo
akshaydeo dismissed stale reviews from coderabbitai[bot] and themself May 14, 2026 14:27

The base branch was changed.

@akshaydeo
akshaydeo force-pushed the 05-14-refactor_remove_duplicate_number_formatting_functions_and_use_a_centralized_function branch from 4f68e70 to dcafd06 Compare May 14, 2026 14:28
@coderabbitai
coderabbitai Bot requested a review from akshaydeo May 14, 2026 14:31
@akshaydeo
akshaydeo merged commit f9f56f3 into dev May 14, 2026
14 of 15 checks passed
@akshaydeo
akshaydeo deleted the 05-14-refactor_remove_duplicate_number_formatting_functions_and_use_a_centralized_function branch May 14, 2026 14:32
akshaydeo pushed a commit that referenced this pull request May 15, 2026
… consolidate number formatting utilities (#3501)

## Summary

Consolidates number formatting utilities across the dashboard and logs UI, and adds tooltip support to chart card totals so users can see the full unrounded value on hover.

## Changes

- Added a `totalTooltip` prop to `ChartCard` (and its internal `TotalChip`/`Header` components) that, when provided, wraps the total chip in a `Tooltip` so hovering reveals the precise value. All chart tabs (Overview, MCP, Provider Usage, Model Rankings) now pass full-precision tooltips for token counts, costs, and latency averages.
- Removed the local `formatTokens` function from `chartUtils.ts` and replaced all usages across chart components (`tokenUsageChart`, `modelUsageChart`, `logVolumeChart`, `mcpVolumeChart`, `mcpTopToolsChart`, `providerTokenChart`) with the shared `formatCompactNumber` from `lib/utils/numbers`.
- Added `formatCurrencyNumber` to `lib/utils/numbers` and replaced the ad-hoc `formatCost` calls used as Y-axis tick formatters in `costChart` and `providerCostChart` with it.
- Removed the duplicate `formatCompactNumber` implementation from `lib/utils/governance.ts`, replacing it with a re-export from `lib/utils/numbers`. Updated `rateLimitDisplay` and `modelRankingsTab` to import from the canonical location.
- Fixed a missing `$0` case in `formatCost` for zero values.
- Token display in the logs table columns and log detail view now uses `formatCompactNumber` instead of the removed `formatTokens`.

## Type of change

- [ ] Bug fix
- [ ] Feature
- [x] Refactor
- [ ] Documentation
- [ ] Chore/CI

## Affected areas

- [ ] Core (Go)
- [ ] Transports (HTTP)
- [ ] Providers/Integrations
- [ ] Plugins
- [x] UI (React)
- [ ] Docs

## How to test

```sh
cd ui
pnpm i || npm i
pnpm test || npm test
pnpm build || npm run build
```

1. Open the dashboard and navigate to the Overview, MCP, Provider Usage, and Model Rankings tabs.
2. Hover over any chart card's total chip (e.g. "Total 1.2M") — a tooltip should appear showing the full unrounded number (e.g. "1,234,567").
3. For cost totals, the tooltip should show the full currency value with up to 6 decimal places.
4. For latency averages, the tooltip should show the value in milliseconds with up to 6 decimal places.
5. Verify Y-axis tick labels on token and cost charts render correctly.
6. Verify token counts in the logs table and log detail sheet display correctly.

## Screenshots/Recordings

Before: Chart card totals show compact numbers with no way to see the exact value.
After: Hovering the total chip reveals a tooltip with the full-precision number.

## Breaking changes

- [x] No

## Related issues

## Security considerations

None.

## Checklist

- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [ ] I added/updated tests where appropriate
- [ ] I updated documentation where needed
- [ ] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable
akshaydeo pushed a commit that referenced this pull request May 15, 2026
… consolidate number formatting utilities (#3501)

## Summary

Consolidates number formatting utilities across the dashboard and logs UI, and adds tooltip support to chart card totals so users can see the full unrounded value on hover.

## Changes

- Added a `totalTooltip` prop to `ChartCard` (and its internal `TotalChip`/`Header` components) that, when provided, wraps the total chip in a `Tooltip` so hovering reveals the precise value. All chart tabs (Overview, MCP, Provider Usage, Model Rankings) now pass full-precision tooltips for token counts, costs, and latency averages.
- Removed the local `formatTokens` function from `chartUtils.ts` and replaced all usages across chart components (`tokenUsageChart`, `modelUsageChart`, `logVolumeChart`, `mcpVolumeChart`, `mcpTopToolsChart`, `providerTokenChart`) with the shared `formatCompactNumber` from `lib/utils/numbers`.
- Added `formatCurrencyNumber` to `lib/utils/numbers` and replaced the ad-hoc `formatCost` calls used as Y-axis tick formatters in `costChart` and `providerCostChart` with it.
- Removed the duplicate `formatCompactNumber` implementation from `lib/utils/governance.ts`, replacing it with a re-export from `lib/utils/numbers`. Updated `rateLimitDisplay` and `modelRankingsTab` to import from the canonical location.
- Fixed a missing `$0` case in `formatCost` for zero values.
- Token display in the logs table columns and log detail view now uses `formatCompactNumber` instead of the removed `formatTokens`.

## Type of change

- [ ] Bug fix
- [ ] Feature
- [x] Refactor
- [ ] Documentation
- [ ] Chore/CI

## Affected areas

- [ ] Core (Go)
- [ ] Transports (HTTP)
- [ ] Providers/Integrations
- [ ] Plugins
- [x] UI (React)
- [ ] Docs

## How to test

```sh
cd ui
pnpm i || npm i
pnpm test || npm test
pnpm build || npm run build
```

1. Open the dashboard and navigate to the Overview, MCP, Provider Usage, and Model Rankings tabs.
2. Hover over any chart card's total chip (e.g. "Total 1.2M") — a tooltip should appear showing the full unrounded number (e.g. "1,234,567").
3. For cost totals, the tooltip should show the full currency value with up to 6 decimal places.
4. For latency averages, the tooltip should show the value in milliseconds with up to 6 decimal places.
5. Verify Y-axis tick labels on token and cost charts render correctly.
6. Verify token counts in the logs table and log detail sheet display correctly.

## Screenshots/Recordings

Before: Chart card totals show compact numbers with no way to see the exact value.
After: Hovering the total chip reveals a tooltip with the full-precision number.

## Breaking changes

- [x] No

## Related issues

## Security considerations

None.

## Checklist

- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [ ] I added/updated tests where appropriate
- [ ] I updated documentation where needed
- [ ] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable
akshaydeo pushed a commit that referenced this pull request May 20, 2026
… consolidate number formatting utilities (#3501)

## Summary

Consolidates number formatting utilities across the dashboard and logs UI, and adds tooltip support to chart card totals so users can see the full unrounded value on hover.

## Changes

- Added a `totalTooltip` prop to `ChartCard` (and its internal `TotalChip`/`Header` components) that, when provided, wraps the total chip in a `Tooltip` so hovering reveals the precise value. All chart tabs (Overview, MCP, Provider Usage, Model Rankings) now pass full-precision tooltips for token counts, costs, and latency averages.
- Removed the local `formatTokens` function from `chartUtils.ts` and replaced all usages across chart components (`tokenUsageChart`, `modelUsageChart`, `logVolumeChart`, `mcpVolumeChart`, `mcpTopToolsChart`, `providerTokenChart`) with the shared `formatCompactNumber` from `lib/utils/numbers`.
- Added `formatCurrencyNumber` to `lib/utils/numbers` and replaced the ad-hoc `formatCost` calls used as Y-axis tick formatters in `costChart` and `providerCostChart` with it.
- Removed the duplicate `formatCompactNumber` implementation from `lib/utils/governance.ts`, replacing it with a re-export from `lib/utils/numbers`. Updated `rateLimitDisplay` and `modelRankingsTab` to import from the canonical location.
- Fixed a missing `$0` case in `formatCost` for zero values.
- Token display in the logs table columns and log detail view now uses `formatCompactNumber` instead of the removed `formatTokens`.

## Type of change

- [ ] Bug fix
- [ ] Feature
- [x] Refactor
- [ ] Documentation
- [ ] Chore/CI

## Affected areas

- [ ] Core (Go)
- [ ] Transports (HTTP)
- [ ] Providers/Integrations
- [ ] Plugins
- [x] UI (React)
- [ ] Docs

## How to test

```sh
cd ui
pnpm i || npm i
pnpm test || npm test
pnpm build || npm run build
```

1. Open the dashboard and navigate to the Overview, MCP, Provider Usage, and Model Rankings tabs.
2. Hover over any chart card's total chip (e.g. "Total 1.2M") — a tooltip should appear showing the full unrounded number (e.g. "1,234,567").
3. For cost totals, the tooltip should show the full currency value with up to 6 decimal places.
4. For latency averages, the tooltip should show the value in milliseconds with up to 6 decimal places.
5. Verify Y-axis tick labels on token and cost charts render correctly.
6. Verify token counts in the logs table and log detail sheet display correctly.

## Screenshots/Recordings

Before: Chart card totals show compact numbers with no way to see the exact value.
After: Hovering the total chip reveals a tooltip with the full-precision number.

## Breaking changes

- [x] No

## Related issues

## Security considerations

None.

## Checklist

- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [ ] I added/updated tests where appropriate
- [ ] I updated documentation where needed
- [ ] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable
@akshaydeo akshaydeo mentioned this pull request May 20, 2026
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.

2 participants