🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
feat(agent-graphs): styling improvements (#8917)
Nimar7ad3818008d3
diff --git a/web/src/components/trace/hooks/usePanelState.ts b/web/src/components/trace/hooks/usePanelState.tsindex e4d86de375..a763eec5dd 100644--- a/web/src/components/trace/hooks/usePanelState.ts+++ b/web/src/components/trace/hooks/usePanelState.ts@@ -34,7 +34,7 @@ export function usePanelState(return {sizes: savedSizes,minSize: 25, // Will be updated by ResizeObserver- maxSize: viewType === "timeline" ? 67 : 50, // Will be updated by ResizeObserver+ maxSize: viewType === "timeline" ? 80 : 70, // Will be updated by ResizeObserver};});@@ -46,7 +46,7 @@ export function usePanelState(setPanelState((prev) => ({...prev,sizes: newSizes,- maxSize: viewType === "timeline" ? 67 : 50,+ maxSize: viewType === "timeline" ? 80 : 70,}));previousViewTypeRef.current = viewType;@@ -56,7 +56,7 @@ export function usePanelState(const updateConstraints = useCallback((containerWidth: number) => {const MIN_WIDTH_PX = 380;- const MAX_TREE_WIDTH_PX = 500;+ const MAX_TREE_WIDTH_PX = 700;if (containerWidth <= 0) return;@@ -66,8 +66,11 @@ export function usePanelState();const maxSize =viewType === "timeline"- ? 67- : Math.max(25, (MAX_TREE_WIDTH_PX / containerWidth) * 100);+ ? 80+ : Math.max(+ 25,+ Math.min(70, (MAX_TREE_WIDTH_PX / containerWidth) * 100),+ );setPanelState((prev) => {if (prev.minSize !== minSize || prev.maxSize !== maxSize) {diff --git a/web/src/components/trace/index.tsx b/web/src/components/trace/index.tsxindex 18250aced6..c6970488b6 100644--- a/web/src/components/trace/index.tsx+++ b/web/src/components/trace/index.tsx@@ -103,6 +103,16 @@ export function Trace(props: {const [showGraph, setShowGraph] = useLocalStorage("showGraph", true);const [collapsedNodes, setCollapsedNodes] = useState<string[]>([]);+ // initial panel sizes for graph resizing+ const [timelineGraphSizes, setTimelineGraphSizes] = useLocalStorage(+ "trace-detail-timeline-graph-vertical",+ [60, 40],+ );+ const [treeGraphSizes, setTreeGraphSizes] = useLocalStorage(+ "trace-detail-tree-graph-vertical",+ [60, 40],+ );+const [minObservationLevel, setMinObservationLevel] =useState<ObservationLevelType>(props.defaultMinObservationLevel ?? ObservationLevel.DEFAULT,@@ -589,8 +599,17 @@ export function Trace(props: {{props.selectedTab?.includes("timeline") ? (<div className="h-full w-full flex-1 flex-col overflow-hidden">{isGraphViewAvailable && showGraph ? (- <div className="flex h-full w-full flex-col overflow-hidden">- <div className="h-1/2 w-full overflow-y-auto overflow-x-hidden">+ <ResizablePanelGroup+ direction="vertical"+ className="flex h-full w-full flex-col overflow-hidden"+ onLayout={setTimelineGraphSizes}+ >+ <ResizablePanel+ defaultSize={timelineGraphSizes[0]}+ minSize={5}+ maxSize={95}+ className="overflow-y-auto overflow-x-hidden"+ ><TraceTimelineViewkey={`timeline-${props.trace.id}`}trace={props.trace}@@ -608,14 +627,22 @@ export function Trace(props: {minLevel={minObservationLevel}setMinLevel={setMinObservationLevel}/>- </div>- <div className="h-1/2 w-full overflow-hidden border-t">+ </ResizablePanel>++ <ResizableHandle className="relative h-px bg-border transition-colors duration-200 after:absolute after:inset-x-0 after:top-0 after:h-1 after:-translate-y-px after:bg-blue-200 after:opacity-0 after:transition-opacity after:duration-200 hover:after:opacity-100 data-[resize-handle-state='drag']:after:opacity-100" />++ <ResizablePanel+ defaultSize={timelineGraphSizes[1]}+ minSize={5}+ maxSize={95}+ className="overflow-hidden"+ ><TraceGraphViewkey={`graph-timeline-${props.trace.id}`}agentGraphData={agentGraphData}/>- </div>- </div>+ </ResizablePanel>+ </ResizablePanelGroup>) : (<div className="flex h-full w-full overflow-y-auto overflow-x-hidden"><TraceTimelineView@@ -641,17 +668,34 @@ export function Trace(props: {) : (<div className="h-full w-full flex-1 flex-col overflow-hidden">{isGraphViewAvailable && showGraph ? (- <div className="flex h-full w-full flex-col overflow-hidden">- <div className="h-1/2 w-full overflow-y-auto overflow-x-hidden px-2">+ <ResizablePanelGroup+ direction="vertical"+ className="flex h-full w-full flex-col overflow-hidden"+ onLayout={setTreeGraphSizes}+ >+ <ResizablePanel+ defaultSize={treeGraphSizes[0]}+ minSize={5}+ maxSize={95}+ className="overflow-y-auto overflow-x-hidden px-2"+ ><div className="pb-2">{treeOrSearchContent}</div>- </div>- <div className="h-1/2 w-full overflow-hidden border-t">+ </ResizablePanel>++ <ResizableHandle className="relative h-px bg-border transition-colors duration-200 after:absolute after:inset-x-0 after:top-0 after:h-1 after:-translate-y-px after:bg-blue-200 after:opacity-0 after:transition-opacity after:duration-200 hover:after:opacity-100 data-[resize-handle-state='drag']:after:opacity-100" />++ <ResizablePanel+ defaultSize={treeGraphSizes[1]}+ minSize={5}+ maxSize={95}+ className="overflow-hidden"+ ><TraceGraphViewkey={`graph-tree-${props.trace.id}`}agentGraphData={agentGraphData}/>- </div>- </div>+ </ResizablePanel>+ </ResizablePanelGroup>) : (<div className="h-full w-full overflow-auto px-2"><div className="pb-2">{treeOrSearchContent}</div>diff --git a/web/src/features/trace-graph-view/components/TraceGraphCanvas.tsx b/web/src/features/trace-graph-view/components/TraceGraphCanvas.tsxindex a91bcf5f9c..887ecb6cc1 100644--- a/web/src/features/trace-graph-view/components/TraceGraphCanvas.tsx+++ b/web/src/features/trace-graph-view/components/TraceGraphCanvas.tsx@@ -1,6 +1,6 @@import React, { useEffect, useRef, useMemo, useState } from "react";import { Network } from "vis-network/standalone";-import { ZoomIn, ZoomOut } from "lucide-react";+import { ZoomIn, ZoomOut, RotateCcw } from "lucide-react";import type { GraphCanvasData } from "../types";import {@@ -34,69 +34,69 @@ export const TraceGraphCanvas: React.FC<TraceGraphCanvasProps> = (props) => {switch (nodeType) {case "AGENT":return {- border: "#9333ea", // purple-600 (text-purple-600)- background: "#c4b5fd", // purple-300- highlight: { border: "#7c3aed", background: "#a78bfa" },+ border: "#c4b5fd", // purple-300 (former background)+ background: "#f3f4f6", // gray-100+ highlight: { border: "#a78bfa", background: "#e5e7eb" }, // gray-200};case "TOOL":return {- border: "#ea580c", // orange-600 (text-orange-600)- background: "#fed7aa", // orange-300- highlight: { border: "#dc2626", background: "#fdba74" },+ border: "#fed7aa", // orange-300 (former background)+ background: "#f3f4f6", // gray-100+ highlight: { border: "#fdba74", background: "#e5e7eb" }, // gray-200};case "GENERATION":return {- border: "#c026d3", // magenta/fuchsia-600 (text-muted-magenta)- background: "#f0abfc", // fuchsia-300- highlight: { border: "#a21caf", background: "#e879f9" },+ border: "#f0abfc", // fuchsia-300 (former background)+ background: "#f3f4f6", // gray-100+ highlight: { border: "#e879f9", background: "#e5e7eb" }, // gray-200};case "SPAN":return {- border: "#2563eb", // blue-600 (text-muted-blue)- background: "#93c5fd", // blue-300- highlight: { border: "#1d4ed8", background: "#60a5fa" },+ border: "#93c5fd", // blue-300 (former background)+ background: "#f3f4f6", // gray-100+ highlight: { border: "#60a5fa", background: "#e5e7eb" }, // gray-200};case "CHAIN":return {- border: "#db2777", // pink-600 (text-pink-600)- background: "#f9a8d4", // pink-300- highlight: { border: "#be185d", background: "#f472b6" },+ border: "#f9a8d4", // pink-300 (former background)+ background: "#f3f4f6", // gray-100+ highlight: { border: "#f472b6", background: "#e5e7eb" }, // gray-200};case "RETRIEVER":return {- border: "#0d9488", // teal-600 (text-teal-600)- background: "#5eead4", // teal-300- highlight: { border: "#0f766e", background: "#2dd4bf" },+ border: "#5eead4", // teal-300 (former background)+ background: "#f3f4f6", // gray-100+ highlight: { border: "#2dd4bf", background: "#e5e7eb" }, // gray-200};case "EVENT":return {- border: "#059669", // green-600 (text-muted-green)- background: "#6ee7b7", // green-300- highlight: { border: "#047857", background: "#34d399" },+ border: "#6ee7b7", // green-300 (former background)+ background: "#f3f4f6", // gray-100+ highlight: { border: "#34d399", background: "#e5e7eb" }, // gray-200};case "EMBEDDING":return {- border: "#d97706", // amber-600 (text-amber-600)- background: "#fbbf24", // amber-300- highlight: { border: "#b45309", background: "#f59e0b" },+ border: "#fbbf24", // amber-300 (former background)+ background: "#f3f4f6", // gray-100+ highlight: { border: "#f59e0b", background: "#e5e7eb" }, // gray-200};case "GUARDRAIL":return {- border: "#dc2626", // red-600 (text-red-600)- background: "#fca5a5", // red-300- highlight: { border: "#b91c1c", background: "#f87171" },+ border: "#fca5a5", // red-300 (former background)+ background: "#f3f4f6", // gray-100+ highlight: { border: "#f87171", background: "#e5e7eb" }, // gray-200};case "LANGGRAPH_SYSTEM":return {- border: "#374151", // gray- background: "#d1d5db",- highlight: { border: "#1f2937", background: "#9ca3af" },+ border: "#d1d5db", // gray (former background)+ background: "#f3f4f6", // gray-100+ highlight: { border: "#9ca3af", background: "#e5e7eb" }, // gray-200};default:return {- border: "#1e3a8a", // default blue- background: "#93c5fd",- highlight: { border: "#1e40af", background: "#60a5fa" },+ border: "#93c5fd", // blue-300 (former background)+ background: "#f3f4f6", // gray-100+ highlight: { border: "#60a5fa", background: "#e5e7eb" }, // gray-200};}};@@ -156,6 +156,14 @@ export const TraceGraphCanvas: React.FC<TraceGraphCanvasProps> = (props) => {() => ({autoResize: true,layout: {+ hierarchical: {+ enabled: true,+ direction: "UD", // Up-Down (top to bottom)+ levelSeparation: 60,+ nodeSpacing: 175,+ sortMethod: "hubsize",+ shakeTowards: "roots",+ },randomSeed: 1,},physics: {@@ -175,7 +183,7 @@ export const TraceGraphCanvas: React.FC<TraceGraphCanvasProps> = (props) => {bottom: 10,left: 10,},- borderWidth: 1,+ borderWidth: 2,font: {size: 14,color: "#000000",@@ -228,6 +236,17 @@ export const TraceGraphCanvas: React.FC<TraceGraphCanvasProps> = (props) => {}};+ const handleReset = () => {+ if (networkRef.current) {+ networkRef.current.fit({+ animation: {+ duration: 300,+ easingFunction: "easeInOutQuad",+ },+ });+ }+ };+useEffect(() => {if (!containerRef.current) {return;@@ -249,7 +268,71 @@ export const TraceGraphCanvas: React.FC<TraceGraphCanvasProps> = (props) => {onCanvasNodeNameChange(null);});- // Add window resize handler to force network redraw+ // Prevent dragging the view completely out of bounds+ // this resets the graph position so that always a little bit is visible+ const constrainView = () => {+ const position = network.getViewPosition();+ const scale = network.getScale();+ const container = containerRef.current;++ if (!container) return;+ const containerRect = container.getBoundingClientRect();++ const nodePositions = network.getPositions();+ const nodeIds = Object.keys(nodePositions);++ if (nodeIds.length === 0) {+ return;+ }++ let minX = Infinity,+ maxX = -Infinity,+ minY = Infinity,+ maxY = -Infinity;++ nodeIds.forEach((nodeId) => {+ const pos = nodePositions[nodeId];+ minX = Math.min(minX, pos.x);+ maxX = Math.max(maxX, pos.x);+ minY = Math.min(minY, pos.y);+ maxY = Math.max(maxY, pos.y);+ });++ // Add some padding for node sizes (approximate node width/height)+ const nodePadding = 100;+ const graphWidth = (maxX - minX + nodePadding * 2) * scale;+ const graphHeight = (maxY - minY + nodePadding * 2) * scale;++ // max amount that a graph can be dragged on respective axis+ const maxDragX = (containerRect.width / 2 + graphWidth * 0.35) / scale;+ const maxDragY = (containerRect.height / 2 + graphHeight * 0.35) / scale;++ // Clamp position within bounds+ const constrainedX = Math.max(-maxDragX, Math.min(maxDragX, position.x));+ const constrainedY = Math.max(-maxDragY, Math.min(maxDragY, position.y));++ if (constrainedX !== position.x || constrainedY !== position.y) {+ network.moveTo({+ position: { x: constrainedX, y: constrainedY },+ scale: scale,+ animation: false,+ });+ }+ };++ // Apply constraints after drag ends+ network.on("dragEnd", (params) => {+ // only if dragging graph not nodes+ if (params.nodes.length === 0) {+ constrainView();+ }+ });++ network.on("zoom", () => {+ constrainView();+ });++ // force redraw on resetting viewconst handleResize = () => {if (network) {network.redraw();@@ -330,6 +413,15 @@ export const TraceGraphCanvas: React.FC<TraceGraphCanvasProps> = (props) => {><ZoomOut className="h-4 w-4" /></Button>+ <Button+ onClick={handleReset}+ variant="ghost"+ size="icon"+ className="p-1.5 shadow-md dark:shadow-border"+ title="Reset view"+ >+ <RotateCcw className="h-4 w-4" />+ </Button></div>)}<div ref={containerRef} className="h-full w-full" />