Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(web): make timeline hover tree rows selectable (#17360)

Nikita Kabardin41bed7fc11cf
diff --git a/web/src/features/traces/components/TraceTimelineDense/TimelineDense.stories.tsx b/web/src/features/traces/components/TraceTimelineDense/TimelineDense.stories.tsx
index 4d8e927241..8cb61a2210 100644
--- a/web/src/features/traces/components/TraceTimelineDense/TimelineDense.stories.tsx
+++ b/web/src/features/traces/components/TraceTimelineDense/TimelineDense.stories.tsx
@@ -656,6 +656,57 @@ export const HoverPeeksTheNames = meta.story({
},
});
+/**
+ * The peek is a navigation surface, not a caption. Clicking a name selects
+ * the observation the same way clicking the bar does.
+ */
+export const PeekRowClickSelects = meta.story({
+ name: "(Test) Peek Row Click Selects",
+ args: {
+ roots: manySpans(40),
+ box: PHONE,
+ gutter: "auto",
+ pointer: "fine",
+ barColor: "type",
+ compress: false,
+ showReadout: true,
+ selectedId: null,
+ onSelect: fn(),
+ onHover: fn(),
+ },
+ play: async ({ canvasElement, args }) => {
+ const surface = canvasElement.querySelector<HTMLElement>(
+ '[data-testid="timeline-dense-surface"]',
+ );
+ if (!surface) throw new Error("dense surface not found");
+ const rect = surface.getBoundingClientRect();
+ surface.dispatchEvent(
+ new PointerEvent("pointermove", {
+ bubbles: true,
+ pointerType: "mouse",
+ clientX: rect.left + 4,
+ clientY: rect.top + 120,
+ }),
+ );
+ await waitFor(() =>
+ expect(
+ canvasElement.querySelector('[data-testid="timeline-dense-peek-row"]'),
+ ).not.toBeNull(),
+ );
+
+ const peekRow = canvasElement.querySelector<HTMLElement>(
+ '[data-testid="timeline-dense-peek-row"]',
+ );
+ if (!peekRow) throw new Error("expected a peek row to click");
+ peekRow.dispatchEvent(
+ new MouseEvent("click", { bubbles: true, detail: 1 }),
+ );
+
+ await expect(args.onSelect).toHaveBeenCalledTimes(1);
+ await expect(args.onSelect).toHaveBeenCalledWith(expect.any(String));
+ },
+});
+
export const DoubleClickFocusesBothAxes = meta.story({
name: "(Test) Double Click Focuses Both Axes",
args: {
diff --git a/web/src/features/traces/components/TraceTimelineDense/TimelineDense.tsx b/web/src/features/traces/components/TraceTimelineDense/TimelineDense.tsx
index c59682406b..369f3d82d8 100644
--- a/web/src/features/traces/components/TraceTimelineDense/TimelineDense.tsx
+++ b/web/src/features/traces/components/TraceTimelineDense/TimelineDense.tsx
@@ -1259,6 +1259,16 @@ export function TimelineDense({
endGesture();
}, [endGesture]);
+ /**
+ * Shared by the bar rows and the hover peek tree. Selecting is not free
+ * (analytics + reopen the detail panel), and a double-click's second click
+ * must not fire it again.
+ */
+ const selectRowOnClick = (event: { detail: number }, nodeId: string) => {
+ if (event.detail > 1 || focusedByTap.current) return;
+ onSelect(nodeId);
+ };
+
/** Double-click an element: both axes move to put it on screen, readably. */
const focusRow = (index: number) => {
const positioned = result.nodes.find((node) => node.index === index);
@@ -1544,16 +1554,7 @@ export function TimelineDense({
)}
style={{ top: `${y}px`, height: `${rowHeight}px` }}
data-testid="timeline-dense-row"
- // A double-click delivers TWO clicks, and selecting is not free:
- // it captures an analytics event and reopens the detail panel.
- // The first click of the pair already selected the row, so the
- // second one only focuses.
- onClick={(event) => {
- // A double-click delivers two clicks; a double-TAP delivers two
- // clicks that both look like the first one.
- if (event.detail > 1 || focusedByTap.current) return;
- onSelect(node.id);
- }}
+ onClick={(event) => selectRowOnClick(event, node.id)}
onDoubleClick={() => focusRow(node.index)}
>
<GutterContent
@@ -1694,7 +1695,7 @@ export function TimelineDense({
<div
key={node.id}
className={cn(
- "absolute inset-x-0",
+ "absolute inset-x-0 cursor-pointer",
rowWashClass({
selected: node.id === selectedId,
focused: node.index === focusIndex,
@@ -1702,6 +1703,9 @@ export function TimelineDense({
}),
)}
style={{ top: `${y}px`, height: `${rowHeight}px` }}
+ data-testid="timeline-dense-peek-row"
+ onClick={(event) => selectRowOnClick(event, node.id)}
+ onDoubleClick={() => focusRow(node.index)}
>
<GutterContent
node={node}