refactor(ui): convert user agent and per-user usage charts to shadcn/recharts - #32725
Conversation
…recharts Swap the tremor BarChart import for the shared shadcn/recharts wrapper in user_agent_activity.tsx (DAU/WAU/MAU charts) and per_user_usage.tsx (usage distribution histogram). All chart props are unchanged; the wrapper exposes the same tremor prop surface with matching defaults. Extend user_agent_activity.test.tsx and add per_user_usage.test.tsx with parity assertions on the real recharts SVG output: bar series per category, stacked x positions, resolved fill colors, axis bucket labels, legend text, and value formatter output on axis ticks. Remove the dead ResizeObserver polyfill in user_agent_activity.test.tsx now that the scoped global mock in tests/setupTests.ts renders charts, which also lowers the no-explicit-any metric by one.
Greptile SummaryThis PR completes the next phase of the shadcn/recharts migration by swapping the Tremor
Confidence Score: 5/5Safe to merge — the production change is a two-line import swap with no logic modifications. Both component files change only a single import line; the chart props, data transformation logic, and surrounding Tremor layout are completely unchanged. The new and updated tests verify the recharts SVG output and have been noted to pass CI. No new logic was introduced that could alter runtime behaviour. No files require special attention.
|
| Filename | Overview |
|---|---|
| ui/litellm-dashboard/src/components/per_user_usage.tsx | Single import swap: BarChart moved from @tremor/react to the shared shadcn/recharts wrapper; all other code unchanged |
| ui/litellm-dashboard/src/components/user_agent_activity.tsx | Single import swap: BarChart moved from @tremor/react to the shared shadcn/recharts wrapper; all chart props and surrounding Tremor layout unchanged |
| ui/litellm-dashboard/src/components/per_user_usage.test.tsx | New test file: asserts recharts SVG output for the usage distribution chart; test anchors rely on Tremor DOM depth and recharts zero-value bar rendering behaviour |
| ui/litellm-dashboard/src/components/user_agent_activity.test.tsx | Drops the now-superseded local ResizeObserver polyfill and adds DAU/WAU/MAU chart rendering assertions; same DOM-traversal and path-parsing patterns noted in previous review threads |
| ui/litellm-dashboard/eslint-metrics.json | no-explicit-any count decremented by 1, matching the removal of the as any ResizeObserver polyfill cast |
Reviews (2): Last reviewed commit: "Merge remote-tracking branch 'origin/lit..." | Re-trigger Greptile
|
@greptileai re review |
…itellm_shadcn_charts_user_agent_per_user # Conflicts: # ui/litellm-dashboard/eslint-metrics.json
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
0ebcda3
into
litellm_internal_staging
Relevant issues
Linear ticket
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
@greptileaito re-request a review after pushing changes)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
QA steps to run against the live dev servers (screenshots to follow in a comment after QA):
python litellm/proxy/proxy_cli.py --config litellm/proxy/dev_config.yaml) and the dashboard dev server (npm run devin ui/litellm-dashboard)for ua in "litellm-qa-cli/1.0" "litellm-qa-sdk/2.0"; do for i in 1 2 3; do curl -s http://localhost:4000/v1/chat/completions -H "Authorization: Bearer sk-..." -H "User-Agent: $ua" -H "Content-Type: application/json" -d '{"model": "gpt-5.2", "messages": [{"role": "user", "content": "hi"}]}'; done; doneType
🧹 Refactoring
Changes
Stage of the charts track of the shadcn migration (foundation landed in #32668). Converts the four tremor BarCharts on the User Agent Activity view to the shared shadcn/recharts
BarChartwrapper: the DAU, WAU and MAU charts inuser_agent_activity.tsxand the usage distribution histogram inper_user_usage.tsxThis is a pure import swap; every chart keeps its exact prop set (data/index/categories/valueFormatter/yAxisWidth/showLegend/stack, plus the explicit 8-color palette on the distribution chart) and the wrapper's defaults match tremor's, so the rendered output is visually identical. No wrapper changes were needed. The surrounding tremor Card/Title/Tab layout is deliberately left alone; page-level layout converts in a later phase
Tests now assert on the real recharts SVG the charts render in jsdom (the scoped ResizeObserver mock from #32668 fires for shadcn ChartContainer subtrees): bar series per category, stacked rectangles sharing an x position, resolved fill colors that distinguish the explicit palette from the default cycle, axis bucket labels, legend text and formatter output on the value axis ticks. Since all tab panels stay mounted, the assertions are scoped to each chart's panel.
per_user_usage.tsxgets its first test file;user_agent_activity.test.tsxdrops its now dead local ResizeObserver polyfill, which also lowers the no-explicit-any count in eslint-metrics.json by one