🪢 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(experiments): open the experiment trace on click of the experiment cell (#16474)
marliessophiec66e955f7ad4
diff --git a/web/src/components/table/data-table.tsx b/web/src/components/table/data-table.tsxindex a09bdb50b9..87c9acc76a 100644--- a/web/src/components/table/data-table.tsx+++ b/web/src/components/table/data-table.tsx@@ -12,6 +12,7 @@ import React, {} from "react";import DocPopup from "@/src/components/layouts/doc-popup";import { DataTablePagination } from "@/src/components/table/data-table-pagination";+import { shouldIgnoreRowClickTarget } from "@/src/components/table/shouldIgnoreRowClickTarget";import { getPlainTextFromReactNode } from "@/src/utils/react-node-plain-text";import {type CustomHeights,@@ -161,15 +162,6 @@ function isValidCssVariableName({return regex.test(name);}-const INTERACTIVE_ROW_CLICK_SELECTOR =- "a, button, input, select, textarea, summary, [role='button'], [role='link']";--const shouldIgnoreRowClickTarget = (target: EventTarget | null) => {- if (!(target instanceof Element)) return false;-- return Boolean(target.closest(INTERACTIVE_ROW_CLICK_SELECTOR));-};-// These are the important styles to make sticky column pinning work!const getCommonPinningStyles = <TData,>(column: Column<TData>,diff --git a/web/src/components/table/shouldIgnoreRowClickTarget.ts b/web/src/components/table/shouldIgnoreRowClickTarget.tsnew file mode 100644index 0000000000..8e0e3cdb81--- /dev/null+++ b/web/src/components/table/shouldIgnoreRowClickTarget.ts@@ -0,0 +1,21 @@+/**+ * Controls that own their own click, so a row- or cell-level click handler+ * must leave them alone.+ */+const INTERACTIVE_ROW_CLICK_SELECTOR =+ "a, button, input, select, textarea, summary, [role='button'], [role='link']";++/**+ * Whether a click landed on a real control rather than on the row's body.+ *+ * Shared with the per-experiment cells in the comparison view, which open+ * their own peek target and need the same exemption the row uses. Note that a+ * hover-card trigger rendered without `asChild` becomes an `<a>` and is+ * therefore ignored here — pass `asChild` so it stays part of the clickable+ * surface.+ */+export const shouldIgnoreRowClickTarget = (target: EventTarget | null) => {+ if (!(target instanceof Element)) return false;++ return Boolean(target.closest(INTERACTIVE_ROW_CLICK_SELECTOR));+};diff --git a/web/src/features/experiments/components/table/ExperimentGridCell.clienttest.tsx b/web/src/features/experiments/components/table/ExperimentGridCell.clienttest.tsxindex 0e901112a8..e13eb5b18e 100644--- a/web/src/features/experiments/components/table/ExperimentGridCell.clienttest.tsx+++ b/web/src/features/experiments/components/table/ExperimentGridCell.clienttest.tsx@@ -30,12 +30,14 @@ const renderGridCell = (showScoreLevelLabels: boolean,columnVisibility: VisibilityState = { output: false, metadata: false },output: unknown = null,+ onExperimentClick?: (event: React.MouseEvent) => void,) =>render(<TooltipProvider><ExperimentGridCellprojectId="project-id"itemId="item-id"+ onExperimentClick={onExperimentClick}output={output}level="GENERATION"startTime={new Date("2026-07-30T10:00:00.000Z")}@@ -127,4 +129,44 @@ describe("ExperimentGridCell", () => {"/project/project-id/traces/execution-trace-id",);});++ it("opens this experiment when its cell is clicked", () => {+ const onExperimentClick = vi.fn();+ const { container } = renderGridCell(+ false,+ { output: false, metadata: false },+ null,+ onExperimentClick,+ );++ fireEvent.click(container.firstElementChild as Element);++ expect(onExperimentClick).toHaveBeenCalledTimes(1);+ });++ it("offers no pointer affordance when the cell cannot open a peek", () => {+ const { container } = renderGridCell(false);++ expect(container.firstElementChild).not.toHaveClass("cursor-pointer");+ });++ // A score name used to render as Radix's default <a>, which the row-click+ // guard always ignores — a dead zone in an otherwise clickable cell.+ it("keeps the score name clickable rather than rendering it as a link", () => {+ const onExperimentClick = vi.fn();+ renderGridCell(+ false,+ { output: false, metadata: false },+ null,+ onExperimentClick,+ );++ const scoreName = screen.getByText("quality");++ expect(scoreName.closest("a")).toBeNull();++ fireEvent.click(scoreName);++ expect(onExperimentClick).toHaveBeenCalledTimes(1);+ });});diff --git a/web/src/features/experiments/components/table/ExperimentGridCell.tsx b/web/src/features/experiments/components/table/ExperimentGridCell.tsxindex bb0169f406..38b29e6742 100644--- a/web/src/features/experiments/components/table/ExperimentGridCell.tsx+++ b/web/src/features/experiments/components/table/ExperimentGridCell.tsx@@ -80,6 +80,8 @@ type ExperimentGridCellProps = {columnVisibility?: VisibilityState;markerClassName?: string;showScoreLevelLabels: boolean;+ /** Clicking this experiment's cell selects it in peek navigation instead of the row's default (baseline) target. */+ onExperimentClick?: (event: React.MouseEvent) => void;};/**@@ -300,8 +302,14 @@ const ScoreItem = ({<div className="flex max-w-[50%] min-w-0 items-center gap-1">{showScoreLevelLabel && <ScoreTag level={level} />}<HoverCard>- <HoverCardTrigger className="min-w-0 cursor-default">- <span className="text-muted-foreground block truncate" title={name}>+ {/* `asChild` keeps this a <span>. Without it Radix renders its+ default <a>, which `shouldIgnoreRowClickTarget` excludes — the+ score name would be a dead zone in a cell that opens on click. */}+ <HoverCardTrigger asChild>+ <span+ className="text-muted-foreground block min-w-0 truncate"+ title={name}+ >{name}</span></HoverCardTrigger>@@ -696,6 +704,7 @@ export const ExperimentGridCell = ({columnVisibility = {},markerClassName,showScoreLevelLabels,+ onExperimentClick,}: ExperimentGridCellProps) => {const scoreDiffs = useMemo(() =>@@ -864,7 +873,13 @@ export const ExperimentGridCell = ({// `scrollbar-visible` is what says so — under the platform's overlay// scrollbars a cell with more to show reads as one that was cut off.return (- <div className="scrollbar-visible flex h-full min-h-0 w-full min-w-0 flex-1 flex-col overflow-auto">+ <div+ className={cn(+ "scrollbar-visible flex h-full min-h-0 w-full min-w-0 flex-1 flex-col overflow-auto",+ onExperimentClick && "cursor-pointer",+ )}+ onClick={onExperimentClick}+ >{sectionsToRender.map((section, index) => {const { row, content } = section;const isFirst = index === 0;diff --git a/web/src/features/experiments/components/table/ExperimentGridView.tsx b/web/src/features/experiments/components/table/ExperimentGridView.tsxindex 76356cde23..85f3155892 100644--- a/web/src/features/experiments/components/table/ExperimentGridView.tsx+++ b/web/src/features/experiments/components/table/ExperimentGridView.tsx@@ -1,4 +1,5 @@import { DataTable } from "@/src/components/table/data-table";+import { shouldIgnoreRowClickTarget } from "@/src/components/table/shouldIgnoreRowClickTarget";import { type LangfuseColumnDef } from "@/src/components/table/types";import { createIOTableColumn } from "@/src/components/design-system/table/columns/createIOTableColumn";import { Badge } from "@/src/components/ui/badge";@@ -189,6 +190,18 @@ export const ExperimentGridView = ({}columnVisibility={columnVisibility}markerClassName={colorStyles?.markerClass}+ onExperimentClick={+ peekView?.openPeek+ ? (event) => {+ if (shouldIgnoreRowClickTarget(event.target)) return;+ event.stopPropagation();+ peekView.openPeek?.(row.original.itemId, {+ ...row.original,+ clickedExperimentId: expId,+ });+ }+ : undefined+ }/>);},@@ -206,6 +219,7 @@ export const ExperimentGridView = ({useExperimentColors,showDiff,singleLine,+ peekView,]);// Build all columns: Select, Input, Expected Output, then experiment columnsdiff --git a/web/src/features/experiments/components/table/ExperimentItemsTable.tsx b/web/src/features/experiments/components/table/ExperimentItemsTable.tsxindex f4f03e22a6..0525195cd7 100644--- a/web/src/features/experiments/components/table/ExperimentItemsTable.tsx+++ b/web/src/features/experiments/components/table/ExperimentItemsTable.tsx@@ -116,6 +116,32 @@ import {type ScoreLevel,} from "@/src/features/experiments/fns/scoreComparisonFilter";import { resetStaleDefaultColumnOrder } from "@/src/features/experiments/fns/experimentItemsColumnOrder";+import { shouldIgnoreRowClickTarget } from "@/src/components/table/shouldIgnoreRowClickTarget";+import { resolveExperimentPeekTarget } from "@/src/features/experiments/fns/resolveExperimentPeekTarget";++/**+ * A row on its way into the peek, carrying which experiment's cell was+ * clicked. Absent for a click on the row itself, which still opens the+ * baseline.+ */+type ClickedExperimentRow = ExperimentItemsTableRow & {+ clickedExperimentId?: string;+};++/** `usePeekNavigation`'s `openPeek`, as the cell handlers need it. */+type PeekOpener = (itemId: string, row: ClickedExperimentRow) => void;++/**+ * Opens the peek on one experiment's cell. Passed to every per-experiment+ * cell; `undefined` when the peek cannot open, which also removes the+ * pointer affordance.+ */+type ExperimentCellClickHandler = (+ event: React.MouseEvent,+ row: ExperimentItemsTableRow,+ experimentId: string,+) => void;+const renderExperimentSpecificHeader = (label: string) => (<span className="text-muted-foreground">{label}</span>);@@ -223,12 +249,17 @@ const StackedExperimentCell = ({colorExperimentIds,renderValue,className,+ row,+ onExperimentClick,}: {experiments: ExperimentItemData[];allExperimentIds: string[];colorExperimentIds?: string[];renderValue: (exp: ExperimentItemData) => React.ReactNode;className?: string;+ row?: ExperimentItemsTableRow;+ /** Clicking one experiment's line opens that run, not the row's baseline. */+ onExperimentClick?: ExperimentCellClickHandler;}) => {const experimentsById = useMemo(() => new Map(experiments.map((exp) => [exp.experimentId, exp])),@@ -249,10 +280,21 @@ const StackedExperimentCell = ({colorExperimentIds ?? allExperimentIds,);const content = exp ? renderValue(exp) : null;+ // Clickable because this run exists for the item — never because it+ // rendered a value. A run with an empty value still has a trace.+ const isClickable = Boolean(exp && row && onExperimentClick);return (<divkey={experimentId}- className="flex min-h-0 items-start overflow-hidden py-0.5 pr-2 pl-1.5"+ className={cn(+ "flex min-h-0 items-start overflow-hidden py-0.5 pr-2 pl-1.5",+ isClickable && "cursor-pointer",+ )}+ onClick={+ isClickable+ ? (event) => onExperimentClick?.(event, row!, experimentId)+ : undefined+ }>{content ? (<>@@ -357,6 +399,8 @@ const StackedOutputCell = ({singleLine,isLoading,expectedOutput,+ row,+ onExperimentClick,}: {outputs: ExperimentOutputData[];allExperimentIds: string[];@@ -369,6 +413,9 @@ const StackedOutputCell = ({* mode, and for the items that simply have no expected output.*/expectedOutput?: string | null;+ row?: ExperimentItemsTableRow;+ /** Clicking one experiment's line opens that run, not the row's baseline. */+ onExperimentClick?: ExperimentCellClickHandler;}) => {const outputsByExperimentId = useMemo(() => new Map(outputs.map((out) => [out.experimentId, out])),@@ -408,10 +455,26 @@ const StackedOutputCell = ({const expectedMatch = showExpectedLine? matchesExpectedOutput(out?.output, expectedOutput): null;+ // Gated on the run existing for this item, never on the output being+ // truthy: a run that legitimately returned "" still has a trace to+ // open, and testing the text would drop the handler and let the click+ // fall through to the row — back to the baseline.+ const hasRun = row?.experiments.some(+ (exp) => exp.experimentId === experimentId,+ );+ const isClickable = Boolean(hasRun && row && onExperimentClick);return (<divkey={experimentId}- className="flex min-h-0 items-start overflow-hidden py-0.5 pr-1 pl-1.5"+ className={cn(+ "flex min-h-0 items-start overflow-hidden py-0.5 pr-1 pl-1.5",+ isClickable && "cursor-pointer",+ )}+ onClick={+ isClickable+ ? (event) => onExperimentClick?.(event, row!, experimentId)+ : undefined+ }>{isLoading ? (<div className="flex h-full min-h-0 min-w-0 items-start">@@ -487,6 +550,35 @@ export default function ExperimentItemsTable({hasBaseline,hideControls,});++ // `openPeek` lives on `usePeekNavigation` further down (it needs state this+ // component only has by then), but the column builders below need a click+ // handler at definition time. The ref bridges the two without making every+ // memoized column depend on a callback that is a fresh literal each render.+ const openPeekRef = useRef<PeekOpener | null>(null);+ const openClickedExperimentPeek = useCallback(+ (+ event: React.MouseEvent,+ row: ExperimentItemsTableRow,+ experimentId: string,+ ) => {+ // A real control inside the cell (a link, a button) owns its own click.+ if (shouldIgnoreRowClickTarget(event.target)) return;+ // Otherwise the row handler would win and re-open the baseline.+ event.stopPropagation();+ openPeekRef.current?.(row.itemId, {+ ...row,+ clickedExperimentId: experimentId,+ });+ },+ [],+ );+ // Undefined when the peek cannot open, so the cells neither act nor offer a+ // pointer cursor — same gate on the affordance as on the action.+ const onExperimentCellClick = canUsePeek+ ? openClickedExperimentPeek+ : undefined;+const { experimentNames } = useExperimentNames({ projectId });const selectedExperimentNames = useMemo(() => {return experimentNames.filter((exp) =>@@ -1053,6 +1145,8 @@ export default function ExperimentItemsTable({experiments={experiments}allExperimentIds={allExperimentIds}colorExperimentIds={colorExperimentIds}+ row={row.original}+ onExperimentClick={onExperimentCellClick}renderValue={(exp) => {const scoresData = exp[scoreField] ?? {};const value = scoresData[scoreKey];@@ -1144,6 +1238,7 @@ export default function ExperimentItemsTable({removeScoreComparisonFilter,captureScoreComparisonFilter,runNameOf,+ onExperimentCellClick,],);@@ -1285,6 +1380,8 @@ export default function ExperimentItemsTable({outputs={outputs}allExperimentIds={allExperimentIds}colorExperimentIds={colorExperimentIds}+ row={row.original}+ onExperimentClick={onExperimentCellClick}singleLine={ioSingleLine}isLoading={ioLoading}// Items with no expected output get no expected line and no@@ -1318,6 +1415,8 @@ export default function ExperimentItemsTable({experiments={experiments}allExperimentIds={allExperimentIds}colorExperimentIds={colorExperimentIds}+ row={row.original}+ onExperimentClick={onExperimentCellClick}renderValue={(exp) => (// Wraps rather than clipping: in a 120px column a six-decimal// cost and its delta do not fit on one line, and half a currency@@ -1359,6 +1458,8 @@ export default function ExperimentItemsTable({experiments={experiments}allExperimentIds={allExperimentIds}colorExperimentIds={colorExperimentIds}+ row={row.original}+ onExperimentClick={onExperimentCellClick}renderValue={(exp) => (<span className="inline-flex min-w-0 flex-wrap items-center gap-x-1 gap-y-0.5">{exp.latencyMs != null ? (@@ -1393,6 +1494,8 @@ export default function ExperimentItemsTable({experiments={experiments}allExperimentIds={allExperimentIds}colorExperimentIds={colorExperimentIds}+ row={row.original}+ onExperimentClick={onExperimentCellClick}renderValue={(exp) => <IdTableCell value={exp.observationId} />}/>);@@ -1417,6 +1520,8 @@ export default function ExperimentItemsTable({experiments={experiments}allExperimentIds={allExperimentIds}colorExperimentIds={colorExperimentIds}+ row={row.original}+ onExperimentClick={onExperimentCellClick}renderValue={(exp) => {const preparedDate = buildLocalIsoDatePresentation({date: exp.startTime,@@ -1446,6 +1551,8 @@ export default function ExperimentItemsTable({experiments={experiments}allExperimentIds={allExperimentIds}colorExperimentIds={colorExperimentIds}+ row={row.original}+ onExperimentClick={onExperimentCellClick}renderValue={(exp) => <span>{exp.level}</span>}/>);@@ -1466,6 +1573,8 @@ export default function ExperimentItemsTable({experiments={experiments}allExperimentIds={allExperimentIds}colorExperimentIds={colorExperimentIds}+ row={row.original}+ onExperimentClick={onExperimentCellClick}renderValue={(exp) => {const expOption = selectedExperimentNames.find((e) => e.experimentId === exp.experimentId,@@ -1601,17 +1710,21 @@ export default function ExperimentItemsTable({],tableName: experimentItemsFilterConfig.tableName,isV4: true,- extractParamsValuesFromRow: (row: ExperimentItemsTableRow) => {- // Use the explicit baseline when present. Without one, use the first- // selected experiment only as the primary trace for URL-compatible peek- // navigation; it is not treated as a baseline in comparison logic.- const baselineExp = baselineId- ? row.experiments.find((e) => e.experimentId === baselineId)- : row.experiments[0];+ extractParamsValuesFromRow: (row: ClickedExperimentRow) => {+ const targetExp = resolveExperimentPeekTarget({+ experiments: row.experiments,+ baselineId,+ clickedExperimentId: row.clickedExperimentId,+ });return {- traceId: baselineExp?.traceId || "",- timestamp: baselineExp?.startTime.toISOString() || "",- observation: baselineExp?.observationId || "",+ traceId: targetExp?.traceId || "",+ timestamp: targetExp?.startTime.toISOString() || "",+ observation: targetExp?.observationId || "",+ // Tells the peek which experiment it opened on, so its prev/next+ // switcher starts from the clicked run rather than the baseline.+ ...(row.clickedExperimentId+ ? { peekExperimentId: row.clickedExperimentId }+ : {}),};},expandConfig: {@@ -1620,6 +1733,9 @@ export default function ExperimentItemsTable({},});+ // Hand the per-experiment cell handlers above the live `openPeek`.+ openPeekRef.current = peekNavigationProps.openPeek;+const { isLoading: isViewLoading, ...viewControllers } = useTableViewManager({tableName: TableViewPresetTableName.ExperimentItems,projectId,@@ -1688,9 +1804,12 @@ export default function ExperimentItemsTable({setDetailPageList("experiment-items",rows.map((item: ExperimentItemsTableRow) => {- const baselineExp = baselineId- ? item.experiments.find((e) => e.experimentId === baselineId)- : item.experiments[0];+ // The list's own default target, same rule the peek uses for a row+ // click. A cell click overrides it via `clickedExperimentId`.+ const baselineExp = resolveExperimentPeekTarget({+ experiments: item.experiments,+ baselineId,+ });// Build experiment targets map for all experimentsconst experimentTargets = Object.fromEntries(diff --git a/web/src/features/experiments/fns/resolveExperimentPeekTarget.clienttest.ts b/web/src/features/experiments/fns/resolveExperimentPeekTarget.clienttest.tsnew file mode 100644index 0000000000..5292b46dba--- /dev/null+++ b/web/src/features/experiments/fns/resolveExperimentPeekTarget.clienttest.ts@@ -0,0 +1,73 @@+import { resolveExperimentPeekTarget } from "./resolveExperimentPeekTarget";+import { type ExperimentItemData } from "../components/table/types";++const run = (experimentId: string, traceId: string): ExperimentItemData => ({+ experimentId,+ level: "DEFAULT",+ startTime: new Date("2026-08-25T09:00:00.000Z"),+ observationId: `obs-${experimentId}`,+ traceId,+ observationScores: {},+ traceScores: {},+});++const baseline = run("exp-baseline", "trace-baseline");+const comparison = run("exp-comparison", "trace-comparison");+const experiments = [baseline, comparison];++describe("resolveExperimentPeekTarget", () => {+ it("opens the clicked comparison run, not the baseline", () => {+ expect(+ resolveExperimentPeekTarget({+ experiments,+ baselineId: "exp-baseline",+ clickedExperimentId: "exp-comparison",+ }),+ ).toBe(comparison);+ });++ it("opens the baseline when the baseline's own cell was clicked", () => {+ expect(+ resolveExperimentPeekTarget({+ experiments,+ baselineId: "exp-baseline",+ clickedExperimentId: "exp-baseline",+ }),+ ).toBe(baseline);+ });++ it("falls back to the baseline for a click on the row itself", () => {+ expect(+ resolveExperimentPeekTarget({+ experiments,+ baselineId: "exp-baseline",+ }),+ ).toBe(baseline);+ });++ it("uses the first run as the primary trace when no baseline is selected", () => {+ expect(resolveExperimentPeekTarget({ experiments })).toBe(baseline);+ });++ // The regression that shipped the bug: clickability and target resolution+ // were derived from the output, so a run returning "" lost its trace.+ it("resolves a run that produced an empty output", () => {+ expect(+ resolveExperimentPeekTarget({+ experiments,+ baselineId: "exp-baseline",+ clickedExperimentId: "exp-comparison",+ }),+ ).toHaveProperty("traceId", "trace-comparison");+ });++ it("returns nothing when the clicked run did not run for the item", () => {+ expect(+ resolveExperimentPeekTarget({+ experiments: [baseline],+ baselineId: "exp-baseline",+ clickedExperimentId: "exp-comparison",+ }),+ ).toBeUndefined();+ });+});diff --git a/web/src/features/experiments/fns/resolveExperimentPeekTarget.ts b/web/src/features/experiments/fns/resolveExperimentPeekTarget.tsnew file mode 100644index 0000000000..60f9ae3c93--- /dev/null+++ b/web/src/features/experiments/fns/resolveExperimentPeekTarget.ts@@ -0,0 +1,30 @@+import { type ExperimentItemData } from "../components/table/types";++/**+ * Which run's trace the peek should open for an item.+ *+ * A click on one experiment's cell names that experiment and wins. Otherwise+ * the row itself was clicked: use the explicit baseline when there is one, and+ * without one fall back to the first selected run purely so the peek has a+ * primary trace to render — that fallback is not a baseline for comparison.+ *+ * Resolution reads the item's run list, never its outputs, so a run that+ * legitimately produced an empty output still resolves to its own trace.+ */+export function resolveExperimentPeekTarget({+ experiments,+ baselineId,+ clickedExperimentId,+}: {+ experiments: ExperimentItemData[];+ baselineId?: string | null;+ clickedExperimentId?: string;+}): ExperimentItemData | undefined {+ if (clickedExperimentId) {+ return experiments.find((e) => e.experimentId === clickedExperimentId);+ }+ if (baselineId) {+ return experiments.find((e) => e.experimentId === baselineId);+ }+ return experiments[0];+}