feat: add tooltip with full precision values to chart card totals and consolidate number formatting utilities - #3501
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (20)
📝 WalkthroughSummary by CodeRabbit
WalkthroughCentralizes 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. ChangesNumber Formatting and ChartCard Tooltips
Sequence DiagramsequenceDiagram
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
This stack of pull requests is managed by Graphite. Learn more about stacking. |
03ef5bf to
594893c
Compare
9e677b6 to
cb00051
Compare
594893c to
228b3ed
Compare
Confidence Score: 5/5Safe 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
Reviews (4): Last reviewed commit: "refactor: remove duplicate number format..." | Re-trigger Greptile |
There was a problem hiding this comment.
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
📒 Files selected for processing (19)
ui/app/workspace/dashboard/components/charts/chartCard.tsxui/app/workspace/dashboard/components/charts/costChart.tsxui/app/workspace/dashboard/components/charts/logVolumeChart.tsxui/app/workspace/dashboard/components/charts/mcpTopToolsChart.tsxui/app/workspace/dashboard/components/charts/mcpVolumeChart.tsxui/app/workspace/dashboard/components/charts/modelUsageChart.tsxui/app/workspace/dashboard/components/charts/providerCostChart.tsxui/app/workspace/dashboard/components/charts/providerTokenChart.tsxui/app/workspace/dashboard/components/charts/tokenUsageChart.tsxui/app/workspace/dashboard/components/mcpTab.tsxui/app/workspace/dashboard/components/modelRankingsTab.tsxui/app/workspace/dashboard/components/overviewTab.tsxui/app/workspace/dashboard/components/providerUsageTab.tsxui/app/workspace/dashboard/utils/chartUtils.tsui/app/workspace/logs/sheets/logDetailView.tsxui/app/workspace/logs/views/columns.tsxui/components/rateLimitDisplay.tsxui/lib/utils/governance.tsui/lib/utils/numbers.ts
fa99222 to
0c119ab
Compare
0c119ab to
4f68e70
Compare
Merge activity
|
The base branch was changed.
4f68e70 to
dcafd06
Compare
… 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
… 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
… 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

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
totalTooltipprop toChartCard(and its internalTotalChip/Headercomponents) that, when provided, wraps the total chip in aTooltipso 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.formatTokensfunction fromchartUtils.tsand replaced all usages across chart components (tokenUsageChart,modelUsageChart,logVolumeChart,mcpVolumeChart,mcpTopToolsChart,providerTokenChart) with the sharedformatCompactNumberfromlib/utils/numbers.formatCurrencyNumbertolib/utils/numbersand replaced the ad-hocformatCostcalls used as Y-axis tick formatters incostChartandproviderCostChartwith it.formatCompactNumberimplementation fromlib/utils/governance.ts, replacing it with a re-export fromlib/utils/numbers. UpdatedrateLimitDisplayandmodelRankingsTabto import from the canonical location.$0case informatCostfor zero values.formatCompactNumberinstead of the removedformatTokens.Type of change
Affected areas
How to test
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
Related issues
Security considerations
None.
Checklist
docs/contributing/README.mdand followed the guidelines