diff --git a/ui/litellm-dashboard/src/components/VirtualKeysPage/VirtualKeysTable.test.tsx b/ui/litellm-dashboard/src/components/VirtualKeysPage/VirtualKeysTable.test.tsx index 93f860333d8..c69662b69dc 100644 --- a/ui/litellm-dashboard/src/components/VirtualKeysPage/VirtualKeysTable.test.tsx +++ b/ui/litellm-dashboard/src/components/VirtualKeysPage/VirtualKeysTable.test.tsx @@ -182,6 +182,8 @@ const lastSearchParam = (onUrlUpdate: Mock, name: string) = const lastKeyParam = (onUrlUpdate: Mock) => lastSearchParam(onUrlUpdate, "key"); +const lastHistoryMode = (onUrlUpdate: Mock) => onUrlUpdate.mock.calls.at(-1)?.[0].options.history; + beforeEach(() => { vi.clearAllMocks(); @@ -377,6 +379,7 @@ it("clicking the key cell deep-links via ?key=", async () => { await waitFor(() => { expect(lastKeyParam(onUrlUpdate)).toBe(mockKey.token); }); + expect(lastHistoryMode(onUrlUpdate)).toBe("push"); }); it("renders KeyInfoView when the URL has ?key= for a key on the current page, without refetching it", async () => { @@ -417,6 +420,7 @@ it("repoints ?key= to the rotated hash once the regenerate dialog is dismissed", await waitFor(() => { expect(lastKeyParam(onUrlUpdate)).toBe("rotated-hash-456"); }); + expect(lastHistoryMode(onUrlUpdate)).toBe("replace"); }); it("fetches the key by id when the URL has ?key= for a key not in the loaded page", async () => { diff --git a/ui/litellm-dashboard/src/components/VirtualKeysPage/VirtualKeysTable.tsx b/ui/litellm-dashboard/src/components/VirtualKeysPage/VirtualKeysTable.tsx index 8ec8b6d0c3f..c424966a0a3 100644 --- a/ui/litellm-dashboard/src/components/VirtualKeysPage/VirtualKeysTable.tsx +++ b/ui/litellm-dashboard/src/components/VirtualKeysPage/VirtualKeysTable.tsx @@ -217,7 +217,7 @@ export function VirtualKeysTable({ headerActions }: VirtualKeysTableProps) { (updated: Partial) => { const rotatedToken = updated.token ?? updated.token_id; if (!rotatedToken || rotatedToken === selectedKeyId) return; - void setSelectedKeyId(rotatedToken); + void setSelectedKeyId(rotatedToken, { history: "replace" }); void refetch(); }, [refetch, selectedKeyId, setSelectedKeyId],