Skip to content

[Feature] UI - Paginated Key Alias Select - #22157

Merged
yuneng-jiang merged 4 commits into
mainfrom
litellm_paginated_key_alias
Feb 26, 2026
Merged

[Feature] UI - Paginated Key Alias Select#22157
yuneng-jiang merged 4 commits into
mainfrom
litellm_paginated_key_alias

Conversation

@yuneng-jiang

Copy link
Copy Markdown
Contributor

Summary

Replace the non-paginated Key Alias filter with a PaginatedKeyAliasSelect component that mirrors the existing PaginatedModelSelect pattern. This aligns the UI with the paginated /key/aliases endpoint from PR #22137, fixing the issue where the UI was fetching all key aliases upfront and causing performance problems with large key sets.

Changes

  • Added useInfiniteKeyAliases hook for paginated key alias fetching with search support
  • Created PaginatedKeyAliasSelect component with 80% scroll threshold for infinite loading
  • Updated keyAliasesCall in networking to accept page, size, search query parameters
  • Replaced Key Alias filters in Request Logs and Virtual Keys tables to use customComponent: PaginatedKeyAliasSelect
  • Removed fetchAllKeyAliases helper function and related upfront fetching logic from filter hooks
  • All 22 new tests pass; all 54 existing tests in modified files pass

Testing

  • Created PaginatedKeyAliasSelect.test.tsx with 14 tests
  • Created useKeyAliases.test.ts with 8 tests
  • Updated existing test mocks to remove references to removed fetchAllKeyAliases
  • All TypeScript types check without errors

Type

🆕 New Feature
✅ Test

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>
@vercel

vercel Bot commented Feb 26, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
litellm Ready Ready Preview, Comment Feb 26, 2026 8:08pm

Request Review

@greptile-apps

greptile-apps Bot commented Feb 26, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Replaces the non-paginated Key Alias filter with a new PaginatedKeyAliasSelect component that uses infinite scrolling and server-side search, mirroring the existing PaginatedModelSelect pattern. This removes the fetchAllKeyAliases upfront fetch from both the Virtual Keys and Request Logs filter hooks, delegating pagination to the component itself.

  • New useInfiniteKeyAliases hook and PaginatedKeyAliasSelect component follow established patterns (useInfiniteModelInfo / PaginatedModelSelect)
  • Clean removal of fetchAllKeyAliases with no stale references remaining
  • 22 new tests added (14 component, 8 hook); existing tests updated to remove old mocks
  • Key concern: The frontend now expects a paginated response shape (total_count, current_page, total_pages, size) from /key/aliases, but the current backend endpoint returns only {"aliases": [...]} with no pagination support. The PR description references backend PR [Fix] /key/aliases: Add pagination and search to prevent OOMs #22137 for this — ensure it is merged first or alongside this PR to avoid a broken Key Alias filter in production

Confidence Score: 3/5

  • Safe to merge only if the companion backend PR [Fix] /key/aliases: Add pagination and search to prevent OOMs #22137 (paginated /key/aliases endpoint) is merged first or simultaneously
  • The UI code itself is well-structured, follows existing patterns, includes comprehensive tests, and cleanly removes old code. However, the frontend now depends on a paginated backend response shape that the current main branch does not provide — merging this alone would result in a non-functional Key Alias filter (pagination and search silently broken).
  • Pay close attention to ui/litellm-dashboard/src/components/networking.tsx — the PaginatedKeyAliasResponse type must match the backend response from the not-yet-merged PR [Fix] /key/aliases: Add pagination and search to prevent OOMs #22137

Important Files Changed

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
Loading

Last reviewed commit: 701ec62

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

15 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment on lines 3330 to +3338
};

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;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@yuneng-jiang
yuneng-jiang merged commit 719b7fd into main Feb 26, 2026
34 of 64 checks passed
@ishaan-berri
ishaan-berri deleted the litellm_paginated_key_alias branch March 26, 2026 22:29
fzowl pushed a commit to fzowl/litellm that referenced this pull request Jun 24, 2026
…lias

[Feature] UI - Paginated Key Alias Select
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.

1 participant