🪢 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
fix(trace-tree): Dynamic row heights for virtualized trace tree (#10620)
Michael Fröhlich23c7204cdf5e
diff --git a/web/src/components/trace/SpanItem.tsx b/web/src/components/trace/SpanItem.tsxindex fbe1c7cd60..c998dcf69a 100644--- a/web/src/components/trace/SpanItem.tsx+++ b/web/src/components/trace/SpanItem.tsx@@ -62,7 +62,9 @@ export const SpanItem: React.FC<SpanItemProps> = ({return (<div className={cn("flex min-w-0 flex-col", className)}><div className="flex min-w-0 items-center gap-2 overflow-hidden">- <span className="flex-shrink truncate text-xs">{node.name}</span>+ <span className="flex-shrink truncate text-xs">+ {node.name || `Unnamed ${node.type.toLowerCase()}`}+ </span><div className="flex items-center gap-x-2">{comments && showComments ? (diff --git a/web/src/components/trace/TraceTree.tsx b/web/src/components/trace/TraceTree.tsxindex 3ef4921b1f..a168c62799 100644--- a/web/src/components/trace/TraceTree.tsx+++ b/web/src/components/trace/TraceTree.tsx@@ -141,11 +141,56 @@ export const TraceTree = ({return flattenTree(tree, collapsedNodes, 0, [], true);}, [tree, collapsedNodes]);+ // Calculate dynamic row height based on node content+ const estimateSize = useCallback(+ (index: number) => {+ const item = flattenedItems[index];+ if (!item) return 37;++ // Base height for node row+ let height = 37;++ // Add height for metrics line if visible+ const hasMetrics =+ (showDuration && (item.node.endTime || item.node.latency !== null)) ||+ (showCostTokens &&+ (item.node.inputUsage ||+ item.node.outputUsage ||+ item.node.totalUsage ||+ item.node.totalCost));+ if (hasMetrics) {+ height += 16; // One line of metrics+ }++ // Add height for scores if visible+ if (showScores) {+ const nodeScores = scores.filter((s) =>+ item.node.type === "TRACE"+ ? s.observationId === null+ : s.observationId === item.node.id,+ );++ if (nodeScores.length > 0) {+ // Estimate 3 score groups per line, each line ~20px+ const estimatedLines = Math.min(Math.ceil(nodeScores.length / 3), 3);+ height += estimatedLines * 20;+ }+ }++ return height;+ },+ [flattenedItems, showDuration, showCostTokens, showScores, scores],+ );+const rowVirtualizer = useVirtualizer({count: flattenedItems.length,getScrollElement: () => parentRef.current,- estimateSize: () => 37, // Approximate height of a row+ estimateSize,overscan: 500,+ measureElement:+ typeof window !== "undefined"+ ? (element) => element.getBoundingClientRect().height+ : undefined,});// Track initial currentNodeId to detect URL-based navigation vs user clicks@@ -198,12 +243,13 @@ export const TraceTree = ({return (<divkey={item.node.id}+ data-index={virtualRow.index}+ ref={rowVirtualizer.measureElement}style={{position: "absolute",top: 0,left: 0,width: "100%",- height: `${virtualRow.size}px`,transform: `translateY(${virtualRow.start}px)`,}}>