From 5a3a0210cb5809b8efc9962091494d49555a668a Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Tue, 17 Feb 2026 17:33:06 -0800 Subject: [PATCH] feat(ui): add guardrail jump link in log detail view (#21437) * feat(ui): add guardrail jump link at top of log detail * fix(ui): align guardrail jump link to the left * fix(ui): move guardrail jump link to trace sidebar * fix(ui): move guardrail pill above event rows in sidebar --- .../LogDetailsDrawer/LogDetailContent.tsx | 46 +++++++++++++++---- .../LogDetailsDrawer/LogDetailsDrawer.tsx | 8 +++- 2 files changed, 45 insertions(+), 9 deletions(-) diff --git a/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/LogDetailContent.tsx b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/LogDetailContent.tsx index f0f4041531c..0552b1837db 100644 --- a/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/LogDetailContent.tsx +++ b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/LogDetailContent.tsx @@ -66,9 +66,6 @@ export function LogDetailContent({ logEntry, onOpenSettings, isLoadingDetails = const hasGuardrailData = guardrailEntries.length > 0; const totalMaskedEntities = calculateTotalMaskedEntities(guardrailEntries); const primaryGuardrailLabel = getGuardrailLabel(guardrailEntries); - const guardrailPolicyNames = Array.from( - new Set(guardrailEntries.map((e: any) => e?.policy_template).filter(Boolean)) - ) as string[]; // Vector store data const hasVectorStoreData = checkHasVectorStoreData(metadata); @@ -127,7 +124,7 @@ export function LogDetailContent({ logEntry, onOpenSettings, isLoadingDetails = )} {hasGuardrailData && ( - + )} @@ -225,7 +222,7 @@ function TagsSection({ tags }: { tags: Record }) { ); } -function GuardrailLabel({ label, maskedCount, policyNames }: { label: string; maskedCount: number; policyNames: string[] }) { +function GuardrailLabel({ label, maskedCount }: { label: string; maskedCount: number }) { const handleClick = () => { const el = document.getElementById("guardrail-section"); if (el) el.scrollIntoView({ behavior: "smooth" }); @@ -239,9 +236,6 @@ function GuardrailLabel({ label, maskedCount, policyNames }: { label: string; ma {maskedCount} masked )} - {policyNames.map((name) => ( - {name} - ))} ); } @@ -424,6 +418,42 @@ function RequestResponseSection({ ); } +export function GuardrailJumpLink({ guardrailEntries }: { guardrailEntries: any[] }) { + const allPassed = guardrailEntries.every((e) => { + const status = e?.guardrail_status || e?.status; + return status === "pass" || status === "passed" || status === "success"; + }); + + const handleClick = () => { + const el = document.getElementById("guardrail-section"); + if (el) el.scrollIntoView({ behavior: "smooth" }); + }; + + return ( +
+
+ {allPassed ? "\u2713" : "\u2717"} {guardrailEntries.length} guardrail{guardrailEntries.length !== 1 ? "s" : ""} evaluated + {"\u2193"} +
+
+ ); +} + function MetadataSection({ metadata }: { metadata: Record }) { return (
diff --git a/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/LogDetailsDrawer.tsx b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/LogDetailsDrawer.tsx index b6feff77a1c..fb761918531 100644 --- a/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/LogDetailsDrawer.tsx +++ b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/LogDetailsDrawer.tsx @@ -12,10 +12,11 @@ import { MCP_CALL_TYPES } from "../constants"; import { getEventDisplayName } from "../utils"; import { DrawerHeader } from "./DrawerHeader"; import { useKeyboardNavigation } from "./useKeyboardNavigation"; -import { LogDetailContent } from "./LogDetailContent"; +import { LogDetailContent, GuardrailJumpLink } from "./LogDetailContent"; import { sessionSpendLogsCall } from "../../networking"; import { useQuery } from "@tanstack/react-query"; import { getSpendString } from "@/utils/dataUtils"; +import { normalizeGuardrailEntries } from "./utils"; import { DRAWER_WIDTH } from "./constants"; import { useLogDetails } from "@/app/(dashboard)/hooks/logDetails/useLogDetails"; @@ -323,6 +324,11 @@ export function LogDetailsDrawer({
+ {normalizeGuardrailEntries(metadata?.guardrail_information).length > 0 && ( +
+ +
+ )} {isSessionMode ? (
{/* Child events — vertical tree line with horizontal connectors */}