The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
refactor(ui): migrate HistoryTree and CollapsibleMessage to shadcn
Yuneng Jiang49c697ee895b
diff --git a/ui/litellm-dashboard/eslint-suppressions.json b/ui/litellm-dashboard/eslint-suppressions.jsonindex 8a86305b4cb..299d2a6cfdf 100644--- a/ui/litellm-dashboard/eslint-suppressions.json+++ b/ui/litellm-dashboard/eslint-suppressions.json@@ -3858,21 +3858,11 @@"count": 1}},- "src/components/view_logs/LogDetailsDrawer/CollapsibleMessage.tsx": {- "no-restricted-imports": {- "count": 1- }- },"src/components/view_logs/LogDetailsDrawer/DrawerHeader.tsx": {"no-restricted-imports": {"count": 1}},- "src/components/view_logs/LogDetailsDrawer/HistoryTree.tsx": {- "no-restricted-imports": {- "count": 1- }- },"src/components/view_logs/LogDetailsDrawer/JsonViewer.tsx": {"no-restricted-imports": {"count": 1diff --git a/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/CollapsibleMessage.tsx b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/CollapsibleMessage.tsxindex 9aa13c3832a..81d2fc20fdf 100644--- a/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/CollapsibleMessage.tsx+++ b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/CollapsibleMessage.tsx@@ -4,10 +4,8 @@*/import { useState } from "react";-import { Typography } from "antd";-import { DownOutlined, RightOutlined } from "@ant-design/icons";--const { Text } = Typography;+import { ChevronDown, ChevronRight } from "lucide-react";+import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible";interface CollapsibleMessageProps {label: string;@@ -17,7 +15,6 @@ interface CollapsibleMessageProps {export function CollapsibleMessage({ label, content, defaultExpanded = false }: CollapsibleMessageProps) {const [isExpanded, setIsExpanded] = useState(defaultExpanded);- const [isHovered, setIsHovered] = useState(false);const charCount = content?.length || 0;if (!content || charCount === 0) {@@ -25,60 +22,23 @@ export function CollapsibleMessage({ label, content, defaultExpanded = false }:}return (- <div style={{ marginBottom: 8 }}>- {/* Clickable Header with hover state */}- <div- onClick={() => setIsExpanded(!isExpanded)}- onMouseEnter={() => setIsHovered(true)}- onMouseLeave={() => setIsHovered(false)}- style={{- display: "flex",- alignItems: "center",- gap: 6,- cursor: "pointer",- padding: "4px 0",- borderRadius: 4,- background: isHovered ? "#f5f5f5" : "transparent",- transition: "background 0.15s ease",- marginBottom: isExpanded ? 4 : 0,- }}- >+ <Collapsible open={isExpanded} onOpenChange={setIsExpanded} className="mb-2">+ <CollapsibleTrigger className="flex w-full items-center gap-1.5 rounded py-1 text-left transition-colors hover:bg-muted">{isExpanded ? (- <DownOutlined style={{ fontSize: 10, color: "#8c8c8c" }} />+ <ChevronDown className="size-3 shrink-0 text-muted-foreground" />) : (- <RightOutlined style={{ fontSize: 10, color: "#8c8c8c" }} />+ <ChevronRight className="size-3 shrink-0 text-muted-foreground" />)}- <Text type="secondary" style={{ fontSize: 10, letterSpacing: "0.5px", textTransform: "uppercase" }}>- {label}- </Text>- <Text type="secondary" style={{ fontSize: 10 }}>- ({charCount.toLocaleString()} chars)- </Text>- </div>+ <span className="text-[10px] uppercase tracking-[0.5px] text-muted-foreground">{label}</span>+ <span className="text-[10px] text-muted-foreground">({charCount.toLocaleString()} chars)</span>+ </CollapsibleTrigger>- {/* Content with smooth animation */}- <div- style={{- maxHeight: isExpanded ? "2000px" : "0px",- overflow: "hidden",- transition: "max-height 0.2s ease-out, opacity 0.2s ease-out",- opacity: isExpanded ? 1 : 0,- }}+ <CollapsibleContent+ keepMounted+ className="mt-1 border-l border-border pl-4 text-[13px] leading-[1.7] break-words whitespace-pre-wrap text-foreground">- <div- style={{- paddingLeft: 16,- fontSize: 13,- lineHeight: 1.7,- color: "#262626",- borderLeft: "1px solid #f0f0f0",- whiteSpace: "pre-wrap",- wordBreak: "break-word",- }}- >- {content}- </div>- </div>- </div>+ {content}+ </CollapsibleContent>+ </Collapsible>);}diff --git a/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/HistoryTree.tsx b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/HistoryTree.tsxindex b6c5048513c..4854ca90fc2 100644--- a/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/HistoryTree.tsx+++ b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/HistoryTree.tsx@@ -4,80 +4,46 @@*/import { useState } from "react";-import { Typography } from "antd";-import { DownOutlined, RightOutlined } from "@ant-design/icons";+import { ChevronDown, ChevronRight } from "lucide-react";+import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible";import { ParsedMessage } from "./prettyMessagesTypes";import { SimpleMessageBlock } from "./SimpleMessageBlock";-const { Text } = Typography;-interface HistoryTreeProps {messages: ParsedMessage[];}export function HistoryTree({ messages }: HistoryTreeProps) {const [isExpanded, setIsExpanded] = useState(false);- const [isHovered, setIsHovered] = useState(false);if (messages.length === 0) {return null;}return (- <div style={{ marginBottom: 8 }}>- {/* Clickable Header with hover state */}- <div- onClick={() => setIsExpanded(!isExpanded)}- onMouseEnter={() => setIsHovered(true)}- onMouseLeave={() => setIsHovered(false)}- style={{- display: "flex",- alignItems: "center",- gap: 6,- cursor: "pointer",- padding: "4px 0",- borderRadius: 4,- background: isHovered ? "#f5f5f5" : "transparent",- transition: "background 0.15s ease",- marginBottom: isExpanded ? 4 : 0,- }}- >+ <Collapsible open={isExpanded} onOpenChange={setIsExpanded} className="mb-2">+ <CollapsibleTrigger className="flex w-full items-center gap-1.5 rounded py-1 text-left transition-colors hover:bg-muted">{isExpanded ? (- <DownOutlined style={{ fontSize: 10, color: "#8c8c8c" }} />+ <ChevronDown className="size-3 shrink-0 text-muted-foreground" />) : (- <RightOutlined style={{ fontSize: 10, color: "#8c8c8c" }} />+ <ChevronRight className="size-3 shrink-0 text-muted-foreground" />)}- <Text type="secondary" style={{ fontSize: 10, letterSpacing: "0.5px", textTransform: "uppercase" }}>+ <span className="text-[10px] uppercase tracking-[0.5px] text-muted-foreground">HISTORY ({messages.length} message{messages.length !== 1 ? "s" : ""})- </Text>- </div>+ </span>+ </CollapsibleTrigger>- {/* Expanded Tree Content with smooth animation */}- <div- style={{- maxHeight: isExpanded ? "2000px" : "0px",- overflow: "hidden",- transition: "max-height 0.2s ease-out, opacity 0.2s ease-out",- opacity: isExpanded ? 1 : 0,- }}- >- <div- style={{- paddingLeft: 16,- borderLeft: "1px solid #f0f0f0",- }}- >- {messages.map((msg, index) => (- <SimpleMessageBlock- key={index}- label={msg.role.toUpperCase()}- content={msg.content}- toolCalls={msg.toolCalls}- isCompact={true}- />- ))}- </div>- </div>- </div>+ <CollapsibleContent keepMounted className="mt-1 border-l border-border pl-4">+ {messages.map((msg, index) => (+ <SimpleMessageBlock+ key={index}+ label={msg.role.toUpperCase()}+ content={msg.content}+ toolCalls={msg.toolCalls}+ isCompact={true}+ />+ ))}+ </CollapsibleContent>+ </Collapsible>);}