Skip to content

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]

fix(ui): design-system audit, single-model picker, scroll fix

Krrish Dholakia856367763e96
diff --git a/ui/litellm-dashboard/eslint-metrics.json b/ui/litellm-dashboard/eslint-metrics.json
index dd68a890ed0..d16be0d2b48 100644
--- a/ui/litellm-dashboard/eslint-metrics.json
+++ b/ui/litellm-dashboard/eslint-metrics.json
@@ -1,6 +1,6 @@
{
"@typescript-eslint/no-explicit-any": 1991,
- "complexity": 129,
+ "complexity": 128,
"max-depth": 59,
"no-console": 484
}
diff --git a/ui/litellm-dashboard/src/app/chat/page.tsx b/ui/litellm-dashboard/src/app/chat/page.tsx
index ddf1bd37120..57bb740fbde 100644
--- a/ui/litellm-dashboard/src/app/chat/page.tsx
+++ b/ui/litellm-dashboard/src/app/chat/page.tsx
@@ -1,27 +1,25 @@
"use client";
import React, { useCallback, useEffect, useRef, useState, useLayoutEffect } from "react";
-import { Plus, ChevronDown, Check } from "lucide-react";
+import { Plus, ChevronDown, Check, X } from "lucide-react";
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
import { Skeleton } from "@/components/ui/skeleton";
import { ScrollArea } from "@/components/ui/scroll-area";
+import { Input } from "@/components/ui/input";
+import { Button } from "@/components/ui/button";
import MessageManager from "@/components/molecules/message_manager";
-import ReactMarkdown from "react-markdown";
-import remarkGfm from "remark-gfm";
import { useRouter } from "next/navigation";
import { useChatShell } from "@/contexts/ChatShellContext";
import { CHAT_ROUTES } from "@/components/chat/ChatShell";
import ChatMessages from "@/components/chat/ChatMessages";
import MCPConnectPicker from "@/components/chat/MCPConnectPicker";
import { fetchAvailableModels } from "@/components/llm_calls/fetch_models";
-import { makeOpenAIChatCompletionRequest } from "@/components/llm_calls/chat_completion";
import { makeOpenAIResponsesRequest } from "@/components/llm_calls/responses_api";
import type { MCPEvent } from "@/components/chat/types";
import { getProviderLogoAndName } from "@/components/provider_info_helpers";
const SUGGESTIONS = ["Write", "Learn", "Code", "Brainstorm"];
-const MAX_COMPARISON_MODELS = 3;
-const LOCALSTORAGE_MODEL_KEY = "litellm_chat_selected_models";
+const LOCALSTORAGE_MODEL_KEY = "litellm_chat_selected_model";
function getGreeting(): string {
const h = new Date().getHours();
@@ -50,59 +48,6 @@ function getProviderFromModelName(modelName: string): string {
return "";
}
-interface ComparisonExchange {
- userMessage: string;
- responses: Record<string, string>; // model → accumulated response text
-}
-
-interface StreamToModelArgs {
- model: string;
- messages: Array<{ role: "user" | "assistant"; content: string }>;
- accessToken: string;
- mcpServers: string[];
- signal: AbortSignal;
- onChunk: (model: string, chunk: string) => void;
- onDone: (model: string) => void;
-}
-
-// Module-level async helper — each model gets its own independent Promise so they all run in parallel.
-async function streamToModel({
- model,
- messages,
- accessToken,
- mcpServers,
- signal,
- onChunk,
- onDone,
-}: StreamToModelArgs): Promise<void> {
- try {
- await makeOpenAIChatCompletionRequest(
- messages,
- (chunk: string) => onChunk(model, chunk),
- model,
- accessToken,
- undefined, // tags
- signal,
- undefined, // onReasoningContent
- undefined,
- undefined,
- undefined,
- undefined,
- undefined,
- undefined, // positions 8-13
- mcpServers.length > 0 ? mcpServers : undefined, // position 14: selectedMCPServers
- );
- } catch (err: unknown) {
- // Surface real errors in the response card; ignore user-triggered aborts
- if (!(err instanceof Error && err.name === "AbortError")) {
- const msg = err instanceof Error ? err.message : String(err);
- onChunk(model, `\n\n_Error: ${msg}_`);
- }
- } finally {
- onDone(model);
- }
-}
-
export default function ChatConversationPage() {
const router = useRouter();
const {
@@ -122,7 +67,7 @@ export default function ChatConversationPage() {
} = useChatShell();
const hadActiveConversationOnMountRef = useRef(activeConversationId !== null);
- const [selectedModels, setSelectedModels] = useState<string[]>([]);
+ const [selectedModel, setSelectedModel] = useState<string | null>(null);
const [models, setModels] = useState<string[]>([]);
const [isLoadingModels, setIsLoadingModels] = useState(true);
const [modelSelectorOpen, setModelSelectorOpen] = useState(false);
@@ -135,12 +80,6 @@ export default function ChatConversationPage() {
const [mcpPopoverOpen, setMcpPopoverOpen] = useState(false);
const [storageBannerDismissed, setStorageBannerDismissed] = useState(false);
- // Comparison mode state (active when selectedModels.length > 1)
- // Each exchange holds the user message + per-model responses so we can do multi-turn comparison.
- const [comparisonExchanges, setComparisonExchanges] = useState<ComparisonExchange[]>([]);
- const [comparisonStreamingSet, setComparisonStreamingSet] = useState<Set<string>>(new Set());
- const comparisonAbortControllersRef = useRef<Record<string, AbortController>>({});
-
const abortControllerRef = useRef<AbortController | null>(null);
const textareaRef = useRef<HTMLTextAreaElement>(null);
const messagesScrollRef = useRef<HTMLDivElement>(null);
@@ -160,22 +99,16 @@ export default function ChatConversationPage() {
setModels(names);
try {
const saved = localStorage.getItem(LOCALSTORAGE_MODEL_KEY);
- if (saved) {
- const parsed: unknown = JSON.parse(saved);
- if (Array.isArray(parsed)) {
- const valid = (parsed as string[]).filter((m) => names.includes(m));
- if (valid.length > 0) {
- setSelectedModels(hadActiveConversationOnMountRef.current ? [valid[0]] : valid);
- return;
- }
- }
+ if (saved && names.includes(saved)) {
+ setSelectedModel(saved);
+ return;
}
} catch {
// ignore parse errors
}
if (names.length > 0) {
- setSelectedModels([names[0]]);
- localStorage.setItem(LOCALSTORAGE_MODEL_KEY, JSON.stringify([names[0]]));
+ setSelectedModel(names[0]);
+ localStorage.setItem(LOCALSTORAGE_MODEL_KEY, names[0]);
}
})
.catch(() => MessageManager.error("Could not load models"))
@@ -189,29 +122,18 @@ export default function ChatConversationPage() {
setResponsesSessionId(null);
}
- const toggleModel = useCallback((model: string) => {
- setSelectedModels((prev) => {
- let next: string[];
- if (prev.includes(model)) {
- next = prev.filter((m) => m !== model);
- } else if (prev.length >= MAX_COMPARISON_MODELS) {
- return prev;
- } else {
- next = [...prev, model];
- }
- localStorage.setItem(LOCALSTORAGE_MODEL_KEY, JSON.stringify(next));
- return next;
- });
+ const selectModel = useCallback((model: string) => {
+ setSelectedModel(model);
+ localStorage.setItem(LOCALSTORAGE_MODEL_KEY, model);
+ setModelSelectorOpen(false);
+ setModelSearchText("");
}, []);
- const isComparisonMode = selectedModels.length > 1;
- const isAnyStreaming = isStreaming || comparisonStreamingSet.size > 0;
-
const handleSend = useCallback(
async (text: string, historyOverride?: Array<{ role: "user" | "assistant"; content: string }>) => {
const trimmed = text.trim();
- if (!trimmed || selectedModels.length === 0 || isStreaming) return;
- const model = selectedModels[0];
+ if (!trimmed || !selectedModel || isStreaming) return;
+ const model = selectedModel;
setInputText("");
let convId = activeConversationId;
@@ -320,7 +242,7 @@ export default function ChatConversationPage() {
[
activeConversationId,
activeConversation,
- selectedModels,
+ selectedModel,
selectedMCPServers,
accessToken,
createConversation,
@@ -332,67 +254,8 @@ export default function ChatConversationPage() {
],
);
- const handleSendComparison = useCallback(
- (text: string, currentExchanges: ComparisonExchange[]) => {
- const trimmed = text.trim();
- if (!trimmed || selectedModels.length === 0 || isAnyStreaming) return;
- setInputText("");
-
- // Append a new exchange with empty responses
- const newExchange: ComparisonExchange = { userMessage: trimmed, responses: {} };
- const newExchangeIdx = currentExchanges.length;
- setComparisonExchanges((prev) => [...prev, newExchange]);
- setComparisonStreamingSet(new Set(selectedModels));
-
- const controllers: Record<string, AbortController> = {};
- selectedModels.forEach((m) => {
- controllers[m] = new AbortController();
- });
- comparisonAbortControllersRef.current = controllers;
-
- // Launch all model streams simultaneously — Promise.allSettled ensures they run in parallel
- // (streamToModel handles its own errors internally so these promises won't reject)
- void Promise.allSettled(
- selectedModels.map((model) => {
- // Build per-model history: each model's past responses become its own context
- const history: Array<{ role: "user" | "assistant"; content: string }> = [];
- for (const ex of currentExchanges) {
- history.push({ role: "user", content: ex.userMessage });
- history.push({ role: "assistant", content: ex.responses[model] ?? "" });
- }
- history.push({ role: "user", content: trimmed });
-
- return streamToModel({
- model,
- messages: history,
- accessToken,
- mcpServers: selectedMCPServers,
- signal: controllers[model].signal,
- onChunk: (m, chunk) =>
- setComparisonExchanges((prev) => {
- const updated = [...prev];
- const ex = { ...updated[newExchangeIdx] };
- ex.responses = { ...ex.responses, [m]: (ex.responses[m] ?? "") + chunk };
- updated[newExchangeIdx] = ex;
- return updated;
- }),
- onDone: (m) =>
- setComparisonStreamingSet((prev) => {
- const next = new Set(prev);
- next.delete(m);
- return next;
- }),
- });
- }),
- );
- },
- [selectedModels, accessToken, selectedMCPServers, isAnyStreaming],
- );
-
const handleStop = useCallback(() => {
abortControllerRef.current?.abort();
- Object.values(comparisonAbortControllersRef.current).forEach((c) => c.abort());
- comparisonAbortControllersRef.current = {};
}, []);
const handleEditAndResend = useCallback(
@@ -411,21 +274,10 @@ export default function ChatConversationPage() {
[activeConversationId, isStreaming, activeConversation, truncateFromMessage, handleSend],
);
- const handleSubmit = useCallback(
- (text: string) => {
- if (isComparisonMode) {
- handleSendComparison(text, comparisonExchanges);
- } else {
- handleSend(text);
- }
- },
- [isComparisonMode, handleSend, handleSendComparison, comparisonExchanges],
- );
-
const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
if (e.key === "Enter" && !e.shiftKey) {
e.preventDefault();
- handleSubmit(inputText);
+ handleSend(inputText);
}
};
@@ -482,62 +334,42 @@ export default function ChatConversationPage() {
}
}, [activeConversation?.messages]);
- const showBlankState = !isComparisonMode
- ? !activeConversation || activeConversation.messages.length === 0
- : comparisonExchanges.length === 0;
+ const showBlankState = !activeConversation || activeConversation.messages.length === 0;
const displayName = userEmail?.split("@")[0] ?? userId ?? "";
const greeting = displayName ? `${getGreeting()}, ${displayName}` : getGreeting();
- // Filtered models: selected ones float to the top, then alphabetical
+ // Filtered models: selected one floats to the top, then alphabetical
const filteredModels = (
modelSearchText ? models.filter((m) => m.toLowerCase().includes(modelSearchText.toLowerCase())) : models
).sort((a, b) => {
- const aSelected = selectedModels.includes(a);
- const bSelected = selectedModels.includes(b);
- if (aSelected && !bSelected) return -1;
- if (!aSelected && bSelected) return 1;
+ if (a === selectedModel) return -1;
+ if (b === selectedModel) return 1;
return 0;
});
const modelSelectorContent = (
- <div className="w-[280px] max-h-[400px] flex flex-col overflow-hidden">
+ <div className="w-[280px] h-[400px] flex flex-col overflow-hidden">
<div className="p-2 pb-1">
- <input
+ <Input
autoFocus
value={modelSearchText}
onChange={(e) => setModelSearchText(e.target.value)}
placeholder="Search models..."
- className="w-full px-2.5 py-1.5 border rounded-md text-[13px] outline-none bg-background text-foreground"
+ className="h-8 text-[13px]"
/>
</div>
- {selectedModels.length >= MAX_COMPARISON_MODELS && (
- <div className="px-3 py-1 text-xs text-muted-foreground">
- Max {MAX_COMPARISON_MODELS} models selected; deselect one to change
- </div>
- )}
- <ScrollArea className="flex-1 min-h-0">
+ <ScrollArea className="flex-1 h-0">
{filteredModels.map((m) => {
- const checked = selectedModels.includes(m);
- const disabled = !checked && selectedModels.length >= MAX_COMPARISON_MODELS;
+ const checked = m === selectedModel;
const provider = getProviderFromModelName(m);
const { logo } = provider ? getProviderLogoAndName(provider) : { logo: "" };
return (
- <button
+ <Button
key={m}
- disabled={disabled}
- onClick={() => toggleModel(m)}
- className={`flex items-center gap-2 w-full px-3 py-[7px] border-none text-left rounded transition-colors ${
- checked ? "bg-accent" : "bg-transparent hover:bg-accent/50"
- } ${disabled ? "opacity-45 cursor-not-allowed" : "cursor-pointer"}`}
+ variant="ghost"
+ onClick={() => selectModel(m)}
+ className={`h-auto w-full justify-start gap-2 rounded px-3 py-[7px] font-normal ${checked ? "bg-accent" : ""}`}
>
- <span
- className={`w-4 h-4 rounded-[3px] flex items-center justify-center shrink-0 transition-all ${
- checked ? "bg-primary border-primary" : "bg-background border-border"
- }`}
- style={{ border: `1.5px solid ${checked ? "var(--color-primary)" : "var(--color-border)"}` }}
- >
- {checked && <Check className="h-2.5 w-2.5 text-primary-foreground" />}
- </span>
{logo ? (
<img
src={logo}
@@ -550,8 +382,11 @@ export default function ChatConversationPage() {
) : (
<span className="w-4 shrink-0" />
)}
- <span className="text-[13px] text-foreground overflow-hidden text-ellipsis whitespace-nowrap">{m}</span>
- </button>
+ <span className="flex-1 text-left text-[13px] text-foreground overflow-hidden text-ellipsis whitespace-nowrap">
+ {m}
+ </span>
+ {checked && <Check className="h-3.5 w-3.5 text-primary shrink-0" />}
+ </Button>
);
})}
</ScrollArea>
@@ -559,7 +394,7 @@ export default function ChatConversationPage() {
);
const modelSelectorTrigger = isLoadingModels ? (
- <Skeleton className="w-40 h-7" />
+ <Skeleton className="w-40 h-8" />
) : (
<Popover
open={modelSelectorOpen}
@@ -569,57 +404,32 @@ export default function ChatConversationPage() {
}}
>
<PopoverTrigger asChild>
- <button className="flex items-center gap-1.5 px-2.5 py-[5px] rounded-md border border-transparent cursor-pointer bg-transparent text-foreground text-sm font-medium max-w-[480px] overflow-hidden hover:bg-accent/50 transition-colors">
- {selectedModels.length === 0 ? (
- <span className="text-muted-foreground">Select model</span>
- ) : selectedModels.length === 1 ? (
+ <Button variant="outline" size="sm" className="max-w-[240px] justify-start gap-1.5 overflow-hidden">
+ {selectedModel ? (
<>
{(() => {
- const provider = getProviderFromModelName(selectedModels[0]);
+ const provider = getProviderFromModelName(selectedModel);
const { logo } = provider ? getProviderLogoAndName(provider) : { logo: "" };
return logo ? (
<img
src={logo}
alt=""
- className="w-[18px] h-[18px] object-contain shrink-0"
+ className="w-4 h-4 object-contain shrink-0"
onError={(e) => {
(e.currentTarget as HTMLImageElement).style.display = "none";
}}
/>
) : null;
})()}
- <span className="overflow-hidden text-ellipsis whitespace-nowrap max-w-[240px]">{selectedModels[0]}</span>
+ <span className="overflow-hidden text-ellipsis whitespace-nowrap">{selectedModel}</span>
</>
) : (
- <div className="flex items-center gap-1 flex-nowrap overflow-hidden">
- {selectedModels.map((m) => {
- const provider = getProviderFromModelName(m);
- const { logo } = provider ? getProviderLogoAndName(provider) : { logo: "" };
- return (
- <span
- key={m}
- className="inline-flex items-center gap-1 px-2 py-0.5 bg-primary/10 rounded-[10px] text-xs text-primary font-medium shrink-0"
- >
- {logo && (
- <img
- src={logo}
- alt=""
- className="w-[13px] h-[13px] object-contain"
- onError={(e) => {
- (e.currentTarget as HTMLImageElement).style.display = "none";
- }}
- />
- )}
- <span className="max-w-[120px] overflow-hidden text-ellipsis whitespace-nowrap">{m}</span>
- </span>
- );
- })}
- </div>
+ <span className="text-muted-foreground">Select model</span>
)}
- <ChevronDown className="h-2.5 w-2.5 text-muted-foreground shrink-0 ml-0.5" />
- </button>
+ <ChevronDown className="h-3 w-3 text-muted-foreground shrink-0" />
+ </Button>
</PopoverTrigger>
- <PopoverContent align="start" className="p-0 w-auto">
+ <PopoverContent align="start" side="top" className="p-0 w-auto">
{modelSelectorContent}
</PopoverContent>
</Popover>
@@ -643,53 +453,45 @@ export default function ChatConversationPage() {
className="flex items-center justify-between border-t"
style={{ padding: inConversation ? "4px 12px 10px" : "8px 12px 12px" }}
>
- <Popover open={mcpPopoverOpen} onOpenChange={setMcpPopoverOpen}>
- <PopoverTrigger asChild>
- <button className="border rounded-md px-2.5 py-[5px] cursor-pointer text-sm text-muted-foreground flex items-center gap-1 bg-transparent hover:bg-accent/50 transition-colors">
- <Plus className="h-3.5 w-3.5" />
- {selectedMCPServers.length > 0 && (
- <span className="text-xs text-primary font-medium">{selectedMCPServers.length}</span>
- )}
- </button>
- </PopoverTrigger>
- <PopoverContent side="top" align="start" className="p-0 w-auto">
- <MCPConnectPicker
- accessToken={accessToken}
- selectedServers={selectedMCPServers}
- onChange={setSelectedMCPServers}
- />
- </PopoverContent>
- </Popover>
+ <div className="flex items-center gap-2 min-w-0">
+ {modelSelectorTrigger}
+ <Popover open={mcpPopoverOpen} onOpenChange={setMcpPopoverOpen}>
+ <PopoverTrigger asChild>
+ <Button variant="outline" size="sm" className="gap-1 px-2.5 text-muted-foreground">
+ <Plus className="h-3.5 w-3.5" />
+ {selectedMCPServers.length > 0 && (
+ <span className="text-xs text-primary font-medium">{selectedMCPServers.length}</span>
+ )}
+ </Button>
+ </PopoverTrigger>
+ <PopoverContent side="top" align="start" className="p-0 w-auto">
+ <MCPConnectPicker
+ accessToken={accessToken}
+ selectedServers={selectedMCPServers}
+ onChange={setSelectedMCPServers}
+ />
+ </PopoverContent>
+ </Popover>
+ </div>
<div className="flex items-center gap-2">
- {!isComparisonMode && (
+ {inConversation && selectedMCPServers.length > 0 && (
<span className="text-xs text-muted-foreground max-w-[160px] overflow-hidden text-ellipsis whitespace-nowrap">
- {inConversation
- ? selectedMCPServers.length > 0
- ? `${selectedMCPServers.length} tool${selectedMCPServers.length > 1 ? "s" : ""} connected`
- : ""
- : selectedModels[0] || "No model"}
+ {selectedMCPServers.length} tool{selectedMCPServers.length > 1 ? "s" : ""} connected
</span>
)}
- {isAnyStreaming ? (
- <button
- onClick={handleStop}
- className="w-8 h-8 rounded-full border-[1.5px] flex items-center justify-center shrink-0 cursor-pointer transition-colors hover:border-muted-foreground bg-transparent text-foreground"
- >
+ {isStreaming ? (
+ <Button variant="outline" size="icon-sm" onClick={handleStop} className="rounded-full shrink-0">
<div className="w-2.5 h-2.5 bg-foreground rounded-[2px]" />
- </button>
+ </Button>
) : (
- <button
- onClick={() => handleSubmit(inputText)}
- disabled={!inputText.trim() || isLoadingModels || selectedModels.length === 0}
- className={`border-none rounded-md px-4 py-[7px] text-sm font-medium transition-colors ${
- inputText.trim() && selectedModels.length > 0
- ? "bg-primary text-primary-foreground cursor-pointer hover:bg-primary/90"
- : "bg-muted text-muted-foreground cursor-not-allowed"
- }`}
+ <Button
+ size="sm"
+ onClick={() => handleSend(inputText)}
+ disabled={!inputText.trim() || isLoadingModels || !selectedModel}
>
Send
- </button>
+ </Button>
)}
</div>
</div>
@@ -698,20 +500,17 @@ export default function ChatConversationPage() {
return (
<>
- <div className="flex items-center px-4 py-2 shrink-0 border-b bg-background h-12">
- <div className="flex items-center gap-2 min-w-0 flex-1">{modelSelectorTrigger}</div>
- </div>
-
{storageUnavailable && !storageBannerDismissed && (
<div className="bg-amber-50 border-b border-amber-200 px-5 py-1.5 text-[13px] text-amber-800 flex justify-between items-center">
<span>Chat history won&apos;t be saved in this browser session</span>
- <button
+ <Button
+ variant="ghost"
+ size="icon-xs"
onClick={() => setStorageBannerDismissed(true)}
- className="text-amber-800 text-base cursor-pointer"
- style={{ background: "none", border: "none" }}
+ className="text-amber-800 hover:bg-amber-100 hover:text-amber-800"
>
- &times;
- </button>
+ <X className="size-3.5" />
+ </Button>
</div>
)}
@@ -719,146 +518,53 @@ export default function ChatConversationPage() {
{showBlankState ? (
<div className="flex-1 flex flex-col items-center justify-center px-6 pb-20">
<h1 className="m-0 mb-8 text-[28px] font-semibold text-foreground tracking-tight text-center">
- {isComparisonMode ? `Compare ${selectedModels.length} models` : greeting}
+ {greeting}
</h1>
- {isComparisonMode ? (
- <p className="-mt-4 mb-6 text-sm text-muted-foreground text-center">
- Send a message to see responses side-by-side
- </p>
- ) : (
- <p className="-mt-4 mb-7 text-sm text-muted-foreground text-center max-w-[520px] leading-relaxed">
- Chat with 100+ LLMs + MCP tools; authenticate once, use them here.{" "}
- <button
- onClick={() => router.push(CHAT_ROUTES.integrations)}
- className="text-primary text-sm font-medium cursor-pointer hover:underline"
- style={{ background: "none", border: "none", padding: 0 }}
- >
- Open Integrations -&gt;
- </button>
- </p>
- )}
+ <p className="-mt-4 mb-7 text-sm text-muted-foreground text-center max-w-[520px] leading-relaxed">
+ Chat with 100+ LLMs + MCP tools; authenticate once, use them here.{" "}
+ <Button
+ variant="link"
+ onClick={() => router.push(CHAT_ROUTES.integrations)}
+ className="h-auto p-0 text-sm font-medium"
+ >
+ Open Integrations -&gt;
+ </Button>
+ </p>
<div className="w-full max-w-[680px]">{inputBar(false)}</div>
- {!isComparisonMode && (
- <div className="flex gap-2 mt-3.5 flex-wrap justify-center">
- {SUGGESTIONS.map((s) => (
- <button
- key={s}
- onClick={() => setInputText(s + ": ")}
- className="bg-secondary border rounded-full px-4 py-[7px] text-sm text-foreground/70 cursor-pointer hover:bg-accent transition-colors"
- >
- {s}
- </button>
- ))}
- </div>
- )}
+ <div className="flex gap-2 mt-3.5 flex-wrap justify-center">
+ {SUGGESTIONS.map((s) => (
+ <Button
+ key={s}
+ variant="outline"
+ size="sm"
+ onClick={() => setInputText(s + ": ")}
+ className="rounded-full px-4 text-muted-foreground"
+ >
+ {s}
+ </Button>
+ ))}
+ </div>
</div>
) : (
- <div
- className="flex-1 min-h-0 flex flex-col mx-auto w-full px-6 relative"
- style={{ maxWidth: isComparisonMode ? (selectedModels.length >= 3 ? 1200 : 960) : 760 }}
- >
+ <div className="flex-1 min-h-0 flex flex-col mx-auto w-full px-6 relative" style={{ maxWidth: 760 }}>
<div
ref={messagesScrollRef}
className="flex-1 min-h-0 overflow-auto pt-6"
style={{ overflowAnchor: "none" }}
>
- {isComparisonMode ? (
- <div className="pb-2">
- {comparisonExchanges.map((exchange, exchangeIdx) => {
- const isLastExchange = exchangeIdx === comparisonExchanges.length - 1;
- return (
- <div key={exchangeIdx} className="mb-8">
- <div className="flex justify-end mb-5">
- <div className="bg-muted rounded-2xl px-4 py-2.5 max-w-[75%] text-sm text-foreground leading-relaxed">
- {exchange.userMessage}
- </div>
- </div>
-
- <div className="flex gap-3.5 items-start">
- {selectedModels.map((model, idx) => {
- const provider = getProviderFromModelName(model);
- const { logo } = provider ? getProviderLogoAndName(provider) : { logo: "" };
- const responseText = exchange.responses[model] ?? "";
- const isModelStreaming = isLastExchange && comparisonStreamingSet.has(model);
- return (
- <div key={model} className="flex-1 border rounded-xl overflow-hidden min-w-0">
- {exchangeIdx === 0 && (
- <div className="px-3.5 py-2.5 border-b flex items-center gap-2 bg-muted/50">
- {logo ? (
- <img
- src={logo}
- alt=""
- className="w-[18px] h-[18px] object-contain shrink-0"
- onError={(e) => {
- (e.currentTarget as HTMLImageElement).style.display = "none";
- }}
- />
- ) : (
- <div className="w-[18px] h-[18px] rounded-full bg-border shrink-0" />
- )}
- <span className="font-semibold text-xs text-foreground">Response {idx + 1}</span>
- <span className="text-[11px] text-muted-foreground overflow-hidden text-ellipsis whitespace-nowrap flex-1 min-w-0">
- {model}
- </span>
- </div>
- )}
- <div className="px-4 py-3.5 min-h-[60px] relative">
- {isModelStreaming && (
- <span className="absolute top-2.5 right-3 text-[9px] text-primary">&#9679;</span>
- )}
- {responseText ? (
- <ReactMarkdown
- remarkPlugins={[remarkGfm]}
- components={{
- p: ({ children }) => (
- <p className="mb-2.5 leading-relaxed text-sm text-foreground">{children}</p>
- ),
- code: ({ className, children }) => {
- const isBlock = /language-(\w+)/.exec(className || "");
- if (isBlock) {
- return (
- <pre className="bg-muted px-3 py-2.5 rounded-md overflow-auto text-[13px] my-2">
- <code>{children}</code>
- </pre>
- );
- }
- return (
- <code className="bg-muted px-1.5 py-0.5 rounded text-[13px]">
- {children}
- </code>
- );
- },
- }}
- >
- {responseText}
- </ReactMarkdown>
- ) : isModelStreaming ? (
- <span className="text-muted-foreground text-sm">Generating&#8230;</span>
- ) : (
- <span className="text-muted-foreground text-sm">&#8212;</span>
- )}
- </div>
- </div>
- );
- })}
- </div>
- </div>
- );
- })}
- </div>
- ) : (
- <ChatMessages
- messages={activeConversation!.messages}
- isStreaming={isStreaming}
- onEditMessage={handleEditAndResend}
- />
- )}
+ <ChatMessages
+ messages={activeConversation!.messages}
+ isStreaming={isStreaming}
+ onEditMessage={handleEditAndResend}
+ />
</div>
{showScrollButton && (
- <button
+ <Button
+ variant="ghost"
+ size="icon"
onClick={() => {
const el = messagesScrollRef.current;
if (el) {
@@ -868,11 +574,11 @@ export default function ChatConversationPage() {
}
}
}}
- className="absolute bottom-[100px] left-1/2 -translate-x-1/2 w-[34px] h-[34px] rounded-full bg-background/75 backdrop-blur-md border border-black/10 shadow-sm cursor-pointer flex items-center justify-center text-muted-foreground z-10 transition-colors hover:bg-background/95"
+ className="absolute bottom-[100px] left-1/2 -translate-x-1/2 z-10 rounded-full border bg-background/75 text-muted-foreground shadow-sm backdrop-blur-md hover:bg-background/95 hover:text-muted-foreground"
aria-label="Scroll to bottom"
>
<ChevronDown className="h-3 w-3" />
- </button>
+ </Button>
)}
<div className="py-3 pb-6">{inputBar(true)}</div>
diff --git a/ui/litellm-dashboard/src/components/chat/AGENTS.md b/ui/litellm-dashboard/src/components/chat/AGENTS.md
new file mode 100644
index 00000000000..4062b67a9ec
--- /dev/null
+++ b/ui/litellm-dashboard/src/components/chat/AGENTS.md
@@ -0,0 +1,47 @@
+# Chat UI — Agent Instructions
+
+Read `design.md` first. That file is the _what_ (tokens, components, patterns). This file is the _when and how_: decision trees for ambiguous cases, and the checklist to run before you're done.
+
+This directory has drifted from its own spec before — a hand-rolled `<button>` sidebar nav item went through five different ad-hoc color attempts in one session (invisible `bg-accent`, a barely-visible shadow, invisible `bg-primary/10`, a `border-l-2` that clipped at the border-radius corner) before landing on the actual fix: use `bg-sidebar-accent`, a token that already existed and was never checked. Every rule below exists to stop that specific failure mode: **reaching for a plausible-looking Tailwind class instead of checking what the design system already provides.**
+
+---
+
+## Decision tree: "I need a new UI element"
+
+1. **Does `design.md` already show this exact pattern?** Copy it verbatim. Don't restyle it "to match" something else you're looking at — if it needs to look different, that's a `design.md` update, not a one-off deviation.
+2. **Is it a clickable thing?** It's a `Button` (some variant/size), full stop. Never a raw `<button>`. If no variant looks right, that's a sign to re-read the Button section in `design.md`, not to hand-roll classes on a `<button>`.
+3. **Does it need a color for "selected" / "active" / "hover"?** Before picking a class:
+ - Read the actual values in `src/app/globals.css` for the classes you're about to use. Don't assume `accent` ≠ `secondary` ≠ `muted` — in this theme they're identical. Confirm contrast against the _actual container_ background, not the general Tailwind palette in your head.
+ - If the element lives inside the sidebar, use the `sidebar-*` token family (`bg-sidebar`, `bg-sidebar-accent`, `text-sidebar-accent-foreground`), not the generic tokens.
+4. **Is the shadcn primitive you want to use not in `src/components/ui/`?** Check the "Known gaps" list in `design.md` first — if it's `Card`, `Textarea`, `sonner`, or a `Sidebar` block, use the documented substitute. If it's something else entirely missing, stop and flag it; don't hand-write a parallel implementation inside a chat component.
+5. **Still unsure?** Grep this directory and `src/app/(dashboard)/` for an existing instance of the same UI idea (e.g. "how does the rest of the dashboard render a data table") before inventing a new pattern for chat specifically. The chat UI should look like the rest of the app, not like its own product.
+
+## Decision tree: "I'm fixing a bug in an existing component"
+
+1. Reproduce it first — actually load the page, don't infer from reading code.
+2. If the bug is visual (wrong color, wrong spacing, misaligned element), check whether the _component_ is even the right primitive before touching classes. A hand-rolled `<button>` with a color bug is often better fixed by replacing it with `Button` than by fixing the color, because the color bug is usually a symptom of not having the component's built-in state handling.
+3. Fix the root cause, not the symptom you can see. "The active tab has an invisible highlight" was fixed correctly only on the _second_ attempt — the first fix (a subtle shadow) treated the symptom (not distinct enough) without asking why `bg-accent` had no contrast in the first place.
+4. After the fix, look for the same bug pattern elsewhere in the same file and sibling files. If one nav item had a contrast bug, check whether the pattern is reused elsewhere before considering it done.
+
+## When it's OK to deviate from `design.md`
+
+- The pattern truly doesn't exist yet in this codebase and adding the missing shadcn piece (e.g. a real `Sidebar` block, `Textarea`, `sonner`) is out of scope for the current change. Use the documented substitute in "Known gaps," and don't block your task on it — but don't invent a _different_ substitute than the one written down either.
+- You're the one updating `design.md` itself because the pattern was wrong (like the `bg-secondary`-sidebar-with-`bg-accent`-active-item combination that shipped with zero contrast). In that case, update `design.md` in the same change, with a note on what was wrong and why the new pattern is correct — don't leave the stale guidance in place for the next agent to copy.
+
+Never deviate silently. If you improvise, the next agent (or you, in six months) will copy the improvisation as if it were the standard.
+
+## Pre-commit checklist
+
+Run through this before considering a chat UI change done:
+
+- [ ] Every clickable element is a `Button` variant, not a raw `<button>` — search your diff for `<button` and justify any that remain (the chat composer's textarea-adjacent icon buttons and similar truly-custom controls are the only accepted exceptions; nav items and dialog actions are not).
+- [ ] Every color class you added actually contrasts against its container — checked in `globals.css`, not assumed.
+- [ ] Sidebar-scoped elements use `sidebar-*` tokens, not generic `accent`/`secondary`/`muted`.
+- [ ] No new `text-foreground/NN` opacity hacks — use `text-muted-foreground`.
+- [ ] Loading states are `Skeleton`, not a bare spinner, unless it's a button's own in-flight state.
+- [ ] Tabs use `variant="line"` if they're section tabs.
+- [ ] Destructive actions go through `AlertDialog`.
+- [ ] `npx tsc --noEmit -p .` is clean for touched files.
+- [ ] `npx prettier --write <files>` run on anything you hand-edited (don't let formatting drift force a second review pass).
+- [ ] Actually opened the page in a browser and looked at the change — a design-system violation that "should" render correctly per the code is still a bug if it doesn't.
+- [ ] If you changed or discovered a gap in `design.md`, `design.md` was updated in the same commit, not left for later.
diff --git a/ui/litellm-dashboard/src/components/chat/ChatMessages.tsx b/ui/litellm-dashboard/src/components/chat/ChatMessages.tsx
index c92b9494e2c..b9f4fb7c3bc 100644
--- a/ui/litellm-dashboard/src/components/chat/ChatMessages.tsx
+++ b/ui/litellm-dashboard/src/components/chat/ChatMessages.tsx
@@ -3,6 +3,7 @@
import { Wrench, Copy, Check, Pencil } from "lucide-react";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible";
+import { Button } from "@/components/ui/button";
import React, { useEffect, useRef, useState } from "react";
import ReactMarkdown from "react-markdown";
import remarkGfm from "remark-gfm";
@@ -122,27 +123,19 @@ function UserBubble({ message, onEdit, isStreaming }: UserBubbleProps) {
className="w-full px-3.5 py-2.5 border-none outline-none resize-none text-sm leading-relaxed text-foreground font-[inherit] bg-transparent box-border min-h-[40px]"
/>
<div className="flex justify-end gap-2 px-2.5 py-1.5 border-t">
- <button
+ <Button
+ variant="outline"
+ size="sm"
onClick={() => {
setEditValue(message.content);
setEditing(false);
}}
- className="px-3 py-1 rounded-md border text-[13px] text-muted-foreground hover:bg-accent transition-colors"
- style={{ background: "none" }}
>
Cancel
- </button>
- <button
- onClick={handleSave}
- disabled={!editValue.trim()}
- className={`px-3 py-1 rounded-md border-none text-[13px] font-medium transition-colors ${
- editValue.trim()
- ? "bg-primary text-primary-foreground cursor-pointer hover:bg-primary/90"
- : "bg-muted text-muted-foreground cursor-not-allowed"
- }`}
- >
- Save &amp; Send
- </button>
+ </Button>
+ <Button size="sm" onClick={handleSave} disabled={!editValue.trim()}>
+ Save & Send
+ </Button>
</div>
</div>
</div>
@@ -160,16 +153,17 @@ function UserBubble({ message, onEdit, isStreaming }: UserBubbleProps) {
<TooltipProvider delayDuration={300}>
<Tooltip>
<TooltipTrigger asChild>
- <button
+ <Button
+ variant="ghost"
+ size="icon-xs"
onClick={() => {
setEditValue(message.content);
setEditing(true);
}}
- className="p-1 rounded-md text-muted-foreground hover:text-foreground transition-colors shrink-0 flex items-center"
- style={{ background: "none", border: "none" }}
+ className="text-muted-foreground hover:text-foreground shrink-0"
>
- <Pencil className="h-3.5 w-3.5" />
- </button>
+ <Pencil className="size-3.5" />
+ </Button>
</TooltipTrigger>
<TooltipContent>
<p>Edit message</p>
@@ -274,15 +268,14 @@ function CopyButton({ text }: { text: string }) {
<TooltipProvider delayDuration={300}>
<Tooltip>
<TooltipTrigger asChild>
- <button
+ <Button
+ variant="ghost"
+ size="icon-xs"
onClick={handleCopy}
- className={`p-1 rounded-md flex items-center gap-1 transition-colors text-[13px] ${
- copied ? "text-emerald-600" : "text-muted-foreground hover:text-foreground"
- }`}
- style={{ background: "none", border: "none" }}
+ className={copied ? "text-emerald-600" : "text-muted-foreground hover:text-foreground"}
>
- {copied ? <Check className="h-3.5 w-3.5" /> : <Copy className="h-3.5 w-3.5" />}
- </button>
+ {copied ? <Check className="size-3.5" /> : <Copy className="size-3.5" />}
+ </Button>
</TooltipTrigger>
<TooltipContent>
<p>{copied ? "Copied!" : "Copy"}</p>
diff --git a/ui/litellm-dashboard/src/components/chat/ChatShell.tsx b/ui/litellm-dashboard/src/components/chat/ChatShell.tsx
index 09af0abdf2f..f4e0703d62b 100644
--- a/ui/litellm-dashboard/src/components/chat/ChatShell.tsx
+++ b/ui/litellm-dashboard/src/components/chat/ChatShell.tsx
@@ -1,19 +1,9 @@
"use client";
-import React, { useState } from "react";
+import React from "react";
import { usePathname, useRouter } from "next/navigation";
-import {
- Pencil,
- PanelLeftClose,
- PanelLeftOpen,
- Search,
- MessageSquare,
- LayoutGrid,
- KeyRound,
- Lock,
- BarChart3,
-} from "lucide-react";
-import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
+import { Plus, MessageSquare, LayoutGrid, KeyRound, Lock, BarChart3 } from "lucide-react";
+import { Button } from "@/components/ui/button";
import { Separator } from "@/components/ui/separator";
import { migratedHref } from "@/utils/migratedPages";
import { useChatShell } from "@/contexts/ChatShellContext";
@@ -37,33 +27,21 @@ interface NavItemProps {
label: string;
onClick: () => void;
active?: boolean;
- collapsed: boolean;
}
-function NavItem({ icon, label, onClick, active = false, collapsed }: NavItemProps) {
- const btn = (
- <button
+function NavItem({ icon, label, onClick, active = false }: NavItemProps) {
+ return (
+ <Button
onClick={onClick}
+ variant="ghost"
aria-current={active ? "page" : undefined}
- className={`flex items-center gap-2.5 px-2.5 py-2 w-full rounded-md border-none text-sm text-left transition-colors ${
- collapsed ? "justify-center" : "justify-start"
- } ${active ? "bg-accent text-accent-foreground" : "text-foreground/70 hover:bg-accent/50"}`}
- style={{ cursor: "pointer" }}
+ className={`w-full justify-start gap-2.5 px-2.5 font-medium hover:bg-sidebar-accent ${
+ active ? "bg-sidebar-accent text-sidebar-accent-foreground" : "text-muted-foreground"
+ }`}
>
<span className="shrink-0">{icon}</span>
- {!collapsed && <span className="flex-1 text-left font-medium">{label}</span>}
- </button>
- );
- if (!collapsed) return btn;
- return (
- <TooltipProvider delayDuration={200}>
- <Tooltip>
- <TooltipTrigger asChild>{btn}</TooltipTrigger>
- <TooltipContent side="right">
- <p>{label}</p>
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
+ <span className="flex-1 text-left">{label}</span>
+ </Button>
);
}
@@ -74,7 +52,6 @@ interface ChatShellProps {
const ChatShell: React.FC<ChatShellProps> = ({ children }) => {
const router = useRouter();
const pathname = stripTrailingSlash(usePathname() ?? "");
- const [sidebarCollapsed, setSidebarCollapsed] = useState(false);
const { conversations, activeConversationId, deleteConversation, renameConversation } = useChatShell();
const isChatsRoute = pathname === CHAT_ROUTES.chats;
@@ -94,45 +71,15 @@ const ChatShell: React.FC<ChatShellProps> = ({ children }) => {
.
</div>
<div className="flex flex-1 min-h-0 overflow-hidden">
- <div
- className="shrink-0 bg-secondary border-r flex flex-col overflow-hidden"
- style={{ width: sidebarCollapsed ? 56 : 260, transition: "width 0.2s cubic-bezier(0.4, 0, 0.2, 1)" }}
- >
- <div className="flex items-center justify-start px-2.5 py-3 shrink-0">
- <TooltipProvider delayDuration={200}>
- <Tooltip>
- <TooltipTrigger asChild>
- <button
- onClick={() => setSidebarCollapsed((v) => !v)}
- className="p-1.5 rounded-md text-muted-foreground hover:text-foreground flex items-center cursor-pointer transition-colors"
- style={{ background: "none", border: "none" }}
- >
- {sidebarCollapsed ? <PanelLeftOpen className="h-4 w-4" /> : <PanelLeftClose className="h-4 w-4" />}
- </button>
- </TooltipTrigger>
- <TooltipContent side="right">
- <p>{sidebarCollapsed ? "Expand sidebar" : "Collapse sidebar"}</p>
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
+ <div className="shrink-0 bg-sidebar border-sidebar-border border-r flex flex-col overflow-hidden w-[260px]">
+ <div className="px-2 pt-3 pb-1 shrink-0">
+ <Button onClick={() => router.push(CHAT_ROUTES.chats)} className="w-full justify-start gap-2.5">
+ <Plus className="h-4 w-4" />
+ New Chat
+ </Button>
</div>
- <div className="px-2 pb-1 shrink-0">
- <NavItem
- icon={<Pencil className="h-4 w-4" />}
- label="New chat"
- onClick={() => router.push(CHAT_ROUTES.chats)}
- collapsed={sidebarCollapsed}
- />
- <NavItem
- icon={<Search className="h-4 w-4" />}
- label="Search chats"
- onClick={() => router.push(CHAT_ROUTES.chats)}
- collapsed={sidebarCollapsed}
- />
- </div>
-
- <Separator className="mx-2 shrink-0" />
+ <Separator className="mx-2 mt-2 shrink-0" />
<div className="px-2 py-1 shrink-0">
<NavItem
@@ -140,55 +87,47 @@ const ChatShell: React.FC<ChatShellProps> = ({ children }) => {
label="Chats"
onClick={() => router.push(CHAT_ROUTES.chats)}
active={isChatsRoute}
- collapsed={sidebarCollapsed}
/>
<NavItem
icon={<LayoutGrid className="h-4 w-4" />}
label="Integrations"
onClick={() => router.push(CHAT_ROUTES.integrations)}
active={pathname === CHAT_ROUTES.integrations}
- collapsed={sidebarCollapsed}
/>
<NavItem
icon={<KeyRound className="h-4 w-4" />}
label="Credentials"
onClick={() => router.push(CHAT_ROUTES.credentials)}
active={pathname === CHAT_ROUTES.credentials}
- collapsed={sidebarCollapsed}
/>
<NavItem
icon={<Lock className="h-4 w-4" />}
label="API Keys"
onClick={() => router.push(CHAT_ROUTES.apiKeys)}
active={pathname === CHAT_ROUTES.apiKeys}
- collapsed={sidebarCollapsed}
/>
<NavItem
icon={<BarChart3 className="h-4 w-4" />}
label="Usage"
onClick={() => router.push(CHAT_ROUTES.usage)}
active={pathname === CHAT_ROUTES.usage}
- collapsed={sidebarCollapsed}
/>
</div>
<Separator className="mx-2 shrink-0" />
- {!sidebarCollapsed && (
- <div className="flex-1 overflow-hidden flex flex-col">
- <ConversationList
- conversations={conversations}
- activeConversationId={activeConversationId}
- onSelect={(id) => router.push(`${CHAT_ROUTES.chats}?id=${id}`)}
- onDelete={(id) => {
- deleteConversation(id);
- if (id === activeConversationId) router.push(CHAT_ROUTES.chats);
- }}
- onNewChat={() => router.push(CHAT_ROUTES.chats)}
- onRename={renameConversation}
- />
- </div>
- )}
+ <div className="flex-1 overflow-hidden flex flex-col">
+ <ConversationList
+ conversations={conversations}
+ activeConversationId={activeConversationId}
+ onSelect={(id) => router.push(`${CHAT_ROUTES.chats}?id=${id}`)}
+ onDelete={(id) => {
+ deleteConversation(id);
+ if (id === activeConversationId) router.push(CHAT_ROUTES.chats);
+ }}
+ onRename={renameConversation}
+ />
+ </div>
</div>
<div className="flex-1 flex flex-col overflow-hidden min-w-0">{children}</div>
diff --git a/ui/litellm-dashboard/src/components/chat/ConversationList.tsx b/ui/litellm-dashboard/src/components/chat/ConversationList.tsx
index a0ac141c0f4..91c18c09935 100644
--- a/ui/litellm-dashboard/src/components/chat/ConversationList.tsx
+++ b/ui/litellm-dashboard/src/components/chat/ConversationList.tsx
@@ -1,7 +1,7 @@
"use client";
import React, { useState, useEffect, useRef, useCallback } from "react";
-import { Pencil, Trash2, Plus, Search, MessageSquare } from "lucide-react";
+import { Pencil, Trash2, Search, MessageSquare } from "lucide-react";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Dialog, DialogContent } from "@/components/ui/dialog";
@@ -26,22 +26,21 @@ interface Props {
activeConversationId: string | null;
onSelect: (id: string) => void;
onDelete: (id: string) => void;
- onNewChat: () => void;
onRename: (id: string, newTitle: string) => void;
}
-type DateGroup = "Today" | "Yesterday" | "Last 7 Days" | "Older";
+type DateGroup = "Recents" | "Yesterday" | "Last 7 Days" | "Older";
const getDateGroup = (timestamp: number): DateGroup => {
const now = dayjs();
const date = dayjs(timestamp);
- if (date.isSame(now, "day")) return "Today";
+ if (date.isSame(now, "day")) return "Recents";
if (date.isSame(now.subtract(1, "day"), "day")) return "Yesterday";
if (date.isAfter(now.subtract(7, "day"))) return "Last 7 Days";
return "Older";
};
-const DATE_GROUP_ORDER: DateGroup[] = ["Today", "Yesterday", "Last 7 Days", "Older"];
+const DATE_GROUP_ORDER: DateGroup[] = ["Recents", "Yesterday", "Last 7 Days", "Older"];
interface GroupedConversations {
group: DateGroup;
@@ -147,13 +146,9 @@ const ConversationRow: React.FC<ConversationRowProps> = ({ conv, isActive, onSel
<TooltipProvider delayDuration={300}>
<Tooltip>
<TooltipTrigger asChild>
- <button
- onClick={startEditing}
- className="w-[22px] h-[22px] p-0 flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground transition-colors"
- style={{ background: "none", border: "none" }}
- >
+ <Button onClick={startEditing} variant="ghost" size="icon-xs" className="text-muted-foreground">
<Pencil className="h-3 w-3" />
- </button>
+ </Button>
</TooltipTrigger>
<TooltipContent side="bottom">
<p>Rename</p>
@@ -166,12 +161,9 @@ const ConversationRow: React.FC<ConversationRowProps> = ({ conv, isActive, onSel
<Tooltip>
<TooltipTrigger asChild>
<AlertDialogTrigger asChild>
- <button
- className="w-[22px] h-[22px] p-0 flex items-center justify-center rounded-md text-muted-foreground hover:text-destructive transition-colors"
- style={{ background: "none", border: "none" }}
- >
+ <Button variant="ghost" size="icon-xs" className="text-muted-foreground hover:text-destructive">
<Trash2 className="h-3 w-3" />
- </button>
+ </Button>
</AlertDialogTrigger>
</TooltipTrigger>
<TooltipContent side="bottom">
@@ -268,14 +260,7 @@ const SearchModal: React.FC<SearchModalProps> = ({ open, conversations, onSelect
);
};
-const ConversationList: React.FC<Props> = ({
- conversations,
- activeConversationId,
- onSelect,
- onDelete,
- onNewChat,
- onRename,
-}) => {
+const ConversationList: React.FC<Props> = ({ conversations, activeConversationId, onSelect, onDelete, onRename }) => {
const [searchModalOpen, setSearchModalOpen] = useState(false);
const handleGlobalKeyDown = useCallback((e: KeyboardEvent) => {
@@ -295,23 +280,7 @@ const ConversationList: React.FC<Props> = ({
return (
<>
<div className="flex flex-col h-full w-full overflow-hidden">
- <div className="px-2.5 pt-3 pb-2">
- <TooltipProvider delayDuration={300}>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button onClick={onNewChat} className="w-full" size="sm">
- <Plus className="h-4 w-4 mr-1.5" />
- New Chat
- </Button>
- </TooltipTrigger>
- <TooltipContent side="right">
- <p>Chats are saved locally in this browser. All requests are logged in Spend -&gt; Logs</p>
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
- </div>
-
- <ScrollArea className="flex-1 px-1.5">
+ <ScrollArea className="flex-1 h-0 px-1.5 pt-2">
{grouped.length === 0 ? (
<div className="text-center text-muted-foreground/60 text-xs mt-8 px-3">
No conversations yet
diff --git a/ui/litellm-dashboard/src/components/chat/KeysPanel.tsx b/ui/litellm-dashboard/src/components/chat/KeysPanel.tsx
index f7e8116d0d4..1935c0f226a 100644
--- a/ui/litellm-dashboard/src/components/chat/KeysPanel.tsx
+++ b/ui/litellm-dashboard/src/components/chat/KeysPanel.tsx
@@ -247,7 +247,7 @@ const KeysPanel: React.FC<Props> = ({ accessToken, userId, premiumUser }) => {
{!record.expires ? (
<span className="text-muted-foreground text-[13px]">Never</span>
) : (
- <Badge variant={expired ? "destructive" : "default"}>
+ <Badge variant={expired ? "destructive" : "outline"}>
{expired ? "Expired" : formatExpiresUtc(record.expires)}
</Badge>
)}
@@ -279,7 +279,7 @@ const KeysPanel: React.FC<Props> = ({ accessToken, userId, premiumUser }) => {
{regeneratedKey ? (
<div>
- <div className="rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-800 mb-4">
+ <div className="rounded-lg border border-amber-200 dark:border-amber-900 bg-amber-50 dark:bg-amber-950 px-3 py-2 text-sm text-amber-800 dark:text-amber-300 mb-4">
Save this key now; you will not see it again
</div>
<div className="text-xs text-muted-foreground mb-1">New Key</div>
@@ -289,13 +289,13 @@ const KeysPanel: React.FC<Props> = ({ accessToken, userId, premiumUser }) => {
</div>
) : (
<div className="flex flex-col gap-4 mt-1">
- <div>
- <Label className="text-sm mb-1.5 block">Key Alias</Label>
+ <div className="flex flex-col gap-1.5">
+ <Label>Key Alias</Label>
<Input value={formState.key_alias} disabled />
</div>
<div className="grid grid-cols-3 gap-3">
- <div>
- <Label className="text-sm mb-1.5 block">Max Budget (USD)</Label>
+ <div className="flex flex-col gap-1.5">
+ <Label>Max Budget (USD)</Label>
<Input
type="number"
step="0.01"
@@ -303,16 +303,16 @@ const KeysPanel: React.FC<Props> = ({ accessToken, userId, premiumUser }) => {
onChange={(e) => updateField("max_budget", e.target.value)}
/>
</div>
- <div>
- <Label className="text-sm mb-1.5 block">TPM Limit</Label>
+ <div className="flex flex-col gap-1.5">
+ <Label>TPM Limit</Label>
<Input
type="number"
value={formState.tpm_limit}
onChange={(e) => updateField("tpm_limit", e.target.value)}
/>
</div>
- <div>
- <Label className="text-sm mb-1.5 block">RPM Limit</Label>
+ <div className="flex flex-col gap-1.5">
+ <Label>RPM Limit</Label>
<Input
type="number"
value={formState.rpm_limit}
@@ -321,30 +321,30 @@ const KeysPanel: React.FC<Props> = ({ accessToken, userId, premiumUser }) => {
</div>
</div>
<div className="grid grid-cols-2 gap-3">
- <div>
- <Label className="text-sm mb-1.5 block">Expire Key</Label>
+ <div className="flex flex-col gap-1.5">
+ <Label>Expire Key</Label>
<Input
placeholder="e.g. 30s, 30h, 30d"
value={formState.duration}
onChange={(e) => updateField("duration", e.target.value)}
/>
- {formErrors.duration && <p className="text-xs text-destructive mt-1">{formErrors.duration}</p>}
- <p className={`text-xs mt-1 ${keyIsExpired ? "text-destructive" : "text-muted-foreground"}`}>
+ {formErrors.duration && <p className="text-xs text-destructive">{formErrors.duration}</p>}
+ <p className={`text-xs ${keyIsExpired ? "text-destructive" : "text-muted-foreground"}`}>
Current: {rotateTarget?.expires ? formatExpiresUtc(rotateTarget.expires) : "Never"}
{keyIsExpired && " (expired)"}
</p>
- {newExpiryTime && <p className="text-xs text-emerald-600 mt-0.5">New: {newExpiryTime}</p>}
+ {newExpiryTime && (
+ <p className="text-xs text-emerald-600 dark:text-emerald-400">New: {newExpiryTime}</p>
+ )}
</div>
- <div>
- <Label className="text-sm mb-1.5 block">Grace Period</Label>
+ <div className="flex flex-col gap-1.5">
+ <Label>Grace Period</Label>
<Input
placeholder="e.g. 24h, 2d"
value={formState.grace_period}
onChange={(e) => updateField("grace_period", e.target.value)}
/>
- {formErrors.grace_period && (
- <p className="text-xs text-destructive mt-1">{formErrors.grace_period}</p>
- )}
+ {formErrors.grace_period && <p className="text-xs text-destructive">{formErrors.grace_period}</p>}
</div>
</div>
</div>
diff --git a/ui/litellm-dashboard/src/components/chat/MCPAppsPanel.tsx b/ui/litellm-dashboard/src/components/chat/MCPAppsPanel.tsx
index 49b4c9a37a5..867522090d2 100644
--- a/ui/litellm-dashboard/src/components/chat/MCPAppsPanel.tsx
+++ b/ui/litellm-dashboard/src/components/chat/MCPAppsPanel.tsx
@@ -42,7 +42,7 @@ const OAuth2ConnectButton: React.FC<OAuth2ConnectButtonProps> = ({
if (variant === "button") {
return (
- <Button onClick={startOAuthFlow} disabled={loading} className="rounded-lg font-semibold h-[38px] min-w-[110px]">
+ <Button onClick={startOAuthFlow} disabled={loading} className="font-semibold h-[38px] min-w-[110px]">
{loading && <Loader2 className="h-4 w-4 animate-spin mr-1.5" />}
{loading ? "Connecting\u2026" : "Connect"}
</Button>
@@ -258,14 +258,15 @@ const MCPAppsPanel: React.FC<Props> = ({ accessToken, selectedServers, onChange
return (
<div className="w-full">
- <button
+ <Button
+ variant="ghost"
+ size="sm"
onClick={() => setDetailServer(null)}
- className="flex items-center gap-1.5 text-muted-foreground text-[13px] pb-5 hover:text-foreground transition-colors"
- style={{ background: "none", border: "none" }}
+ className="-ml-3 mb-5 gap-1.5 text-muted-foreground hover:text-foreground"
>
<ArrowLeft className="h-3 w-3" />
Back
- </button>
+ </Button>
<div className="flex items-start gap-5 mb-7">
{detailServer.mcp_info?.logo_url ? (
@@ -310,7 +311,7 @@ const MCPAppsPanel: React.FC<Props> = ({ accessToken, selectedServers, onChange
});
onChangeRef.current(selectedServersRef.current.filter((s) => s !== name));
}}
- className="rounded-lg font-semibold h-[38px] min-w-[110px]"
+ className="font-semibold h-[38px] min-w-[110px]"
>
Disconnect
</Button>
@@ -329,7 +330,7 @@ const MCPAppsPanel: React.FC<Props> = ({ accessToken, selectedServers, onChange
variant={isConnected ? "outline" : "default"}
disabled={isTogglingOn}
onClick={() => handleToggle(name, !isConnected, detailServer.server_id)}
- className="rounded-lg font-semibold h-[38px] min-w-[110px]"
+ className="font-semibold h-[38px] min-w-[110px]"
>
{isTogglingOn && <Loader2 className="h-4 w-4 animate-spin mr-1.5" />}
{isConnected ? "Disconnect" : "Connect"}
@@ -338,7 +339,7 @@ const MCPAppsPanel: React.FC<Props> = ({ accessToken, selectedServers, onChange
</div>
<h3 className="m-0 mb-3 text-[15px] font-semibold text-foreground">Information</h3>
- <div className="border rounded-xl overflow-hidden mb-7">
+ <div className="border rounded-lg overflow-hidden mb-7">
{[
["Server ID", detailServer.server_id],
["Transport", handleTransport(detailServer.transport, detailServer.spec_path)],
@@ -362,8 +363,13 @@ const MCPAppsPanel: React.FC<Props> = ({ accessToken, selectedServers, onChange
)}
</div>
{loadingTools ? (
- <div className="flex justify-center py-6">
- <Loader2 className="h-5 w-5 animate-spin text-muted-foreground" />
+ <div className="flex flex-col gap-2">
+ {Array.from({ length: 3 }, (_, i) => (
+ <div key={i} className="border rounded-lg px-3.5 py-2.5 bg-muted/30 flex flex-col gap-1.5">
+ <Skeleton className="h-3.5 w-1/3" />
+ <Skeleton className="h-3 w-2/3" />
+ </div>
+ ))}
</div>
) : detailTools.length === 0 ? (
<div className="text-muted-foreground text-[13px] py-2">No tools available</div>
@@ -432,8 +438,19 @@ const MCPAppsPanel: React.FC<Props> = ({ accessToken, selectedServers, onChange
</Tabs>
{loading ? (
- <div className="flex justify-center py-12">
- <Loader2 className="h-5 w-5 animate-spin text-muted-foreground" />
+ <div className="grid grid-cols-2 border rounded-lg overflow-hidden">
+ {Array.from({ length: 6 }, (_, idx) => (
+ <div
+ key={idx}
+ className={`flex items-center gap-3 p-4 ${idx % 2 === 0 ? "border-r" : ""} ${idx < 4 ? "border-b" : ""}`}
+ >
+ <Skeleton className="w-[38px] h-[38px] rounded-xl shrink-0" />
+ <div className="flex-1 min-w-0 flex flex-col gap-1.5">
+ <Skeleton className="h-3.5 w-2/3" />
+ <Skeleton className="h-3 w-1/2" />
+ </div>
+ </div>
+ ))}
</div>
) : filtered.length === 0 ? (
<div className="text-center text-muted-foreground text-[13px] py-12 px-3">
@@ -444,7 +461,7 @@ const MCPAppsPanel: React.FC<Props> = ({ accessToken, selectedServers, onChange
: "No servers match your search."}
</div>
) : (
- <div className="grid grid-cols-2 border rounded-xl overflow-hidden">
+ <div className="grid grid-cols-2 border rounded-lg overflow-hidden">
{filtered.map((server, idx) => {
const name = nameOf(server);
const isConnected = selectedServers.includes(name);
@@ -456,7 +473,7 @@ const MCPAppsPanel: React.FC<Props> = ({ accessToken, selectedServers, onChange
<div
key={server.server_id}
onClick={() => setDetailServer(server)}
- className={`flex items-center gap-3 px-4 py-3.5 bg-background cursor-pointer transition-colors hover:bg-accent/30 min-w-0 ${
+ className={`flex items-center gap-3 p-4 bg-card cursor-pointer transition-colors hover:bg-accent/30 min-w-0 ${
isLeftCol ? "border-r" : ""
} ${Math.floor(idx / 2) < Math.floor((filtered.length - 1) / 2) ? "border-b" : ""}`}
>
@@ -510,7 +527,7 @@ const MCPAppsPanel: React.FC<Props> = ({ accessToken, selectedServers, onChange
/>
)
) : isConnected ? (
- <span className="w-[7px] h-[7px] rounded-full bg-primary shrink-0" />
+ <span className="w-[7px] h-[7px] rounded-full bg-emerald-600 dark:bg-emerald-400 shrink-0" />
) : null}
<ChevronRight className="h-3 w-3 text-muted-foreground/40 shrink-0" />
</div>
diff --git a/ui/litellm-dashboard/src/components/chat/MCPConnectPicker.tsx b/ui/litellm-dashboard/src/components/chat/MCPConnectPicker.tsx
index 8b816e6a842..abeccb0f041 100644
--- a/ui/litellm-dashboard/src/components/chat/MCPConnectPicker.tsx
+++ b/ui/litellm-dashboard/src/components/chat/MCPConnectPicker.tsx
@@ -1,6 +1,7 @@
import React, { useEffect, useState } from "react";
import { Loader2 } from "lucide-react";
import { Switch } from "@/components/ui/switch";
+import { Skeleton } from "@/components/ui/skeleton";
import MessageManager from "@/components/molecules/message_manager";
import { fetchMCPServers, listMCPTools } from "../networking";
import { MCPServer } from "../mcp_tools/types";
@@ -72,8 +73,19 @@ const MCPConnectPicker: React.FC<Props> = ({ accessToken, selectedServers, onCha
return (
<div className="max-w-[320px] max-h-[400px] overflow-y-auto py-2">
{loadingServers ? (
- <div className="flex justify-center py-6">
- <Loader2 className="h-5 w-5 animate-spin text-muted-foreground" />
+ <div className="flex flex-col gap-1">
+ {Array.from({ length: 3 }).map((_, i) => (
+ <div key={i} className="flex items-center justify-between px-3 py-2 gap-3">
+ <div className="flex items-start gap-3 flex-1 min-w-0">
+ <Skeleton className="h-6 w-6 rounded-md shrink-0" />
+ <div className="flex flex-col gap-1.5 flex-1 min-w-0">
+ <Skeleton className="h-3.5 w-24" />
+ <Skeleton className="h-3 w-32" />
+ </div>
+ </div>
+ <Skeleton className="h-3.5 w-6 rounded-full shrink-0" />
+ </div>
+ ))}
</div>
) : servers.length === 0 ? (
<div className="px-3 py-4 text-muted-foreground text-[13px] text-center">No MCP servers configured</div>
diff --git a/ui/litellm-dashboard/src/components/chat/MCPCredentialsTab.tsx b/ui/litellm-dashboard/src/components/chat/MCPCredentialsTab.tsx
index c59fe43367b..f73d18081d8 100644
--- a/ui/litellm-dashboard/src/components/chat/MCPCredentialsTab.tsx
+++ b/ui/litellm-dashboard/src/components/chat/MCPCredentialsTab.tsx
@@ -4,7 +4,20 @@ import React, { useState } from "react";
import { useQuery, useQueryClient } from "@tanstack/react-query";
import { Loader2, Trash2, Link } from "lucide-react";
import { Badge } from "@/components/ui/badge";
+import { Button } from "@/components/ui/button";
+import { Skeleton } from "@/components/ui/skeleton";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
+import {
+ AlertDialog,
+ AlertDialogAction,
+ AlertDialogCancel,
+ AlertDialogContent,
+ AlertDialogDescription,
+ AlertDialogFooter,
+ AlertDialogHeader,
+ AlertDialogTitle,
+ AlertDialogTrigger,
+} from "@/components/ui/alert-dialog";
import MessageManager from "@/components/molecules/message_manager";
import { deleteMCPOAuthUserCredential, listMCPUserCredentials, MCPUserCredentialListItem } from "../networking";
@@ -33,9 +46,9 @@ function relativeTime(isoString: string | null | undefined): string {
function expiryLabel(isoString: string | null | undefined): {
text: string;
- variant: "default" | "destructive" | "outline";
+ variant: "secondary" | "destructive" | "outline";
} {
- if (!isoString) return { text: "Does not expire", variant: "outline" };
+ if (!isoString) return { text: "Does not expire", variant: "secondary" };
try {
const exp = new Date(isoString);
const diffMs = exp.getTime() - Date.now();
@@ -44,9 +57,9 @@ function expiryLabel(isoString: string | null | undefined): {
const diffMin = Math.floor(diffSec / 60);
const diffHr = Math.floor(diffMin / 60);
const diffDay = Math.floor(diffHr / 24);
- if (diffDay > 0) return { text: `Expires in ${diffDay}d`, variant: "default" };
- if (diffHr > 0) return { text: `Expires in ${diffHr}h`, variant: "default" };
- return { text: `Expires in ${diffMin}m`, variant: "default" };
+ if (diffDay > 0) return { text: `Expires in ${diffDay}d`, variant: "outline" };
+ if (diffHr > 0) return { text: `Expires in ${diffHr}h`, variant: "outline" };
+ return { text: `Expires in ${diffMin}m`, variant: "outline" };
} catch {
return { text: "", variant: "outline" };
}
@@ -90,8 +103,43 @@ const MCPCredentialsTab: React.FC<Props> = ({ accessToken }) => {
</div>
{loading ? (
- <div className="flex justify-center py-12">
- <Loader2 className="h-5 w-5 animate-spin text-muted-foreground" />
+ <div className="rounded-lg border overflow-hidden">
+ <Table>
+ <TableHeader>
+ <TableRow className="bg-muted/50">
+ <TableHead className="text-[11px] font-medium uppercase tracking-wide text-muted-foreground">
+ App
+ </TableHead>
+ <TableHead className="text-[11px] font-medium uppercase tracking-wide text-muted-foreground">
+ Connected
+ </TableHead>
+ <TableHead className="text-[11px] font-medium uppercase tracking-wide text-muted-foreground">
+ Status
+ </TableHead>
+ <TableHead className="text-[11px] font-medium uppercase tracking-wide text-muted-foreground text-right">
+ Actions
+ </TableHead>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {Array.from({ length: 3 }, (_, i) => (
+ <TableRow key={i}>
+ <TableCell>
+ <Skeleton className="h-4 w-24" />
+ </TableCell>
+ <TableCell>
+ <Skeleton className="h-4 w-16" />
+ </TableCell>
+ <TableCell>
+ <Skeleton className="h-4 w-20" />
+ </TableCell>
+ <TableCell className="text-right">
+ <Skeleton className="h-4 w-8 ml-auto" />
+ </TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
</div>
) : credentials.length === 0 ? (
<div className="text-center text-muted-foreground text-sm py-12 border border-dashed rounded-lg">
@@ -107,10 +155,18 @@ const MCPCredentialsTab: React.FC<Props> = ({ accessToken }) => {
<Table>
<TableHeader>
<TableRow className="bg-muted/50">
- <TableHead className="text-xs font-semibold uppercase tracking-wide">App</TableHead>
- <TableHead className="text-xs font-semibold uppercase tracking-wide">Connected</TableHead>
- <TableHead className="text-xs font-semibold uppercase tracking-wide">Status</TableHead>
- <TableHead className="text-xs font-semibold uppercase tracking-wide text-right">Actions</TableHead>
+ <TableHead className="text-[11px] font-medium uppercase tracking-wide text-muted-foreground">
+ App
+ </TableHead>
+ <TableHead className="text-[11px] font-medium uppercase tracking-wide text-muted-foreground">
+ Connected
+ </TableHead>
+ <TableHead className="text-[11px] font-medium uppercase tracking-wide text-muted-foreground">
+ Status
+ </TableHead>
+ <TableHead className="text-[11px] font-medium uppercase tracking-wide text-muted-foreground text-right">
+ Actions
+ </TableHead>
</TableRow>
</TableHeader>
<TableBody>
@@ -127,19 +183,38 @@ const MCPCredentialsTab: React.FC<Props> = ({ accessToken }) => {
<Badge variant={exp.variant}>{exp.text}</Badge>
</TableCell>
<TableCell className="text-right">
- <button
- onClick={() => handleRevoke(cred.server_id)}
- disabled={isRevoking}
- title="Revoke connection"
- className="inline-flex items-center justify-center rounded-md border px-2 py-1 text-muted-foreground hover:text-destructive hover:border-destructive/50 transition-colors disabled:opacity-50 disabled:cursor-not-allowed"
- style={{ background: "none" }}
- >
- {isRevoking ? (
- <Loader2 className="h-3.5 w-3.5 animate-spin" />
- ) : (
- <Trash2 className="h-3.5 w-3.5" />
- )}
- </button>
+ <AlertDialog>
+ <AlertDialogTrigger asChild>
+ <Button
+ variant="outline"
+ size="icon-sm"
+ disabled={isRevoking}
+ title="Revoke connection"
+ className="text-muted-foreground hover:text-destructive hover:border-destructive/50"
+ >
+ {isRevoking ? (
+ <Loader2 className="h-3.5 w-3.5 animate-spin" />
+ ) : (
+ <Trash2 className="h-3.5 w-3.5" />
+ )}
+ </Button>
+ </AlertDialogTrigger>
+ <AlertDialogContent>
+ <AlertDialogHeader>
+ <AlertDialogTitle>Revoke connection?</AlertDialogTitle>
+ <AlertDialogDescription>
+ This removes the stored OAuth credential for {displayName(cred)}. You&apos;ll need to
+ reconnect to use it in chat again.
+ </AlertDialogDescription>
+ </AlertDialogHeader>
+ <AlertDialogFooter>
+ <AlertDialogCancel>Cancel</AlertDialogCancel>
+ <AlertDialogAction variant="destructive" onClick={() => handleRevoke(cred.server_id)}>
+ Revoke
+ </AlertDialogAction>
+ </AlertDialogFooter>
+ </AlertDialogContent>
+ </AlertDialog>
</TableCell>
</TableRow>
);
diff --git a/ui/litellm-dashboard/src/components/chat/UsagePanel.tsx b/ui/litellm-dashboard/src/components/chat/UsagePanel.tsx
index 2c7e4332ac4..578e389571f 100644
--- a/ui/litellm-dashboard/src/components/chat/UsagePanel.tsx
+++ b/ui/litellm-dashboard/src/components/chat/UsagePanel.tsx
@@ -152,7 +152,7 @@ const UsagePanel: React.FC<Props> = ({ accessToken, userId }) => {
{isLoading ? (
<div className="grid grid-cols-2 gap-3">
{[...Array(4)].map((_, i) => (
- <div key={i} className="border rounded-lg px-4 py-3.5 flex flex-col gap-2">
+ <div key={i} className="border rounded-lg p-4 bg-card flex flex-col gap-2">
<Skeleton className="h-3 w-1/2" />
<Skeleton className="h-5 w-2/3" />
</div>
@@ -167,7 +167,7 @@ const UsagePanel: React.FC<Props> = ({ accessToken, userId }) => {
<div>
<div className="grid grid-cols-2 gap-3 mb-5">
{statCards.map((card) => (
- <div key={card.label} className="border rounded-lg px-4 py-3.5">
+ <div key={card.label} className="border rounded-lg p-4 bg-card">
<div className="text-xs text-muted-foreground mb-1">{card.label}</div>
<div className="text-xl font-semibold text-foreground">{card.value}</div>
{card.sub && (
@@ -185,11 +185,11 @@ const UsagePanel: React.FC<Props> = ({ accessToken, userId }) => {
{dailyData.length > 1 && (
<div className="grid grid-cols-2 gap-3">
- <div className="border rounded-lg px-4 py-3.5">
+ <div className="border rounded-lg p-4 bg-card">
<div className="text-xs text-muted-foreground mb-2">Daily Spend</div>
<SparklineBar data={dailySpend} maxVal={maxSpend} />
</div>
- <div className="border rounded-lg px-4 py-3.5">
+ <div className="border rounded-lg p-4 bg-card">
<div className="text-xs text-muted-foreground mb-2">Daily Requests</div>
<SparklineBar data={dailyRequests} maxVal={maxRequests} />
</div>
diff --git a/ui/litellm-dashboard/src/components/chat/design.md b/ui/litellm-dashboard/src/components/chat/design.md
index b357ec7df59..498f9d1e84e 100644
--- a/ui/litellm-dashboard/src/components/chat/design.md
+++ b/ui/litellm-dashboard/src/components/chat/design.md
@@ -1,360 +1,376 @@
-# LiteLLM Chat UI Design System
+# Chat UI Design Reference
-## 1. Vision
+Tactical guide for building chat UI features. Copy patterns exactly — don't improvise spacing, colors, or components.
-A focused, professional chat interface that puts the conversation first. Inspired by the best of Microsoft Copilot, GitHub Copilot Chat, and modern SaaS tooling: clean surfaces, tight typography, restrained color, and purposeful motion. Every pixel earns its place
+> **Agents:** Read `AGENTS.md` alongside this file. It contains decision trees, the pre-commit checklist, and the rules that govern when to use each pattern here. This file is the _what_; `AGENTS.md` is the _when and how_.
-## 2. Design Principles
+---
-**Density over decoration.** Maximize usable space. No ornamental gradients, no heavy shadows, no gratuitous whitespace. The UI should feel like a precision tool, not a marketing page
+## Stack
-**Quiet until needed.** Secondary controls (edit, delete, copy) appear on hover or focus. Primary actions (send, new chat) are always visible. Enterprise features (key rotation) surface only for entitled users
+- **Next.js 16** App Router, TypeScript
+- **Tailwind CSS v4** — utility classes only, no custom CSS except in `globals.css`
+- **shadcn/ui** — import from `@/components/ui/*`. Available today: `alert-dialog`, `badge`, `button`, `collapsible`, `dialog`, `input`, `label`, `popover`, `scroll-area`, `select`, `separator`, `skeleton`, `switch`, `table`, `tabs`, `tooltip`. **Not installed**: `Card`, `Textarea`, `sonner`. Don't reference them until they're actually added — see "Known gaps" below.
+- **lucide-react** — only icon library, no emoji in UI
+- System font stack (`-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif`), inherited from `ChatShell`'s root
-**System-native feel.** Use the OS font stack. Respect prefers-reduced-motion. Match native scrollbar behavior. The chat should feel like it belongs on the user's machine
+---
-**One layout, many views.** The sidebar + main area split is the single structural pattern. Sidebar switches between views (Chats, Apps, Credentials, API Keys, Usage) without page transitions. The main area hosts either the chat or a full-width panel
+## Tokens
-## 3. Layout
+Never hardcode hex values. Use these CSS variables via Tailwind classes — all verified present in `src/app/globals.css`.
+### Colors
+
+| Token | Tailwind class | Use |
+| ----------------------------- | ------------------------------------- | -------------------------------------------------------------- |
+| `--background` | `bg-background` | Main content area, input surfaces |
+| `--foreground` | `text-foreground` | Primary text |
+| `--card` | `bg-card` | Popover/dialog surfaces (no `<Card>` component yet — see gaps) |
+| `--muted` | `bg-muted` | Table header rows, subtle fills |
+| `--muted-foreground` | `text-muted-foreground` | Secondary/helper text, timestamps |
+| `--border` | `border-border` (or bare `border`) | All 1px separators |
+| `--primary` | `bg-primary` / `text-primary` | Send button, checkmarks, active links |
+| `--destructive` | `bg-destructive` / `text-destructive` | Delete, error actions |
+| `--sidebar` | `bg-sidebar` | **Left sidebar background — use this, not `bg-secondary`** |
+| `--sidebar-foreground` | `text-sidebar-foreground` | Sidebar text |
+| `--sidebar-accent` | `bg-sidebar-accent` | Active/hover nav item fill |
+| `--sidebar-accent-foreground` | `text-sidebar-accent-foreground` | Active nav item text |
+| `--sidebar-border` | `border-sidebar-border` | Sidebar's own dividers/right border |
+
+**Known gotcha — verified in `globals.css`:** `--accent`, `--secondary`, and `--muted` all resolve to the _identical_ OKLCH value in both light and dark themes. Using `bg-accent` for a "selected" state against a `bg-secondary` container is **invisible** — there is zero contrast. This bit us repeatedly in this exact sidebar. Rules:
+
+- Sidebar container: `bg-sidebar`, never `bg-secondary` or `bg-accent`.
+- Active/selected nav item: `bg-sidebar-accent text-sidebar-accent-foreground`, never `bg-accent` on its own inside the sidebar.
+- Anywhere else `bg-accent`/`bg-muted` is used for hover/selected state, confirm the container isn't _also_ `bg-accent`/`bg-secondary`/`bg-muted` before shipping — check `globals.css` values, don't assume.
+
+### Status colors (semantic — don't substitute)
+
+| State | Class | Use |
+| ------------------- | -------------------------------------------------------- | --------------------------- |
+| Success / connected | `text-emerald-600 dark:text-emerald-400` | Completed, connected, ready |
+| Running / warning | `text-amber-600 dark:text-amber-400` | In-flight, expiring |
+| Error | `text-red-600 dark:text-red-400` (or `text-destructive`) | Failed, expired |
+| Info | `text-muted-foreground` | Informational |
+
+---
+
+## Typography
+
+```tsx
+// Page/greeting heading
+<h1 className="text-[28px] font-semibold tracking-tight">Good afternoon</h1>
+
+// Section heading (panel titles: "Your API Keys", "Your Usage")
+<h2 className="text-base font-semibold tracking-tight">Your Usage</h2>
+
+// Body text
+<p className="text-sm text-foreground">Body</p>
+
+// Secondary / helper text
+<p className="text-xs text-muted-foreground">Helper</p>
+
+// Table header
+<th className="text-[11px] font-medium uppercase tracking-wide text-muted-foreground">Col</th>
+
+// Monospace (keys, IDs, JSON, tool args)
+<span className="font-mono text-xs">sk-...abcd</span>
```
-+--sidebar(260px)--+--------main-area--------+
-| logo + collapse | top-bar (model selector) |
-| nav items | |
-| divider | content area |
-| view tabs | (chat / panel view) |
-| divider | |
-| [chats list] | input bar (chat only) |
-+------------------+--------------------------+
+
+**Rules:**
+
+- Use `tracking-tight` on headings
+- Never set `text-foreground/50` or `text-foreground/70` for secondary text — use `text-muted-foreground`
+- Monospace for: masked keys, conversation/tool-call IDs, tool arguments, JSON values
+
+---
+
+## Spacing
+
+4px base grid.
+
+| Context | Value |
+| ---------------------------------- | ------------------------------------------- |
+| Sidebar outer padding | `p-2` (8px) |
+| Nav item padding | `px-2.5 py-2` |
+| Inline icon-to-label gap | `gap-2.5` in nav items, `gap-1.5` elsewhere |
+| Section divider margin | `mx-2` |
+| Panel content padding | `px-8 py-8` |
+| Card/bordered-div internal padding | `p-4` |
+| Dialog body padding | `px-6 pb-6` |
+
+---
+
+## Border Radius
+
+```tsx
+rounded-md // 8px — buttons, inputs, nav items, bordered divs
+rounded-lg // 10px — panel cards, table containers
+rounded-xl // 14px — chat input composer
+rounded-2xl // 16px — chat message bubbles
+rounded-full // pills, avatars, status dots
```
-### Sidebar
+---
-- Width: 260px expanded, 56px collapsed
-- Background: `bg-secondary` (the shadcn muted/secondary surface)
-- Border right: `border` (1px, uses --border token)
-- Collapse animation: 200ms cubic-bezier(0.4, 0, 0.2, 1)
-- Nav items: 36px tall, 8px horizontal padding, radius-md, full-width
-- Active nav item: `bg-accent` with `text-accent-foreground`
-- Hover: `bg-accent/50`
-- Icon size in nav: 16px. Label font: 14px/500
-
-### Main area
+## Components
-- Background: `bg-background` (white in light mode)
-- Top bar: 48px tall, bottom border, contains model selector left + settings right
-- Content: flex column, fills remaining space
-- Panel views (Apps, Credentials, Keys, Usage): max-width 800px, centered, 32px vertical padding, 24px horizontal
-
-### Responsive behavior
-
-- Below 768px: sidebar auto-collapses to icon rail
-- Below 480px: sidebar becomes an overlay drawer
-- Input bar sticks to bottom in all viewports
-
-## 4. Color
-
-Use the shadcn/Tailwind CSS variable system already defined in globals.css. No hardcoded hex values in components
-
-| Token | Usage |
-| -------------------------- | ---------------------------------------- |
-| `background` | Main area, input surfaces |
-| `foreground` | Primary text |
-| `muted` | Sidebar background, disabled surfaces |
-| `muted-foreground` | Secondary text, timestamps, placeholders |
-| `primary` | Send button, active indicators, links |
-| `primary-foreground` | Text on primary surfaces |
-| `secondary` | Sidebar surface, subtle backgrounds |
-| `border` | All 1px separators |
-| `accent` | Hover states, active nav items |
-| `destructive` | Delete actions, error states |
-| `card` / `card-foreground` | Elevated surfaces (modals, popovers) |
+### Button
-### Accent colors for status
+Always the shadcn `Button` — never a raw `<button>` with hand-rolled Tailwind, even for icon-only triggers. If it's borderline whether something is a "button" (e.g. a nav row, a suggestion pill), it still gets a `variant`.
-- Connected/success: `text-emerald-600`
-- Warning/expiring: `text-amber-600`
-- Error/expired: `text-destructive`
-- Info/neutral: `text-muted-foreground`
+```tsx
+import { Button } from "@/components/ui/button"
-## 5. Typography
+<Button>Send</Button>
+<Button variant="outline">Cancel</Button>
+<Button variant="ghost">Nav item / low-emphasis</Button>
+<Button variant="destructive">Delete</Button>
+<Button variant="ghost" size="icon"><Settings className="size-4" /></Button>
+
+// Loading
+<Button disabled={loading}>
+ {loading && <Loader2 className="size-4 animate-spin" />}
+ Save
+</Button>
+```
-Font stack: system default inherited from body (defined in globals.css, `-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif`)
+Sizes: `default` (h-9), `sm` (h-8), `xs` (h-6), `lg` (h-10), `icon` (size-9), `icon-sm` (size-8), `icon-xs` (size-6).
-| Element | Size | Weight | Line Height | Color |
-| ----------------------- | ---- | ------ | ----------- | ------------------ |
-| Page heading (greeting) | 28px | 600 | 1.2 | `foreground` |
-| Section heading | 18px | 600 | 1.3 | `foreground` |
-| Subsection heading | 15px | 600 | 1.4 | `foreground` |
-| Body / message text | 14px | 400 | 1.7 | `foreground` |
-| UI label (nav, button) | 14px | 500 | 1 | varies |
-| Small label | 13px | 400 | 1.4 | `muted-foreground` |
-| Timestamp | 11px | 400 | 1 | `muted-foreground` |
-| Group header (Today) | 11px | 600 | 1 | `muted-foreground` |
-| Code (inline) | 13px | 400 | 1.4 | `foreground` |
-| Code (block) | 13px | 400 | 1.5 | `foreground` |
+### Sidebar nav item
-Monospace stack for code: `ui-monospace, SFMono-Regular, 'SF Mono', Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace`
+No dedicated shadcn `Sidebar` block is installed (see gaps). Build nav items from `Button variant="ghost"`, full width, left-aligned, with the sidebar-specific active state:
-## 6. Spacing
+```tsx
+<Button
+ variant="ghost"
+ aria-current={active ? "page" : undefined}
+ className={`w-full justify-start gap-2.5 px-2.5 font-medium hover:bg-sidebar-accent ${
+ active ? "bg-sidebar-accent text-sidebar-accent-foreground" : "text-muted-foreground"
+ }`}
+>
+ <Icon className="size-4 shrink-0" />
+ <span className="flex-1 text-left">{label}</span>
+</Button>
+```
-Use Tailwind's spacing scale consistently. Avoid arbitrary pixel values
+There is no collapsible/icon-rail sidebar mode — it was removed (added complexity, no real use case, and its collapse toggle button had nowhere sensible to live). Don't reintroduce collapse state without a concrete reason.
-| Context | Value |
-| ----------------------- | ----------------------------------------------- |
-| Sidebar padding (outer) | `p-2` (8px) |
-| Nav item padding | `px-2.5 py-2` (10px, 8px) |
-| Section divider margin | `my-1 mx-2` (4px, 8px) |
-| Content area padding | `p-6` (24px) horizontal, `py-8` (32px) vertical |
-| Card internal padding | `p-3` to `p-4` (12-16px) |
-| Message gap | `gap-4` (16px) between messages |
-| Button internal padding | `px-4 py-2` (16px, 8px) default |
+### ScrollArea
-## 7. Component Specifications
+**Known gotcha — cost real debugging time:** a `ScrollArea` won't actually scroll if its container is sized with `max-height` instead of `height`, even though the box _looks_ correctly capped. Radix's `ScrollArea` viewport is `size-full` (`height: 100%`), and CSS percentage-height resolution requires the ancestor chain to have a genuinely _definite_ height — `max-height` on a flex container doesn't count as definite for this purpose, even though the browser renders the box at the capped size. The result: the viewport silently grows to its full content height instead of 100% of the visible box, `scrollHeight === clientHeight` is reported (no overflow, so no scrollbar), and scroll events fall through to whatever's behind the popover/panel instead of scrolling the list.
-### 7.1 Chat Bubbles
+```tsx
+// Wrong — looks capped, doesn't scroll (max-height isn't a definite height)
+<div className="w-[280px] max-h-[400px] flex flex-col overflow-hidden">
+ <ScrollArea className="flex-1 min-h-0">{items}</ScrollArea>
+</div>
-**User bubble**
+// Right — explicit height propagates as definite through the whole chain
+<div className="w-[280px] h-[400px] flex flex-col overflow-hidden">
+ <ScrollArea className="flex-1 h-0">{items}</ScrollArea>
+</div>
+```
-- Alignment: right-aligned, max-width 72%
-- Background: `bg-muted` (light gray)
-- Border radius: 16px (`rounded-2xl`)
-- Padding: 10px 14px
-- Font: 14px, line-height 1.6
-- Edit button appears on hover to the left, icon-only, `text-muted-foreground`
+If you need "shrink to fit content, cap at N px" rather than "always N px," you cannot get both with pure CSS here — pick the fixed height (the common case: any list that can realistically exceed the cap, e.g. a model picker with hundreds of entries) over one that only works when short.
-**Assistant bubble**
+### Input / Textarea
-- Alignment: left-aligned, max-width 80%
-- No background (text renders directly)
-- Markdown rendered with syntax highlighting for code blocks
-- Copy button below, muted until hovered
+`Input` exists; `Textarea` does not (see gaps — until added, a plain `<textarea>` with `border-none outline-none resize-none` inside a bordered container, as in the chat composer, is the accepted exception).
-**Tool call card**
-
-- Collapsible (collapsed by default)
-- Border: `border`, rounded-lg
-- Background: `bg-muted/50`
-- Header: tool icon + tool name, 13px/500
-- Content sections labeled "Arguments" / "Result" in uppercase 11px/600
+```tsx
+import { Input } from "@/components/ui/input";
+import { Label } from "@/components/ui/label";
-### 7.2 Input Bar
+<div className="flex flex-col gap-1.5">
+ <Label htmlFor="alias">Key alias</Label>
+ <Input id="alias" disabled />
+ {error && <p className="text-xs text-destructive">{error}</p>}
+</div>;
+```
-- Position: bottom of chat area, above-fold
-- Container: `border rounded-xl` with inner padding
-- Textarea: auto-growing, no visible border, inherits font
-- Bottom row: model indicator left, send button right
-- Send button: `bg-primary text-primary-foreground rounded-md px-4 py-1.5`
-- Disabled send: `bg-muted text-muted-foreground cursor-not-allowed`
-- Stop button (during streaming): circular, 32px, border only, square stop icon inside
+Errors go **below** the field. Never a toast for form validation.
-### 7.3 Model Selector
+### Bordered surfaces (Card substitute)
-- Trigger: ghost button in top bar showing model name + provider logo
-- Dropdown: popover with search input + scrollable model list
-- Selected model: checkmark icon, `text-primary`
-- Comparison mode: up to 3 models, shown as pills
-
-### 7.4 Sidebar Navigation
-
-Each nav item is a full-width row:
+No `Card` component is installed. Use a bordered div — this is already the documented pattern here, keep it:
+```tsx
+<div className="border rounded-lg p-4 bg-card">{/* content */}</div>
```
-[icon 16px] [label 14px/500]
+
+### Badge
+
+```tsx
+import { Badge } from "@/components/ui/badge"
+
+<Badge variant="secondary">connected</Badge>
+<Badge variant="outline">expiring</Badge>
+<Badge variant="destructive">expired</Badge>
```
-- Default: `text-muted-foreground`, transparent background
-- Hover: `bg-accent/50`
-- Active: `bg-accent text-accent-foreground` with `font-medium`
-- Collapsed sidebar: icon only, centered, with tooltip on hover
+### Dialog / AlertDialog
+
+```tsx
+import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from "@/components/ui/dialog";
+
+<Dialog open={open} onOpenChange={setOpen}>
+ <DialogContent className="sm:max-w-lg">
+ <DialogHeader>
+ <DialogTitle>Rotate key</DialogTitle>
+ </DialogHeader>
+ <div className="flex flex-col gap-4">{/* form */}</div>
+ <DialogFooter>
+ <Button variant="outline" onClick={() => setOpen(false)}>
+ Cancel
+ </Button>
+ <Button onClick={handleSubmit} disabled={loading}>
+ {loading && <Loader2 className="size-4 animate-spin" />}
+ Rotate
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+</Dialog>;
+```
-### 7.5 Conversation List
+Use `AlertDialog` (not a manual confirm) for any destructive action — delete conversation, revoke credential.
+
+### Table
+
+```tsx
+import { Table, TableHeader, TableBody, TableRow, TableHead, TableCell } from "@/components/ui/table";
+
+<div className="border rounded-lg overflow-hidden">
+ <Table>
+ <TableHeader>
+ <TableRow className="bg-muted/50">
+ <TableHead className="text-[11px] font-medium uppercase tracking-wide">Key</TableHead>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ <TableRow>
+ <TableCell className="font-mono text-xs">sk-...abcd</TableCell>
+ </TableRow>
+ </TableBody>
+ </Table>
+</div>;
+```
-- Grouped by date: Today, Yesterday, Last 7 Days, Older
-- Group headers: uppercase, 11px/600, `text-muted-foreground`, letter-spacing 0.04em
-- Row: 34px min-height, `rounded-md`, 6px 8px padding
-- Active row: `bg-accent`
-- Hover row: `bg-accent/50`
-- Action icons (edit, delete): appear on hover, opacity transition 150ms
-- Delete confirmation: shadcn AlertDialog, not a popconfirm tooltip
+### Tabs
-### 7.6 Cmd+K Search
+Always pass `variant="line"` for section tabs (Apps: All/Connected). The default variant renders a boxed pill with a background/shadow meant for compact toggle groups, not section tabs, and combining it with hand-added `border-b-2` classes produces a broken double-border look.
-- Trigger: Ctrl/Cmd + K globally
-- Dialog (shadcn Dialog, not Modal): 480px wide, centered vertically
-- Search input at top with search icon prefix
-- Results list: scrollable, max-height 320px
-- Each result: message icon, truncated title, date badge right-aligned
-- Click selects and closes
+```tsx
+import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
-### 7.7 Data Tables (Keys, Credentials)
+<Tabs value={tab} onValueChange={setTab}>
+ <TabsList variant="line" className="w-full justify-start border-b rounded-none h-auto p-0">
+ <TabsTrigger value="all" className="rounded-none px-4 py-2 text-[13px]">
+ All
+ </TabsTrigger>
+ </TabsList>
+</Tabs>;
+```
-Use shadcn's table primitives (Table, TableHeader, TableBody, TableRow, TableCell) with Tailwind styling, not antd Table
+### Loading states
-- Border: `border rounded-lg overflow-hidden`
-- Header row: `bg-muted/50`, uppercase 11px/600 labels
-- Body rows: 44px min-height, `border-b last:border-0`
-- Hover: `bg-accent/30`
-- Cell text: 13-14px
-- Action buttons: ghost/outline variant, icon-only where possible
-
-### 7.8 Dialogs and Modals
-
-Use shadcn Dialog component
-
-- Overlay: black at 50% opacity
-- Content: `bg-card`, rounded-xl, max-width varies (480px for search, 520px for forms)
-- Header: title left, close X right
-- Footer: action buttons right-aligned, primary action on the right
-- Form inputs: shadcn Input with label above
-- Spacing: 24px padding, 16px between form fields
+Skeleton loaders while fetching — never a bare spinner or blank screen for list/table content. `Loader2` + `animate-spin` is reserved for **inside a button** during a submit action, not as a page/panel loading state.
-### 7.9 Status Badges
+```tsx
+import { Skeleton } from "@/components/ui/skeleton";
-Use shadcn Badge component
+<div className="flex flex-col gap-3">
+ <div className="border rounded-lg p-4 flex flex-col gap-2">
+ <Skeleton className="h-4 w-1/3" />
+ <Skeleton className="h-3 w-2/3" />
+ </div>
+</div>;
+```
-- Default (neutral): `bg-secondary text-secondary-foreground`
-- Active/connected: green outline variant
-- Warning/expiring: amber outline variant
-- Error/expired: destructive variant
-- Enterprise: primary variant with lock icon
+### Toast / notifications
-### 7.10 Loading States
+**Gap:** `sonner` is not installed. This codebase currently uses `MessageManager` (antd-message-based) for toasts across the chat UI. Don't introduce a second toast mechanism — keep using `MessageManager` until `sonner` is added as a deliberate, separate change (see `AGENTS.md`).
-- Spinner: use a simple CSS spinner or Lucide `Loader2` icon with `animate-spin`, not antd Spin
-- Skeleton: use shadcn Skeleton (pulsing gray bars)
-- Typing indicator: three bouncing dots (keep existing CSS animation)
-- Thinking placeholder: pulsing "Thinking..." text
+---
-### 7.11 MCP Server Cards (Apps Panel)
+## Page Layout Patterns
-- Grid: 2-column on desktop, 1-column below 640px
-- Card: `border rounded-lg` with padding 14px 16px
-- Avatar: 38px, rounded-xl, either logo image or initial with hash-based color
-- Hover: `bg-accent/30` transition 100ms
-- Detail view: back button, larger avatar (64px), info table, tools list
+### Chat shell (sidebar + routed content)
-### 7.12 Keys Panel
+```tsx
+<div className="flex h-full w-full flex-col bg-background overflow-hidden">
+ {/* optional full-width banner */}
+ <div className="flex flex-1 min-h-0 overflow-hidden">
+ <aside
+ className="shrink-0 bg-sidebar border-r flex flex-col overflow-hidden"
+ style={{ width: collapsed ? 56 : 260 }}
+ >
+ {/* nav items, conversation list */}
+ </aside>
+ <main className="flex-1 flex flex-col overflow-hidden min-w-0">{children}</main>
+ </div>
+</div>
+```
+
+### Routed panel (Integrations, Credentials, API Keys, Usage)
-- Table with columns: Key Alias, Key (masked), Spend/Budget, Expires, Created
-- Masked key format: `sk-...XXXX` (last 4 chars)
-- Rotate button: outline variant, only rendered when `premiumUser === true`
-- Non-premium users see a muted "Enterprise" badge where rotate would be
-- Rotation modal: form with duration, key alias, max budget, grace period fields
-- After rotation: show new key in a mono-font box with copy button
+```tsx
+<div className="flex-1 min-h-0 overflow-auto w-full py-8 px-8">
+ <PanelComponent />
+</div>
+```
-### 7.13 Usage Panel
+No max-width cap on panel content — matches the rest of the dashboard's own pages (verified: `(dashboard)/api-keys/ApiKeysDashboard.tsx` has no width cap). A narrow `max-w-[800px]` here previously made wide tables (Keys) look cramped on real monitors; don't reintroduce it.
-- Time range selector: segmented control (7d / 30d / 90d)
-- Stat cards row: 4 cards showing Total Spend, API Requests, Tokens, Success Rate
-- Each card: `border rounded-lg p-4`, label above, large number below, subtitle
-- Charts: simple inline bar charts using divs with percentage widths
-- Colors: `bg-primary` for spend bars, `bg-chart-2` for request bars
+---
-### 7.14 Toggle/Switch (MCP Connect Picker)
+## Icons
-Use shadcn Switch component
+`lucide-react` only. `size-4` (16px) inline/nav, `size-5` (20px) standalone actions, `size-3.5` (14px) inside badges/small buttons.
-- Size: small (16px height)
-- Track: `bg-input` unchecked, `bg-primary` checked
-- Loading state: spinner overlaid
+---
-## 8. Interaction & Motion
+## Dos and Don'ts
-| Interaction | Timing | Easing |
-| ------------------- | ----------- | ---------------------------- |
-| Hover background | 150ms | ease |
-| Sidebar collapse | 200ms | cubic-bezier(0.4, 0, 0.2, 1) |
-| Modal open/close | 150ms | ease-out / ease-in |
-| Icon opacity reveal | 150ms | ease |
-| Tooltip appear | 200ms delay | ease |
-| Button press | 100ms | ease |
+| Do | Don't |
+| --------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
+| `Button` (any variant) for every clickable control | Raw `<button>` with hand-rolled Tailwind |
+| `bg-sidebar` / `bg-sidebar-accent` for sidebar surfaces | `bg-secondary` / `bg-accent` for sidebar surfaces (identical values, zero contrast) |
+| `Tabs variant="line"` for section tabs | Default `Tabs` variant + manual `border-b-2` overrides |
+| Skeleton loaders for panel/list content | Spinner or blank screen while fetching |
+| `text-muted-foreground` for secondary text | `text-foreground/50`, `text-foreground/60`, `text-foreground/70` |
+| `AlertDialog` for destructive confirmations | Instant delete, or a hand-rolled confirm |
+| Verify a prop/variant exists in `components/ui/*.tsx` before using it | Assume a shadcn prop exists because another shadcn app has it |
+| `MessageManager` for toasts (until sonner lands) | Introduce a second, competing toast library |
-All motion respects `prefers-reduced-motion: reduce` by collapsing to 0ms
-
-## 9. Accessibility
+---
-- All interactive elements have visible focus rings (shadcn default: `ring-ring/50`)
-- Keyboard navigation: Tab through nav items, Enter/Space to activate
-- Cmd+K search is keyboard-accessible end-to-end
-- Tooltip content duplicated in aria-label for icon-only buttons
-- Color contrast: all text meets WCAG 2.1 AA (4.5:1 for body text, 3:1 for large text)
-- Screen reader: conversation list items use role="listbox" + role="option"
-
-## 10. shadcn Components Used
+## Known gaps (tracked, not blockers)
-Components to install and use across the chat UI:
+These are real, current gaps in this codebase's shadcn setup — don't silently work around them by reinventing the missing piece with raw Tailwind; either use the documented substitute above or flag the addition as its own change:
-| Component | Replaces (antd) | Used in |
-| ----------- | -------------------- | ----------------------------- |
-| Button | antd Button | All buttons |
-| Input | antd Input | Search, rename, form fields |
-| Dialog | antd Modal | Search, key rotation, delete |
-| AlertDialog | antd Popconfirm | Delete confirmation |
-| Popover | antd Popover | Model selector, MCP picker |
-| Tooltip | antd Tooltip | Icon tooltips |
-| Table\* | antd Table | Keys, credentials |
-| Badge | antd Tag | Status indicators |
-| Switch | antd Switch | MCP server toggles |
-| Select | antd Select | Time range, form selects |
-| Skeleton | antd Skeleton | Loading placeholders |
-| ScrollArea | native overflow-auto | Conversation list, model list |
-| Collapsible | antd Collapse | Tool call cards |
-| Separator | div with border | Sidebar dividers |
-| Label | (none) | Form field labels |
-| Tabs | custom tab buttons | Apps panel tabs |
-
-\*For tables, use the shadcn table primitives (Table, TableHeader, TableRow, etc.) which are thin wrappers around native `<table>` with Tailwind classes, not a heavy data-table library
+1. **No `Card` component.** Substitute: bordered div (`border rounded-lg p-4 bg-card`), already the established pattern.
+2. **No `Textarea` component.** Substitute: raw `<textarea>` with `border-none outline-none resize-none`, only inside an already-bordered container (chat composer).
+3. **No `sonner`.** Substitute: existing `MessageManager`.
+4. **No shadcn `Sidebar` primitive block** (`SidebarProvider`/`SidebarMenu`/etc). Substitute: the "Sidebar nav item" pattern above, built from `Button variant="ghost"` + the `sidebar-*` tokens.
-## 11. File Structure
+## File Structure
```
src/components/chat/
- ChatPage.tsx # Layout shell, routing, state orchestration
- ConversationList.tsx # Sidebar chat list with date grouping
- ChatMessages.tsx # Message rendering (user, assistant, tool)
- MCPAppsPanel.tsx # Apps grid + detail view
- MCPConnectPicker.tsx # MCP server toggle popover
- MCPCredentialsTab.tsx # OAuth credentials table
- KeysPanel.tsx # API key viewing + rotation
- UsagePanel.tsx # Spend/usage analytics
- types.ts # Shared TypeScript types
- useChatHistory.ts # Chat persistence hook
- design.md # This file
+ ChatShell.tsx # Sidebar chrome (nav, collapse, conversation list), shared across all /chat/* routes
+ ConversationList.tsx # Date-grouped chat list + Cmd+K search
+ ChatMessages.tsx # Message rendering (user, assistant, tool)
+ MCPAppsPanel.tsx # Integrations grid + detail view
+ MCPConnectPicker.tsx # MCP server toggle popover
+ MCPCredentialsTab.tsx # OAuth credentials table
+ KeysPanel.tsx # API key viewing + rotation
+ UsagePanel.tsx # Spend/usage analytics
+ types.ts # Shared TypeScript types
+ useChatHistory.ts # Chat persistence hook
+ design.md # This file
+ AGENTS.md # When/how to apply this file
+../../contexts/ChatShellContext.tsx # Cross-route state: MCP server selection, conversation history
+../../app/chat/ # Route tree: page.tsx (chats), layout.tsx (auth gate + shell),
+ # integrations/, credentials/, api-keys/, usage/
```
-
-## 12. Migration Notes
-
-The migration from antd to shadcn is component-by-component. Each file should:
-
-1. Replace antd imports with shadcn component imports + Lucide icons
-2. Convert inline `style={{}}` objects to Tailwind classes where practical
-3. Use CSS variables via Tailwind tokens (`bg-primary`, `text-muted-foreground`) instead of hardcoded hex
-4. Keep the same prop interfaces and behavioral contracts
-5. Preserve all keyboard shortcuts and accessibility features
-
-antd's `@ant-design/icons` are replaced by Lucide React icons (already the shadcn default icon library per components.json). Mapping:
-
-| antd icon | Lucide equivalent |
-| ------------------- | ----------------- |
-| EditOutlined | Pencil |
-| DeleteOutlined | Trash2 |
-| PlusOutlined | Plus |
-| SearchOutlined | Search |
-| MenuFoldOutlined | PanelLeftClose |
-| MenuUnfoldOutlined | PanelLeftOpen |
-| MessageOutlined | MessageSquare |
-| AppstoreOutlined | LayoutGrid |
-| KeyOutlined | KeyRound |
-| LockOutlined | Lock |
-| BarChartOutlined | BarChart3 |
-| SettingOutlined | Settings |
-| ArrowLeftOutlined | ArrowLeft |
-| DownOutlined | ChevronDown |
-| CheckOutlined | Check |
-| CopyOutlined | Copy |
-| SyncOutlined | RefreshCw |
-| ToolOutlined | Wrench |
-| RightOutlined | ChevronRight |
-| CheckCircleOutlined | CheckCircle |
-| UserOutlined | User |
-| LinkOutlined | Link |