Skip to content

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

fix(events-table): move peek view out of data table (#12099)

Nimarec82339df196
diff --git a/web/src/components/session/index.tsx b/web/src/components/session/index.tsx
index 577086b04f..cf78cb11eb 100644
--- a/web/src/components/session/index.tsx
+++ b/web/src/components/session/index.tsx
@@ -541,7 +541,6 @@ export const SessionPage: React.FC<{
expandPeek,
resolveDetailNavigationPath,
children: <PeekViewTraceDetail projectId={projectId} />,
- tableDataUpdatedAt: session.dataUpdatedAt,
}}
/>
</Page>
@@ -1056,7 +1055,6 @@ export const SessionEventsPage: React.FC<{
expandPeek,
resolveDetailNavigationPath,
children: <PeekViewTraceDetail projectId={projectId} />,
- tableDataUpdatedAt: tracesQuery.dataUpdatedAt,
}}
/>
</Page>
diff --git a/web/src/components/table/data-table.tsx b/web/src/components/table/data-table.tsx
index 192b78f8b7..9e2f207f48 100644
--- a/web/src/components/table/data-table.tsx
+++ b/web/src/components/table/data-table.tsx
@@ -40,10 +40,7 @@ import {
type VisibilityState,
type Row,
} from "@tanstack/react-table";
-import {
- type DataTablePeekViewProps,
- TablePeekView,
-} from "@/src/components/table/peek";
+import { type DataTablePeekViewProps } from "@/src/components/table/peek";
import isEqual from "lodash/isEqual";
import { useRouter } from "next/router";
import { useColumnSizing } from "@/src/components/table/hooks/useColumnSizing";
@@ -74,6 +71,7 @@ interface DataTableProps<TData, TValue> {
className?: string;
shouldRenderGroupHeaders?: boolean;
onRowClick?: (row: TData, event?: React.MouseEvent) => void;
+ /** Used for row click handling and MemoizedTableBody snapshot only. Render <TablePeekView> as a sibling outside DataTable. */
peekView?: DataTablePeekViewProps;
hidePagination?: boolean;
tableName: string;
@@ -416,7 +414,6 @@ export function DataTable<TData extends object, TValue>({
onRowClick={hasRowClickAction ? handleOnRowClick : undefined}
getRowClassName={getRowClassName}
tableSnapshot={{
- tableDataUpdatedAt: peekView?.tableDataUpdatedAt,
columnVisibility,
columnOrder,
rowSelection,
@@ -438,7 +435,6 @@ export function DataTable<TData extends object, TValue>({
</Table>
</div>
</div>
- {peekView && <TablePeekView peekView={peekView} />}
{!hidePagination && pagination !== undefined ? (
<div
className={cn(
@@ -480,7 +476,6 @@ interface TableBodyComponentProps<TData> {
onRowClick?: (row: TData, event?: React.MouseEvent) => void;
getRowClassName?: (row: TData) => string;
tableSnapshot?: {
- tableDataUpdatedAt?: number;
columnVisibility?: VisibilityState;
columnOrder?: ColumnOrderState;
rowSelection?: RowSelectionState;
@@ -642,12 +637,6 @@ const MemoizedTableBody = React.memo(TableBodyComponent, (prev, next) => {
return !prev.tableSnapshot && !next.tableSnapshot;
// Check reference equality first (faster)
- if (
- prev.tableSnapshot.tableDataUpdatedAt !==
- next.tableSnapshot.tableDataUpdatedAt
- ) {
- return false;
- }
if (prev.table.options.data !== next.table.options.data) return false;
if (prev.data.isLoading !== next.data.isLoading) return false;
if (prev.rowheighttw !== next.rowheighttw) return false;
diff --git a/web/src/components/table/peek.tsx b/web/src/components/table/peek.tsx
index a22d1b1be0..83964b236a 100644
--- a/web/src/components/table/peek.tsx
+++ b/web/src/components/table/peek.tsx
@@ -59,9 +59,6 @@ export type DataTablePeekViewProps = {
* The content to display in the peek view.
*/
children: React.ReactNode;
-
- /** The timestamp of the last time the table data was updated */
- tableDataUpdatedAt: number;
};
export const createPeekEventHandler = (options?: PeekEventControlOptions) => {
@@ -172,7 +169,4 @@ function TablePeekViewComponent(props: TablePeekViewProps) {
);
}
-export const TablePeekView = memo(TablePeekViewComponent, (prev, next) => {
- // TODO LFE-6627: drop tableDataUpdatedAt and allow memoization to work independently of table data updates
- return prev.peekView.tableDataUpdatedAt === next.peekView.tableDataUpdatedAt;
-}) as typeof TablePeekViewComponent;
+export const TablePeekView = memo(TablePeekViewComponent);
diff --git a/web/src/components/table/use-cases/observations.tsx b/web/src/components/table/use-cases/observations.tsx
index 3e904e31a0..c38dd0abfc 100644
--- a/web/src/components/table/use-cases/observations.tsx
+++ b/web/src/components/table/use-cases/observations.tsx
@@ -68,7 +68,10 @@ import { useSelectAll } from "@/src/features/table/hooks/useSelectAll";
import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";
import { TableActionMenu } from "@/src/features/table/components/TableActionMenu";
import { type TableAction } from "@/src/features/table/types";
-import { type DataTablePeekViewProps } from "@/src/components/table/peek";
+import {
+ type DataTablePeekViewProps,
+ TablePeekView,
+} from "@/src/components/table/peek";
import { useScoreColumns } from "@/src/features/scores/hooks/useScoreColumns";
import { scoreFilters } from "@/src/features/scores/lib/scoreColumns";
import { AddObservationsToDatasetDialog } from "@/src/features/batch-actions/components/AddObservationsToDatasetDialog/index";
@@ -1226,10 +1229,9 @@ export default function ObservationsTable({
customTitlePrefix: "Observation ID:",
detailNavigationKey: "observations",
children: <PeekViewObservationDetail projectId={projectId} />,
- tableDataUpdatedAt: generations.dataUpdatedAt,
...peekNavigationProps,
};
- }, [projectId, generations.dataUpdatedAt, peekNavigationProps, hideControls]);
+ }, [projectId, peekNavigationProps, hideControls]);
const rows: ObservationsTableRow[] = useMemo(() => {
return generations.isSuccess
@@ -1437,6 +1439,7 @@ export default function ObservationsTable({
/>
</div>
</ResizableFilterLayout>
+ {peekConfig && <TablePeekView peekView={peekConfig} />}
</div>
{/* Add to Dataset Dialog */}
diff --git a/web/src/components/table/use-cases/traces.tsx b/web/src/components/table/use-cases/traces.tsx
index 158c1a326a..0ab09c74e8 100644
--- a/web/src/components/table/use-cases/traces.tsx
+++ b/web/src/components/table/use-cases/traces.tsx
@@ -76,6 +76,7 @@ import { useSidebarFilterState } from "@/src/features/filters/hooks/useSidebarFi
import { traceFilterConfig } from "@/src/features/filters/config/traces-config";
import { PeekViewTraceDetail } from "@/src/components/table/peek/peek-trace-detail";
import { usePeekNavigation } from "@/src/components/table/peek/hooks/usePeekNavigation";
+import { TablePeekView } from "@/src/components/table/peek";
import { useTableViewManager } from "@/src/components/table/table-view-presets/hooks/useTableViewManager";
import { useFullTextSearch } from "@/src/components/table/use-cases/useFullTextSearch";
import { type TableDateRange } from "@/src/utils/date-range-utils";
@@ -1214,19 +1215,9 @@ export default function TracesTable({
ignoredSelectors: ['[role="checkbox"]', '[aria-label="bookmark"]'],
},
children: <PeekViewTraceDetail projectId={projectId} />,
- tableDataUpdatedAt: Math.max(
- traces.dataUpdatedAt,
- traceMetrics.dataUpdatedAt,
- ),
...peekNavigationProps,
};
- }, [
- projectId,
- hideControls,
- peekNavigationProps,
- traces.dataUpdatedAt,
- traceMetrics.dataUpdatedAt,
- ]);
+ }, [projectId, hideControls, peekNavigationProps]);
// Create ref-based wrapper to avoid stale closure when queryFilter updates
const queryFilterRef = useRef(queryFilter);
@@ -1425,6 +1416,7 @@ export default function TracesTable({
/>
</div>
</ResizableFilterLayout>
+ {peekConfig && <TablePeekView peekView={peekConfig} />}
</div>
</DataTableControlsProvider>
);
diff --git a/web/src/features/datasets/components/DatasetCompareRunsTable.tsx b/web/src/features/datasets/components/DatasetCompareRunsTable.tsx
index 2560f89283..95c001a724 100644
--- a/web/src/features/datasets/components/DatasetCompareRunsTable.tsx
+++ b/web/src/features/datasets/components/DatasetCompareRunsTable.tsx
@@ -7,7 +7,7 @@ import { IOTableCell } from "@/src/components/ui/IOTableCell";
import useColumnVisibility from "@/src/features/column-visibility/hooks/useColumnVisibility";
import { getDatasetRunAggregateColumnProps } from "@/src/features/datasets/components/DatasetRunAggregateColumnHelpers";
import { useDatasetRunAggregateColumns } from "@/src/features/datasets/hooks/useDatasetRunAggregateColumns";
-import { useState, useEffect } from "react";
+import { useState, useEffect, useMemo } from "react";
import { usePaginationState } from "@/src/hooks/usePaginationState";
import { api } from "@/src/utils/api";
import { Button } from "@/src/components/ui/button";
@@ -29,6 +29,7 @@ import { type Prisma } from "@langfuse/shared";
import { type EnrichedDatasetRunItem } from "@langfuse/shared/src/server";
import { usePeekNavigation } from "@/src/components/table/peek/hooks/usePeekNavigation";
import { PeekViewTraceDetail } from "@/src/components/table/peek/peek-trace-detail";
+import { TablePeekView } from "@/src/components/table/peek";
export type DatasetCompareRunRowData = {
id: string;
@@ -112,6 +113,17 @@ function DatasetCompareRunsTableInternal(props: {
},
});
+ const peekConfig = useMemo(
+ () => ({
+ itemType: "TRACE" as const,
+ children: <PeekViewTraceDetail projectId={props.projectId} />,
+ closePeek,
+ expandPeek,
+ // openPeek is handled by DatasetAggregateTableCell's custom handleOpenPeek
+ }),
+ [props.projectId, closePeek, expandPeek],
+ );
+
const { runAggregateColumns, isLoading: cellsLoading } =
useDatasetRunAggregateColumns({
projectId: props.projectId,
@@ -289,15 +301,9 @@ function DatasetCompareRunsTableInternal(props: {
m: "h-64",
l: "h-96",
}}
- peekView={{
- itemType: "TRACE",
- children: <PeekViewTraceDetail projectId={props.projectId} />,
- tableDataUpdatedAt: datasetItemsWithRunData.dataUpdatedAt,
- closePeek,
- expandPeek,
- // openPeek is handled by DatasetAggregateTableCell's custom handleOpenPeek
- }}
+ peekView={peekConfig}
/>
+ <TablePeekView peekView={peekConfig} />
</>
);
}
diff --git a/web/src/features/evals/components/eval-templates-table.tsx b/web/src/features/evals/components/eval-templates-table.tsx
index 2125b09335..dd94c1d08e 100644
--- a/web/src/features/evals/components/eval-templates-table.tsx
+++ b/web/src/features/evals/components/eval-templates-table.tsx
@@ -7,11 +7,12 @@ import { safeExtract } from "@/src/utils/map-utils";
import { createColumnHelper } from "@tanstack/react-table";
import { Copy, Pen } from "lucide-react";
import { useQueryParam, StringParam, withDefault } from "use-query-params";
-import { useEffect, useState } from "react";
+import { useEffect, useMemo, useState } from "react";
import { usePaginationState } from "@/src/hooks/usePaginationState";
import TableIdOrName from "@/src/components/table/table-id";
import { PeekViewEvaluatorTemplateDetail } from "@/src/components/table/peek/peek-evaluator-template-detail";
import { usePeekNavigation } from "@/src/components/table/peek/hooks/usePeekNavigation";
+import { TablePeekView } from "@/src/components/table/peek";
import { useDetailPageLists } from "@/src/features/navigate-detail-pages/context";
import { Button } from "@/src/components/ui/button";
import { useRouter } from "next/router";
@@ -292,6 +293,21 @@ export default function EvalsTemplateTable({
},
});
+ const peekConfig = useMemo(
+ () => ({
+ itemType: "EVALUATOR" as const,
+ detailNavigationKey: "eval-templates",
+ peekEventOptions: {
+ ignoredSelectors: [
+ "[aria-label='apply'], [aria-label='actions'], [aria-label='edit'], [aria-label='clone']",
+ ],
+ },
+ children: <PeekViewEvaluatorTemplateDetail projectId={projectId} />,
+ ...peekNavigationProps,
+ }),
+ [projectId, peekNavigationProps],
+ );
+
const convertToTableRow = (
template: RouterOutputs["evals"]["templateNames"]["templates"][number],
): EvalsTemplateRow => {
@@ -325,18 +341,7 @@ export default function EvalsTemplateTable({
<DataTable
tableName={"evalTemplates"}
columns={columns}
- peekView={{
- itemType: "EVALUATOR",
- detailNavigationKey: "eval-templates",
- peekEventOptions: {
- ignoredSelectors: [
- "[aria-label='apply'], [aria-label='actions'], [aria-label='edit'], [aria-label='clone']",
- ],
- },
- tableDataUpdatedAt: templates.dataUpdatedAt,
- children: <PeekViewEvaluatorTemplateDetail projectId={projectId} />,
- ...peekNavigationProps,
- }}
+ peekView={peekConfig}
data={
templates.isLoading
? { isLoading: true, isError: false }
@@ -362,6 +367,7 @@ export default function EvalsTemplateTable({
columnVisibility={columnVisibility}
onColumnVisibilityChange={setColumnVisibility}
/>
+ <TablePeekView peekView={peekConfig} />
<Dialog
open={!!editTemplateId && template.isSuccess}
onOpenChange={(open) => {
diff --git a/web/src/features/evals/components/evaluator-table.tsx b/web/src/features/evals/components/evaluator-table.tsx
index 8c682e9d35..f761bbfe67 100644
--- a/web/src/features/evals/components/evaluator-table.tsx
+++ b/web/src/features/evals/components/evaluator-table.tsx
@@ -37,6 +37,7 @@ import {
} from "lucide-react";
import { usePeekNavigation } from "@/src/components/table/peek/hooks/usePeekNavigation";
import { PeekViewEvaluatorConfigDetail } from "@/src/components/table/peek/peek-evaluator-config-detail";
+import { TablePeekView } from "@/src/components/table/peek";
import {
DropdownMenu,
DropdownMenuItem,
@@ -463,6 +464,21 @@ export default function EvaluatorTable({ projectId }: { projectId: string }) {
const peekNavigationProps = usePeekNavigation();
+ const peekConfig = useMemo(
+ () => ({
+ itemType: "RUNNING_EVALUATOR" as const,
+ detailNavigationKey: "evals",
+ peekEventOptions: {
+ ignoredSelectors: [
+ "[aria-label='edit'], [aria-label='actions'], [aria-label='view-logs'], [aria-label='delete']",
+ ],
+ },
+ children: <PeekViewEvaluatorConfigDetail projectId={projectId} />,
+ ...peekNavigationProps,
+ }),
+ [projectId, peekNavigationProps],
+ );
+
const convertToTableRow = (
jobConfig: RouterOutputs["evals"]["allConfigs"]["configs"][number],
): EvaluatorDataRow => {
@@ -553,23 +569,7 @@ export default function EvaluatorTable({ projectId }: { projectId: string }) {
<DataTable
tableName={"evalConfigs"}
columns={columns}
- peekView={{
- itemType: "RUNNING_EVALUATOR",
- detailNavigationKey: "evals",
- peekEventOptions: {
- ignoredSelectors: [
- "[aria-label='edit'], [aria-label='actions'], [aria-label='view-logs'], [aria-label='delete']",
- ],
- },
- tableDataUpdatedAt: Math.max(
- evaluators.dataUpdatedAt,
- costs.dataUpdatedAt,
- ),
- children: (
- <PeekViewEvaluatorConfigDetail projectId={projectId} />
- ),
- ...peekNavigationProps,
- }}
+ peekView={peekConfig}
data={
evaluators.isLoading
? { isLoading: true, isError: false }
@@ -599,6 +599,7 @@ export default function EvaluatorTable({ projectId }: { projectId: string }) {
/>
</div>
</ResizableFilterLayout>
+ <TablePeekView peekView={peekConfig} />
</div>
<Dialog
open={!!editConfigId && existingEvaluator.isSuccess}
diff --git a/web/src/features/events/components/EventsTable.tsx b/web/src/features/events/components/EventsTable.tsx
index 69b138a963..b5a099527b 100644
--- a/web/src/features/events/components/EventsTable.tsx
+++ b/web/src/features/events/components/EventsTable.tsx
@@ -57,7 +57,10 @@ import { TableSelectionManager } from "@/src/features/table/components/TableSele
import { useSelectAll } from "@/src/features/table/hooks/useSelectAll";
import { TableActionMenu } from "@/src/features/table/components/TableActionMenu";
import { type TableAction } from "@/src/features/table/types";
-import { type DataTablePeekViewProps } from "@/src/components/table/peek";
+import {
+ type DataTablePeekViewProps,
+ TablePeekView,
+} from "@/src/components/table/peek";
import { useScoreColumns } from "@/src/features/scores/hooks/useScoreColumns";
import { scoreFilters } from "@/src/features/scores/lib/scoreColumns";
import useColumnVisibility from "@/src/features/column-visibility/hooks/useColumnVisibility";
@@ -1073,10 +1076,9 @@ export default function ObservationsEventsTable({
customTitlePrefix: "Observation ID:",
detailNavigationKey: "observations",
children: <PeekViewObservationDetail projectId={projectId} />,
- tableDataUpdatedAt: dataUpdatedAt,
...peekNavigationProps,
};
- }, [projectId, dataUpdatedAt, peekNavigationProps, hideControls]);
+ }, [projectId, peekNavigationProps, hideControls]);
const rows: EventsTableRow[] = useMemo(() => {
const result =
@@ -1321,6 +1323,7 @@ export default function ObservationsEventsTable({
/>
</div>
</ResizableFilterLayout>
+ {peekConfig && <TablePeekView peekView={peekConfig} />}
</div>
</DataTableControlsProvider>
);