Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions ui/litellm-dashboard/src/app/chat/page.integration.test.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React from "react";
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
import { fireEvent, render, screen, waitFor, within } from "@testing-library/react";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { useChatHistory } from "@/components/chat/useChatHistory";
import ChatConversationPage from "./page";

const { mockMakeOpenAIResponsesRequest } = vi.hoisted(() => ({
const { mockMakeOpenAIResponsesRequest, shellState } = vi.hoisted(() => ({
mockMakeOpenAIResponsesRequest: vi.fn(),
shellState: { storageUnavailable: false },
}));

vi.mock("next/navigation", () => ({
Expand Down Expand Up @@ -50,7 +51,7 @@
conversations: history.conversations,
activeConversation: history.activeConversation,
activeConversationId: history.currentActiveId,
storageUnavailable: false,
storageUnavailable: shellState.storageUnavailable,
staleId: false,
createConversation: history.createConversation,
appendMessage: history.appendMessage,
Expand Down Expand Up @@ -81,6 +82,7 @@
beforeEach(() => {
localStorage.clear();
mockMakeOpenAIResponsesRequest.mockReset();
shellState.storageUnavailable = false;
});

it("renders latency, TTFT, token counts and cost reported for the assistant turn", async () => {
Expand All @@ -92,7 +94,7 @@

updateTextUI("assistant", "Sixty three microdollars.");
onTimingData?.(250);
onUsageData?.({ promptTokens: 12, completionTokens: 8, totalTokens: 20, cost: 0.000063 });

Check warning on line 97 in ui/litellm-dashboard/src/app/chat/page.integration.test.tsx

View workflow job for this annotation

GitHub Actions / frontend-lint

Object literal with 4 properties passed inline as an argument; assign it to a named variable first
onTotalLatency?.(1200);
});

Expand Down Expand Up @@ -130,3 +132,20 @@
expect(document.querySelector(".response-metrics")).toBeNull();
});
});

describe("/ui/chat storage banner", () => {
beforeEach(() => {
localStorage.clear();
mockMakeOpenAIResponsesRequest.mockReset();
shellState.storageUnavailable = true;
});

it("keeps the dismiss control amber on hover instead of the ghost variant's foreground", async () => {
render(<ChatConversationPage />);

const banner = await screen.findByText("Chat history won't be saved in this browser session");
const dismiss = within(banner.parentElement!).getByRole("button");
expect(dismiss).toHaveClass("hover:text-warning/80");
expect(dismiss).not.toHaveClass("hover:text-foreground");
});
});
2 changes: 1 addition & 1 deletion ui/litellm-dashboard/src/app/chat/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@
className={`h-auto w-full justify-start gap-2 rounded px-3 py-[7px] font-normal ${checked ? "bg-accent" : ""}`}
>
{logo ? (
<img

Check warning on line 381 in ui/litellm-dashboard/src/app/chat/page.tsx

View workflow job for this annotation

GitHub Actions / frontend-lint

Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` or a custom image loader to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element
src={logo}
alt=""
className="w-4 h-4 object-contain shrink-0"
Expand Down Expand Up @@ -419,7 +419,7 @@
const provider = getProviderFromModelName(selectedModel);
const { logo } = provider ? getProviderLogoAndName(provider) : { logo: "" };
return logo ? (
<img

Check warning on line 422 in ui/litellm-dashboard/src/app/chat/page.tsx

View workflow job for this annotation

GitHub Actions / frontend-lint

Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` or a custom image loader to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element
src={logo}
alt=""
className="w-4 h-4 object-contain shrink-0"
Expand Down Expand Up @@ -518,7 +518,7 @@
variant="ghost"
size="icon-xs"
onClick={() => setStorageBannerDismissed(true)}
className="text-warning hover:bg-warning/15 "
className="text-warning hover:bg-warning/15 hover:text-warning/80"
>
<X className="size-3.5" />
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,12 @@ describe("SidebarUsageCard", () => {
await user.click(rail);
expect(onExpandRail).toHaveBeenCalledOnce();
});

it("keeps the collapsed rail tinted on hover instead of the outline variant's foreground", async () => {
renderWithClient(<SidebarUsageCard accessToken="token" collapsed onExpandRail={vi.fn()} />);

const rail = await screen.findByTitle("Enterprise usage");
expect(rail).toHaveClass("hover:text-sidebar-primary/80");
expect(rail).not.toHaveClass("hover:text-foreground");
});
});
2 changes: 1 addition & 1 deletion ui/litellm-dashboard/src/components/SidebarUsageCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export default function SidebarUsageCard({ accessToken, collapsed, onExpandRail
variant="outline"
onClick={onExpandRail}
title="Enterprise usage"
className="h-9 w-full rounded-lg border-sidebar-border bg-sidebar text-sidebar-primary shadow-none hover:bg-sidebar-accent"
className="h-9 w-full rounded-lg border-sidebar-border bg-sidebar text-sidebar-primary shadow-none hover:bg-sidebar-accent hover:text-sidebar-primary/80"
>
<Award className="size-[18px]" strokeWidth={1.75} />
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,22 @@ describe("LoggingSettings", () => {
expect(source.match(HARDCODED_PALETTE) ?? []).toHaveLength(0);
});

it("keeps the remove button destructive on hover instead of the ghost variant's foreground", () => {
const initialValue = [
{
callback_name: "langsmith",
callback_type: "success",
callback_vars: {},
},
];

renderWithProviders(<LoggingSettings value={initialValue} onChange={vi.fn()} />);

const remove = screen.getByRole("button", { name: "Remove" });
expect(remove).toHaveClass("hover:text-destructive/80");
expect(remove).not.toHaveClass("hover:text-foreground");
});

it("reports the chosen event type when a different option is picked", async () => {
const user = userEvent.setup({ delay: null });
const mockOnChange = vi.fn();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
handleChange(newValue);
};

const updateLoggingConfig = (index: number, field: keyof LoggingConfig, newValue: any) => {

Check warning on line 107 in ui/litellm-dashboard/src/components/team/LoggingSettings.tsx

View workflow job for this annotation

GitHub Actions / frontend-lint

Unexpected any. Specify a different type
const updatedConfigs = [...value];
if (field === "callback_name") {
// Convert display name to callback value and reset callback_vars when callback changes
Expand Down Expand Up @@ -172,7 +172,7 @@
width={400}
placeholder={`os.environ/${paramName.toUpperCase()}`}
value={config.callback_vars[paramName] || ""}
onChange={(e: any) => updateCallbackVar(configIndex, paramName, e.target.value)}

Check warning on line 175 in ui/litellm-dashboard/src/components/team/LoggingSettings.tsx

View workflow job for this annotation

GitHub Actions / frontend-lint

Unexpected any. Specify a different type
/>
) : (
<CallbackVarInput
Expand Down Expand Up @@ -278,7 +278,7 @@
variant="ghost"
onClick={() => removeLoggingConfig(index)}
size="sm"
className="text-destructive hover:bg-destructive/10"
className="text-destructive hover:bg-destructive/10 hover:text-destructive/80"
type="button"
>
<Trash2 />
Expand Down
Loading