Skip to content

refactor(ui): colocate the policies view, keeping PolicySelector shared - #32720

Merged
ryan-crabbe-berri merged 2 commits into
litellm_internal_stagingfrom
litellm_colocate_policies
Jul 10, 2026
Merged

ryan-crabbe-berri merged 2 commits into
litellm_internal_stagingfrom
litellm_colocate_policies

Conversation

@ryan-crabbe-berri

Copy link
Copy Markdown
Contributor

Relevant issues

Linear ticket

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • My PR passes all CI/CD checks (e.g., lint, format, unit tests)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review (Greptile reviews automatically once the PR is opened; only comment @greptileai to 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

Relocation with no behavior change; the proof is that the page renders and the shared PolicySelector still works for its other consumers. On a live proxy:

  1. http://localhost:4000/ui/policies renders the policies view (create/edit policy, attachments, pipeline builder, policy test panel still work)
  2. In the Playground, the ComplianceUI policy selector still lists and applies policies; the key edit view still shows its policy picker

Local checks: npx vitest run on the moved folder plus PolicySelector and its ComplianceUI consumer passes with 123 tests across 12 files, npm run build compiles every route, and make pre-commit passes.

Type

🧹 Refactoring

Changes

A "group 1" colocation split from the App Router follow-up. The policies folder lived in the shared src/components dump but is only partly shared: PolicySelector (imported by the Playground, ComplianceUI, and the key edit view) and its types are genuinely reusable, while the policy-management view is owned by the policies route. Moving the whole folder would either break those consumers or bury a shared widget inside one route's private folder, so it is split

PolicySelector and types stay in @/components/policies; the management view (27 files: the index panel, policy/attachment tables, forms, modals, the pipeline flow builder, the test panel, and their tests) moves into policies/_components. The moved files' imports of the retained shared files become @/components/policies paths, other escaping relative imports are absolutized against the @/ alias (including @/data/... and the repo test-utils via @/../tests/...), and moved test files have both their from imports and their vi.mock paths rewritten so the mocks keep matching the source. Grandfathered lint suppressions for the moved files are re-keyed with counts unchanged. PolicySelector did not move, so its external consumers are untouched. No behavior change

This is the same split pattern as the tag-management and vector-stores PR. guardrails is intentionally not included: like agents, it is a file-plus-folder combo (guardrails.tsx sits beside the guardrails/ folder), which needs different handling and will be a separate PR

Group-1 colocation split. The policies folder lived in the shared src/components
dump but is only partly shared: PolicySelector (used by the Playground,
ComplianceUI, and key edit view) and its types stay in @/components/policies,
while the policy-management view (27 files: index, tables, forms, modals,
pipeline builder, and their tests) moves to policies/_components.

Moved files' imports of the retained shared files become @/components/policies
paths; other escaping relative imports are absolutized against the @/ alias
(including @/data/... and the repo test-utils via @/../tests/...), and moved
test files have both their `from` imports and `vi.mock` paths rewritten so the
mocks keep matching the source. Grandfathered lint suppressions for moved files
are re-keyed. PolicySelector did not move, so its external consumers are
untouched. No behavior change.
@greptile-apps

greptile-apps Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR colocates the policy-management view components alongside the /policies route by moving 27 files from src/components/policies/ into src/app/(dashboard)/policies/_components/. The shared PolicySelector component, its types.ts, and PolicySelector.test.tsx deliberately remain in src/components/policies/ so that the Playground, ComplianceUI, and key-edit-view consumers are unaffected.

  • All relative imports in moved files are rewritten to absolute @/ aliases (@/components/policies/types, @/components/networking, @/components/molecules/notifications_manager, @/data/compliancePrompts, @/../tests/test-utils), and all vi.mock paths in moved test files are updated to match the new source import paths so Vitest's module interceptor keeps working.
  • ESLint suppression keys for the 14 files that had grandfathered lint rules are re-keyed to the new _components/ paths; the PolicySelector.tsx suppression is correctly left at its original src/components/policies/PolicySelector.tsx key.
  • page.tsx is updated to import PoliciesPanel from ./_components instead of the old @/components/policies path.

Confidence Score: 5/5

Pure file move and import path rewrite with no logic changes; all consumers, mocks, and ESLint suppressions are correctly updated.

Every moved file has its imports rewritten to verified @/ aliases, every test vi.mock path matches the new source import path, the ESLint suppression keys are all re-keyed consistently, and the unmoved shared files (PolicySelector.tsx, types.ts) remain at their original locations with untouched external consumers. No behavioral changes were introduced.

No files require special attention.

Important Files Changed

Filename Overview
ui/litellm-dashboard/eslint-suppressions.json All moved file keys properly re-keyed to new _components/ paths; PolicySelector.tsx suppression correctly retained at original src/components/policies/PolicySelector.tsx location.
ui/litellm-dashboard/src/app/(dashboard)/policies/page.tsx Import of PoliciesPanel updated from @/components/policies to ./_components; behavior unchanged.
ui/litellm-dashboard/src/app/(dashboard)/policies/_components/index.tsx Imports rewritten from relative to @/components/... aliases; no logic changes.
ui/litellm-dashboard/src/app/(dashboard)/policies/_components/pipeline_flow_builder.tsx Relative imports for types, networking, notifications, and @/data/compliancePrompts rewritten to absolute @/ aliases; no logic changes.
ui/litellm-dashboard/src/app/(dashboard)/policies/_components/index.test.tsx vi.mock("../networking") updated to vi.mock("@/components/networking") matching the source file's new import path; renderWithProviders import updated to @/../tests/test-utils; mocks still intercept the correct module.
ui/litellm-dashboard/src/app/(dashboard)/policies/_components/add_attachment_form.test.tsx All imports and vi.mock paths updated to @/ aliases; mocks remain aligned with the source file's imports.
ui/litellm-dashboard/src/app/(dashboard)/policies/_components/impact_popover.test.tsx Mock path updated from ../networking to @/components/networking to match source import; test logic unchanged.
ui/litellm-dashboard/src/app/(dashboard)/policies/_components/policy_info.test.tsx Import and mock paths updated; vi.mock("./pipeline_flow_builder", ...) kept as a correct relative path since both files moved to the same folder.

Reviews (2): Last reviewed commit: "fix(ui): keep PolicySelector.tsx eslint ..." | Re-trigger Greptile

@codspeed

codspeed Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing litellm_colocate_policies (e9e7414) with litellm_internal_staging (3d5d5e1)

Open in CodSpeed

PolicySelector.tsx stays in src/components/policies (only the management view
moved to _components), but the suppression re-key wrongly moved its
no-nested-ternary entry to the phantom _components path, orphaning the real
file's suppression. Revert that one key. (Greptile P1 on #32720.)
@ryan-crabbe-berri

Copy link
Copy Markdown
Contributor Author

Good catch. Fixed in e9e7414: reverted the PolicySelector.tsx suppression key back to src/components/policies/PolicySelector.tsx since that file stays put; only the moved view files should be re-keyed. Confirmed eslint on the real PolicySelector.tsx passes with its no-nested-ternary suppression applied

@greptileai

@greptile-apps

greptile-apps Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Fix confirmed in e9e7414 — the 1-line change to eslint-suppressions.json correctly restores src/components/policies/PolicySelector.tsx as the key for its no-nested-ternary suppression. Since PolicySelector.tsx never moved, the original key was always the right one; only the 27 view files that actually relocated to _components should carry re-keyed entries. The suppression is no longer orphaned. ✓

@ryan-crabbe-berri

Copy link
Copy Markdown
Contributor Author

@greptileai re review

@ryan-crabbe-berri
ryan-crabbe-berri merged commit 2a12707 into litellm_internal_staging Jul 10, 2026
77 checks passed
@ryan-crabbe-berri
ryan-crabbe-berri deleted the litellm_colocate_policies branch July 10, 2026 05:44
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