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
fix(ui): hold the landing until the role hydrates before deciding the redirect
Tin Chi Lo531854db4eb8
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/page.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/page.test.tsxindex affcca401f2..89975f231aa 100644--- a/ui/litellm-dashboard/src/app/(dashboard)/page.test.tsx+++ b/ui/litellm-dashboard/src/app/(dashboard)/page.test.tsx@@ -96,6 +96,21 @@ describe("dashboard landing keyless redirect", () => {expect(mockUseKeys.mock.calls[0][3]).toBe(false);});+ it("holds the loading screen on the landing until the role hydrates, instead of flashing the dashboard", () => {+ state.userRole = "";+ render(<CreateKeyPage />);+ expect(screen.getByTestId("loading-screen")).toBeInTheDocument();+ expect(screen.queryByTestId("api-keys-dashboard")).not.toBeInTheDocument();+ expect(mockReplace).not.toHaveBeenCalled();+ });++ it("does not hold the dashboard for an unhydrated role outside the post-login landing", () => {+ state.login = null;+ state.userRole = "";+ render(<CreateKeyPage />);+ expect(screen.getByTestId("api-keys-dashboard")).toBeInTheDocument();+ });+it("holds the loading screen while the key lookup is in flight", () => {state.keysLoading = true;render(<CreateKeyPage />);diff --git a/ui/litellm-dashboard/src/app/(dashboard)/page.tsx b/ui/litellm-dashboard/src/app/(dashboard)/page.tsxindex 682ba0bbcb2..c43ba12985d 100644--- a/ui/litellm-dashboard/src/app/(dashboard)/page.tsx+++ b/ui/litellm-dashboard/src/app/(dashboard)/page.tsx@@ -93,10 +93,12 @@ function CreateKeyPageContent() {const isPostLoginLanding = searchParams.get("login") === "success";const isSignedIn = !authLoading && Boolean(token);+ const isAwaitingRole = isPostLoginLanding && isSignedIn && userRole === "";const shouldCheckForKeys = isPostLoginLanding && isSignedIn && internalUserRoles.includes(userRole);const { data: keysData, isLoading: keysLoading } = useKeys(1, 1, { userID }, shouldCheckForKeys);const isKeylessLanding = shouldCheckForKeys && !keysLoading && keysData?.keys?.length === 0;const isResolvingKeylessLanding = (shouldCheckForKeys && keysLoading) || isKeylessLanding;+ const isResolvingLanding = isAwaitingRole || isResolvingKeylessLanding;useEffect(() => {if (isKeylessLanding && !didReturnRedirectRef.current) {@@ -104,7 +106,7 @@ function CreateKeyPageContent() {}}, [isKeylessLanding, router]);- const isRedirecting = redirectToLogin || isLegacyRedirect || isResolvingKeylessLanding;+ const isRedirecting = redirectToLogin || isLegacyRedirect || isResolvingLanding;if (authLoading || isRedirecting) {return <LoadingScreen />;