diff --git a/ui/litellm-dashboard/eslint-suppressions.json b/ui/litellm-dashboard/eslint-suppressions.json index 764bafc16b8..2f4def9ffa2 100644 --- a/ui/litellm-dashboard/eslint-suppressions.json +++ b/ui/litellm-dashboard/eslint-suppressions.json @@ -3794,21 +3794,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/LogDetailContent.tsx": { "no-nested-ternary": { "count": 3 diff --git a/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/CollapsibleMessage.test.tsx b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/CollapsibleMessage.test.tsx index 1477febd967..3aa8d21c31c 100644 --- a/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/CollapsibleMessage.test.tsx +++ b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/CollapsibleMessage.test.tsx @@ -37,4 +37,18 @@ describe("CollapsibleMessage", () => { await user.click(screen.getByText("SYSTEM")); expect(screen.getByText("Toggle me")).toBeInTheDocument(); }); + + it("should expand with Enter and collapse with Space from the keyboard", async () => { + const user = userEvent.setup(); + render(); + + expect(screen.getByText("Toggle me")).not.toBeVisible(); + + await user.tab(); + await user.keyboard("{Enter}"); + expect(screen.getByText("Toggle me")).toBeVisible(); + + await user.keyboard(" "); + expect(screen.getByText("Toggle me")).not.toBeVisible(); + }); }); diff --git a/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/CollapsibleMessage.tsx b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/CollapsibleMessage.tsx index 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 ( -
- {/* Clickable Header with hover state */} -
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, - }} - > + + {isExpanded ? ( - + ) : ( - + )} - - {label} - - - ({charCount.toLocaleString()} chars) - -
+ {label} + ({charCount.toLocaleString()} chars) + - {/* Content with smooth animation */} -
-
- {content} -
-
-
+ {content} + + ); } diff --git a/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/HistoryTree.test.tsx b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/HistoryTree.test.tsx index 10d6bfa0847..0726a9f4b82 100644 --- a/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/HistoryTree.test.tsx +++ b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/HistoryTree.test.tsx @@ -41,4 +41,22 @@ describe("HistoryTree", () => { expect(screen.getByText("Hello")).toBeInTheDocument(); expect(screen.getByText("Hi there")).toBeInTheDocument(); }); + + it("should expand with Enter and collapse with Space from the keyboard", async () => { + const user = userEvent.setup(); + const messages: ParsedMessage[] = [ + { role: "user", content: "Hello" }, + { role: "assistant", content: "Hi there" }, + ]; + render(); + + expect(screen.getByText("Hello")).not.toBeVisible(); + + await user.tab(); + await user.keyboard("{Enter}"); + expect(screen.getByText("Hello")).toBeVisible(); + + await user.keyboard(" "); + expect(screen.getByText("Hello")).not.toBeVisible(); + }); }); diff --git a/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/HistoryTree.tsx b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/HistoryTree.tsx index 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 ( -
- {/* Clickable Header with hover state */} -
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, - }} - > + + {isExpanded ? ( - + ) : ( - + )} - + HISTORY ({messages.length} message{messages.length !== 1 ? "s" : ""}) - -
+ + - {/* Expanded Tree Content with smooth animation */} -
-
- {messages.map((msg, index) => ( - - ))} -
-
-
+ + {messages.map((msg, index) => ( + + ))} + + ); }