Skip to content

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]

[Fix] UI - Virtual Keys: Reset refetch button on error so user can retry

yuneng-jiang129ed1014b44
diff --git a/ui/litellm-dashboard/src/components/VirtualKeysPage/VirtualKeysTable.test.tsx b/ui/litellm-dashboard/src/components/VirtualKeysPage/VirtualKeysTable.test.tsx
index d7322d6d760..35f87e8770e 100644
--- a/ui/litellm-dashboard/src/components/VirtualKeysPage/VirtualKeysTable.test.tsx
+++ b/ui/litellm-dashboard/src/components/VirtualKeysPage/VirtualKeysTable.test.tsx
@@ -854,4 +854,20 @@ describe("refetch button", () => {
expect(mockRefetch).toHaveBeenCalledTimes(1);
});
+
+ it("should show Fetch button enabled on error so user can retry", () => {
+ mockUseKeys.mockReturnValue({
+ data: null,
+ isPending: false,
+ isFetching: false,
+ isError: true,
+ refetch: vi.fn(),
+ } as any);
+
+ renderWithProviders(<VirtualKeysTable {...defaultMockProps} />);
+
+ const fetchButton = screen.getByTitle("Fetch data");
+ expect(fetchButton).not.toBeDisabled();
+ expect(screen.getByText("Fetch")).toBeInTheDocument();
+ });
});
diff --git a/ui/litellm-dashboard/src/components/VirtualKeysPage/VirtualKeysTable.tsx b/ui/litellm-dashboard/src/components/VirtualKeysPage/VirtualKeysTable.tsx
index b4588a899d4..d9c590938fb 100644
--- a/ui/litellm-dashboard/src/components/VirtualKeysPage/VirtualKeysTable.tsx
+++ b/ui/litellm-dashboard/src/components/VirtualKeysPage/VirtualKeysTable.tsx
@@ -81,6 +81,7 @@ export function VirtualKeysTable({ teams, organizations, onSortChange, currentSo
data: keys,
isPending: isLoading,
isFetching,
+ isError,
refetch,
} = useKeys(tablePagination.pageIndex + 1, tablePagination.pageSize, {
sortBy: sortBy || undefined,
@@ -100,7 +101,7 @@ export function VirtualKeysTable({ teams, organizations, onSortChange, currentSo
// 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;
+ const isButtonLoading = (isFetching || isFetchingDeferred) && !isError;
const handleRefresh = () => {
refetch();