[Feature] UI - Paginated Key Alias Select - #22157
Conversation
Replace the non-paginated Key Alias filter with a new PaginatedKeyAliasSelect component that mirrors the existing PaginatedModelSelect pattern. This aligns the UI with the paginated /key/aliases endpoint from PR #22137. Changes: - Added useInfiniteKeyAliases hook for paginated key alias fetching - Created PaginatedKeyAliasSelect component with infinite scroll (80% threshold) - Updated keyAliasesCall in networking to accept page/size/search params - Replaced Key Alias filter in Request Logs and Virtual Keys tables to use customComponent - Removed fetchAllKeyAliases helper and related upfront fetching logic - Added 22 tests for new component and hook; all existing tests pass (54 tests) Fixes the issue where the UI was fetching all key aliases at once, causing performance issues with large key sets. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryReplaces the non-paginated Key Alias filter with a new
Confidence Score: 3/5
|
| Filename | Overview |
|---|---|
| ui/litellm-dashboard/src/components/networking.tsx | Updated keyAliasesCall to accept pagination params (page, size, search) and return PaginatedKeyAliasResponse. The new response type does not match the current backend /key/aliases endpoint (which has no pagination) — this depends on unmerged PR #22137. |
| ui/litellm-dashboard/src/app/(dashboard)/hooks/keys/useKeyAliases.ts | New useInfiniteKeyAliases hook using @tanstack/react-query infinite query pattern, mirrors existing useInfiniteModelInfo. Clean implementation with proper getNextPageParam logic. |
| ui/litellm-dashboard/src/components/KeyAliasSelect/PaginatedKeyAliasSelect/PaginatedKeyAliasSelect.tsx | New paginated select component that mirrors PaginatedModelSelect. Implements debounced search, scroll-based infinite loading at 80% threshold, and deduplication of aliases. Props are compatible with FilterOptionCustomComponentProps. |
| ui/litellm-dashboard/src/components/key_team_helpers/filter_helpers.ts | Removed fetchAllKeyAliases helper and its keyAliasesCall import. Clean removal with no stale references left behind. |
| ui/litellm-dashboard/src/components/key_team_helpers/filter_logic.tsx | Removed the useQuery call for fetchAllKeyAliases and the allKeyAliases return value. Key alias filtering is now handled by the PaginatedKeyAliasSelect custom component in the filter UI. |
| ui/litellm-dashboard/src/components/view_logs/index.tsx | Replaced old searchable Key Alias filter (with searchFn calling fetchAllKeyAliases) with customComponent: PaginatedKeyAliasSelect. Clean integration with FilterComponent. |
| ui/litellm-dashboard/src/components/VirtualKeysPage/VirtualKeysTable.tsx | Replaced old searchable Key Alias filter with customComponent: PaginatedKeyAliasSelect. Removed allKeyAliases destructuring from useFilterLogic return. |
Sequence Diagram
sequenceDiagram
participant User
participant PaginatedKeyAliasSelect
participant useInfiniteKeyAliases
participant keyAliasesCall
participant Backend as /key/aliases
User->>PaginatedKeyAliasSelect: Opens filter dropdown
PaginatedKeyAliasSelect->>useInfiniteKeyAliases: Hook initializes (page=1, size=50)
useInfiniteKeyAliases->>keyAliasesCall: Fetch page 1
keyAliasesCall->>Backend: GET /key/aliases?page=1&size=50
Backend-->>keyAliasesCall: { aliases, total_count, current_page, total_pages, size }
keyAliasesCall-->>useInfiniteKeyAliases: PaginatedKeyAliasResponse
useInfiniteKeyAliases-->>PaginatedKeyAliasSelect: data.pages[0]
PaginatedKeyAliasSelect-->>User: Renders alias options
User->>PaginatedKeyAliasSelect: Scrolls past 80% threshold
PaginatedKeyAliasSelect->>useInfiniteKeyAliases: fetchNextPage()
useInfiniteKeyAliases->>keyAliasesCall: Fetch page 2
keyAliasesCall->>Backend: GET /key/aliases?page=2&size=50
Backend-->>keyAliasesCall: Next page data
keyAliasesCall-->>useInfiniteKeyAliases: PaginatedKeyAliasResponse
useInfiniteKeyAliases-->>PaginatedKeyAliasSelect: data.pages[0..1]
PaginatedKeyAliasSelect-->>User: Appends new options
User->>PaginatedKeyAliasSelect: Types search text
PaginatedKeyAliasSelect->>PaginatedKeyAliasSelect: Debounce 300ms
PaginatedKeyAliasSelect->>useInfiniteKeyAliases: search="text" (resets to page 1)
useInfiniteKeyAliases->>keyAliasesCall: Fetch with search
keyAliasesCall->>Backend: GET /key/aliases?page=1&size=50&search=text
Backend-->>keyAliasesCall: Filtered results
keyAliasesCall-->>useInfiniteKeyAliases: PaginatedKeyAliasResponse
useInfiniteKeyAliases-->>PaginatedKeyAliasSelect: Filtered data
PaginatedKeyAliasSelect-->>User: Shows filtered aliases
Last reviewed commit: 701ec62
| }; | ||
|
|
||
| export const keyAliasesCall = async (accessToken: string): Promise<{ aliases: string[] }> => { | ||
| export interface PaginatedKeyAliasResponse { | ||
| aliases: string[]; | ||
| total_count: number; | ||
| current_page: number; | ||
| total_pages: number; | ||
| size: number; | ||
| } |
There was a problem hiding this comment.
Backend endpoint mismatch with PaginatedKeyAliasResponse
The current backend /key/aliases endpoint (in key_management_endpoints.py:4110) accepts no query parameters and returns a flat {"aliases": List[str]} — it does not support page, size, or search, and does not return total_count, current_page, total_pages, or size fields.
This PR's description mentions aligning with a paginated endpoint from PR #22137, but that backend change does not appear to be merged into main yet. If this UI PR is merged before #22137, the useInfiniteKeyAliases hook will receive a response missing current_page and total_pages, causing getNextPageParam to always return undefined (since undefined < undefined is false). The component will still render the first page of aliases, but pagination and search will silently not work.
Please ensure PR #22137 (the backend pagination support) is merged first, or merge both together to avoid a broken intermediate state.
…lias [Feature] UI - Paginated Key Alias Select
Summary
Replace the non-paginated Key Alias filter with a
PaginatedKeyAliasSelectcomponent that mirrors the existingPaginatedModelSelectpattern. This aligns the UI with the paginated/key/aliasesendpoint from PR #22137, fixing the issue where the UI was fetching all key aliases upfront and causing performance problems with large key sets.Changes
useInfiniteKeyAliaseshook for paginated key alias fetching with search supportPaginatedKeyAliasSelectcomponent with 80% scroll threshold for infinite loadingkeyAliasesCallin networking to acceptpage,size,searchquery parameterscustomComponent: PaginatedKeyAliasSelectfetchAllKeyAliaseshelper function and related upfront fetching logic from filter hooksTesting
PaginatedKeyAliasSelect.test.tsxwith 14 testsuseKeyAliases.test.tswith 8 testsfetchAllKeyAliasesType
🆕 New Feature
✅ Test