From 6b77454ba19a068da8d02f2e881f103d44c50f3e Mon Sep 17 00:00:00 2001 From: Lucas Song Date: Fri, 17 Apr 2026 21:31:15 -0700 Subject: [PATCH] fix(ui): show KeyModelList when key models array is empty Empty models on a virtual key means all proxy models, not no access. Gate KeyModelList on key token instead of models.length; clarify Settings copy and add regression test with fetchKeyModelCall mock. Made-with: Cursor --- .../templates/key_info_view.test.tsx | 32 +++++++++++++++++++ .../components/templates/key_info_view.tsx | 15 +++++---- 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/ui/litellm-dashboard/src/components/templates/key_info_view.test.tsx b/ui/litellm-dashboard/src/components/templates/key_info_view.test.tsx index f269ad96a27..b2d7a0f5e23 100644 --- a/ui/litellm-dashboard/src/components/templates/key_info_view.test.tsx +++ b/ui/litellm-dashboard/src/components/templates/key_info_view.test.tsx @@ -27,6 +27,20 @@ vi.mock("../networking", () => ({ getPolicyInfoWithGuardrails: vi.fn().mockResolvedValue({ resolved_guardrails: ["guardrail-1", "guardrail-2"], }), + fetchKeyModelCall: vi.fn().mockResolvedValue({ + model_display_sections: [ + { + section_kind: "all_proxy_models", + title: "All proxy models", + models: ["gpt-4o"], + }, + ], + source: "default", + resolved_total_count: 1, + matched_count: 1, + models_truncated: false, + all_team_models_without_team: false, + }), })); const mockResetKeySpendMutate = vi.fn(); @@ -151,6 +165,24 @@ describe("KeyInfoView", () => { }); }); + it("should render KeyModelList when models is empty but the key has a token", async () => { + vi.mocked(useAuthorized).mockReturnValue(baseUseAuthorizedMock); + + renderWithProviders( + {}} + keyId="test-key-id" + onKeyDataUpdate={() => {}} + teams={[]} + />, + ); + + await waitFor(() => { + expect(screen.getByTestId("key-model-list-scroll")).toBeInTheDocument(); + }); + }); + it("should not render tags in metadata textarea", async () => { vi.mocked(useAuthorized).mockReturnValue(baseUseAuthorizedMock); diff --git a/ui/litellm-dashboard/src/components/templates/key_info_view.tsx b/ui/litellm-dashboard/src/components/templates/key_info_view.tsx index 6fe3cea901a..7b6f0ae16ad 100644 --- a/ui/litellm-dashboard/src/components/templates/key_info_view.tsx +++ b/ui/litellm-dashboard/src/components/templates/key_info_view.tsx @@ -489,14 +489,14 @@ export default function KeyInfoView({ RPM: {currentKeyData.rpm_limit !== null ? currentKeyData.rpm_limit : "Unlimited"} - {currentKeyData.models && currentKeyData.models.length > 0 ? ( - + {currentKeyData.token ? ( + ) : ( Models -
- No models specified -
+
+ Key token unavailable +
)} @@ -765,7 +765,10 @@ export default function KeyInfoView({ )) ) : ( - No models specified + + No explicit list — this key can use all models available on the proxy. See the Models + section on the Overview tab for the resolved list. + )}