The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
feat(ui): rebuild the Virtual Keys table on the shared DataTable (#32991)
yuneng-jiangfa09cde3c09b
diff --git a/ui/litellm-dashboard/eslint-suppressions.json b/ui/litellm-dashboard/eslint-suppressions.jsonindex 953de4fe480..7c6df4e7bb9 100644--- a/ui/litellm-dashboard/eslint-suppressions.json+++ b/ui/litellm-dashboard/eslint-suppressions.json@@ -1690,14 +1690,6 @@"count": 1}},- "src/components/VirtualKeysPage/VirtualKeysTable.tsx": {- "no-nested-ternary": {- "count": 2- },- "no-restricted-imports": {- "count": 1- }- },"src/components/activity_metrics.tsx": {"no-nested-ternary": {"count": 1diff --git a/ui/litellm-dashboard/src/components/VirtualKeysPage/VirtualKeysTable.test.tsx b/ui/litellm-dashboard/src/components/VirtualKeysPage/VirtualKeysTable.test.tsxindex 02f5d588149..cf4beeed40f 100644--- a/ui/litellm-dashboard/src/components/VirtualKeysPage/VirtualKeysTable.test.tsx+++ b/ui/litellm-dashboard/src/components/VirtualKeysPage/VirtualKeysTable.test.tsx@@ -63,7 +63,7 @@ const mockKey: KeyResponse = {key_alias: "Test Key Alias",spend: 5.5,max_budget: 100,- expires: "2024-12-31T23:59:59Z",+ expires: "2999-12-31T23:59:59Z",models: ["gpt-3.5-turbo", "gpt-4"],aliases: {},config: {},@@ -154,6 +154,8 @@ const keysResult = (keys: KeyResponse[], data: Partial<KeysResponse> = {}, extra...extra,}) as any;+const openFilters = () => fireEvent.click(screen.getByRole("button", { name: "Filters" }));+beforeEach(() => {vi.clearAllMocks();@@ -170,6 +172,12 @@ it("should render VirtualKeysTable component", () => {expect(screen.getByText("Test Key Alias")).toBeInTheDocument();});+it("renders the page header with the create-key action slot", () => {+ renderWithProviders(<VirtualKeysTable headerActions={<button>Create New Key</button>} />);+ expect(screen.getByRole("heading", { name: "Virtual Keys" })).toBeInTheDocument();+ expect(screen.getByRole("button", { name: "Create New Key" })).toBeInTheDocument();+});+it("should display key information correctly", async () => {renderWithProviders(<VirtualKeysTable />);@@ -177,6 +185,7 @@ it("should display key information correctly", async () => {expect(screen.getByText("Test Key Alias")).toBeInTheDocument();expect(screen.getByText("Test Team")).toBeInTheDocument();expect(screen.getByText("$5.5000")).toBeInTheDocument();+ expect(screen.getByText("of $100")).toBeInTheDocument();});});@@ -188,14 +197,49 @@ it("should display user email correctly", async () => {});});-it("should show loading message only on initial load (isPending)", () => {+it("shows the user alias over the email in the visible cell when both exist", async () => {+ mockUseKeys.mockReturnValue(+ keysResult([{ ...mockKey, user: { user_id: "user-1", user_email: "[email protected]", user_alias: "The User" } }]),+ );++ renderWithProviders(<VirtualKeysTable />);++ const row = (await screen.findByText("Test Key Alias")).closest("tr") as HTMLElement;+ expect(within(row).getByText("The User")).toBeInTheDocument();+ expect(within(row).queryByText("[email protected]")).not.toBeInTheDocument();+});++it("shows created_by_user alias over email in the Created By column when it is enabled", async () => {+ mockUseKeys.mockReturnValue(+ keysResult([+ {+ ...mockKey,+ created_by: "some-uuid",+ created_by_user: { user_id: "some-uuid", user_email: "[email protected]", user_alias: "The Creator" },+ },+ ]),+ );+ const user = userEvent.setup();+ renderWithProviders(<VirtualKeysTable />);++ // Created By is hidden by default; turn it on via the Columns menu.+ await user.click(screen.getByRole("button", { name: "Columns" }));+ await user.click(await screen.findByText("Created By"));+ await user.keyboard("{Escape}");++ const row = (await screen.findByText("Test Key Alias")).closest("tr") as HTMLElement;+ expect(within(row).getByText("The Creator")).toBeInTheDocument();+ expect(within(row).queryByText("[email protected]")).not.toBeInTheDocument();+});++it("should show a loading state on the initial load and hide the data", () => {mockUseKeys.mockReturnValue(keysResult([], {}, { data: null, isPending: true, isFetching: true }));renderWithProviders(<VirtualKeysTable />);- expect(screen.getByText("🚅 Loading keys...")).toBeInTheDocument();+ expect(screen.getByText("Loading keys...")).toBeInTheDocument();+ expect(screen.getAllByTestId("skeleton-row").length).toBeGreaterThan(0);expect(screen.queryByText("Test Key Alias")).not.toBeInTheDocument();- expect(screen.queryByText("Test Team")).not.toBeInTheDocument();});it("should show 'No keys found' message when the key list is empty", () => {@@ -206,61 +250,52 @@ it("should show 'No keys found' message when the key list is empty", () => {expect(screen.getByText("No keys found")).toBeInTheDocument();});-it("should handle models with more than 3 entries to trigger expansion UI", () => {+it("collapses models beyond the visible limit into a '+N more' badge", () => {mockUseKeys.mockReturnValue(keysResult([{ ...mockKey, models: ["gpt-3.5-turbo", "gpt-4", "gpt-4-turbo", "claude-3", "claude-3-5-sonnet"] }]),);renderWithProviders(<VirtualKeysTable />);- expect(screen.getByText("Test Key Alias")).toBeInTheDocument();+ expect(screen.getByText("+2 more")).toBeInTheDocument();});-it("should render table headers correctly", () => {+it("should render the redesigned table headers", () => {renderWithProviders(<VirtualKeysTable />);- expect(screen.getByText("Key ID")).toBeInTheDocument();- expect(screen.getByText("Key Alias")).toBeInTheDocument();+ expect(screen.getByText("Key")).toBeInTheDocument();expect(screen.getByText("Team")).toBeInTheDocument();expect(screen.getByText("Models")).toBeInTheDocument();- expect(screen.getByText("Spend (USD)")).toBeInTheDocument();+ expect(screen.getByText("Spend / Budget")).toBeInTheDocument();});-it("should handle column resizing hover events", () => {+it("sorts by the backend key_alias field (not the column label) when the Key header is clicked", async () => {renderWithProviders(<VirtualKeysTable />);- const headerCell = document.querySelector("[data-header-id]") as HTMLElement;- expect(headerCell).toBeInTheDocument();-- const resizer = headerCell?.querySelector(".resizer") as HTMLElement;- expect(resizer).toBeInTheDocument();- expect(resizer.style.opacity).toBe("0");+ const keyHeader = screen.getByText("Key").closest("button") as HTMLElement;+ fireEvent.click(keyHeader);- fireEvent.mouseEnter(headerCell);- expect(resizer.style.opacity).toBe("0.5");-- fireEvent.mouseLeave(headerCell);- expect(resizer.style.opacity).toBe("0");+ await waitFor(() => {+ expect(mockUseKeys).toHaveBeenLastCalledWith(1, 50, expect.objectContaining({ sortBy: "key_alias" }));+ });});-it("should open KeyInfoView when clicking on a key ID button", async () => {+it("should open KeyInfoView when clicking the key cell", async () => {renderWithProviders(<VirtualKeysTable />);await waitFor(() => {expect(screen.getByText("Test Key Alias")).toBeInTheDocument();});- expect(screen.getByText(/Showing.*results/)).toBeInTheDocument();+ expect(screen.getByTestId("pagination-range")).toBeInTheDocument();- const keyIdButton = screen.getByText("sk-1234567890abcdef");- fireEvent.click(keyIdButton);+ fireEvent.click(screen.getByText("Test Key Alias"));await waitFor(() => {expect(screen.getByText("Back to Keys")).toBeInTheDocument();- expect(screen.getByText("Created At")).toBeInTheDocument();});- expect(screen.queryByText(/Showing.*results/)).not.toBeInTheDocument();+ expect(screen.queryByTestId("pagination-range")).not.toBeInTheDocument();});it("should display 'Default Proxy Admin' for user_id when value is 'default_user_id'", async () => {@@ -282,44 +317,6 @@ it("should display 'Default Proxy Admin' for user_id when value is 'default_user});});-it("should display created_by_user email in 'Created By' column when available", async () => {- mockUseKeys.mockReturnValue(- keysResult([- {- ...mockKey,- created_by: "some-uuid-1234",- created_by_user: { user_id: "some-uuid-1234", user_email: "[email protected]", user_alias: null },- },- ]),- );-- renderWithProviders(<VirtualKeysTable />);-- await waitFor(() => {- expect(screen.getByText("[email protected]")).toBeInTheDocument();- });-});--it("should display created_by_user alias over email when both are available", async () => {- mockUseKeys.mockReturnValue(- keysResult([- {- ...mockKey,- created_by: "some-uuid-1234",- created_by_user: { user_id: "some-uuid-1234", user_email: "[email protected]", user_alias: "The Creator" },- },- ]),- );-- renderWithProviders(<VirtualKeysTable />);-- // Scope to the key's row so we assert the visible cell value: the hover popover that- // also holds the email is portaled out of the row, not the displayed "Created By" text.- const row = (await screen.findByText("Test Key Alias")).closest("tr") as HTMLElement;- expect(within(row).getByText("The Creator")).toBeInTheDocument();- expect(within(row).queryByText("[email protected]")).not.toBeInTheDocument();-});-it("should render table without crashing when models is null", async () => {mockUseKeys.mockReturnValue(keysResult([{ ...mockKey, models: null as unknown as string[] }]));@@ -327,6 +324,7 @@ it("should render table without crashing when models is null", async () => {await waitFor(() => {expect(screen.getByText("Test Key Alias")).toBeInTheDocument();+ expect(screen.getByText("All Proxy Models")).toBeInTheDocument();});});@@ -341,13 +339,14 @@ it("should display 'Unknown' for last_active when value is null", async () => {});describe("server-side filtering – the LIT-4080 regression guard", () => {- it("threads an active User ID filter into the useKeys query so any refetch keeps it", async () => {+ it("threads an applied User ID filter into the useKeys query so any refetch keeps it", async () => {renderWithProviders(<VirtualKeysTable />);- fireEvent.click(screen.getByRole("button", { name: "Filters" }));+ openFilters();- const userIdInput = await screen.findByPlaceholderText("Enter User ID...");+ const userIdInput = await screen.findByPlaceholderText(/Enter User ID/);fireEvent.change(userIdInput, { target: { value: "user-42" } });+ fireEvent.click(screen.getByTestId("filter-drawer-apply"));await waitFor(() => {expect(mockUseKeys).toHaveBeenLastCalledWith(1, 50, expect.objectContaining({ userID: "user-42" }));@@ -361,18 +360,19 @@ describe("server-side filtering – the LIT-4080 regression guard", () => {expect(lastCall[2] ?? {}).toMatchObject({ userID: undefined, teamID: undefined, keyHash: undefined });});- it("drops the filter from the useKeys query when Reset Filters is clicked", async () => {+ it("drops the filter from the useKeys query when it is cleared", async () => {renderWithProviders(<VirtualKeysTable />);- fireEvent.click(screen.getByRole("button", { name: "Filters" }));- const userIdInput = await screen.findByPlaceholderText("Enter User ID...");+ openFilters();+ const userIdInput = await screen.findByPlaceholderText(/Enter User ID/);fireEvent.change(userIdInput, { target: { value: "user-42" } });+ fireEvent.click(screen.getByTestId("filter-drawer-apply"));await waitFor(() => {expect(mockUseKeys).toHaveBeenLastCalledWith(1, 50, expect.objectContaining({ userID: "user-42" }));});- fireEvent.click(screen.getByRole("button", { name: "Reset Filters" }));+ fireEvent.click(screen.getByTestId("datatable-clear-filters"));await waitFor(() => {const lastCall = mockUseKeys.mock.calls[mockUseKeys.mock.calls.length - 1];@@ -388,8 +388,8 @@ describe("pagination display – total count comes from useKeys", () => {renderWithProviders(<VirtualKeysTable />);await waitFor(() => {- expect(screen.getByText("Showing 1 - 50 of 509 results")).toBeInTheDocument();- expect(screen.getByText("Page 1 of 11")).toBeInTheDocument();+ expect(screen.getByTestId("pagination-range")).toHaveTextContent("Showing 1-50 of 509");+ expect(screen.getByTestId("pagination-page")).toHaveTextContent("Page 1 of 11");});});@@ -399,67 +399,66 @@ describe("pagination display – total count comes from useKeys", () => {renderWithProviders(<VirtualKeysTable />);await waitFor(() => {- expect(screen.getByText("Showing 1 - 1 of 1 results")).toBeInTheDocument();- expect(screen.getByText("Page 1 of 1")).toBeInTheDocument();+ expect(screen.getByTestId("pagination-range")).toHaveTextContent("Showing 1-1 of 1");+ expect(screen.getByTestId("pagination-page")).toHaveTextContent("Page 1 of 1");});});});-describe("refetch button", () => {- it("should show Fetch button in normal state", () => {+describe("refresh button", () => {+ it("renders an enabled refresh control in the normal state", () => {renderWithProviders(<VirtualKeysTable />);- const fetchButton = screen.getByTitle("Fetch data");- expect(fetchButton).toBeInTheDocument();- expect(fetchButton).not.toBeDisabled();- expect(screen.getByText("Fetch")).toBeInTheDocument();+ const refresh = screen.getByTestId("datatable-refresh");+ expect(refresh).toBeInTheDocument();+ expect(refresh).not.toBeDisabled();});- it("should show Fetching state and keep table data visible during refetch", () => {+ it("disables the refresh control while a fetch is in flight but keeps data visible", () => {mockUseKeys.mockReturnValue(keysResult([mockKey], {}, { isFetching: true }));renderWithProviders(<VirtualKeysTable />);- expect(screen.getByText("Fetching")).toBeInTheDocument();- expect(screen.getByTitle("Fetch data")).toBeDisabled();+ expect(screen.getByTestId("datatable-refresh")).toBeDisabled();expect(screen.getByText("Test Key Alias")).toBeInTheDocument();- expect(screen.queryByText("🚅 Loading keys...")).not.toBeInTheDocument();});- it("should call refetch when Fetch button is clicked", () => {+ it("calls refetch when the refresh control is clicked", () => {const mockRefetch = vi.fn();mockUseKeys.mockReturnValue(keysResult([mockKey], {}, { refetch: mockRefetch }));renderWithProviders(<VirtualKeysTable />);- fireEvent.click(screen.getByTitle("Fetch data"));+ fireEvent.click(screen.getByTestId("datatable-refresh"));expect(mockRefetch).toHaveBeenCalledTimes(1);});+});- it("should show Fetch button enabled on error so user can retry", () => {- mockUseKeys.mockReturnValue(keysResult([], {}, { data: null, isError: true }));+describe("Status column reflects blocked / expiry / scim metadata", () => {+ it("renders Active for a non-blocked, unexpired key", async () => {+ mockUseKeys.mockReturnValue(keysResult([{ ...mockKey, blocked: false, metadata: {} }]));renderWithProviders(<VirtualKeysTable />);- const fetchButton = screen.getByTitle("Fetch data");- expect(fetchButton).not.toBeDisabled();- expect(screen.getByText("Fetch")).toBeInTheDocument();+ await waitFor(() => {+ expect(screen.getByTestId(`key-status-${mockKey.token_id}`)).toHaveTextContent("Active");+ });});-});-describe("Status column reflects key.blocked / scim_blocked metadata", () => {- it("should render Active for a non-blocked key", async () => {- mockUseKeys.mockReturnValue(keysResult([{ ...mockKey, blocked: false, metadata: {} }]));+ it("renders Expired when the expiry date has passed", async () => {+ mockUseKeys.mockReturnValue(+ keysResult([{ ...mockKey, blocked: false, metadata: {}, expires: "2020-01-01T00:00:00Z" }]),+ );renderWithProviders(<VirtualKeysTable />);await waitFor(() => {- expect(screen.getByTestId(`key-status-${mockKey.token_id}`)).toHaveTextContent("Active");+ expect(screen.getByTestId(`key-status-${mockKey.token_id}`)).toHaveTextContent("Expired");});});- it("should render Blocked when key.blocked is true", async () => {+ it("renders Blocked when key.blocked is true", async () => {mockUseKeys.mockReturnValue(keysResult([{ ...mockKey, blocked: true, metadata: {} }]));renderWithProviders(<VirtualKeysTable />);@@ -470,7 +469,7 @@ describe("Status column reflects key.blocked / scim_blocked metadata", () => {expect(screen.queryByText(/Blocked by SCIM/i)).not.toBeInTheDocument();});- it("should mark a SCIM-blocked key with the SCIM tooltip reason", async () => {+ it("marks a SCIM-blocked key with the SCIM tooltip reason", async () => {mockUseKeys.mockReturnValue(keysResult([{ ...mockKey, blocked: true, metadata: { scim_blocked: true } }]));renderWithProviders(<VirtualKeysTable />);diff --git a/ui/litellm-dashboard/src/components/VirtualKeysPage/VirtualKeysTable.tsx b/ui/litellm-dashboard/src/components/VirtualKeysPage/VirtualKeysTable.tsxindex 697318af62f..112b6cbcba4 100644--- a/ui/litellm-dashboard/src/components/VirtualKeysPage/VirtualKeysTable.tsx+++ b/ui/litellm-dashboard/src/components/VirtualKeysPage/VirtualKeysTable.tsx@@ -1,811 +1,251 @@"use client";-import { useKeys, KeyListCallOptions } from "@/app/(dashboard)/hooks/keys/useKeys";++import { useKeys } from "@/app/(dashboard)/hooks/keys/useKeys";import { useOrganizations } from "@/app/(dashboard)/hooks/organizations/useOrganizations";import { useAllTeams } from "@/app/(dashboard)/hooks/teams/useTeams";-import { useDebouncedValue } from "@tanstack/react-pacer/debouncer";-import { formatNumberWithCommas } from "@/utils/dataUtils";import { DEBOUNCE_WAIT_MS } from "@/utils/debounceConstants";-import { ChevronDownIcon, ChevronRightIcon, ChevronUpIcon, SwitchVerticalIcon } from "@heroicons/react/outline";import {- ColumnDef,- flexRender,- getCoreRowModel,- PaginationState,- SortingState,- useReactTable,-} from "@tanstack/react-table";-import { Badge, Icon, Table, TableBody, TableCell, TableHead, TableHeaderCell, TableRow, Text } from "@tremor/react";-import { InfoCircleOutlined, SyncOutlined } from "@ant-design/icons";-import { Button as AntButton, Popover, Skeleton, Typography } from "antd";-import { DateCell, IdCell, MoneyCell, StatusBadge } from "@/components/shared/table_cells";-import React, { useDeferredValue, useMemo, useState } from "react";-import { getModelDisplayName } from "../key_team_helpers/fetch_available_models_team_key";-import { PaginatedKeyAliasSelect } from "../KeyAliasSelect/PaginatedKeyAliasSelect/PaginatedKeyAliasSelect";+ DataTable,+ DataTableFilterDrawer,+ DataTableFilterField,+ DataTableToolbar,+} from "@/components/shared/DataTable";+import { SearchSelect } from "@/components/shared/SearchSelect";+import { PageHeader } from "@/components/shared/PageHeader";+import { Input } from "@/components/ui/input";+import { useDebouncedValue } from "@tanstack/react-pacer/debouncer";+import { ColumnFiltersState, OnChangeFn, PaginationState, SortingState } from "@tanstack/react-table";+import { KeyRound } from "lucide-react";+import React, { useCallback, useMemo, useState } from "react";+import { KeyResponse, Team } from "../key_team_helpers/key_list";-import FilterComponent, { FilterOption } from "../molecules/filter";-import DefaultProxyAdminTag from "../common_components/DefaultProxyAdminTag";import KeyInfoView from "../templates/key_info_view";+import { getKeyTableColumns, KEY_TABLE_HIDDEN_COLUMNS } from "./keyTableColumns";-type KeyFilterState = {- "Team ID": string;- "Organization ID": string;- "Key Alias": string;- "User ID": string;- "Key Hash": string;-};+interface VirtualKeysTableProps {+ headerActions?: React.ReactNode;+}++const DEFAULT_SORTING: SortingState = [{ id: "created_at", desc: true }];-const DEFAULT_KEY_FILTERS: KeyFilterState = {- "Team ID": "",- "Organization ID": "",- "Key Alias": "",- "User ID": "",- "Key Hash": "",+const toSortOrder = (sorting: SortingState): "asc" | "desc" | undefined => {+ const active = sorting[0];+ if (!active) return undefined;+ return active.desc ? "desc" : "asc";};-type KeyListFilterOptions = Pick<- KeyListCallOptions,- "teamID" | "organizationID" | "selectedKeyAlias" | "userID" | "keyHash"->;+const FILTER_LABELS: Record<string, string> = {+ team_id: "Team",+ org_id: "Organization",+ user_id: "User ID",+ key_hash: "Key ID",+};-const toKeyListFilters = (filters: KeyFilterState): KeyListFilterOptions => ({- teamID: filters["Team ID"].trim() || undefined,- organizationID: filters["Organization ID"].trim() || undefined,- selectedKeyAlias: filters["Key Alias"].trim() || undefined,- userID: filters["User ID"].trim() || undefined,- keyHash: filters["Key Hash"].trim() || undefined,-});+export function VirtualKeysTable({ headerActions }: VirtualKeysTableProps) {+ const { data: fetchedOrganizations } = useOrganizations();+ const organizations = useMemo(() => fetchedOrganizations ?? [], [fetchedOrganizations]);+ const { data: fetchedTeams } = useAllTeams();+ const allTeams = useMemo<Team[]>(() => fetchedTeams ?? [], [fetchedTeams]);-export function VirtualKeysTable() {- const { data: fetchedOrganizations, isLoading: isOrgsLoading } = useOrganizations();- const resolvedOrganizations = useMemo(() => fetchedOrganizations ?? [], [fetchedOrganizations]);const [selectedKey, setSelectedKey] = useState<KeyResponse | null>(null);- const [sorting, setSorting] = React.useState<SortingState>([{ id: "created_at", desc: true }]);- const [tablePagination, setTablePagination] = React.useState<PaginationState>({- pageIndex: 0,- pageSize: 50,- });- const [filters, setFilters] = useState<KeyFilterState>(DEFAULT_KEY_FILTERS);- const [debouncedFilters] = useDebouncedValue(filters, { wait: DEBOUNCE_WAIT_MS });+ const [sorting, setSorting] = useState<SortingState>(DEFAULT_SORTING);+ const [tablePagination, setTablePagination] = useState<PaginationState>({ pageIndex: 0, pageSize: 50 });+ const [columnFilters, setColumnFilters] = useState<ColumnFiltersState>([]);+ const [filtersOpen, setFiltersOpen] = useState(false);+ const [searchInput, setSearchInput] = useState("");+ const [searchQuery] = useDebouncedValue(searchInput, { wait: DEBOUNCE_WAIT_MS });++ const getFilterValue = useCallback(+ (columnId: string): string | undefined => {+ const entry = columnFilters.find((filter) => filter.id === columnId);+ return typeof entry?.value === "string" && entry.value.trim() ? entry.value.trim() : undefined;+ },+ [columnFilters],+ );- const sortBy = sorting.length > 0 ? sorting[0].id : null;- const sortOrder = sorting.length > 0 ? (sorting[0].desc ? "desc" : "asc") : null;+ const sortBy = sorting[0]?.id;+ const sortOrder = toSortOrder(sorting);++ const keyListOptions = {+ teamID: getFilterValue("team_id"),+ organizationID: getFilterValue("org_id"),+ selectedKeyAlias: searchQuery.trim() || undefined,+ userID: getFilterValue("user_id"),+ keyHash: getFilterValue("key_hash"),+ sortBy,+ sortOrder,+ expand: "user",+ };const {data: keys,isPending: isLoading,isFetching,- isError,refetch,- } = useKeys(tablePagination.pageIndex + 1, tablePagination.pageSize, {- ...toKeyListFilters(debouncedFilters),- sortBy: sortBy || undefined,- sortOrder: sortOrder || undefined,- expand: "user",- });- const [expandedAccordions, setExpandedAccordions] = useState<Record<string, boolean>>({});+ } = useKeys(tablePagination.pageIndex + 1, tablePagination.pageSize, keyListOptions);const keyList = useMemo(() => keys?.keys ?? [], [keys]);+ const rowCount = keys?.total_count ?? 0;- const { data: fetchedTeams, isLoading: isTeamsLoading } = useAllTeams();- const allTeams = useMemo<Team[]>(() => fetchedTeams ?? [], [fetchedTeams]);-- // Defer the transition so the button stays in loading state until the table- // has rendered with the new data (mirrors the spend-logs pattern)- const isFetchingDeferred = useDeferredValue(isFetching);- const isButtonLoading = (isFetching || isFetchingDeferred) && !isError;-- const handleRefresh = () => {- refetch();- };-- const handleFilterChange = (newFilters: Record<string, string>) => {- setFilters({- "Team ID": newFilters["Team ID"] || "",- "Organization ID": newFilters["Organization ID"] || "",- "Key Alias": newFilters["Key Alias"] || "",- "User ID": newFilters["User ID"] || "",- "Key Hash": newFilters["Key Hash"] || "",- });+ const handleSearchChange = useCallback((value: string) => {+ setSearchInput(value);setTablePagination((prev) => ({ ...prev, pageIndex: 0 }));- };+ }, []);- const handleFilterReset = () => {- setFilters(DEFAULT_KEY_FILTERS);+ const handleSortingChange = useCallback<OnChangeFn<SortingState>>((updaterOrValue) => {+ setSorting(updaterOrValue);setTablePagination((prev) => ({ ...prev, pageIndex: 0 }));- };-- const totalCount = keys?.total_count ?? 0;-- const columns: ColumnDef<KeyResponse>[] = useMemo(- () => [- {- id: "expander",- header: () => null,- size: 40,- enableSorting: false,- cell: ({ row }) =>- row.getCanExpand() ? (- <button onClick={row.getToggleExpandedHandler()} style={{ cursor: "pointer" }}>- {row.getIsExpanded() ? "▼" : "▶"}- </button>- ) : null,- },- {- id: "token",- accessorKey: "token",- header: "Key ID",- size: 100,- enableSorting: true,- cell: (info) => <IdCell value={info.getValue() as string} onClick={() => setSelectedKey(info.row.original)} />,- },- {- id: "key_alias",- accessorKey: "key_alias",- header: "Key Alias",- size: 150,- enableSorting: true,- cell: (info) => {- const value = info.getValue() as string;- const width = info.cell.column.getSize();- return (- <span className="font-mono text-xs truncate block" style={{ maxWidth: width, overflow: "hidden" }}>- {value ?? "-"}- </span>- );- },- },- {- id: "status",- header: "Status",- size: 100,- enableSorting: false,- cell: ({ row }) => {- const key = row.original;- if (key.blocked !== true) {- return <StatusBadge tone="success" label="Active" dataTestId={`key-status-${key.token_id}`} />;- }- const isScimBlocked = (key.metadata as Record<string, unknown> | null | undefined)?.scim_blocked === true;- const reason = isScimBlocked- ? "Blocked by SCIM (external identity provider deactivated or deleted the owning user)."- : "Blocked. Requests using this key will be rejected with 401.";- return (- <StatusBadge tone="error" label="Blocked" tooltip={reason} dataTestId={`key-status-${key.token_id}`} />- );- },- },- {- id: "key_name",- accessorKey: "key_name",- header: "Secret Key",- size: 120,- enableSorting: false,- cell: (info) => <span className="font-mono text-xs">{info.getValue() as string}</span>,- },- {- id: "team_alias",- accessorKey: "team_id",- header: "Team",- size: 120,- enableSorting: false,- cell: (info) => {- const teamId = info.getValue() as string | null;- if (!teamId) return "-";- const team = allTeams.find((t) => t.team_id === teamId);- const displayValue = team?.team_alias || teamId;- const width = info.cell.column.getSize();- return (- <span className="font-mono text-xs truncate block" style={{ maxWidth: width, overflow: "hidden" }}>- {displayValue}- </span>- );- },- },- {- id: "organization_alias",- accessorKey: "org_id",- header: "Organization",- size: 140,- enableSorting: false,- cell: (info) => {- const orgId = info.getValue() as string | null;- if (!orgId) return "-";- const org = resolvedOrganizations.find((o) => o.organization_id === orgId);- const displayValue = org?.organization_alias || orgId;- const width = info.cell.column.getSize();- return (- <span className="font-mono text-xs truncate block" style={{ maxWidth: width, overflow: "hidden" }}>- {displayValue}- </span>- );- },- },- {- id: "user",- accessorKey: "user",- header: () => (- <span className="flex items-center gap-1">- User- <Popover content="Displays the first available value: User Alias, User Email, or User ID." trigger="hover">- <InfoCircleOutlined className="text-gray-400 text-xs cursor-help" />- </Popover>- </span>- ),- size: 160,- enableSorting: false,- cell: ({ row }) => {- const key = row.original;- const userAlias = key.user?.user_alias ?? null;- const userEmail = key.user?.user_email ?? key.user_email ?? null;- const userId = key.user_id ?? null;- const isDefaultAdmin = userId === "default_user_id";- const displayValue = userAlias || userEmail || userId;- const width = 160;-- const popoverContent = (- <div className="flex flex-col gap-2 text-xs min-w-[200px] max-w-[300px]">- {[- { label: "User Alias", value: userAlias },- { label: "User Email", value: userEmail },- { label: "User ID", value: userId },- ].map(({ label, value }) => (- <div key={label} className="flex flex-col min-w-0">- <span className="text-gray-400">{label}</span>- {value ? (- <Typography.Text className="font-mono text-xs" ellipsis={{ tooltip: value }} copyable>- {value}- </Typography.Text>- ) : (- <span className="font-mono">-</span>- )}- </div>- ))}- </div>- );-- if (isDefaultAdmin && !userAlias && !userEmail) {- return (- <Popover content={popoverContent} trigger="hover" placement="bottomLeft">- <span className="cursor-default">- <DefaultProxyAdminTag userId={userId} />- </span>- </Popover>- );- }-- return (- <Popover content={popoverContent} trigger="hover" placement="bottomLeft">- <span- className="font-mono text-xs truncate block cursor-default"- style={{ maxWidth: width, overflow: "hidden" }}- >- {displayValue || "-"}- </span>- </Popover>- );- },- },- {- id: "created_at",- accessorKey: "created_at",- header: "Created At",- size: 120,- enableSorting: true,- cell: (info) => <DateCell value={info.getValue() as string | null} precision="date" />,- },- {- id: "created_by",- accessorKey: "created_by",- header: "Created By",- size: 160,- enableSorting: false,- cell: (info) => {- const userId = info.getValue() as string | null;- if (!userId) return "-";- const key = info.row.original;- const createdByUser = key.created_by_user;- const userAlias = createdByUser?.user_alias ?? null;- const userEmail = createdByUser?.user_email ?? null;- const isDefaultAdmin = userId === "default_user_id";- const displayValue = userAlias || userEmail || userId;- const width = 160;-- const popoverContent = (- <div className="flex flex-col gap-2 text-xs min-w-[200px] max-w-[300px]">- {[- { label: "User Alias", value: userAlias },- { label: "User Email", value: userEmail },- { label: "User ID", value: userId },- ].map(({ label, value }) => (- <div key={label} className="flex flex-col min-w-0">- <span className="text-gray-400">{label}</span>- {value ? (- <Typography.Text className="font-mono text-xs" ellipsis={{ tooltip: value }} copyable>- {value}- </Typography.Text>- ) : (- <span className="font-mono">-</span>- )}- </div>- ))}- </div>- );+ }, []);- if (isDefaultAdmin && !userAlias && !userEmail) {- return (- <Popover content={popoverContent} trigger="hover" placement="bottomLeft">- <span className="cursor-default">- <DefaultProxyAdminTag userId={userId} />- </span>- </Popover>- );- }+ const handleColumnFiltersChange = useCallback<OnChangeFn<ColumnFiltersState>>((updaterOrValue) => {+ setColumnFilters(updaterOrValue);+ setTablePagination((prev) => ({ ...prev, pageIndex: 0 }));+ }, []);- return (- <Popover content={popoverContent} trigger="hover" placement="bottomLeft">- <span- className="font-mono text-xs truncate block cursor-default"- style={{ maxWidth: width, overflow: "hidden" }}- >- {displayValue}- </span>- </Popover>- );- },- },- {- id: "updated_at",- accessorKey: "updated_at",- header: "Updated At",- size: 120,- enableSorting: true,- cell: (info) => <DateCell value={info.getValue() as string | null} precision="date" fallback="Never" />,- },- {- id: "last_active",- accessorKey: "last_active",- header: () => (- <span className="flex items-center gap-1">- Last Active- <Popover- content="This is a new field and is not backfilled. Only new key usage will update this value."- trigger="hover"- >- <InfoCircleOutlined className="text-gray-400 text-xs cursor-help" />- </Popover>- </span>- ),- size: 130,- enableSorting: false,- cell: (info) => <DateCell value={info.getValue() as string | null} precision="date" fallback="Unknown" />,- },- {- id: "expires",- accessorKey: "expires",- header: "Expires",- size: 120,- enableSorting: false,- cell: (info) => <DateCell value={info.getValue() as string | null} precision="date" fallback="Never" />,- },- {- id: "spend",- accessorKey: "spend",- header: "Spend (USD)",- size: 100,- enableSorting: true,- cell: (info) => <MoneyCell value={info.getValue() as number} decimals={4} />,- },- {- id: "max_budget",- accessorKey: "max_budget",- header: "Budget (USD)",- size: 110,- enableSorting: true,- cell: (info) => {- const maxBudget = info.getValue() as number | null;- if (maxBudget !== null) {- return `$${formatNumberWithCommas(maxBudget)}`;- }- const teamId = info.row.original.team_id;- const team = allTeams.find((t) => t.team_id === teamId);- if (team?.max_budget != null) {- return `$${formatNumberWithCommas(team.max_budget)} (Team)`;- }- return "Unlimited";- },- },- {- id: "budget_reset_at",- accessorKey: "budget_reset_at",- header: "Budget Reset",- size: 130,- enableSorting: false,- cell: (info) => <DateCell value={info.getValue() as string | null} fallback="Never" />,- },- {- id: "models",- accessorKey: "models",- header: "Models",- size: 200,- enableSorting: false,- cell: (info) => {- const models = info.getValue() as string[];- return (- <div className="flex flex-col py-2">- {Array.isArray(models) ? (- <div className="flex flex-col">- {models.length === 0 ? (- <Badge size={"xs"} className="mb-1" color="red">- <Text>All Proxy Models</Text>- </Badge>- ) : (- <>- <div className="flex items-start">- {models.length > 3 && (- <div>- <Icon- icon={expandedAccordions[info.row.id] ? ChevronDownIcon : ChevronRightIcon}- className="cursor-pointer"- size="xs"- onClick={() => {- setExpandedAccordions((prev) => ({- ...prev,- [info.row.id]: !prev[info.row.id],- }));- }}- />- </div>- )}- <div className="flex flex-wrap gap-1">- {models.slice(0, 3).map((model, index) =>- model === "all-proxy-models" ? (- <Badge key={index} size={"xs"} color="red">- <Text>All Proxy Models</Text>- </Badge>- ) : (- <Badge key={index} size={"xs"} color="blue">- <Text>- {model.length > 30- ? `${getModelDisplayName(model).slice(0, 30)}...`- : getModelDisplayName(model)}- </Text>- </Badge>- ),- )}- {models.length > 3 && !expandedAccordions[info.row.id] && (- <Badge size={"xs"} color="gray" className="cursor-pointer">- <Text>- +{models.length - 3} {models.length - 3 === 1 ? "more model" : "more models"}- </Text>- </Badge>- )}- {expandedAccordions[info.row.id] && (- <div className="flex flex-wrap gap-1">- {models.slice(3).map((model, index) =>- model === "all-proxy-models" ? (- <Badge key={index + 3} size={"xs"} color="red">- <Text>All Proxy Models</Text>- </Badge>- ) : (- <Badge key={index + 3} size={"xs"} color="blue">- <Text>- {model.length > 30- ? `${getModelDisplayName(model).slice(0, 30)}...`- : getModelDisplayName(model)}- </Text>- </Badge>- ),- )}- </div>- )}- </div>- </div>- </>- )}- </div>- ) : null}- </div>- );- },- },- {- id: "rate_limits",- header: "Rate Limits",- size: 140,- enableSorting: false,- cell: ({ row }) => {- const key = row.original;- return (- <div>- <div>TPM: {key.tpm_limit !== null ? key.tpm_limit : "Unlimited"}</div>- <div>RPM: {key.rpm_limit !== null ? key.rpm_limit : "Unlimited"}</div>- </div>- );- },- },- ],- [allTeams, resolvedOrganizations],+ const columns = useMemo(+ () => getKeyTableColumns({ allTeams, organizations, onSelectKey: setSelectedKey }),+ [allTeams, organizations],);- const filterOptions: FilterOption[] = [- {- name: "Team ID",- label: "Team ID",- isSearchable: true,- loading: isTeamsLoading,- searchFn: async (searchText: string) => {- if (!allTeams || allTeams.length === 0) return [];-- const filteredTeams = allTeams.filter(- (team) =>- team.team_id.toLowerCase().includes(searchText.toLowerCase()) ||- (team.team_alias && team.team_alias.toLowerCase().includes(searchText.toLowerCase())),- );-- return filteredTeams.map((team) => ({- label: `${team.team_alias || team.team_id} (${team.team_id})`,- value: team.team_id,- }));- },- },- {- name: "Organization ID",- label: "Organization ID",- isSearchable: true,- loading: isOrgsLoading,- searchFn: async (searchText: string) => {- if (!resolvedOrganizations || resolvedOrganizations.length === 0) return [];-- const filteredOrgs = resolvedOrganizations.filter(- (org) => org.organization_id?.toLowerCase().includes(searchText.toLowerCase()) ?? false,- );+ const teamOptions = useMemo(+ () =>+ allTeams.map((team) => ({+ label: team.team_alias || team.team_id,+ value: team.team_id,+ sublabel: team.team_alias ? team.team_id : undefined,+ })),+ [allTeams],+ );- return filteredOrgs- .filter((org) => org.organization_id !== null && org.organization_id !== undefined)- .map((org) => ({- label: `${org.organization_id || "Unknown"} (${org.organization_id})`,- value: org.organization_id as string,- }));- },- },- {- name: "Key Alias",- label: "Key Alias",- customComponent: PaginatedKeyAliasSelect,- },- {- name: "User ID",- label: "User ID",- isSearchable: false,- },- {- name: "Key Hash",- label: "Key ID",- isSearchable: false,- },- ];+ const orgOptions = useMemo(+ () =>+ organizations+ .filter((org) => org.organization_id)+ .map((org) => {+ const id = org.organization_id as string;+ return { label: org.organization_alias || id, value: id, sublabel: org.organization_alias ? id : undefined };+ }),+ [organizations],+ );- const table = useReactTable({- data: keyList,- columns: columns.filter((col) => col.id !== "expander"),- columnResizeMode: "onChange",- columnResizeDirection: "ltr",- state: {- sorting,- pagination: tablePagination,- },- onSortingChange: (updaterOrValue) => {- const newSorting = typeof updaterOrValue === "function" ? updaterOrValue(sorting) : updaterOrValue;- setSorting(newSorting);- setTablePagination((prev) => ({ ...prev, pageIndex: 0 }));+ const formatFilterValue = useCallback(+ (columnId: string, value: unknown): string => {+ const raw = String(value);+ if (columnId === "team_id") {+ return allTeams.find((team) => team.team_id === raw)?.team_alias || raw;+ }+ if (columnId === "org_id") {+ return organizations.find((org) => org.organization_id === raw)?.organization_alias || raw;+ }+ return raw;},- onPaginationChange: setTablePagination,- getCoreRowModel: getCoreRowModel(),- enableSorting: true,- manualSorting: true,- manualPagination: true,- pageCount: Math.ceil(totalCount / tablePagination.pageSize),- });+ [allTeams, organizations],+ );- const { pageIndex, pageSize } = table.getState().pagination;- const start = pageIndex * pageSize + 1;- const end = Math.min((pageIndex + 1) * pageSize, totalCount);- const rangeLabel = `${start} - ${end}`;- return (- <div className="w-full h-full overflow-hidden">- {selectedKey ? (+ if (selectedKey) {+ return (+ <div className="w-full h-full overflow-hidden"><KeyInfoViewkeyId={selectedKey.token}onClose={() => setSelectedKey(null)}keyData={selectedKey}teams={allTeams}+ onDelete={refetch}/>- ) : (- <div className="border-b py-4 flex-1 overflow-hidden">- <div className="w-full mb-6">- <FilterComponent- options={filterOptions}- onApplyFilters={handleFilterChange}- initialValues={filters}- onResetFilters={handleFilterReset}- />- </div>+ </div>+ );+ }- <div className="flex items-center justify-between w-full mb-4">- <div className="inline-flex items-center gap-2">- {isLoading ? (- <Skeleton.Node active style={{ width: 200, height: 20 }} />- ) : (- <span className="inline-flex text-sm text-gray-700">- Showing {rangeLabel} of {totalCount} results- </span>- )}-- <AntButton- type="default"- icon={<SyncOutlined spin={isButtonLoading} />}- onClick={handleRefresh}- disabled={isButtonLoading}- title="Fetch data"- >- {isButtonLoading ? "Fetching" : "Fetch"}- </AntButton>- </div>-- <div className="inline-flex items-center gap-2">- {isLoading ? (- <Skeleton.Node active style={{ width: 74, height: 20 }} />- ) : (- <span className="text-sm text-gray-700">- Page {pageIndex + 1} of {table.getPageCount()}- </span>- )}-- {isLoading ? (- <Skeleton.Button active size="small" style={{ width: 84, height: 30 }} />- ) : (- <button- onClick={() => table.previousPage()}- disabled={isLoading || !table.getCanPreviousPage()}- className="px-3 py-1 text-sm border rounded-md hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed"- >- Previous- </button>- )}-- {isLoading ? (- <Skeleton.Button active size="small" style={{ width: 58, height: 30 }} />- ) : (- <button- onClick={() => table.nextPage()}- disabled={isLoading || !table.getCanNextPage()}- className="px-3 py-1 text-sm border rounded-md hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed"- >- Next- </button>+ return (+ <div className="flex h-full flex-col gap-4 overflow-hidden py-2">+ <PageHeader+ icon={<KeyRound className="size-5" />}+ title="Virtual Keys"+ subtitle="Every key that authenticates requests to the gateway."+ actions={headerActions}+ />+ <DataTable+ data={keyList}+ columns={columns}+ getRowId={(row) => row.token}+ defaultColumnVisibility={KEY_TABLE_HIDDEN_COLUMNS}+ sortingMode="server"+ sorting={sorting}+ onSortingChange={handleSortingChange}+ paginationMode="server"+ pagination={tablePagination}+ onPaginationChange={setTablePagination}+ rowCount={rowCount}+ filterMode="server"+ columnFilters={columnFilters}+ onColumnFiltersChange={handleColumnFiltersChange}+ enableColumnResizing+ columnResizeMode="onChange"+ isLoading={isLoading}+ loadingMessage="Loading keys..."+ noDataMessage="No keys found"+ maxBodyHeight="calc(75vh - 210px)"+ size="compact"+ toolbar={(table) => (+ <>+ <DataTableToolbar+ table={table}+ searchValue={searchInput}+ onSearchChange={handleSearchChange}+ searchPlaceholder="Search by key alias…"+ onRefresh={() => refetch?.()}+ isRefreshing={isFetching}+ onOpenFilters={() => setFiltersOpen(true)}+ filterLabels={FILTER_LABELS}+ formatFilterValue={formatFilterValue}+ />+ <DataTableFilterDrawer+ table={table}+ open={filtersOpen}+ onOpenChange={setFiltersOpen}+ title="Filters"+ description="Narrow down virtual keys"+ >+ {({ get, set }) => (+ <>+ <DataTableFilterField label="Team">+ <SearchSelect+ options={teamOptions}+ value={(get("team_id") as string) || undefined}+ onValueChange={(value) => set("team_id", value)}+ placeholder="Select a team…"+ emptyText="No teams found"+ />+ </DataTableFilterField>+ <DataTableFilterField label="Organization">+ <SearchSelect+ options={orgOptions}+ value={(get("org_id") as string) || undefined}+ onValueChange={(value) => set("org_id", value)}+ placeholder="Select an organization…"+ emptyText="No organizations found"+ />+ </DataTableFilterField>+ <DataTableFilterField label="User ID">+ <Input+ value={(get("user_id") as string) ?? ""}+ onChange={(event) => set("user_id", event.target.value)}+ placeholder="Enter User ID…"+ />+ </DataTableFilterField>+ <DataTableFilterField label="Key ID">+ <Input+ value={(get("key_hash") as string) ?? ""}+ onChange={(event) => set("key_hash", event.target.value)}+ placeholder="Enter Key ID…"+ />+ </DataTableFilterField>+ </>)}- </div>- </div>- <div className="h-[75vh] overflow-auto">- <div className="rounded-lg custom-border relative">- <div className="overflow-x-auto">- <Table className="[&_td]:py-0.5 [&_th]:py-1" style={{ width: table.getCenterTotalSize() }}>- <TableHead>- {table.getHeaderGroups().map((headerGroup) => (- <TableRow key={headerGroup.id}>- {headerGroup.headers.map((header) => (- <TableHeaderCell- key={header.id}- data-header-id={header.id}- className={`py-1 h-8 relative hover:bg-gray-50 ${- header.id === "actions"- ? "sticky right-0 bg-white shadow-[-4px_0_8px_-6px_rgba(0,0,0,0.1)]"- : ""- }`}- style={{- width: header.getSize(),- position: "relative",- cursor: header.column.getCanSort() ? "pointer" : "default",- }}- onMouseEnter={() => {- const resizer = document.querySelector(`[data-header-id="${header.id}"] .resizer`);- if (resizer) {- (resizer as HTMLElement).style.opacity = "0.5";- }- }}- onMouseLeave={() => {- const resizer = document.querySelector(`[data-header-id="${header.id}"] .resizer`);- if (resizer && !header.column.getIsResizing()) {- (resizer as HTMLElement).style.opacity = "0";- }- }}- onClick={header.column.getCanSort() ? header.column.getToggleSortingHandler() : undefined}- >- <div className="flex items-center justify-between gap-2">- <div className="flex items-center">- {header.isPlaceholder- ? null- : flexRender(header.column.columnDef.header, header.getContext())}- </div>- {header.id !== "actions" && header.column.getCanSort() && (- <div className="w-4">- {header.column.getIsSorted() ? (- {- asc: <ChevronUpIcon className="h-4 w-4 text-blue-500" />,- desc: <ChevronDownIcon className="h-4 w-4 text-blue-500" />,- }[header.column.getIsSorted() as string]- ) : (- <SwitchVerticalIcon className="h-4 w-4 text-gray-400" />- )}- </div>- )}- <div- onDoubleClick={() => header.column.resetSize()}- onMouseDown={header.getResizeHandler()}- onTouchStart={header.getResizeHandler()}- className={`resizer ${table.options.columnResizeDirection} ${header.column.getIsResizing() ? "isResizing" : ""}`}- style={{- position: "absolute",- right: 0,- top: 0,- height: "100%",- width: "5px",- background: header.column.getIsResizing() ? "#3b82f6" : "transparent",- cursor: "col-resize",- userSelect: "none",- touchAction: "none",- opacity: header.column.getIsResizing() ? 1 : 0,- }}- />- </div>- </TableHeaderCell>- ))}- </TableRow>- ))}- </TableHead>- <TableBody>- {isLoading ? (- <TableRow>- <TableCell colSpan={columns.length} className="h-8 text-center">- <div className="text-center text-gray-500">- <p>🚅 Loading keys...</p>- </div>- </TableCell>- </TableRow>- ) : keyList.length > 0 ? (- table.getRowModel().rows.map((row) => (- <TableRow key={row.id} className="h-8">- {row.getVisibleCells().map((cell) => (- <TableCell- key={cell.id}- style={{- width: cell.column.getSize(),- maxWidth: "8-x",- whiteSpace: "pre-wrap",- overflow: "hidden",- }}- className={`py-0.5 max-h-8 overflow-hidden text-ellipsis whitespace-nowrap ${cell.column.id === "models" && Array.isArray(cell.getValue()) && (cell.getValue() as string[]).length > 3 ? "px-0" : ""}`}- >- {flexRender(cell.column.columnDef.cell, cell.getContext())}- </TableCell>- ))}- </TableRow>- ))- ) : (- <TableRow>- <TableCell colSpan={columns.length} className="h-8 text-center">- <div className="text-center text-gray-500">- <p>No keys found</p>- </div>- </TableCell>- </TableRow>- )}- </TableBody>- </Table>- </div>- </div>- </div>- </div>- )}+ </DataTableFilterDrawer>+ </>+ )}+ /></div>);}diff --git a/ui/litellm-dashboard/src/components/VirtualKeysPage/keyTableColumns.tsx b/ui/litellm-dashboard/src/components/VirtualKeysPage/keyTableColumns.tsxnew file mode 100644index 00000000000..e2dc48fed9d--- /dev/null+++ b/ui/litellm-dashboard/src/components/VirtualKeysPage/keyTableColumns.tsx@@ -0,0 +1,353 @@+"use client";++import { InfoCircleOutlined } from "@ant-design/icons";+import { ColumnDef } from "@tanstack/react-table";+import { Popover, Typography } from "antd";++import { DataTableSortHeader } from "@/components/shared/DataTable";+import { Skeleton } from "@/components/ui/skeleton";+import {+ DateCell,+ IdCell,+ IdentityCell,+ ModelsCell,+ SpendBudgetCell,+ StatusBadge,+ type StatusTone,+} from "@/components/shared/table_cells";++import DefaultProxyAdminTag from "../common_components/DefaultProxyAdminTag";+import { KeyResponse, Team } from "../key_team_helpers/key_list";+import { Organization } from "../networking";++interface KeyStatus {+ tone: StatusTone;+ label: string;+ tooltip?: string;+}++const getKeyStatus = (key: KeyResponse): KeyStatus => {+ if (key.blocked === true) {+ const isScimBlocked = (key.metadata as Record<string, unknown> | null | undefined)?.scim_blocked === true;+ return {+ tone: "error",+ label: "Blocked",+ tooltip: isScimBlocked+ ? "Blocked by SCIM (external identity provider deactivated or deleted the owning user)."+ : "Blocked. Requests using this key will be rejected with 401.",+ };+ }+ const expiresAt = key.expires ? Date.parse(key.expires) : Number.NaN;+ if (!Number.isNaN(expiresAt) && expiresAt < Date.now()) {+ return { tone: "warning", label: "Expired", tooltip: "This key has passed its expiry date." };+ }+ return { tone: "success", label: "Active" };+};++const UserPopoverCell = ({+ userAlias,+ userEmail,+ userId,+ width,+}: {+ userAlias: string | null;+ userEmail: string | null;+ userId: string | null;+ width: number;+}) => {+ const displayValue = userAlias || userEmail || userId;+ const isDefaultAdmin = userId === "default_user_id";++ const popoverContent = (+ <div className="flex flex-col gap-2 text-xs min-w-[200px] max-w-[300px]">+ {[+ { label: "User Alias", value: userAlias },+ { label: "User Email", value: userEmail },+ { label: "User ID", value: userId },+ ].map(({ label, value }) => (+ <div key={label} className="flex flex-col min-w-0">+ <span className="text-gray-400">{label}</span>+ {value ? (+ <Typography.Text className="font-mono text-xs" ellipsis={{ tooltip: value }} copyable>+ {value}+ </Typography.Text>+ ) : (+ <span className="font-mono">-</span>+ )}+ </div>+ ))}+ </div>+ );++ if (isDefaultAdmin && !userAlias && !userEmail) {+ return (+ <Popover content={popoverContent} trigger="hover" placement="bottomLeft">+ <span className="cursor-default">+ <DefaultProxyAdminTag userId={userId} />+ </span>+ </Popover>+ );+ }++ return (+ <Popover content={popoverContent} trigger="hover" placement="bottomLeft">+ <span className="font-mono text-xs truncate block cursor-default" style={{ maxWidth: width, overflow: "hidden" }}>+ {displayValue || "-"}+ </span>+ </Popover>+ );+};++const InfoHeader = ({ label, tooltip }: { label: string; tooltip: string }) => (+ <span className="flex items-center gap-1">+ {label}+ <Popover content={tooltip} trigger="hover">+ <InfoCircleOutlined className="text-gray-400 text-xs cursor-help" />+ </Popover>+ </span>+);++interface KeyTableColumnsDeps {+ allTeams: Team[];+ organizations: Organization[];+ onSelectKey: (key: KeyResponse) => void;+}++export const getKeyTableColumns = ({+ allTeams,+ organizations,+ onSelectKey,+}: KeyTableColumnsDeps): ColumnDef<KeyResponse>[] => [+ {+ id: "key_alias",+ accessorKey: "key_alias",+ meta: {+ title: "Key",+ renderSkeleton: () => (+ <div className="flex flex-col gap-1 py-1">+ <Skeleton className="h-4 w-32" />+ <div className="flex items-center gap-2">+ <Skeleton className="h-3 w-20" />+ <Skeleton className="h-5 w-16 rounded-full" />+ </div>+ </div>+ ),+ },+ header: ({ column }) => <DataTableSortHeader column={column} title="Key" variant="header-cycle" />,+ size: 260,+ enableSorting: true,+ cell: ({ row }) => {+ const status = getKeyStatus(row.original);+ return (+ <IdentityCell+ title={row.original.key_alias || "-"}+ subtitle={row.original.key_name}+ badge={+ <StatusBadge+ tone={status.tone}+ label={status.label}+ tooltip={status.tooltip}+ dataTestId={`key-status-${row.original.token_id}`}+ />+ }+ onClick={() => onSelectKey(row.original)}+ />+ );+ },+ },+ {+ id: "token",+ accessorKey: "token",+ meta: { title: "Key ID" },+ header: ({ column }) => <DataTableSortHeader column={column} title="Key ID" variant="header-cycle" />,+ size: 120,+ enableSorting: true,+ cell: (info) => <IdCell value={info.getValue() as string | null} onClick={() => onSelectKey(info.row.original)} />,+ },+ {+ id: "team_alias",+ accessorKey: "team_id",+ meta: { title: "Team" },+ header: "Team",+ size: 120,+ enableSorting: false,+ cell: (info) => {+ const teamId = info.getValue() as string | null;+ if (!teamId) return "-";+ const team = allTeams.find((t) => t.team_id === teamId);+ const displayValue = team?.team_alias || teamId;+ const width = info.cell.column.getSize();+ return (+ <span className="font-mono text-xs truncate block" style={{ maxWidth: width, overflow: "hidden" }}>+ {displayValue}+ </span>+ );+ },+ },+ {+ id: "organization_alias",+ accessorKey: "org_id",+ meta: { title: "Organization" },+ header: "Organization",+ size: 140,+ enableSorting: false,+ cell: (info) => {+ const orgId = info.getValue() as string | null;+ if (!orgId) return "-";+ const org = organizations.find((o) => o.organization_id === orgId);+ const displayValue = org?.organization_alias || orgId;+ const width = info.cell.column.getSize();+ return (+ <span className="font-mono text-xs truncate block" style={{ maxWidth: width, overflow: "hidden" }}>+ {displayValue}+ </span>+ );+ },+ },+ {+ id: "user",+ accessorKey: "user",+ meta: { title: "User" },+ header: () => (+ <InfoHeader label="User" tooltip="Displays the first available value: User Alias, User Email, or User ID." />+ ),+ size: 160,+ enableSorting: false,+ cell: ({ row }) => {+ const key = row.original;+ return (+ <UserPopoverCell+ userAlias={key.user?.user_alias ?? null}+ userEmail={key.user?.user_email ?? key.user_email ?? null}+ userId={key.user_id ?? null}+ width={160}+ />+ );+ },+ },+ {+ id: "created_at",+ accessorKey: "created_at",+ meta: { title: "Created At" },+ header: ({ column }) => <DataTableSortHeader column={column} title="Created At" variant="header-cycle" />,+ size: 120,+ enableSorting: true,+ cell: (info) => <DateCell value={info.getValue() as string | null} precision="date" />,+ },+ {+ id: "created_by",+ accessorKey: "created_by",+ meta: { title: "Created By" },+ header: "Created By",+ size: 160,+ enableSorting: false,+ cell: (info) => {+ const userId = info.getValue() as string | null;+ if (!userId) return "-";+ const createdByUser = info.row.original.created_by_user;+ return (+ <UserPopoverCell+ userAlias={createdByUser?.user_alias ?? null}+ userEmail={createdByUser?.user_email ?? null}+ userId={userId}+ width={160}+ />+ );+ },+ },+ {+ id: "updated_at",+ accessorKey: "updated_at",+ meta: { title: "Updated At" },+ header: ({ column }) => <DataTableSortHeader column={column} title="Updated At" variant="header-cycle" />,+ size: 120,+ enableSorting: true,+ cell: (info) => <DateCell value={info.getValue() as string | null} precision="date" fallback="Never" />,+ },+ {+ id: "last_active",+ accessorKey: "last_active",+ meta: { title: "Last Active" },+ header: () => (+ <InfoHeader+ label="Last Active"+ tooltip="This is a new field and is not backfilled. Only new key usage will update this value."+ />+ ),+ size: 130,+ enableSorting: false,+ cell: (info) => <DateCell value={info.getValue() as string | null} precision="date" fallback="Unknown" />,+ },+ {+ id: "expires",+ accessorKey: "expires",+ meta: { title: "Expires" },+ header: "Expires",+ size: 120,+ enableSorting: false,+ cell: (info) => <DateCell value={info.getValue() as string | null} precision="date" fallback="Never" />,+ },+ {+ id: "spend",+ accessorKey: "spend",+ meta: { title: "Spend / Budget", skeleton: "meter" },+ header: ({ column }) => <DataTableSortHeader column={column} title="Spend / Budget" variant="header-cycle" />,+ size: 180,+ enableSorting: true,+ cell: ({ row }) => {+ const teamId = row.original.team_id;+ const team = allTeams.find((t) => t.team_id === teamId);+ return (+ <SpendBudgetCell+ spend={row.original.spend}+ maxBudget={row.original.max_budget}+ teamMaxBudget={team?.max_budget ?? null}+ />+ );+ },+ },+ {+ id: "budget_reset_at",+ accessorKey: "budget_reset_at",+ meta: { title: "Budget Reset" },+ header: "Budget Reset",+ size: 130,+ enableSorting: false,+ cell: (info) => <DateCell value={info.getValue() as string | null} fallback="Never" />,+ },+ {+ id: "models",+ accessorKey: "models",+ meta: { title: "Models", skeleton: "chips" },+ header: "Models",+ size: 220,+ enableSorting: false,+ cell: (info) => <ModelsCell models={info.getValue() as string[] | null | undefined} />,+ },+ {+ id: "rate_limits",+ meta: { title: "Rate Limits" },+ header: "Rate Limits",+ size: 140,+ enableSorting: false,+ cell: ({ row }) => {+ const key = row.original;+ return (+ <div className="text-xs">+ <div>TPM: {key.tpm_limit !== null ? key.tpm_limit : "Unlimited"}</div>+ <div>RPM: {key.rpm_limit !== null ? key.rpm_limit : "Unlimited"}</div>+ </div>+ );+ },+ },+];++export const KEY_TABLE_HIDDEN_COLUMNS: Record<string, boolean> = {+ token: false,+ organization_alias: false,+ created_by: false,+ updated_at: false,+ expires: false,+ budget_reset_at: false,+ rate_limits: false,+};diff --git a/ui/litellm-dashboard/src/components/shared/DataTable/DataTable.test.tsx b/ui/litellm-dashboard/src/components/shared/DataTable/DataTable.test.tsxindex ef0d842ad3e..d8d4c9392dc 100644--- a/ui/litellm-dashboard/src/components/shared/DataTable/DataTable.test.tsx+++ b/ui/litellm-dashboard/src/components/shared/DataTable/DataTable.test.tsx@@ -303,6 +303,38 @@ describe("DataTable loading", () => {// per-column widths differ instead of every cell sharing one fixed widthexpect(new Set(bars.map((bar) => bar.className)).size).toBeGreaterThan(1);});++ it("renders shape-specific skeletons for badge, chips, and meter columns", () => {+ const columns: ColumnDef<Person, unknown>[] = [+ { id: "badge", header: "Badge", meta: { skeleton: "badge" }, cell: () => null },+ { id: "chips", header: "Chips", meta: { skeleton: "chips" }, cell: () => null },+ { id: "meter", header: "Meter", meta: { skeleton: "meter" }, cell: () => null },+ ];+ render(<DataTable data={CHARLIE_ALICE_BOB} columns={columns} isLoading />);++ const firstRow = screen.getAllByTestId("skeleton-row").at(0);+ const cells = Array.from(firstRow?.querySelectorAll("td") ?? []);+ const barsIn = (cell: Element | undefined) => cell?.querySelectorAll('[data-slot="skeleton"]').length ?? 0;++ // badge = a single pill, chips = three pills, meter = value bar + track bar+ expect(barsIn(cells[0])).toBe(1);+ expect(cells[0]?.querySelector('[data-slot="skeleton"]')?.className).toContain("rounded-full");+ expect(barsIn(cells[1])).toBe(3);+ expect(barsIn(cells[2])).toBe(2);+ });++ it("uses a column's renderSkeleton override when provided", () => {+ const columns: ColumnDef<Person, unknown>[] = [+ {+ id: "custom",+ header: "Custom",+ meta: { renderSkeleton: () => <div data-testid="custom-skeleton">loading</div> },+ cell: () => null,+ },+ ];+ render(<DataTable data={CHARLIE_ALICE_BOB} columns={columns} isLoading />);+ expect(screen.getAllByTestId("custom-skeleton").length).toBeGreaterThan(0);+ });});describe("DataTable column visibility", () => {diff --git a/ui/litellm-dashboard/src/components/shared/DataTable/DataTable.tsx b/ui/litellm-dashboard/src/components/shared/DataTable/DataTable.tsxindex 758ca5a597b..bc13318dd58 100644--- a/ui/litellm-dashboard/src/components/shared/DataTable/DataTable.tsx+++ b/ui/litellm-dashboard/src/components/shared/DataTable/DataTable.tsx@@ -338,7 +338,11 @@ const SKELETON_WIDTHS = ["w-[58%]", "w-[44%]", "w-[70%]", "w-[50%]", "w-[64%]",function SkeletonCell<TData>({ column, index }: { column: Column<TData, unknown> | undefined; index: number }) {const meta = column?.columnDef.meta;const width = SKELETON_WIDTHS[index % SKELETON_WIDTHS.length];- if (meta?.skeleton === "twoLine") {+ const shape = meta?.skeleton;+ if (meta?.renderSkeleton !== undefined) {+ return <>{meta.renderSkeleton()}</>;+ }+ if (shape === "twoLine") {return (<div className="flex flex-col gap-2"><Skeleton className={cn("h-3.5", width)} />@@ -346,6 +350,26 @@ function SkeletonCell<TData>({ column, index }: { column: Column<TData, unknown></div>);}+ if (shape === "badge") {+ return <Skeleton className={cn("h-5 w-16 rounded-full", meta?.numeric ? "ml-auto" : "")} />;+ }+ if (shape === "chips") {+ return (+ <div className="flex items-center gap-1.5">+ <Skeleton className="h-5 w-14 rounded-full" />+ <Skeleton className="h-5 w-20 rounded-full" />+ <Skeleton className="h-5 w-9 rounded-full opacity-65" />+ </div>+ );+ }+ if (shape === "meter") {+ return (+ <div className="flex flex-col gap-1.5">+ <Skeleton className="h-3.5 w-24" />+ <Skeleton className="h-1.5 w-full rounded-full" />+ </div>+ );+ }return <Skeleton className={cn("h-3.5", width, meta?.numeric ? "ml-auto" : "")} />;}diff --git a/ui/litellm-dashboard/src/components/shared/DataTable/columnMeta.ts b/ui/litellm-dashboard/src/components/shared/DataTable/columnMeta.tsindex 0f14c277c6f..eff4e0cb7db 100644--- a/ui/litellm-dashboard/src/components/shared/DataTable/columnMeta.ts+++ b/ui/litellm-dashboard/src/components/shared/DataTable/columnMeta.ts@@ -1,4 +1,5 @@import type { RowData } from "@tanstack/react-table";+import type * as React from "react";import type { ColumnPinnedSide, DataTableSkeletonShape } from "./types";@@ -10,5 +11,7 @@ declare module "@tanstack/react-table" {title?: string;pinned?: ColumnPinnedSide;skeleton?: DataTableSkeletonShape;+ /** Full control over this column's loading skeleton, for cells the built-in shapes can't mirror. */+ renderSkeleton?: () => React.ReactNode;}}diff --git a/ui/litellm-dashboard/src/components/shared/DataTable/types.ts b/ui/litellm-dashboard/src/components/shared/DataTable/types.tsindex f5130b4c823..672ab512ef4 100644--- a/ui/litellm-dashboard/src/components/shared/DataTable/types.ts+++ b/ui/litellm-dashboard/src/components/shared/DataTable/types.ts@@ -18,7 +18,7 @@ export type FilterMode = "none" | "client" | "server";export type ColumnResizeMode = "onEnd" | "onChange";export type DataTableSize = "compact" | "default";export type ColumnPinnedSide = "left" | "right";-export type DataTableSkeletonShape = "text" | "twoLine";+export type DataTableSkeletonShape = "text" | "twoLine" | "badge" | "chips" | "meter";export interface DataTableProps<TData extends RowData, TValue> {data: TData[];diff --git a/ui/litellm-dashboard/src/components/shared/PageHeader.test.tsx b/ui/litellm-dashboard/src/components/shared/PageHeader.test.tsxnew file mode 100644index 00000000000..f7a313271da--- /dev/null+++ b/ui/litellm-dashboard/src/components/shared/PageHeader.test.tsx@@ -0,0 +1,31 @@+import { render, screen } from "@testing-library/react";+import { describe, expect, it } from "vitest";++import { PageHeader } from "./PageHeader";++describe("PageHeader", () => {+ it("renders the title as a heading", () => {+ render(<PageHeader title="Virtual Keys" />);+ expect(screen.getByRole("heading", { name: "Virtual Keys" })).toBeInTheDocument();+ });++ it("renders the subtitle, icon, and actions when provided", () => {+ render(+ <PageHeader+ title="Virtual Keys"+ subtitle="Every key that authenticates requests"+ icon={<svg data-testid="icon" />}+ actions={<button>Create New Key</button>}+ />,+ );+ expect(screen.getByText("Every key that authenticates requests")).toBeInTheDocument();+ expect(screen.getByTestId("icon")).toBeInTheDocument();+ expect(screen.getByRole("button", { name: "Create New Key" })).toBeInTheDocument();+ });++ it("omits the optional slots when not provided", () => {+ render(<PageHeader title="Virtual Keys" />);+ expect(screen.queryByRole("button")).not.toBeInTheDocument();+ expect(document.querySelector("p")).toBeNull();+ });+});diff --git a/ui/litellm-dashboard/src/components/shared/PageHeader.tsx b/ui/litellm-dashboard/src/components/shared/PageHeader.tsxnew file mode 100644index 00000000000..34d478e1cd9--- /dev/null+++ b/ui/litellm-dashboard/src/components/shared/PageHeader.tsx@@ -0,0 +1,29 @@+"use client";++import * as React from "react";++interface PageHeaderProps {+ title: React.ReactNode;+ subtitle?: React.ReactNode;+ icon?: React.ReactNode;+ actions?: React.ReactNode;+}++export function PageHeader({ title, subtitle, icon, actions }: PageHeaderProps) {+ return (+ <div className="flex flex-wrap items-start justify-between gap-4">+ <div className="flex items-center gap-3">+ {icon != null && (+ <span className="flex size-9 flex-none items-center justify-center rounded-lg bg-primary text-primary-foreground">+ {icon}+ </span>+ )}+ <div className="min-w-0">+ <h1 className="text-xl font-semibold tracking-tight text-foreground">{title}</h1>+ {subtitle != null && <p className="mt-0.5 text-sm text-muted-foreground">{subtitle}</p>}+ </div>+ </div>+ {actions != null && <div className="flex items-center gap-2">{actions}</div>}+ </div>+ );+}diff --git a/ui/litellm-dashboard/src/components/shared/SearchSelect.test.tsx b/ui/litellm-dashboard/src/components/shared/SearchSelect.test.tsxnew file mode 100644index 00000000000..acf50d282b4--- /dev/null+++ b/ui/litellm-dashboard/src/components/shared/SearchSelect.test.tsx@@ -0,0 +1,64 @@+import { render, screen } from "@testing-library/react";+import userEvent from "@testing-library/user-event";+import { describe, expect, it, vi } from "vitest";++import { SearchSelect } from "./SearchSelect";++const OPTIONS = [+ { label: "Acme Prod", value: "team-1" },+ { label: "Growth", value: "team-2" },+ { label: "Data Team", value: "team-3" },+];++describe("SearchSelect", () => {+ it("renders the placeholder when nothing is selected", () => {+ render(<SearchSelect options={OPTIONS} onValueChange={vi.fn()} placeholder="Select Team…" />);+ expect(screen.getByPlaceholderText("Select Team…")).toBeInTheDocument();+ });++ it("shows the selected option's label in the field", () => {+ render(<SearchSelect options={OPTIONS} value="team-2" onValueChange={vi.fn()} />);+ expect(screen.getByRole("combobox")).toHaveValue("Growth");+ });++ it("shows a clear control only when a value is selected", () => {+ const { rerender } = render(<SearchSelect options={OPTIONS} onValueChange={vi.fn()} />);+ expect(document.querySelector('[data-slot="combobox-clear"]')).toBeNull();+ rerender(<SearchSelect options={OPTIONS} value="team-1" onValueChange={vi.fn()} />);+ expect(document.querySelector('[data-slot="combobox-clear"]')).not.toBeNull();+ });++ it("filters the options client-side as you type", async () => {+ const user = userEvent.setup();+ render(<SearchSelect options={OPTIONS} onValueChange={vi.fn()} />);+ const input = screen.getByRole("combobox");+ await user.click(input);+ await user.type(input, "grow");+ expect(await screen.findByText("Growth")).toBeInTheDocument();+ expect(screen.queryByText("Acme Prod")).not.toBeInTheDocument();+ });++ it("renders a muted sublabel and matches it when searching", async () => {+ const user = userEvent.setup();+ render(+ <SearchSelect+ options={[{ label: "Acme Prod", value: "team-1", sublabel: "team-abc-123" }]}+ onValueChange={vi.fn()}+ />,+ );+ const input = screen.getByRole("combobox");+ await user.click(input);+ expect(await screen.findByText("team-abc-123")).toBeInTheDocument();+ await user.type(input, "abc-123");+ expect(await screen.findByText("Acme Prod")).toBeInTheDocument();+ });++ it("selects an option and reports its value", async () => {+ const onValueChange = vi.fn();+ const user = userEvent.setup();+ render(<SearchSelect options={OPTIONS} onValueChange={onValueChange} />);+ await user.click(screen.getByRole("combobox"));+ await user.click(await screen.findByText("Growth"));+ expect(onValueChange).toHaveBeenCalledWith("team-2");+ });+});diff --git a/ui/litellm-dashboard/src/components/shared/SearchSelect.tsx b/ui/litellm-dashboard/src/components/shared/SearchSelect.tsxnew file mode 100644index 00000000000..c29e099a1c6--- /dev/null+++ b/ui/litellm-dashboard/src/components/shared/SearchSelect.tsx@@ -0,0 +1,76 @@+"use client";++import {+ Combobox,+ ComboboxContent,+ ComboboxEmpty,+ ComboboxInput,+ ComboboxItem,+ ComboboxList,+} from "@/components/ui/combobox";++export interface SearchSelectOption {+ label: string;+ value: string;+ /** Optional muted second line (e.g. an id); also matched when searching. */+ sublabel?: string;+}++interface SearchSelectProps {+ options: SearchSelectOption[];+ value?: string;+ onValueChange: (value: string) => void;+ placeholder?: string;+ emptyText?: string;+ disabled?: boolean;+ className?: string;+}++export function SearchSelect({+ options,+ value,+ onValueChange,+ placeholder = "Select…",+ emptyText = "No results",+ disabled = false,+ className,+}: SearchSelectProps) {+ const selected = options.find((option) => option.value === value) ?? null;++ return (+ <Combobox+ items={options}+ value={selected}+ onValueChange={(item: SearchSelectOption | null) => onValueChange(item?.value ?? "")}+ isItemEqualToValue={(a: SearchSelectOption, b: SearchSelectOption) => a.value === b.value}+ itemToStringLabel={(item: SearchSelectOption) => item.label}+ filter={(item: SearchSelectOption, query: string) => {+ const q = query.trim().toLowerCase();+ if (!q) return true;+ return item.label.toLowerCase().includes(q) || (item.sublabel?.toLowerCase().includes(q) ?? false);+ }}+ disabled={disabled}+ >+ <ComboboxInput+ placeholder={placeholder}+ showClear={value != null && value !== ""}+ className={`w-full ${className ?? ""}`}+ />+ <ComboboxContent>+ <ComboboxEmpty>{emptyText}</ComboboxEmpty>+ <ComboboxList>+ {(item: SearchSelectOption) => (+ <ComboboxItem key={item.value} value={item}>+ <span className="flex min-w-0 flex-col">+ <span className="truncate">{item.label}</span>+ {item.sublabel != null && item.sublabel !== "" && (+ <span className="truncate text-xs text-muted-foreground">{item.sublabel}</span>+ )}+ </span>+ </ComboboxItem>+ )}+ </ComboboxList>+ </ComboboxContent>+ </Combobox>+ );+}diff --git a/ui/litellm-dashboard/src/components/shared/table_cells/identity_cell.test.tsx b/ui/litellm-dashboard/src/components/shared/table_cells/identity_cell.test.tsxnew file mode 100644index 00000000000..db4e93c7cb2--- /dev/null+++ b/ui/litellm-dashboard/src/components/shared/table_cells/identity_cell.test.tsx@@ -0,0 +1,38 @@+import { render, screen } from "@testing-library/react";+import userEvent from "@testing-library/user-event";+import { describe, expect, it, vi } from "vitest";++import { IdentityCell } from "./identity_cell";++describe("IdentityCell", () => {+ it("renders the title", () => {+ render(<IdentityCell title="prod-gateway" />);+ expect(screen.getByText("prod-gateway")).toBeInTheDocument();+ });++ it("renders the subtitle and an inline badge together", () => {+ render(<IdentityCell title="prod-gateway" subtitle="sk-...v0Pw" badge={<span>Active</span>} />);+ expect(screen.getByText("sk-...v0Pw")).toBeInTheDocument();+ expect(screen.getByText("Active")).toBeInTheDocument();+ });++ it("omits the subtitle row when there is no subtitle or badge", () => {+ render(<IdentityCell title="a" />);+ expect(document.querySelector("span.font-mono")).toBeNull();+ });++ it("renders a static div (no button) when not clickable", () => {+ render(<IdentityCell title="a" subtitle="b" />);+ expect(screen.queryByRole("button")).not.toBeInTheDocument();+ });++ it("renders a clickable button and fires onClick", async () => {+ const onClick = vi.fn();+ const user = userEvent.setup();+ render(<IdentityCell title="prod-gateway" subtitle="sk-...v0Pw" onClick={onClick} />);+ const button = screen.getByRole("button");+ expect(button.querySelector(".lucide-chevron-right")).not.toBeNull();+ await user.click(button);+ expect(onClick).toHaveBeenCalledTimes(1);+ });+});diff --git a/ui/litellm-dashboard/src/components/shared/table_cells/identity_cell.tsx b/ui/litellm-dashboard/src/components/shared/table_cells/identity_cell.tsxnew file mode 100644index 00000000000..4d3e3d8e4dd--- /dev/null+++ b/ui/litellm-dashboard/src/components/shared/table_cells/identity_cell.tsx@@ -0,0 +1,48 @@+"use client";++import { ChevronRight } from "lucide-react";+import * as React from "react";++import { cn } from "@/lib/cva.config";++interface IdentityCellProps {+ title: React.ReactNode;+ subtitle?: React.ReactNode;+ badge?: React.ReactNode;+ onClick?: () => void;+ className?: string;+ titleClassName?: string;+}++export function IdentityCell({ title, subtitle, badge, onClick, className, titleClassName }: IdentityCellProps) {+ const hasSubtitleRow = (subtitle != null && subtitle !== "") || badge != null;++ const body = (+ <div className="flex min-w-0 flex-col gap-0.5">+ <span className={cn("truncate text-sm font-medium text-foreground", titleClassName)}>{title}</span>+ {hasSubtitleRow && (+ <span className="flex min-w-0 items-center gap-2">+ {subtitle != null && subtitle !== "" && (+ <span className="truncate font-mono text-xs text-muted-foreground">{subtitle}</span>+ )}+ {badge}+ </span>+ )}+ </div>+ );++ if (onClick != null) {+ return (+ <button+ type="button"+ onClick={onClick}+ className={cn("group flex w-full items-center gap-2 rounded-md py-1 text-left", className)}+ >+ {body}+ <ChevronRight className="ml-auto size-4 shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100" />+ </button>+ );+ }++ return <div className={cn("min-w-0", className)}>{body}</div>;+}diff --git a/ui/litellm-dashboard/src/components/shared/table_cells/index.ts b/ui/litellm-dashboard/src/components/shared/table_cells/index.tsindex e189413d43d..9fdd04d169c 100644--- a/ui/litellm-dashboard/src/components/shared/table_cells/index.ts+++ b/ui/litellm-dashboard/src/components/shared/table_cells/index.ts@@ -1,5 +1,8 @@export { CellTooltip } from "./cell_tooltip";export { DateCell, formatCellDate, formatFullTimestamp, type DatePrecision } from "./date_cell";export { IdCell, type IdCellVariant } from "./id_cell";+export { IdentityCell } from "./identity_cell";+export { ModelsCell } from "./models_cell";export { MoneyCell } from "./money_cell";+export { SpendBudgetCell } from "./spend_budget_cell";export { StatusBadge, type StatusTone } from "./status_badge";diff --git a/ui/litellm-dashboard/src/components/shared/table_cells/models_cell.test.tsx b/ui/litellm-dashboard/src/components/shared/table_cells/models_cell.test.tsxnew file mode 100644index 00000000000..d3fad1d3244--- /dev/null+++ b/ui/litellm-dashboard/src/components/shared/table_cells/models_cell.test.tsx@@ -0,0 +1,45 @@+import { render, screen } from "@testing-library/react";+import userEvent from "@testing-library/user-event";+import { describe, expect, it } from "vitest";++import { ModelsCell } from "./models_cell";++describe("ModelsCell", () => {+ it("shows 'All Proxy Models' when the list is empty, null, or undefined", () => {+ const { rerender } = render(<ModelsCell models={[]} />);+ expect(screen.getByText("All Proxy Models")).toBeInTheDocument();+ rerender(<ModelsCell models={null} />);+ expect(screen.getByText("All Proxy Models")).toBeInTheDocument();+ rerender(<ModelsCell models={undefined} />);+ expect(screen.getByText("All Proxy Models")).toBeInTheDocument();+ });++ it("renders every model with no overflow badge when at or below the limit", () => {+ render(<ModelsCell models={["gpt-4o", "claude-sonnet-4-5", "o3-mini"]} maxVisible={3} />);+ expect(screen.getByText("gpt-4o")).toBeInTheDocument();+ expect(screen.getByText("claude-sonnet-4-5")).toBeInTheDocument();+ expect(screen.getByText("o3-mini")).toBeInTheDocument();+ expect(screen.queryByText(/more$/)).not.toBeInTheDocument();+ });++ it("collapses models beyond the limit into a '+N more' badge", () => {+ render(<ModelsCell models={["a", "b", "c", "d", "e"]} maxVisible={2} />);+ expect(screen.getByText("a")).toBeInTheDocument();+ expect(screen.getByText("b")).toBeInTheDocument();+ expect(screen.queryByText("c")).not.toBeInTheDocument();+ expect(screen.getByText("+3 more")).toBeInTheDocument();+ });++ it("reveals the hidden models in a tooltip on hover", async () => {+ const user = userEvent.setup();+ render(<ModelsCell models={["a", "b", "c", "d"]} maxVisible={2} />);+ await user.hover(screen.getByText("+2 more"));+ expect(await screen.findByText("c")).toBeInTheDocument();+ expect(await screen.findByText("d")).toBeInTheDocument();+ });++ it("labels the all-proxy-models wildcard", () => {+ render(<ModelsCell models={["all-proxy-models"]} />);+ expect(screen.getByText("All Proxy Models")).toBeInTheDocument();+ });+});diff --git a/ui/litellm-dashboard/src/components/shared/table_cells/models_cell.tsx b/ui/litellm-dashboard/src/components/shared/table_cells/models_cell.tsxnew file mode 100644index 00000000000..712d8511c78--- /dev/null+++ b/ui/litellm-dashboard/src/components/shared/table_cells/models_cell.tsx@@ -0,0 +1,56 @@+"use client";++import { getModelDisplayName } from "@/components/key_team_helpers/fetch_available_models_team_key";+import { Badge } from "@/components/ui/badge";++import { CellTooltip } from "./cell_tooltip";++interface ModelsCellProps {+ models: string[] | null | undefined;+ maxVisible?: number;+}++const WILDCARD_MODEL = "all-proxy-models";++const formatModel = (model: string): string => {+ if (model === WILDCARD_MODEL) {+ return "All Proxy Models";+ }+ const name = getModelDisplayName(model);+ return name.length > 30 ? `${name.slice(0, 30)}...` : name;+};++export function ModelsCell({ models, maxVisible = 3 }: ModelsCellProps) {+ if (!Array.isArray(models) || models.length === 0) {+ return <Badge variant="secondary">All Proxy Models</Badge>;+ }++ const visible = models.slice(0, maxVisible);+ const overflow = models.slice(maxVisible);++ return (+ <div className="flex flex-wrap items-center gap-1">+ {visible.map((model, index) => (+ <Badge key={index} variant={model === WILDCARD_MODEL ? "secondary" : "outline"}>+ {formatModel(model)}+ </Badge>+ ))}+ {overflow.length > 0 && (+ <CellTooltip+ content={+ <div className="flex max-w-[280px] flex-col gap-0.5">+ {overflow.map((model, index) => (+ <span key={index}>{formatModel(model)}</span>+ ))}+ </div>+ }+ trigger={+ <Badge variant="outline" className="cursor-default">+ +{overflow.length} more+ </Badge>+ }+ />+ )}+ </div>+ );+}diff --git a/ui/litellm-dashboard/src/components/shared/table_cells/spend_budget_cell.test.tsx b/ui/litellm-dashboard/src/components/shared/table_cells/spend_budget_cell.test.tsxnew file mode 100644index 00000000000..707441aef1d--- /dev/null+++ b/ui/litellm-dashboard/src/components/shared/table_cells/spend_budget_cell.test.tsx@@ -0,0 +1,53 @@+import { render, screen } from "@testing-library/react";+import { describe, expect, it } from "vitest";++import { SpendBudgetCell } from "./spend_budget_cell";++const indicator = (container: HTMLElement) => container.querySelector('[data-slot="meter-indicator"]');++describe("SpendBudgetCell", () => {+ it("shows Unlimited and renders no meter when there is no budget", () => {+ const { container } = render(<SpendBudgetCell spend={0.5} maxBudget={null} />);+ expect(screen.getByText("· Unlimited")).toBeInTheDocument();+ expect(screen.queryByRole("meter")).not.toBeInTheDocument();+ expect(indicator(container)).toBeNull();+ });++ it("shows $0.00 for zero or undefined spend, never a hyphen", () => {+ const { rerender } = render(<SpendBudgetCell spend={0} maxBudget={100} />);+ expect(screen.getByText("$0.00")).toBeInTheDocument();+ expect(screen.queryByText("-")).not.toBeInTheDocument();+ rerender(<SpendBudgetCell spend={null} maxBudget={null} />);+ expect(screen.getByText("$0.00")).toBeInTheDocument();+ expect(screen.queryByText("-")).not.toBeInTheDocument();+ });++ it("renders a meter carrying the spend and budget when a budget exists", () => {+ render(<SpendBudgetCell spend={25} maxBudget={100} />);+ const meter = screen.getByRole("meter");+ expect(meter).toHaveAttribute("aria-valuenow", "25");+ expect(meter).toHaveAttribute("aria-valuemax", "100");+ expect(screen.getByText("of $100")).toBeInTheDocument();+ });++ it("keeps the default tone below 80% usage", () => {+ const { container } = render(<SpendBudgetCell spend={50} maxBudget={100} />);+ expect(indicator(container)?.className).toContain("bg-primary");+ });++ it("switches to the warning tone at 80% usage", () => {+ const { container } = render(<SpendBudgetCell spend={80} maxBudget={100} />);+ expect(indicator(container)?.className).toContain("bg-amber-500");+ });++ it("switches to the over tone above 100% usage", () => {+ const { container } = render(<SpendBudgetCell spend={150} maxBudget={100} />);+ expect(indicator(container)?.className).toContain("bg-destructive");+ });++ it("falls back to the team budget and labels it", () => {+ render(<SpendBudgetCell spend={10} maxBudget={null} teamMaxBudget={200} />);+ expect(screen.getByText("of $200 (Team)")).toBeInTheDocument();+ expect(screen.getByRole("meter")).toHaveAttribute("aria-valuemax", "200");+ });+});diff --git a/ui/litellm-dashboard/src/components/shared/table_cells/spend_budget_cell.tsx b/ui/litellm-dashboard/src/components/shared/table_cells/spend_budget_cell.tsxnew file mode 100644index 00000000000..10956f23b1c--- /dev/null+++ b/ui/litellm-dashboard/src/components/shared/table_cells/spend_budget_cell.tsx@@ -0,0 +1,44 @@+"use client";++import { Meter, MeterIndicator, MeterTrack } from "@/components/ui/meter";+import { formatNumberWithCommas, getSpendString } from "@/utils/dataUtils";++interface SpendBudgetCellProps {+ spend: number | null | undefined;+ maxBudget: number | null | undefined;+ teamMaxBudget?: number | null;+}++const meterTone = (pct: number): "default" | "warning" | "over" => {+ if (pct > 100) return "over";+ if (pct >= 80) return "warning";+ return "default";+};++export function SpendBudgetCell({ spend, maxBudget, teamMaxBudget }: SpendBudgetCellProps) {+ const spendValue = typeof spend === "number" && !Number.isNaN(spend) ? spend : 0;+ const budget = maxBudget ?? teamMaxBudget ?? null;+ const isTeamBudget = maxBudget == null && teamMaxBudget != null;+ const hasBudget = typeof budget === "number" && budget > 0;+ const pct = hasBudget ? (spendValue / budget) * 100 : 0;++ const spendText = spendValue > 0 ? getSpendString(spendValue, 4) : "$0.00";+ const budgetLabel =+ budget === null ? "· Unlimited" : `of $${formatNumberWithCommas(budget)}${isTeamBudget ? " (Team)" : ""}`;++ return (+ <div className="flex min-w-[130px] flex-col gap-1">+ <div className="whitespace-nowrap text-xs">+ <span className="font-medium tabular-nums text-foreground">{spendText}</span>{" "}+ <span className="text-muted-foreground">{budgetLabel}</span>+ </div>+ {hasBudget && (+ <Meter value={spendValue} max={budget} aria-valuetext={`${spendText} of $${formatNumberWithCommas(budget)}`}>+ <MeterTrack>+ <MeterIndicator tone={meterTone(pct)} />+ </MeterTrack>+ </Meter>+ )}+ </div>+ );+}diff --git a/ui/litellm-dashboard/src/components/ui/combobox.tsx b/ui/litellm-dashboard/src/components/ui/combobox.tsxnew file mode 100644index 00000000000..2854928140e--- /dev/null+++ b/ui/litellm-dashboard/src/components/ui/combobox.tsx@@ -0,0 +1,266 @@+"use client";++import * as React from "react";+import { Combobox as ComboboxPrimitive } from "@base-ui/react";++import { cn } from "@/lib/cva.config";+import { Button } from "@/components/ui/button";+import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput } from "@/components/ui/input-group";+import { ChevronDownIcon, XIcon, CheckIcon } from "lucide-react";++const Combobox = ComboboxPrimitive.Root;++function ComboboxValue({ ...props }: ComboboxPrimitive.Value.Props) {+ return <ComboboxPrimitive.Value data-slot="combobox-value" {...props} />;+}++const ComboboxTrigger = React.forwardRef<+ React.ComponentRef<typeof ComboboxPrimitive.Trigger>,+ ComboboxPrimitive.Trigger.Props+>(({ className, children, ...props }, ref) => {+ return (+ <ComboboxPrimitive.Trigger+ ref={ref}+ data-slot="combobox-trigger"+ className={cn("[&_svg:not([class*='size-'])]:size-4", className)}+ {...props}+ >+ {children}+ <ChevronDownIcon className="pointer-events-none size-4 text-muted-foreground" />+ </ComboboxPrimitive.Trigger>+ );+});+ComboboxTrigger.displayName = "ComboboxTrigger";++function ComboboxClear({ className, ...props }: ComboboxPrimitive.Clear.Props) {+ return (+ <ComboboxPrimitive.Clear+ data-slot="combobox-clear"+ render={<InputGroupButton variant="ghost" size="icon-xs" />}+ className={cn(className)}+ {...props}+ >+ <XIcon className="pointer-events-none" />+ </ComboboxPrimitive.Clear>+ );+}++function ComboboxInput({+ className,+ children,+ disabled = false,+ showTrigger = true,+ showClear = false,+ ...props+}: ComboboxPrimitive.Input.Props & {+ showTrigger?: boolean;+ showClear?: boolean;+}) {+ return (+ <InputGroup className={cn("w-auto", className)}>+ <ComboboxPrimitive.Input render={<InputGroupInput disabled={disabled} />} {...props} />+ <InputGroupAddon align="inline-end">+ {showTrigger && (+ <InputGroupButton+ size="icon-xs"+ variant="ghost"+ render={<ComboboxTrigger />}+ data-slot="input-group-button"+ className="group-has-data-[slot=combobox-clear]/input-group:hidden data-pressed:bg-transparent"+ disabled={disabled}+ />+ )}+ {showClear && <ComboboxClear disabled={disabled} />}+ </InputGroupAddon>+ {children}+ </InputGroup>+ );+}++function ComboboxContent({+ className,+ side = "bottom",+ sideOffset = 6,+ align = "start",+ alignOffset = 0,+ anchor,+ ...props+}: ComboboxPrimitive.Popup.Props &+ Pick<ComboboxPrimitive.Positioner.Props, "side" | "align" | "sideOffset" | "alignOffset" | "anchor">) {+ return (+ <ComboboxPrimitive.Portal>+ <ComboboxPrimitive.Positioner+ side={side}+ sideOffset={sideOffset}+ align={align}+ alignOffset={alignOffset}+ anchor={anchor}+ className="isolate z-50"+ >+ <ComboboxPrimitive.Popup+ data-slot="combobox-content"+ data-chips={!!anchor}+ className={cn(+ "group/combobox-content relative max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-[calc(var(--anchor-width)+--spacing(7))] origin-(--transform-origin) overflow-hidden rounded-md bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[chips=true]:min-w-(--anchor-width) data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 *:data-[slot=input-group]:m-1 *:data-[slot=input-group]:mb-0 *:data-[slot=input-group]:h-8 *:data-[slot=input-group]:border-input/30 *:data-[slot=input-group]:bg-input/30 *:data-[slot=input-group]:shadow-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",+ className,+ )}+ {...props}+ />+ </ComboboxPrimitive.Positioner>+ </ComboboxPrimitive.Portal>+ );+}++function ComboboxList({ className, ...props }: ComboboxPrimitive.List.Props) {+ return (+ <ComboboxPrimitive.List+ data-slot="combobox-list"+ className={cn(+ "no-scrollbar max-h-[min(calc(--spacing(72)---spacing(9)),calc(var(--available-height)---spacing(9)))] scroll-py-1 overflow-y-auto overscroll-contain p-1 data-empty:p-0",+ className,+ )}+ {...props}+ />+ );+}++function ComboboxItem({ className, children, ...props }: ComboboxPrimitive.Item.Props) {+ return (+ <ComboboxPrimitive.Item+ data-slot="combobox-item"+ className={cn(+ "relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-highlighted:bg-accent data-highlighted:text-accent-foreground not-data-[variant=destructive]:data-highlighted:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",+ className,+ )}+ {...props}+ >+ {children}+ <ComboboxPrimitive.ItemIndicator+ render={<span className="pointer-events-none absolute right-2 flex size-4 items-center justify-center" />}+ >+ <CheckIcon className="pointer-events-none" />+ </ComboboxPrimitive.ItemIndicator>+ </ComboboxPrimitive.Item>+ );+}++function ComboboxGroup({ className, ...props }: ComboboxPrimitive.Group.Props) {+ return <ComboboxPrimitive.Group data-slot="combobox-group" className={cn(className)} {...props} />;+}++function ComboboxLabel({ className, ...props }: ComboboxPrimitive.GroupLabel.Props) {+ return (+ <ComboboxPrimitive.GroupLabel+ data-slot="combobox-label"+ className={cn("px-2 py-1.5 text-xs text-muted-foreground", className)}+ {...props}+ />+ );+}++function ComboboxCollection({ ...props }: ComboboxPrimitive.Collection.Props) {+ return <ComboboxPrimitive.Collection data-slot="combobox-collection" {...props} />;+}++function ComboboxEmpty({ className, ...props }: ComboboxPrimitive.Empty.Props) {+ return (+ <ComboboxPrimitive.Empty+ data-slot="combobox-empty"+ className={cn(+ "hidden w-full justify-center py-2 text-center text-sm text-muted-foreground group-data-empty/combobox-content:flex",+ className,+ )}+ {...props}+ />+ );+}++function ComboboxSeparator({ className, ...props }: ComboboxPrimitive.Separator.Props) {+ return (+ <ComboboxPrimitive.Separator+ data-slot="combobox-separator"+ className={cn("-mx-1 my-1 h-px bg-border", className)}+ {...props}+ />+ );+}++function ComboboxChips({+ className,+ ...props+}: React.ComponentPropsWithRef<typeof ComboboxPrimitive.Chips> & ComboboxPrimitive.Chips.Props) {+ return (+ <ComboboxPrimitive.Chips+ data-slot="combobox-chips"+ className={cn(+ "flex min-h-9 flex-wrap items-center gap-1.5 rounded-md border border-input bg-transparent bg-clip-padding px-2.5 py-1.5 text-sm shadow-xs transition-[color,box-shadow] focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50 has-aria-invalid:border-destructive has-aria-invalid:ring-3 has-aria-invalid:ring-destructive/20 has-data-[slot=combobox-chip]:px-1.5 dark:bg-input/30 dark:has-aria-invalid:border-destructive/50 dark:has-aria-invalid:ring-destructive/40",+ className,+ )}+ {...props}+ />+ );+}++function ComboboxChip({+ className,+ children,+ showRemove = true,+ ...props+}: ComboboxPrimitive.Chip.Props & {+ showRemove?: boolean;+}) {+ return (+ <ComboboxPrimitive.Chip+ data-slot="combobox-chip"+ className={cn(+ "flex h-[calc(--spacing(5.5))] w-fit items-center justify-center gap-1 rounded-sm bg-muted px-1.5 text-xs font-medium whitespace-nowrap text-foreground has-disabled:pointer-events-none has-disabled:cursor-not-allowed has-disabled:opacity-50 has-data-[slot=combobox-chip-remove]:pr-0",+ className,+ )}+ {...props}+ >+ {children}+ {showRemove && (+ <ComboboxPrimitive.ChipRemove+ render={<Button variant="ghost" size="icon-xs" />}+ className="-ml-1 opacity-50 hover:opacity-100"+ data-slot="combobox-chip-remove"+ >+ <XIcon className="pointer-events-none" />+ </ComboboxPrimitive.ChipRemove>+ )}+ </ComboboxPrimitive.Chip>+ );+}++function ComboboxChipsInput({ className, ...props }: ComboboxPrimitive.Input.Props) {+ return (+ <ComboboxPrimitive.Input+ data-slot="combobox-chip-input"+ className={cn("min-w-16 flex-1 outline-none", className)}+ {...props}+ />+ );+}++function useComboboxAnchor() {+ return React.useRef<HTMLDivElement | null>(null);+}++export {+ Combobox,+ ComboboxInput,+ ComboboxContent,+ ComboboxList,+ ComboboxItem,+ ComboboxGroup,+ ComboboxLabel,+ ComboboxCollection,+ ComboboxEmpty,+ ComboboxSeparator,+ ComboboxChips,+ ComboboxChip,+ ComboboxChipsInput,+ ComboboxTrigger,+ ComboboxValue,+ useComboboxAnchor,+};diff --git a/ui/litellm-dashboard/src/components/ui/input-group.tsx b/ui/litellm-dashboard/src/components/ui/input-group.tsxnew file mode 100644index 00000000000..8ee9b7f17bd--- /dev/null+++ b/ui/litellm-dashboard/src/components/ui/input-group.tsx@@ -0,0 +1,140 @@+"use client";++import * as React from "react";+import { type VariantProps } from "cva";++import { cn, cva } from "@/lib/cva.config";+import { Button } from "@/components/ui/button";+import { Input } from "@/components/ui/input";+import { Textarea } from "@/components/ui/textarea";++function InputGroup({ className, ...props }: React.ComponentProps<"div">) {+ return (+ <div+ data-slot="input-group"+ role="group"+ className={cn(+ "group/input-group relative flex h-9 w-full min-w-0 items-center rounded-md border border-input shadow-xs transition-[color,box-shadow] outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5",+ className,+ )}+ {...props}+ />+ );+}++const inputGroupAddonVariants = cva({+ base: "flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4",+ variants: {+ align: {+ "inline-start": "order-first pl-2 has-[>button]:-ml-1 has-[>kbd]:ml-[-0.15rem]",+ "inline-end": "order-last pr-2 has-[>button]:-mr-1 has-[>kbd]:mr-[-0.15rem]",+ "block-start":+ "order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2",+ "block-end": "order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2",+ },+ },+ defaultVariants: {+ align: "inline-start",+ },+});++function InputGroupAddon({+ className,+ align = "inline-start",+ ...props+}: React.ComponentProps<"div"> & VariantProps<typeof inputGroupAddonVariants>) {+ return (+ <div+ role="group"+ data-slot="input-group-addon"+ data-align={align}+ className={cn(inputGroupAddonVariants({ align }), className)}+ onClick={(e) => {+ if ((e.target as HTMLElement).closest("button")) {+ return;+ }+ e.currentTarget.parentElement?.querySelector("input")?.focus();+ }}+ {...props}+ />+ );+}++const inputGroupButtonVariants = cva({+ base: "flex items-center gap-2 text-sm shadow-none",+ variants: {+ size: {+ xs: "h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5",+ sm: "",+ "icon-xs": "size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0",+ "icon-sm": "size-8 p-0 has-[>svg]:p-0",+ },+ },+ defaultVariants: {+ size: "xs",+ },+});++const InputGroupButton = React.forwardRef<+ React.ComponentRef<typeof Button>,+ Omit<React.ComponentProps<typeof Button>, "size" | "type"> &+ VariantProps<typeof inputGroupButtonVariants> & {+ type?: "button" | "submit" | "reset";+ }+>(({ className, type = "button", variant = "ghost", size = "xs", ...props }, ref) => {+ return (+ <Button+ ref={ref}+ type={type}+ data-size={size}+ variant={variant}+ className={cn(inputGroupButtonVariants({ size }), className)}+ {...props}+ />+ );+});+InputGroupButton.displayName = "InputGroupButton";++function InputGroupText({ className, ...props }: React.ComponentProps<"span">) {+ return (+ <span+ className={cn(+ "flex items-center gap-2 text-sm text-muted-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",+ className,+ )}+ {...props}+ />+ );+}++const InputGroupInput = React.forwardRef<HTMLInputElement, React.ComponentPropsWithoutRef<"input">>(+ ({ className, ...props }, ref) => {+ return (+ <Input+ ref={ref}+ data-slot="input-group-control"+ className={cn(+ "flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 aria-invalid:ring-0 dark:bg-transparent",+ className,+ )}+ {...props}+ />+ );+ },+);+InputGroupInput.displayName = "InputGroupInput";++function InputGroupTextarea({ className, ...props }: React.ComponentProps<"textarea">) {+ return (+ <Textarea+ data-slot="input-group-control"+ className={cn(+ "flex-1 resize-none rounded-none border-0 bg-transparent py-2 shadow-none ring-0 focus-visible:ring-0 aria-invalid:ring-0 dark:bg-transparent",+ className,+ )}+ {...props}+ />+ );+}++export { InputGroup, InputGroupAddon, InputGroupButton, InputGroupText, InputGroupInput, InputGroupTextarea };diff --git a/ui/litellm-dashboard/src/components/ui/textarea.tsx b/ui/litellm-dashboard/src/components/ui/textarea.tsxnew file mode 100644index 00000000000..591f8a0e63b--- /dev/null+++ b/ui/litellm-dashboard/src/components/ui/textarea.tsx@@ -0,0 +1,18 @@+import * as React from "react";++import { cn } from "@/lib/cva.config";++function Textarea({ className, ...props }: React.ComponentProps<"textarea">) {+ return (+ <textarea+ data-slot="textarea"+ className={cn(+ "flex field-sizing-content min-h-16 w-full rounded-md border border-input bg-transparent px-2.5 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",+ className,+ )}+ {...props}+ />+ );+}++export { Textarea };diff --git a/ui/litellm-dashboard/src/components/user_dashboard.tsx b/ui/litellm-dashboard/src/components/user_dashboard.tsxindex 689b5680fcc..8d30f9f2c86 100644--- a/ui/litellm-dashboard/src/components/user_dashboard.tsx+++ b/ui/litellm-dashboard/src/components/user_dashboard.tsx@@ -288,18 +288,21 @@ const UserDashboard: React.FC<UserDashboardProps> = ({<div className="w-full mx-4 h-[75vh]"><Grid numItems={1} className="gap-2 p-8 w-full mt-2"><Col numColSpan={1} className="flex flex-col gap-2">- {canCreateKey && (- <CreateKey- key={selectedTeam ? selectedTeam.team_id : null}- team={selectedTeam as Team | null}- teams={teams as Team[]}- data={keys}- addKey={addKey}- autoOpenCreate={autoOpenCreate}- prefillData={prefillData}- />- )}- <VirtualKeysTable />+ <VirtualKeysTable+ headerActions={+ canCreateKey ? (+ <CreateKey+ key={selectedTeam ? selectedTeam.team_id : null}+ team={selectedTeam as Team | null}+ teams={teams as Team[]}+ data={keys}+ addKey={addKey}+ autoOpenCreate={autoOpenCreate}+ prefillData={prefillData}+ />+ ) : undefined+ }+ /></Col></Grid></div>