🪢 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
refactor(web): remove eslint-disable from TimelineDense (#19601)
cursor[bot]90fe2b9e2907
diff --git a/web/src/features/traces/components/TraceTimelineDense/TimelineDense.tsx b/web/src/features/traces/components/TraceTimelineDense/TimelineDense.tsxindex 4880112b24..6c7cfd7a7d 100644--- a/web/src/features/traces/components/TraceTimelineDense/TimelineDense.tsx+++ b/web/src/features/traces/components/TraceTimelineDense/TimelineDense.tsx@@ -1,4 +1,3 @@-/* eslint-disable @typescript-eslint/no-use-before-define *//*** The Timeline. `TraceTimelineCompact` measures a box and renders this inside it,* and the trace panel's Timeline view IS this — for everyone, on every device,@@ -567,38 +566,6 @@ export function TimelineDense({const pointerPosRef = useRef(pointerPos);pointerPosRef.current = pointerPos;- /**- * Tell the caller which row is under the pointer, resolved from a VIEWPORT- * rather than from the last pointermove: a zoom, a scroll, a zoom button and a- * focus flight all slide a new row under a pointer that never moved. The- * tooltip already follows that (`focusIndex` above re-derives every render),- * but the callback did not, so the row the user is looking at was the one row- * the caller never prefetched.- */- const notifyHover = (- viewport: Viewport,- // Only the surface-local point matters here; the viewport coordinates the- // tooltip needs are not this function's business.- at: { x: number; y: number } | null = pointerPosRef.current,- ): void => {- if (!at || !onHover) return;- const live = layoutRef.current;- const index = rowIndexAtOffset(- viewport,- at.y,- live.rowHeight,- live.rows.length,- );- const id = index == null ? null : live.rows[index]?.node.id;- if (!id || id === hoveredRef.current) return;- hoveredRef.current = id;- onHover(id);- };- // Reached through a ref from the stable callbacks below, the same way they- // reach the zoom pair: they attach once and must not close over this render.- const notifyHoverRef = useRef(notifyHover);- notifyHoverRef.current = notifyHover;-const density: Density = useMemo(() => ({pointer,@@ -666,6 +633,19 @@ export function TimelineDense({distance: 0,midpoint: { x: 0, y: 0 },});+ /**+ * Double-TAP focuses a row, because `dblclick` is not dependable from touch —+ * Safari in particular does not synthesise it. Detected here rather than+ * relied upon: two taps close in time and place, on the same row.+ */+ const lastTap = useRef({ at: 0, x: 0, y: 0 });+ /**+ * Set when a double-tap has just fired, so the tap's own click does not also+ * select. `event.detail` cannot carry this on touch: WebKit neither synthesises+ * `dblclick` from taps nor counts them, so both taps report `detail: 1` and a+ * detail-based guard only ever catches a mouse.+ */+ const focusedByTap = useRef(false);const tween = useRef(0);const cancelTween = useCallback(() => {@@ -704,6 +684,38 @@ export function TimelineDense({rows: prepared.rows,};+ /**+ * Tell the caller which row is under the pointer, resolved from a VIEWPORT+ * rather than from the last pointermove: a zoom, a scroll, a zoom button and a+ * focus flight all slide a new row under a pointer that never moved. The+ * tooltip already follows that (`focusIndex` above re-derives every render),+ * but the callback did not, so the row the user is looking at was the one row+ * the caller never prefetched.+ */+ const notifyHover = (+ viewport: Viewport,+ // Only the surface-local point matters here; the viewport coordinates the+ // tooltip needs are not this function's business.+ at: { x: number; y: number } | null = pointerPosRef.current,+ ): void => {+ if (!at || !onHover) return;+ const live = layoutRef.current;+ const index = rowIndexAtOffset(+ viewport,+ at.y,+ live.rowHeight,+ live.rows.length,+ );+ const id = index == null ? null : live.rows[index]?.node.id;+ if (!id || id === hoveredRef.current) return;+ hoveredRef.current = id;+ onHover(id);+ };+ // Reached through a ref from the stable callbacks below, the same way they+ // reach the zoom pair: they attach once and must not close over this render.+ const notifyHoverRef = useRef(notifyHover);+ notifyHoverRef.current = notifyHover;+/*** Zooming and re-anchoring are ONE operation, not two: `anchorTimeToRows`* exists precisely so a zoom cannot land on empty air, so every zoom entry@@ -908,6 +920,25 @@ export function TimelineDense({[cancelTween],);+ /** 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);+ const row = prepared.rows[index];+ if (!positioned || !row) return;+ // The click that opened this double-click already selected the row, and this+ // flight is about to put it exactly where it should be — so the reveal below+ // must not also chase it and cancel the animation.+ revealedRef.current = row.node.id;+ const startMs = compression.toCompressedMs(positioned.startMs);+ flyTo(+ focusViewport(limits, {+ rowIndex: index,+ startMs,+ durationMs: compression.toCompressedMs(positioned.endMs) - startMs,+ }),+ );+ };+const showLabels = () => {const { limits: live, extentOf } = layoutRef.current;setLabelsPinned(true);@@ -1246,19 +1277,6 @@ export function TimelineDense({}};- /**- * Double-TAP focuses a row, because `dblclick` is not dependable from touch —- * Safari in particular does not synthesise it. Detected here rather than- * relied upon: two taps close in time and place, on the same row.- */- const lastTap = useRef({ at: 0, x: 0, y: 0 });- /**- * Set when a double-tap has just fired, so the tap's own click does not also- * select. `event.detail` cannot carry this on touch: WebKit neither synthesises- * `dblclick` from taps nor counts them, so both taps report `detail: 1` and a- * detail-based guard only ever catches a mouse.- */- const focusedByTap = useRef(false);const maybeDoubleTap = (event: ReactPointerEvent<HTMLDivElement>) => {if (event.pointerType === "mouse") return; // the mouse has a real dblclickif (touches.current.points.size > 1 || gesture.current.dragging) return;@@ -1308,25 +1326,6 @@ export function TimelineDense({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);- const row = prepared.rows[index];- if (!positioned || !row) return;- // The click that opened this double-click already selected the row, and this- // flight is about to put it exactly where it should be — so the reveal below- // must not also chase it and cancel the animation.- revealedRef.current = row.node.id;- const startMs = compression.toCompressedMs(positioned.startMs);- flyTo(- focusViewport(limits, {- rowIndex: index,- startMs,- durationMs: compression.toCompressedMs(positioned.endMs) - startMs,- }),- );- };-const focused =focusIndex == null? null