From bd866b82c39dc755168f8c5650e134eae94f8a01 Mon Sep 17 00:00:00 2001 From: ryan-crabbe-berri Date: Sun, 12 Jul 2026 23:06:39 -0700 Subject: [PATCH 1/3] refactor(ui): rename OldTeams component file to Teams --- .../e2e_tests/helpers/navigation.ts | 2 +- ui/litellm-dashboard/eslint-suppressions.json | 32 +++++----- .../src/app/(dashboard)/teams/page.tsx | 4 +- .../{OldTeams.test.tsx => Teams.test.tsx} | 64 +++++++++---------- .../components/{OldTeams.tsx => Teams.tsx} | 0 5 files changed, 49 insertions(+), 53 deletions(-) rename ui/litellm-dashboard/src/components/{OldTeams.test.tsx => Teams.test.tsx} (92%) rename ui/litellm-dashboard/src/components/{OldTeams.tsx => Teams.tsx} (100%) diff --git a/ui/litellm-dashboard/e2e_tests/helpers/navigation.ts b/ui/litellm-dashboard/e2e_tests/helpers/navigation.ts index 6b5e7f7bb8d7..a58ece16f9c7 100644 --- a/ui/litellm-dashboard/e2e_tests/helpers/navigation.ts +++ b/ui/litellm-dashboard/e2e_tests/helpers/navigation.ts @@ -41,7 +41,7 @@ export async function dismissFeedbackPopup(page: PlaywrightPage): Promise /** * Click on a team ID in the table. Team IDs are rendered differently depending * on the component version — try button first (Tremor Button), fall back to - * clickable span (OldTeams Typography.Text). + * clickable span (Teams Typography.Text). */ export async function clickTeamId(page: PlaywrightPage, teamId: string): Promise { const cell = page.locator("td").filter({ hasText: teamId }).first(); diff --git a/ui/litellm-dashboard/eslint-suppressions.json b/ui/litellm-dashboard/eslint-suppressions.json index 3f6f4da25d05..ba2e2a375cab 100644 --- a/ui/litellm-dashboard/eslint-suppressions.json +++ b/ui/litellm-dashboard/eslint-suppressions.json @@ -1400,22 +1400,6 @@ "count": 1 } }, - "src/components/OldTeams.test.tsx": { - "max-nested-callbacks": { - "count": 4 - } - }, - "src/components/OldTeams.tsx": { - "no-nested-ternary": { - "count": 4 - }, - "no-restricted-imports": { - "count": 1 - }, - "react-hooks/set-state-in-effect": { - "count": 4 - } - }, "src/components/SCIM.tsx": { "no-restricted-imports": { "count": 1 @@ -1506,6 +1490,22 @@ "count": 1 } }, + "src/components/Teams.test.tsx": { + "max-nested-callbacks": { + "count": 4 + } + }, + "src/components/Teams.tsx": { + "no-nested-ternary": { + "count": 4 + }, + "no-restricted-imports": { + "count": 1 + }, + "react-hooks/set-state-in-effect": { + "count": 4 + } + }, "src/components/ToolDetail.tsx": { "unused-imports/no-unused-imports": { "count": 2 diff --git a/ui/litellm-dashboard/src/app/(dashboard)/teams/page.tsx b/ui/litellm-dashboard/src/app/(dashboard)/teams/page.tsx index 7d3f019e6e39..2d99041c1ce4 100644 --- a/ui/litellm-dashboard/src/app/(dashboard)/teams/page.tsx +++ b/ui/litellm-dashboard/src/app/(dashboard)/teams/page.tsx @@ -1,9 +1,9 @@ "use client"; -import OldTeams from "@/components/OldTeams"; +import Teams from "@/components/Teams"; import useAuthorized from "@/app/(dashboard)/hooks/useAuthorized"; export default function TeamsPage() { const { accessToken, userId, userRole, premiumUser } = useAuthorized(); - return ; + return ; } diff --git a/ui/litellm-dashboard/src/components/OldTeams.test.tsx b/ui/litellm-dashboard/src/components/Teams.test.tsx similarity index 92% rename from ui/litellm-dashboard/src/components/OldTeams.test.tsx rename to ui/litellm-dashboard/src/components/Teams.test.tsx index 0b6e5786aaf2..ee84e17d0c96 100644 --- a/ui/litellm-dashboard/src/components/OldTeams.test.tsx +++ b/ui/litellm-dashboard/src/components/Teams.test.tsx @@ -4,7 +4,7 @@ import React from "react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { fetchAvailableModelsForTeamOrKey } from "./key_team_helpers/fetch_available_models_team_key"; import { fetchMCPAccessGroups, getGuardrailsList, teamCreateCall } from "./networking"; -import OldTeams from "./OldTeams"; +import Teams from "./Teams"; import { teamListCall } from "@/app/(dashboard)/hooks/teams/useTeams"; const mockTeamInfoView = vi.fn(); @@ -131,7 +131,7 @@ const renderWithQueryClient = (component: React.ReactElement) => { return render({component}); }; -describe("OldTeams - handleCreate organization handling", () => { +describe("Teams - handleCreate organization handling", () => { beforeEach(() => { vi.clearAllMocks(); mockTeamInfoView.mockClear(); @@ -372,7 +372,7 @@ describe("OldTeams - handleCreate organization handling", () => { page_size: 100, total_pages: 1, }); - renderWithQueryClient(); + renderWithQueryClient(); await waitFor(() => { expect(screen.getByTestId("delete-team-button")).toBeInTheDocument(); }); @@ -384,7 +384,7 @@ describe("OldTeams - handleCreate organization handling", () => { }); }); -describe("OldTeams - empty state", () => { +describe("Teams - empty state", () => { beforeEach(() => { vi.clearAllMocks(); mockUseOrganizations.mockReturnValue({ data: [] }); @@ -392,7 +392,7 @@ describe("OldTeams - empty state", () => { it("should display empty state message when teams array is empty", async () => { vi.mocked(teamListCall).mockResolvedValue({ teams: [], total: 0, page: 1, page_size: 100, total_pages: 1 }); - renderWithQueryClient(); + renderWithQueryClient(); await waitFor(() => { expect(screen.getByText("No teams yet")).toBeInTheDocument(); @@ -404,7 +404,7 @@ describe("OldTeams - empty state", () => { it("should display empty state message when teams is null", async () => { vi.mocked(teamListCall).mockResolvedValue({ teams: [], total: 0, page: 1, page_size: 100, total_pages: 1 }); - renderWithQueryClient(); + renderWithQueryClient(); await waitFor(() => { expect(screen.getByText("No teams yet")).toBeInTheDocument(); @@ -437,7 +437,7 @@ describe("OldTeams - empty state", () => { page_size: 100, total_pages: 1, }); - renderWithQueryClient(); + renderWithQueryClient(); await waitFor(() => { expect(screen.getByText("Test Team")).toBeInTheDocument(); @@ -449,7 +449,7 @@ describe("OldTeams - empty state", () => { }); }); -describe("OldTeams - helper functions", () => { +describe("Teams - helper functions", () => { describe("getAdminOrganizations", () => { it("should return all organizations for Admin role", () => { const organizations = [ @@ -575,7 +575,7 @@ describe("OldTeams - helper functions", () => { }); }); -describe("OldTeams - premium props", () => { +describe("Teams - premium props", () => { beforeEach(() => { mockTeamInfoView.mockClear(); vi.mocked(fetchAvailableModelsForTeamOrKey).mockResolvedValue([]); @@ -607,7 +607,7 @@ describe("OldTeams - premium props", () => { page_size: 100, total_pages: 1, }); - renderWithQueryClient(); + renderWithQueryClient(); const teamIdElement = await screen.findByText("team-123456789"); act(() => { @@ -620,7 +620,7 @@ describe("OldTeams - premium props", () => { }); }); -describe("OldTeams - Default Team Settings tab visibility", () => { +describe("Teams - Default Team Settings tab visibility", () => { beforeEach(() => { vi.clearAllMocks(); mockUseOrganizations.mockReturnValue({ data: [] }); @@ -649,7 +649,7 @@ describe("OldTeams - Default Team Settings tab visibility", () => { page_size: 100, total_pages: 1, }); - renderWithQueryClient(); + renderWithQueryClient(); expect(screen.getByRole("tab", { name: "Default Team Settings" })).toBeInTheDocument(); }); @@ -677,7 +677,7 @@ describe("OldTeams - Default Team Settings tab visibility", () => { page_size: 100, total_pages: 1, }); - renderWithQueryClient(); + renderWithQueryClient(); expect(screen.getByRole("tab", { name: "Default Team Settings" })).toBeInTheDocument(); }); @@ -705,7 +705,7 @@ describe("OldTeams - Default Team Settings tab visibility", () => { page_size: 100, total_pages: 1, }); - renderWithQueryClient(); + renderWithQueryClient(); expect(screen.queryByRole("tab", { name: "Default Team Settings" })).not.toBeInTheDocument(); }); @@ -733,13 +733,13 @@ describe("OldTeams - Default Team Settings tab visibility", () => { page_size: 100, total_pages: 1, }); - renderWithQueryClient(); + renderWithQueryClient(); expect(screen.queryByRole("tab", { name: "Default Team Settings" })).not.toBeInTheDocument(); }); }); -describe("OldTeams - access_group_ids in team create", () => { +describe("Teams - access_group_ids in team create", () => { beforeEach(() => { vi.clearAllMocks(); mockTeamInfoView.mockClear(); @@ -762,7 +762,7 @@ describe("OldTeams - access_group_ids in team create", () => { it("should pass access_group_ids to teamCreateCall when creating team", async () => { vi.mocked(teamListCall).mockResolvedValue({ teams: [], total: 0, page: 1, page_size: 100, total_pages: 1 }); - renderWithQueryClient(); + renderWithQueryClient(); const createButton = screen.getAllByRole("button", { name: /create team/i })[0]; act(() => { @@ -806,7 +806,7 @@ describe("OldTeams - access_group_ids in team create", () => { }); }); -describe("OldTeams - models dropdown options", () => { +describe("Teams - models dropdown options", () => { beforeEach(() => { vi.clearAllMocks(); vi.mocked(fetchAvailableModelsForTeamOrKey).mockResolvedValue(["gpt-4", "gpt-3.5-turbo"]); @@ -817,7 +817,7 @@ describe("OldTeams - models dropdown options", () => { vi.mocked(fetchAvailableModelsForTeamOrKey).mockResolvedValue(["gpt-4", "gpt-3.5-turbo"]); vi.mocked(teamListCall).mockResolvedValue({ teams: [], total: 0, page: 1, page_size: 100, total_pages: 1 }); - renderWithQueryClient(); + renderWithQueryClient(); await waitFor(() => { expect(fetchAvailableModelsForTeamOrKey).toHaveBeenCalled(); @@ -836,7 +836,7 @@ describe("OldTeams - models dropdown options", () => { }); }); -describe("OldTeams - organization alias display", () => { +describe("Teams - organization alias display", () => { beforeEach(() => { vi.clearAllMocks(); mockUseOrganizations.mockReturnValue({ data: [] }); @@ -887,7 +887,7 @@ describe("OldTeams - organization alias display", () => { page_size: 100, total_pages: 1, }); - renderWithQueryClient(); + renderWithQueryClient(); await waitFor(() => { expect(screen.getByText("Test Organization")).toBeInTheDocument(); @@ -920,7 +920,7 @@ describe("OldTeams - organization alias display", () => { page_size: 100, total_pages: 1, }); - renderWithQueryClient(); + renderWithQueryClient(); await waitFor(() => { expect(screen.getByText("org-unknown")).toBeInTheDocument(); @@ -952,7 +952,7 @@ describe("OldTeams - organization alias display", () => { page_size: 100, total_pages: 1, }); - renderWithQueryClient(); + renderWithQueryClient(); await waitFor(() => { // When organization_id is null, the table shows "—" in the Organization column @@ -961,7 +961,7 @@ describe("OldTeams - organization alias display", () => { }); }); -describe("OldTeams - Resources column keys badge", () => { +describe("Teams - Resources column keys badge", () => { beforeEach(() => { vi.clearAllMocks(); mockUseOrganizations.mockReturnValue({ data: [] }); @@ -991,9 +991,7 @@ describe("OldTeams - Resources column keys badge", () => { page_size: 100, total_pages: 1, }); - const { container } = renderWithQueryClient( - , - ); + const { container } = renderWithQueryClient(); await waitFor(() => { expect(screen.getByText("Team With Keys")).toBeInTheDocument(); @@ -1026,9 +1024,7 @@ describe("OldTeams - Resources column keys badge", () => { page_size: 100, total_pages: 1, }); - const { container } = renderWithQueryClient( - , - ); + const { container } = renderWithQueryClient(); await waitFor(() => { expect(screen.getByText("Legacy Team")).toBeInTheDocument(); @@ -1039,7 +1035,7 @@ describe("OldTeams - Resources column keys badge", () => { }); }); -describe("OldTeams - delete team warning copy", () => { +describe("Teams - delete team warning copy", () => { beforeEach(() => { vi.clearAllMocks(); mockUseOrganizations.mockReturnValue({ data: [] }); @@ -1053,7 +1049,7 @@ describe("OldTeams - delete team warning copy", () => { page_size: 100, total_pages: 1, }); - renderWithQueryClient(); + renderWithQueryClient(); await waitFor(() => { expect(screen.getByTestId("delete-team-button")).toBeInTheDocument(); }); @@ -1098,7 +1094,7 @@ describe("OldTeams - delete team warning copy", () => { }); }); -describe("OldTeams - LIT-2530 organization stays optional for proxy admin with a single org", () => { +describe("Teams - LIT-2530 organization stays optional for proxy admin with a single org", () => { beforeEach(() => { vi.clearAllMocks(); mockTeamInfoView.mockClear(); @@ -1121,7 +1117,7 @@ describe("OldTeams - LIT-2530 organization stays optional for proxy admin with a }); it("creates a team with no organization when exactly one organization exists", async () => { - renderWithQueryClient(); + renderWithQueryClient(); const createButton = screen.getAllByRole("button", { name: /create team/i })[0]; act(() => { diff --git a/ui/litellm-dashboard/src/components/OldTeams.tsx b/ui/litellm-dashboard/src/components/Teams.tsx similarity index 100% rename from ui/litellm-dashboard/src/components/OldTeams.tsx rename to ui/litellm-dashboard/src/components/Teams.tsx From 229ede3b1836638652e0e0f2a892008eef6aca04 Mon Sep 17 00:00:00 2001 From: ryan-crabbe-berri Date: Sun, 12 Jul 2026 23:16:17 -0700 Subject: [PATCH 2/3] fix: show and allow editing team model aliases after team creation --- .../management_endpoints/team_endpoints.py | 2 +- .../test_team_endpoints.py | 93 ++++++++++ .../src/components/team/TeamInfo.test.tsx | 166 ++++++++++++++++++ .../src/components/team/TeamInfo.tsx | 53 +++++- 4 files changed, 312 insertions(+), 2 deletions(-) diff --git a/litellm/proxy/management_endpoints/team_endpoints.py b/litellm/proxy/management_endpoints/team_endpoints.py index f468f5ec30b5..797f46008576 100644 --- a/litellm/proxy/management_endpoints/team_endpoints.py +++ b/litellm/proxy/management_endpoints/team_endpoints.py @@ -3550,7 +3550,7 @@ async def team_info( try: team_info: Optional[BaseModel] = await TeamRepository(prisma_client).table.find_unique( where={"team_id": team_id}, - include={"object_permission": True}, + include={"litellm_model_table": True, "object_permission": True}, ) if team_info is None: raise Exception diff --git a/tests/test_litellm/proxy/management_endpoints/test_team_endpoints.py b/tests/test_litellm/proxy/management_endpoints/test_team_endpoints.py index 59b08a7ec4e0..f7b2df45a855 100644 --- a/tests/test_litellm/proxy/management_endpoints/test_team_endpoints.py +++ b/tests/test_litellm/proxy/management_endpoints/test_team_endpoints.py @@ -18,6 +18,7 @@ from litellm.proxy._types import UserAPIKeyAuth # Import UserAPIKeyAuth from litellm.proxy._types import ( LiteLLM_BudgetTableFull, + LiteLLM_ModelTable, LiteLLM_OrganizationMembershipTable, LiteLLM_OrganizationTable, LiteLLM_OrganizationTableWithMembers, @@ -30,6 +31,7 @@ ProxyErrorTypes, ProxyException, TeamMemberAddRequest, + UpdateTeamRequest, ) from litellm.proxy.management_endpoints.team_endpoints import ( user_api_key_auth, # Assuming this dependency is needed @@ -40,6 +42,7 @@ _persist_deleted_team_records, _save_deleted_team_records, _transform_teams_to_deleted_records, + _update_model_table, _validate_and_populate_member_user_info, _verify_team_access, delete_team, @@ -9436,6 +9439,96 @@ async def test_team_info_forwards_key_limit_to_get_data(): assert mock_prisma.get_data.await_args.kwargs["limit"] == 7 +@pytest.mark.asyncio +async def test_team_info_returns_model_aliases(): + """/team/info must join LiteLLM_ModelTable so the response exposes the team's + current model aliases; without the ``litellm_model_table`` include the field + comes back null and the Admin UI can never display them. + """ + from fastapi import Request + + from litellm.proxy.management_endpoints import team_endpoints + + team_row = LiteLLM_TeamTable( + team_id="team-1", + litellm_model_table=LiteLLM_ModelTable( + id=1, + model_aliases={"gpt-4o": "gpt-4o-team-1"}, + created_by="admin", + updated_by="admin", + ), + ) + + mock_prisma = MagicMock() + mock_prisma.db.litellm_teamtable.find_unique = AsyncMock(return_value=team_row) + mock_prisma.get_data = AsyncMock(return_value=[]) + + with ( + patch("litellm.proxy.proxy_server.prisma_client", mock_prisma), + patch.object( + team_endpoints, "get_all_team_memberships", AsyncMock(return_value=[]) + ), + ): + response = await team_endpoints.team_info( + http_request=MagicMock(spec=Request), + team_id="team-1", + user_api_key_dict=UserAPIKeyAuth(user_role=LitellmUserRoles.PROXY_ADMIN), + ) + + include = mock_prisma.db.litellm_teamtable.find_unique.await_args.kwargs["include"] + assert include["litellm_model_table"] is True + + litellm_model_table = response["team_info"].litellm_model_table + assert litellm_model_table is not None + assert litellm_model_table.model_aliases == {"gpt-4o": "gpt-4o-team-1"} + + +@pytest.mark.asyncio +async def test_update_model_table_clears_aliases_with_empty_map(): + """``model_aliases={}`` on /team/update must persist an empty map (json.dumps({})) + so existing aliases are cleared, while ``model_aliases=None`` must be a no-op that + leaves the model table untouched. + """ + mock_prisma = MagicMock() + mock_prisma.db.litellm_modeltable.create = AsyncMock() + mock_prisma.db.litellm_modeltable.upsert = AsyncMock( + return_value=MagicMock(id="model-123") + ) + user_api_key_dict = UserAPIKeyAuth( + user_role=LitellmUserRoles.PROXY_ADMIN, user_id="admin" + ) + + returned_model_id = await _update_model_table( + data=UpdateTeamRequest(team_id="team-1", model_aliases={}), + model_id="model-123", + prisma_client=mock_prisma, + user_api_key_dict=user_api_key_dict, + litellm_proxy_admin_name="default_user_id", + ) + + mock_prisma.db.litellm_modeltable.upsert.assert_awaited_once() + upsert_kwargs = mock_prisma.db.litellm_modeltable.upsert.await_args.kwargs + assert upsert_kwargs["where"] == {"id": "model-123"} + assert upsert_kwargs["data"]["update"]["model_aliases"] == json.dumps({}) + assert upsert_kwargs["data"]["create"]["model_aliases"] == json.dumps({}) + assert returned_model_id == "model-123" + + mock_prisma.db.litellm_modeltable.create.reset_mock() + mock_prisma.db.litellm_modeltable.upsert.reset_mock() + + noop_model_id = await _update_model_table( + data=UpdateTeamRequest(team_id="team-1", model_aliases=None), + model_id="model-123", + prisma_client=mock_prisma, + user_api_key_dict=user_api_key_dict, + litellm_proxy_admin_name="default_user_id", + ) + + mock_prisma.db.litellm_modeltable.create.assert_not_called() + mock_prisma.db.litellm_modeltable.upsert.assert_not_called() + assert noop_model_id == "model-123" + + class TestEmitTeamMembersMetric: """The _emit_team_members_metric seam between the team handlers and Prometheus.""" diff --git a/ui/litellm-dashboard/src/components/team/TeamInfo.test.tsx b/ui/litellm-dashboard/src/components/team/TeamInfo.test.tsx index f0e27607ffbf..a57676d07b88 100644 --- a/ui/litellm-dashboard/src/components/team/TeamInfo.test.tsx +++ b/ui/litellm-dashboard/src/components/team/TeamInfo.test.tsx @@ -91,6 +91,16 @@ vi.mock("@/components/team/member_permissions", () => ({ default: vi.fn(() =>
Member Permissions
), })); +vi.mock("@/components/common_components/ModelAliasManager", () => ({ + default: vi.fn(({ initialModelAliases, onAliasUpdate }) => ( +
+
{JSON.stringify(initialModelAliases)}
+ + +
+ )), +})); + vi.mock("@/app/(dashboard)/hooks/accessGroups/useAccessGroups", () => ({ useAccessGroups: vi.fn().mockReturnValue({ data: [ @@ -858,4 +868,160 @@ describe("TeamInfoView", () => { }); }); }); + + describe("model aliases", () => { + const openSettingsEditor = async (user: ReturnType) => { + await waitFor(() => { + const teamNameElements = screen.queryAllByText("Test Team"); + expect(teamNameElements.length).toBeGreaterThan(0); + }); + + await user.click(screen.getByRole("tab", { name: "Settings" })); + + await waitFor(() => { + expect(screen.getByRole("button", { name: /edit settings/i })).toBeInTheDocument(); + }); + + await user.click(screen.getByRole("button", { name: /edit settings/i })); + + await waitFor(() => { + expect(screen.getByLabelText("Team Name")).toBeInTheDocument(); + }); + }; + + it("should render existing model aliases in the read-only settings view", async () => { + const user = userEvent.setup({ delay: null }); + vi.mocked(networking.teamInfoCall).mockResolvedValue( + createMockTeamData({ + litellm_model_table: { model_aliases: { "my-smart-model": "gpt-4", "my-fast-model": "gpt-3.5-turbo" } }, + }), + ); + + renderWithProviders(); + + await waitFor(() => { + const teamNameElements = screen.queryAllByText("Test Team"); + expect(teamNameElements.length).toBeGreaterThan(0); + }); + + await user.click(screen.getByRole("tab", { name: "Settings" })); + + await waitFor(() => { + expect(screen.getByText("Team Settings")).toBeInTheDocument(); + }); + + expect(screen.getByText("Model Aliases")).toBeInTheDocument(); + expect(screen.getByText("my-smart-model")).toBeInTheDocument(); + expect(screen.getByText("gpt-4")).toBeInTheDocument(); + expect(screen.getByText("my-fast-model")).toBeInTheDocument(); + expect(screen.getByText("gpt-3.5-turbo")).toBeInTheDocument(); + }); + + it("should show an empty state when the team has no model aliases", async () => { + const user = userEvent.setup({ delay: null }); + vi.mocked(networking.teamInfoCall).mockResolvedValue(createMockTeamData({ litellm_model_table: null })); + + renderWithProviders(); + + await waitFor(() => { + const teamNameElements = screen.queryAllByText("Test Team"); + expect(teamNameElements.length).toBeGreaterThan(0); + }); + + await user.click(screen.getByRole("tab", { name: "Settings" })); + + await waitFor(() => { + expect(screen.getByText("Team Settings")).toBeInTheDocument(); + }); + + expect(screen.getByText("No model aliases configured")).toBeInTheDocument(); + }); + + it("should seed the alias editor from existing team aliases", async () => { + const user = userEvent.setup({ delay: null }); + vi.mocked(networking.teamInfoCall).mockResolvedValue( + createMockTeamData({ + models: ["gpt-4"], + litellm_model_table: { model_aliases: { "my-smart-model": "gpt-4" } }, + }), + ); + + renderWithProviders(); + + await openSettingsEditor(user); + + expect(screen.getByTestId("alias-editor-initial")).toHaveTextContent( + JSON.stringify({ "my-smart-model": "gpt-4" }), + ); + }); + + it("should pass model_aliases to teamUpdateCall when aliases are added", async () => { + const user = userEvent.setup({ delay: null }); + vi.mocked(networking.teamInfoCall).mockResolvedValue(createMockTeamData({ models: ["gpt-4"] })); + vi.mocked(networking.teamUpdateCall).mockResolvedValue({ data: {}, team_id: "123" } as any); + + renderWithProviders(); + + await openSettingsEditor(user); + + await user.click(screen.getByRole("button", { name: "Set Alias" })); + await user.click(screen.getByRole("button", { name: /save changes/i })); + + await waitFor(() => { + expect(networking.teamUpdateCall).toHaveBeenCalledWith( + "test-token", + expect.objectContaining({ + team_id: "123", + model_aliases: { "gpt-4o": "gpt-4" }, + }), + ); + }); + }); + + it("should send an empty model_aliases map to clear existing aliases", async () => { + const user = userEvent.setup({ delay: null }); + vi.mocked(networking.teamInfoCall).mockResolvedValue( + createMockTeamData({ + models: ["gpt-4"], + litellm_model_table: { model_aliases: { "my-smart-model": "gpt-4" } }, + }), + ); + vi.mocked(networking.teamUpdateCall).mockResolvedValue({ data: {}, team_id: "123" } as any); + + renderWithProviders(); + + await openSettingsEditor(user); + + await user.click(screen.getByRole("button", { name: "Clear Aliases" })); + await user.click(screen.getByRole("button", { name: /save changes/i })); + + await waitFor(() => { + expect(networking.teamUpdateCall).toHaveBeenCalled(); + }); + + const payload = vi.mocked(networking.teamUpdateCall).mock.calls[0][1] as Record; + expect(payload.model_aliases).toEqual({}); + }); + + it("should not include model_aliases when the team has none and the editor is untouched", async () => { + const user = userEvent.setup({ delay: null }); + vi.mocked(networking.teamInfoCall).mockResolvedValue( + createMockTeamData({ models: ["gpt-4"], litellm_model_table: null }), + ); + vi.mocked(networking.teamUpdateCall).mockResolvedValue({ data: {}, team_id: "123" } as any); + + renderWithProviders(); + + await openSettingsEditor(user); + + await user.click(screen.getByRole("button", { name: /save changes/i })); + + await waitFor(() => { + expect(networking.teamUpdateCall).toHaveBeenCalled(); + }); + + const payload = vi.mocked(networking.teamUpdateCall).mock.calls[0][1] as Record; + expect(payload).not.toHaveProperty("model_aliases"); + }); + }); }); diff --git a/ui/litellm-dashboard/src/components/team/TeamInfo.tsx b/ui/litellm-dashboard/src/components/team/TeamInfo.tsx index 3b80c598d349..3c66efaad074 100644 --- a/ui/litellm-dashboard/src/components/team/TeamInfo.tsx +++ b/ui/litellm-dashboard/src/components/team/TeamInfo.tsx @@ -34,6 +34,7 @@ import { CheckIcon, CopyIcon } from "lucide-react"; import React, { useEffect, useMemo, useState } from "react"; import { copyToClipboard as utilCopyToClipboard } from "../../utils/dataUtils"; import AccessGroupSelector from "../common_components/AccessGroupSelector"; +import ModelAliasManager from "../common_components/ModelAliasManager"; import AgentSelector from "../agent_management/AgentSelector"; import DeleteResourceModal from "../common_components/DeleteResourceModal"; import DurationSelect from "../common_components/DurationSelect"; @@ -206,6 +207,7 @@ const TeamInfoView: React.FC = ({ const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false); const [isDeleting, setIsDeleting] = useState(false); const [isTeamSaving, setIsTeamSaving] = useState(false); + const [teamModelAliases, setTeamModelAliases] = useState>({}); const routerSettingsRef = React.useRef(null); const [organization, setOrganization] = useState(null); const { userRole, userId } = useAuthorized(); @@ -619,6 +621,11 @@ const TeamInfoView: React.FC = ({ updateData.default_team_member_models = values.default_team_member_models; } + const previousModelAliases = info.litellm_model_table?.model_aliases ?? {}; + if (Object.keys(teamModelAliases).length > 0 || Object.keys(previousModelAliases).length > 0) { + updateData.model_aliases = teamModelAliases; + } + // Handle router_settings - read fresh values from DOM at save time. const currentRouterSettings = routerSettingsRef.current?.getValue(); if (currentRouterSettings?.router_settings) { @@ -905,7 +912,13 @@ const TeamInfoView: React.FC = ({
Team Settings {canEditTeam && !isEditing && ( - )} @@ -1026,6 +1039,24 @@ const TeamInfoView: React.FC = ({ /> + + Model Aliases{" "} + + + + + } + > + + + @@ -1520,6 +1551,26 @@ const TeamInfoView: React.FC = ({
)} +
+ Model Aliases + {(() => { + const aliasEntries = Object.entries(info.litellm_model_table?.model_aliases ?? {}); + if (aliasEntries.length === 0) { + return
No model aliases configured
; + } + return ( +
+ {aliasEntries.map(([alias, target]) => ( +
+ {alias} + {" -> "} + {target} +
+ ))} +
+ ); + })()} +
Rate Limits
TPM: {info.tpm_limit || "Unlimited"}
From b61982cdf44f1c715f73924fd24f6e8483ca6ada Mon Sep 17 00:00:00 2001 From: ryan-crabbe-berri Date: Mon, 13 Jul 2026 07:34:52 -0700 Subject: [PATCH 3/3] fix(ui): mark team model_aliases as nullable to match the prisma schema --- ui/litellm-dashboard/src/components/team/TeamInfo.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/litellm-dashboard/src/components/team/TeamInfo.tsx b/ui/litellm-dashboard/src/components/team/TeamInfo.tsx index 3c66efaad074..74f201b40c6b 100644 --- a/ui/litellm-dashboard/src/components/team/TeamInfo.tsx +++ b/ui/litellm-dashboard/src/components/team/TeamInfo.tsx @@ -107,7 +107,7 @@ export interface TeamData { budget_reset_at: string | null; model_id: string | null; litellm_model_table: { - model_aliases: Record; + model_aliases: Record | null; } | null; created_at: string; access_group_ids?: string[];