Skip to content

πŸͺ’ Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

feat(trace): condense the detail layout + smoother timeline (LFE-10539, LFE-10538) (#14598)

Nikita Kabardinbb409633bb30
diff --git a/web/src/components/trace/components/TraceTimeline/TimelineBar.stories.tsx b/web/src/components/trace/components/TraceTimeline/TimelineBar.stories.tsx
index 1b6a62e488..6e77ba382b 100644
--- a/web/src/components/trace/components/TraceTimeline/TimelineBar.stories.tsx
+++ b/web/src/components/trace/components/TraceTimeline/TimelineBar.stories.tsx
@@ -18,7 +18,7 @@ const meta = preview.meta({
// row-height relative track so its left offset renders in context.
decorators: [
(Story) => (
- <div className="bg-background relative h-[42px] w-[640px] rounded border">
+ <div className="bg-background relative h-[26px] w-[640px] rounded border">
<Story />
</div>
),
diff --git a/web/src/components/trace/components/TraceTimeline/TimelineBar.tsx b/web/src/components/trace/components/TraceTimeline/TimelineBar.tsx
index d0f4a34fc9..d94cc57d3f 100644
--- a/web/src/components/trace/components/TraceTimeline/TimelineBar.tsx
+++ b/web/src/components/trace/components/TraceTimeline/TimelineBar.tsx
@@ -128,7 +128,7 @@ export function TimelineBar({
>
<div
className={cn(
- "border-border flex h-5 overflow-hidden rounded-sm border",
+ "border-border flex h-4 overflow-hidden rounded-sm border",
// Dashed when in-flight (no width yet), matching the non-streaming bar.
itemWidth ? "" : "border-dashed",
ringClass,
@@ -156,7 +156,7 @@ export function TimelineBar({
>
<div
className={cn(
- "border-border bg-muted h-5 rounded-sm border",
+ "border-border bg-muted h-4 rounded-sm border",
itemWidth ? "" : "border-dashed",
ringClass,
)}
diff --git a/web/src/components/trace/components/TraceTimeline/TimelineGutterRow.stories.tsx b/web/src/components/trace/components/TraceTimeline/TimelineGutterRow.stories.tsx
index ce7937e611..97544ed1c5 100644
--- a/web/src/components/trace/components/TraceTimeline/TimelineGutterRow.stories.tsx
+++ b/web/src/components/trace/components/TraceTimeline/TimelineGutterRow.stories.tsx
@@ -5,7 +5,7 @@ import { flattenTreeWithTimelineMetrics } from "./timeline-flattening";
import { makeItem, makeTreeNode } from "./timeline.fixtures";
const ROW_BOX =
- "bg-background relative h-[42px] w-[320px] overflow-hidden rounded border";
+ "bg-background relative h-[26px] w-[320px] overflow-hidden rounded border";
const PANEL_BOX = "bg-background w-[320px] overflow-hidden rounded border";
// fn() gives Storybook actions; cast to the prop type so meta args and the
@@ -209,7 +209,7 @@ export const TreeShowcase = meta.story({
return (
<>
{items.map((item) => (
- <div key={item.node.id} className="h-[42px]">
+ <div key={item.node.id} className="h-[26px]">
<TimelineGutterRow
item={item}
isSelected={false}
diff --git a/web/src/components/trace/components/TraceTimeline/index.tsx b/web/src/components/trace/components/TraceTimeline/index.tsx
index 95945a4633..978eeb1882 100644
--- a/web/src/components/trace/components/TraceTimeline/index.tsx
+++ b/web/src/components/trace/components/TraceTimeline/index.tsx
@@ -2,10 +2,12 @@
* TraceTimeline - Gantt waterfall: a fixed name-gutter + a scrollable chart.
*
* Two panes, side by side, sharing the virtualized rows:
- * - Gutter pane (fixed, resizable): the indented name tree. Never scrolls
- * horizontally; its vertical scroll is mirrored from the chart.
- * - Chart pane (flex-1): the gantt bars. Owns the only horizontal scrollbar
- * (and the vertical one). It is the virtualizer's scroll element.
+ * - Gutter pane (fixed, resizable): the indented name tree. It never scrolls
+ * itself β€” its content is a one-way translateY projection of the chart's
+ * vertical scroll, so the two panes can't drift; wheeling over it drives the
+ * chart.
+ * - Chart pane (flex-1): the gantt bars. Owns the only scrollbars (horizontal
+ * and vertical) and is the virtualizer's scroll element.
*
* The time scale sits in an overflow-hidden header strip whose inner is
* transform-synced to the chart's horizontal scroll, so the scale stays aligned
@@ -31,11 +33,15 @@ import { TimelineBar } from "./TimelineBar";
import { useDesktopLayoutContextOptional } from "../_layout/TraceLayoutDesktop";
import { cn } from "@/src/utils/tailwind";
-// Width of the left name gutter. Resizable; these bound it.
-const GUTTER_WIDTH_DEFAULT = 240;
+// Width of the left name gutter. Resizable; these bound it. Kept slim so the
+// waterfall (the point of the timeline) gets the central space.
+const GUTTER_WIDTH_DEFAULT = 200;
const GUTTER_WIDTH_MIN = 160;
const GUTTER_WIDTH_MAX = 560;
-const ROW_HEIGHT = 42;
+// Dense waterfall rows (LFE-10539): the 16px bar / 16px name chip sit centered
+// with ~5px of breathing room. Drives both the virtualizer estimate and the
+// rendered row height, so the two never drift.
+const ROW_HEIGHT = 26;
export function TraceTimeline() {
const { roots, serverScores: scores, comments } = useTraceData();
@@ -52,7 +58,9 @@ export function TraceTimeline() {
// Optional (null in the mobile layout): reopen the detail panel on select.
const layout = useDesktopLayoutContextOptional();
- const gutterRef = useRef<HTMLDivElement>(null);
+ // The chart is the single vertical scroller; the gutter content is a one-way
+ // transform projection of it (gutterInnerRef), so the two panes can't drift.
+ const gutterInnerRef = useRef<HTMLDivElement>(null);
const chartRef = useRef<HTMLDivElement>(null);
const scaleInnerRef = useRef<HTMLDivElement>(null);
@@ -129,11 +137,15 @@ export function TraceTimeline() {
}, [flattenedItems]);
// Virtualizer drives off the chart pane; the gutter mirrors its vertical scroll.
+ // overscan is a ROW COUNT (not px): keep it small so a long trace re-renders
+ // only a few dozen rows per scroll step instead of ~1000 (the old "500" β€” a
+ // px-vs-items mix-up β€” made big traces stutter). ~16 rows β‰ˆ half a viewport of
+ // headroom, enough to avoid blank rows on a normal scroll.
const rowVirtualizer = useVirtualizer({
count: flattenedItems.length,
getScrollElement: () => chartRef.current,
estimateSize: () => ROW_HEIGHT,
- overscan: 500,
+ overscan: 16,
});
// Auto-scroll to selected node on initial load (URL-based navigation only).
@@ -160,25 +172,36 @@ export function TraceTimeline() {
}
}, [selectedNodeId, flattenedItems, rowVirtualizer]);
- // Vertical scroll sync (chart ⇄ gutter) + horizontal sync (chart β†’ scale).
- // Guard with !== so mirroring doesn't loop (setting an equal value is a no-op).
+ // The chart owns the only vertical scroll. The gutter and the time scale are
+ // one-way projections of it (translateY / translateX) updated in the same
+ // scroll frame β€” no second scroll container to fight the chart's momentum,
+ // which is what made the two panes drift apart.
const handleChartScroll = useCallback(() => {
const chart = chartRef.current;
if (!chart) return;
- if (gutterRef.current && gutterRef.current.scrollTop !== chart.scrollTop) {
- gutterRef.current.scrollTop = chart.scrollTop;
+ if (gutterInnerRef.current) {
+ gutterInnerRef.current.style.transform = `translateY(${-chart.scrollTop}px)`;
}
if (scaleInnerRef.current) {
scaleInnerRef.current.style.transform = `translateX(${-chart.scrollLeft}px)`;
}
}, []);
- const handleGutterScroll = useCallback(() => {
- const gutter = gutterRef.current;
- if (!gutter) return;
- if (chartRef.current && chartRef.current.scrollTop !== gutter.scrollTop) {
- chartRef.current.scrollTop = gutter.scrollTop;
- }
+ // The gutter doesn't scroll itself; wheeling over it drives the chart, which
+ // then projects back onto the gutter via handleChartScroll. Normalize the
+ // delta to pixels first: Firefox (and classic mouse wheels) report deltaMode
+ // in lines (1) or pages (2), not pixels (0) β€” without this, a line-mode wheel
+ // moves ~1px per notch and the gutter feels stuck.
+ const handleGutterWheel = useCallback((e: React.WheelEvent) => {
+ const chart = chartRef.current;
+ if (!chart) return;
+ const unit =
+ e.deltaMode === 1
+ ? ROW_HEIGHT
+ : e.deltaMode === 2
+ ? chart.clientHeight
+ : 1;
+ chart.scrollTop += e.deltaY * unit;
}, []);
// Parent totals for heatmap coloring (aggregate across all roots).
@@ -207,11 +230,15 @@ export function TraceTimeline() {
useLayoutEffect(() => {
const el = chartRef.current;
if (!el) return;
- const measure = () =>
- setChartScrollbar({
- x: el.offsetWidth - el.clientWidth,
- y: el.offsetHeight - el.clientHeight,
- });
+ const measure = () => {
+ const x = el.offsetWidth - el.clientWidth;
+ const y = el.offsetHeight - el.clientHeight;
+ // Only re-render when the measurement actually changes β€” the observer
+ // fires on every content resize, but the scrollbar size rarely moves.
+ setChartScrollbar((prev) =>
+ prev.x === x && prev.y === y ? prev : { x, y },
+ );
+ };
measure();
const ro = new ResizeObserver(measure);
ro.observe(el);
@@ -336,17 +363,24 @@ export function TraceTimeline() {
className="flex min-h-0 flex-1"
onMouseLeave={() => setHoveredNodeId(null)}
>
- {/* Gutter pane β€” vertical scroll mirrored from the chart; scrollbar hidden. */}
+ {/* Gutter pane β€” a one-way projection of the chart's vertical scroll
+ (translateY), never its own scroll container, so it stays locked to
+ the chart. Wheeling over it drives the chart. */}
<div
- ref={gutterRef}
- onScroll={handleGutterScroll}
- className="shrink-0 overflow-x-hidden overflow-y-auto [&::-webkit-scrollbar]:hidden"
- style={{ width: `${gutterWidth}px`, scrollbarWidth: "none" }}
+ onWheel={handleGutterWheel}
+ className="shrink-0 overflow-hidden"
+ style={{ width: `${gutterWidth}px` }}
>
<div
+ ref={gutterInnerRef}
style={{
+ // Match the chart's scrollable extent, including the height its
+ // horizontal scrollbar steals on classic (Windows/Linux) bars, so
+ // the projected rows line up to the very bottom (0 on macOS overlay
+ // bars).
height: `${totalSize + chartScrollbar.y}px`,
position: "relative",
+ willChange: "transform",
}}
>
{virtualItems.map((vr) => renderRow(vr, "gutter"))}
diff --git a/web/src/components/trace/components/_layout/TraceLayoutDesktop.tsx b/web/src/components/trace/components/_layout/TraceLayoutDesktop.tsx
index ab47ce1054..f4d3c1c648 100644
--- a/web/src/components/trace/components/_layout/TraceLayoutDesktop.tsx
+++ b/web/src/components/trace/components/_layout/TraceLayoutDesktop.tsx
@@ -16,10 +16,13 @@ import {
} from "react";
import { PanelRightOpen } from "lucide-react";
import { Button } from "@/src/components/ui/button";
+import { cn } from "@/src/utils/tailwind";
import { useViewPreferences } from "@/src/components/trace/contexts/ViewPreferencesContext";
import { useSelection } from "@/src/components/trace/contexts/SelectionContext";
-const RESIZABLE_PANEL_GROUP_ID = "trace-layout";
+// v2: the default split now gives the trace (tree/timeline) the central space
+// with a slimmer detail panel. Bumped so a stale saved layout doesn't mask it.
+const RESIZABLE_PANEL_GROUP_ID = "trace-layout-v2";
const RESIZABLE_PANEL_HANDLE_ID = "trace-layout-handle";
const RESIZABLE_PANEL_NAVIGATION_ID = "trace-layout-panel-navigation";
const RESIZABLE_PANEL_PREVIEW_ID = "trace-layout-panel-preview";
@@ -164,21 +167,9 @@ export function TraceLayoutDesktop({ children }: { children: ReactNode }) {
>
{children}
</Group>
-
- {/* When the detail panel is fully collapsed, a tab on the right edge
- brings it back (the drag handle alone isn't discoverable). */}
- {isDetailPanelCollapsed && (
- <Button
- variant="outline"
- size="icon"
- title="Show detail panel"
- aria-label="Show detail panel"
- onClick={expandDetailPanel}
- className="bg-background absolute top-1/2 right-0 z-30 h-9 w-6 -translate-y-1/2 rounded-l-md rounded-r-none border-r-0 shadow-sm"
- >
- <PanelRightOpen className="h-4 w-4" />
- </Button>
- )}
+ {/* When the detail panel is collapsed, the navigation header surfaces a
+ "show detail panel" button at its right edge (TracePanelNavigationHeader)
+ β€” no floating edge tab. */}
</div>
</LayoutContext.Provider>
);
@@ -199,7 +190,7 @@ TraceLayoutDesktop.NavigationPanel = function Navigation({
collapsible={true}
collapsedSize="40px"
minSize="260px"
- defaultSize="450px"
+ defaultSize="60%"
onResize={() => {
setIsNavigationPanelCollapsed(panelRef.current?.isCollapsed() ?? false);
}}
@@ -228,19 +219,25 @@ TraceLayoutDesktop.DetailPanel = function Detail({
}: {
children: ReactNode;
}) {
- const { detailPanelRef, setIsDetailPanelCollapsed } = useLayoutContext();
+ const {
+ detailPanelRef,
+ setIsDetailPanelCollapsed,
+ isDetailPanelCollapsed,
+ expandDetailPanel,
+ } = useLayoutContext();
return (
// Collapsible like the navigation panel: dragging it below the 360px floor
- // snaps it shut (collapsedSize 0) so the timeline/tree can take the full
- // width. A tab on the right edge (rendered by TraceLayoutDesktop) brings it
- // back. 360px is the readable minimum the narrow peek already renders at.
+ // snaps it to a 40px rail (collapsedSize) so the timeline/tree takes the
+ // rest of the width while a "show detail panel" button on the rail brings it
+ // back β€” mirroring the navigation panel's collapsed strip. 360px is the
+ // readable minimum the narrow peek already renders at.
<Panel
id={RESIZABLE_PANEL_PREVIEW_ID}
panelRef={detailPanelRef}
- defaultSize="70%"
+ defaultSize="40%"
collapsible={true}
- collapsedSize="0px"
+ collapsedSize="40px"
minSize="360px"
onResize={() => {
setIsDetailPanelCollapsed(
@@ -248,7 +245,26 @@ TraceLayoutDesktop.DetailPanel = function Detail({
);
}}
>
- {children}
+ {/* Keep the detail content MOUNTED while collapsed (just hidden), so its
+ scroll position, local state, and in-progress comment/annotation
+ drafts survive a collapse β†’ expand round-trip. */}
+ <div className={cn("h-full w-full", isDetailPanelCollapsed && "hidden")}>
+ {children}
+ </div>
+ {isDetailPanelCollapsed && (
+ <div className="flex h-full w-full flex-col items-center p-2">
+ <Button
+ variant="ghost"
+ size="icon"
+ title="Show detail panel"
+ aria-label="Show detail panel"
+ onClick={expandDetailPanel}
+ className="h-7 w-7 shrink-0"
+ >
+ <PanelRightOpen className="h-3.5 w-3.5" />
+ </Button>
+ </div>
+ )}
</Panel>
);
};
diff --git a/web/src/components/trace/components/_layout/TracePanelNavigationHeader.tsx b/web/src/components/trace/components/_layout/TracePanelNavigationHeader.tsx
index cdceaa9b0d..6c938bb939 100644
--- a/web/src/components/trace/components/_layout/TracePanelNavigationHeader.tsx
+++ b/web/src/components/trace/components/_layout/TracePanelNavigationHeader.tsx
@@ -45,6 +45,7 @@ import {
downloadServerTraceAsJson,
} from "../../lib/download-trace";
import { TracePanelNavigationButton } from "./TracePanelNavigationButton";
+import { useDesktopLayoutContextOptional } from "./TraceLayoutDesktop";
import { toast } from "sonner";
import { TRACE_DOWNLOAD_OMIT_LARGE_FIELDS_THRESHOLD } from "@/src/features/traces/shared/traceDownloadConfig";
import { useWatchedPromiseCallback } from "@/src/hooks/useWatchedPromiseCallback";
@@ -93,6 +94,13 @@ function TracePanelNavigationHeaderExpanded({
const { isBetaEnabled } = useV4Beta();
const [viewMode, setViewMode] = useQueryParam("view", StringParam);
+ // When the detail (info) panel is closed, the tree/timeline owns the whole
+ // surface β€” so the left "collapse panel" toggle would only shrink the one
+ // thing on screen. Hide it. Re-opening the detail panel is handled by its own
+ // collapsed rail (see TraceLayoutDesktop), so the header needs no button.
+ const layout = useDesktopLayoutContextOptional();
+ const isDetailPanelCollapsed = layout?.isDetailPanelCollapsed ?? false;
+
const handleSearchKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
if (e.key === "Enter") {
// Skip debouncing and search immediately
@@ -157,16 +165,22 @@ function TracePanelNavigationHeaderExpanded({
return (
<Command className="flex h-auto shrink-0 flex-col gap-1 overflow-hidden rounded-none border-b">
<div className="@container/navheader flex flex-row items-center justify-between pr-2 pl-1">
- {/* Panel Toggle Button; special p-0.5 offset to pixel align with closed version */}
- <div className="flex flex-row items-center p-0.5">
- <TracePanelNavigationButton
- isPanelCollapsed={isPanelCollapsed}
- onTogglePanel={onTogglePanel}
- shouldPulseToggle={shouldPulseToggle}
- />
- </div>
+ {/* Panel Toggle Button; special p-0.5 offset to pixel align with closed
+ version. Hidden while the detail panel is closed (nothing useful to
+ collapse the full-width tree/timeline into). */}
+ {!isDetailPanelCollapsed && (
+ <div className="flex flex-row items-center p-0.5">
+ <TracePanelNavigationButton
+ isPanelCollapsed={isPanelCollapsed}
+ onTogglePanel={onTogglePanel}
+ shouldPulseToggle={shouldPulseToggle}
+ />
+ </div>
+ )}
{/* Search Input */}
- <div className="relative flex-1">
+ <div
+ className={cn("relative flex-1", isDetailPanelCollapsed && "pl-1")}
+ >
<CommandInput
showBorder={false}
placeholder="Search"
@@ -255,6 +269,9 @@ function TracePanelNavigationHeaderExpanded({
isTimelineView={isTimelineView}
onSelect={(timeline) => setViewMode(timeline ? "timeline" : null)}
/>
+ {/* When the detail panel is closed it shows its own collapsed rail +
+ expand button on the right edge (mirrors the navigation panel), so
+ the header needs no re-open button β€” see TraceLayoutDesktop. */}
</div>
</div>
</Command>