refactor(ui): colocate 11 route segments' components into _components/ - #32704
Conversation
Colocation follow-up to the App Router migration: move each page's owned components out of the shared src/components dump and into its route segment's _components/ folder, draining the shared bucket. Convention: a component used by exactly one segment goes in that segment's _components/ (private, matching Next's _ route-exclusion); a component shared by 2+ segments stays in @/components. No new _shared/ folder. Rename-in-place (segment already had a local components/ folder): - api-reference (also relocates the shared CodeBlock, used by playground and cost-tracking, to @/components/CodeBlock) - memory, budgets, access-groups - caching, projects, guardrails-monitor Extract from src/components (page view lived in the shared dump): - AdminPanel -> admin-panel, organizations -> organizations, general_settings -> router-settings, usage -> old-usage Each folder/view was verified to have no importer other than its own page (cross-checked across src, tests, and e2e_tests). Relative imports inside moved single files are rewritten to absolute @/components/*; colocated tests move with their subject and have their vi.mock paths rewritten to match. Grandfathered lint suppressions (tremor, react-hooks, and similar, all pre-existing) are re-keyed to the new paths with counts unchanged. No behavior change.
Greptile SummaryThis PR is a structural refactoring that collocates route-private UI components into their owning route segment's
Confidence Score: 5/5Safe to merge — every moved file has only import-path updates; no component logic, props, or rendered output changed. All 78 files are pure file moves with import rewrites. Old component locations no longer exist and no stale import paths remain in src, tests, or e2e_tests. ESLint suppressions, vi.mock paths, and named exports are all correctly updated. No behavior changes were introduced. No files require special attention. The one intentional inconsistency — cost-tracking/components/ still using components instead of _components/ — is explicitly deferred per the PR description.
|
| Filename | Overview |
|---|---|
| ui/litellm-dashboard/eslint-suppressions.json | All 11 moved component paths rekeyed to new _components/ locations with counts unchanged; no suppressions added or removed. |
| ui/litellm-dashboard/src/app/(dashboard)/admin-panel/_components/AdminPanel.tsx | Moved from src/components/AdminPanel.tsx; only change is rewriting 12 relative imports to absolute @/components/ paths. |
| ui/litellm-dashboard/src/app/(dashboard)/admin-panel/_components/AdminPanel.test.tsx | Moved from src/components/AdminPanel.test.tsx; 7 vi.mock paths updated from relative to @/components/ form; all 325 lines preserved. |
| ui/litellm-dashboard/src/app/(dashboard)/organizations/_components/organizations.tsx | Moved from src/components/organizations.tsx; 10 relative imports rewritten to absolute; fetchOrganizations named export preserved and correctly referenced by the test mock. |
| ui/litellm-dashboard/src/app/(dashboard)/router-settings/_components/general_settings.tsx | Moved from src/components/general_settings.tsx; 5 relative imports rewritten to absolute; no logic changes. |
| ui/litellm-dashboard/src/app/(dashboard)/old-usage/_components/usage.tsx | Moved from src/components/usage.tsx; 5 relative imports rewritten to absolute; no logic changes. |
| ui/litellm-dashboard/src/components/CodeBlock.tsx | Promoted from api-reference/components/CodeBlock.tsx to the shared @/components/ root; all three consumers (api-reference, cost-tracking, playground) now import from the new location. |
| ui/litellm-dashboard/tests/CreateKeyPage.expiredToken.test.tsx | Three vi.mock paths updated to reflect new locations of organizations, general_settings, and usage; test logic unchanged. |
| ui/litellm-dashboard/src/app/(dashboard)/api-reference/_components/APIReferenceView.tsx | Moved from api-reference/ root into _components/; CodeBlock import updated to @/components/CodeBlock. |
| ui/litellm-dashboard/src/app/(dashboard)/playground/components/chat_ui/AgentBuilderView.tsx | Single import line updated: CodeBlock now imported from @/components/CodeBlock instead of the old api-reference/components/CodeBlock. |
Reviews (1): Last reviewed commit: "refactor(ui): colocate 11 route segments..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
65d90fd
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
Pure relocation with no behavior change; the proof is that each affected page still renders and shared dependencies still resolve. On a live proxy, load each and confirm it renders (and, where noted, that the interactive bits still work):
/ui/api-reference(copy button = the moved CodeBlock),/ui/cost-trackingand/ui/playground(also use CodeBlock)/ui/memory,/ui/budgets(budget modals),/ui/access-groups(create/edit modals)/ui/caching(cache settings tab),/ui/projects(project modals),/ui/guardrails-monitor/ui/admin-panel(SSO/IP/SCIM tabs),/ui/organizations(create/edit org + info view),/ui/router-settings,/ui/old-usageLocal checks:
npx vitest runacross all moved suites passes with 208 tests over 22 files,npm run buildcompiles every route, andmake pre-commitpasses.Type
🧹 Refactoring
Changes
Colocation follow-up to the App Router migration. It moves each page's owned components out of the shared
src/componentsdump and into its route segment's_components/folder. This consolidates what were four separate colocation PRs (api-reference, the memory/budgets/access-groups batch, the caching/projects/guardrails-monitor batch, and the admin-panel/organizations/router-settings/old-usage extracts) into oneThe convention, applied per component by its import count: a component used by exactly one segment goes in that segment's
_components/(private to the segment, matching Next's_route-exclusion); a component shared by two or more segments stays in@/components. No new_shared/folder, so there's no fuzzy second shared home to reason aboutTwo shapes of change are included. For segments that already had a local
components/folder, it is renamed to_components/(api-reference, memory, budgets, access-groups, caching, projects, guardrails-monitor); api-reference additionally relocates the sharedCodeBlock, which playground and cost-tracking also import, to@/components/CodeBlock. For segments whose page view still lived in the shared dump, the view is extracted into the owning segment (AdminPanel to admin-panel, organizations to organizations, general_settings to router-settings, usage to old-usage)Every folder or view was verified to have no importer other than its own page, cross-checked across src, tests, and e2e_tests. Relative imports inside moved single files are rewritten from
./xto@/components/xsince their genuinely shared dependencies stay in@/components; colocated tests move with their subject and have theirvi.mockpaths rewritten to keep matching the source's now-absolute imports. Grandfathered lint suppressions (tremor, react-hooks, and similar, all pre-existing) are re-keyed to the new paths with counts unchanged. No behavior changesLeft out deliberately: two larger extracts (
UsagePage, 28 files, andsettings, 51 files) are mechanical but big enough to warrant their own PRs, and a few views (view_logs,claude_code_plugins, the AIHub/model-hub pair) are genuinely shared across features and need a split rather than a straight move