feat(ui): migrate old usage report to App Router path route#30694
Conversation
Greptile SummaryMigrates the legacy "Old Usage" report (
Confidence Score: 5/5Safe to merge — pure UI routing refactor with no backend changes and no behaviour regressions on existing pages. All five changed files follow the established App Router migration pattern. The Usage component already accepts null for the keys prop via optional chaining; the test update replaces a now-stale 'is undefined' guard with an equivalent positive assertion; and the e2e fixture is kept in sync. No logic paths are broken or left untested. No files require special attention.
|
| Filename | Overview |
|---|---|
| ui/litellm-dashboard/src/utils/migratedPages.ts | Adds usage: "old-usage" to MIGRATED_PAGES; comment updated to document the two-entry usage split. No issues. |
| ui/litellm-dashboard/src/app/(dashboard)/old-usage/page.tsx | New App Router route for the legacy Usage report. Uses useAuthorized() consistently with other migrated pages. Passes keys={null}, which is safe — the Usage component's prop type is `any[] |
| ui/litellm-dashboard/src/app/(dashboard)/page.tsx | Removes the Usage import and explicit api-keys arm; makes UserDashboard the default else branch. Unrecognized ?page= values now fall to the dashboard, which is the sensible default. |
| ui/litellm-dashboard/src/utils/migratedPages.test.ts | Correctly replaces the old toBeUndefined() assertion with new test verifying usage→old-usage mapping and its redirect href. Coverage is maintained, not weakened. |
| ui/litellm-dashboard/e2e_tests/fixtures/migratedPages.ts | Adds usage→old-usage entry to the e2e fixture, keeping it in sync with the source MIGRATED_PAGES map. |
Reviews (1): Last reviewed commit: "feat(ui): migrate old usage report to Ap..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Cut the legacy "Old Usage" report (?page=usage) over from the switch in
(dashboard)/page.tsx to a path route at (dashboard)/old-usage. The segment is
old-usage rather than usage because the modern usage dashboard (new_usage)
already owns /usage. Adding the MIGRATED_PAGES entry repoints the sidebar item
and redirects existing ?page=usage links to /ui/old-usage.
The report was the switch's catch-all else, so removing it means choosing a new
fallback: collapse the now-redundant explicit api-keys arm into the else so the
main dashboard (UserDashboard) is the default. Unknown ?page= values now land on
the dashboard instead of the Old Usage report, which is the sensible default.
The new route sources identity from useAuthorized() and passes keys={null}: the
key-filter dropdown read the parent's keys state, which was already empty on
direct navigation to ?page=usage, so this preserves that rather than wiring a
paginated key fetch into a deprecated report.
ad22f41 to
40e42ee
Compare
382d78e
into
litellm_internal_staging
Relevant issues
Linear ticket
Refs LIT-3687
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
make test-unit@greptileaiand received a Confidence Score of at least 4/5 before requesting a maintainer reviewCI (LiteLLM team)
Branch creation CI run
Link:
CI run for the last commit
Link:
Merge / cherry-pick CI run
Links:
Screenshots / Proof of Fix
UI routing change, no backend component. To verify locally against the built dashboard or the proxy that serves it:
/ui/old-usage(not/ui/?page=usage) and the usage report renders/ui/old-usagedirectly and confirm it still renders (no 404)/ui/?page=usageand confirm it redirects to/ui/old-usage/ui/usageType
🧹 Refactoring
Changes
Continues the App Router migration by cutting the legacy "Old Usage" report (
?page=usage, the item under the Experimental section of the sidebar) over from the?page=switch in(dashboard)/page.tsxto a path route at(dashboard)/old-usage/page.tsx. The segment isold-usagerather thanusagebecause the modern usage dashboard (new_usage) already owns/usage. Adding theusage -> old-usageentry toMIGRATED_PAGESrepoints the sidebar item and redirects existing?page=usagedeep links, the same mechanism every migrated page uses.The report was the switch's catch-all
elsebranch, so migrating it out requires choosing a new fallback. I collapsed the now-redundant explicitapi-keysarm into theelse, making the main dashboard (UserDashboard) the default branch. Behavior for?page=api-keysis unchanged; the only difference is that unrecognized?page=values now land on the dashboard instead of the Old Usage report, which is the sensible default.The new route sources identity from
useAuthorized()and passeskeys={null}. The Usage page useskeysonly to populate a key-filter dropdown, and the legacy page read the parent'skeysstate, which was already empty on direct navigation to?page=usage; this preserves that behavior rather than wiring a paginated key fetch into a deprecated report. Added a unit test asserting theusage -> old-usagemapping and its redirect href, and the e2e migration fixture entry so the navigation smoke covers it.Note for sequencing: this touches the same
page.tsxswitch as the in-flight models (#30677) and pass-through (#30692) PRs, so whichever merges later will need a small conflict resolution in that block.