Skip to content

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

fix(tables): cmd+click opens traces and observations in a new tab (#9161)

Leo Weigand8d5c445dc502
diff --git a/web/src/components/table/data-table.tsx b/web/src/components/table/data-table.tsx
index 3a8dafd438..b81e86251d 100644
--- a/web/src/components/table/data-table.tsx
+++ b/web/src/components/table/data-table.tsx
@@ -70,7 +70,7 @@ interface DataTableProps<TData, TValue> {
customRowHeights?: CustomHeights;
className?: string;
shouldRenderGroupHeaders?: boolean;
- onRowClick?: (row: TData) => void;
+ onRowClick?: (row: TData, event?: React.MouseEvent) => void;
peekView?: DataTablePeekViewProps;
hidePagination?: boolean;
tableName: string;
@@ -237,13 +237,18 @@ export function DataTable<TData extends object, TValue>({
});
const handleOnRowClick = useCallback(
- (row: TData) => {
- if ("id" in row && typeof row.id === "string") {
- peekView?.openPeek(row.id, row);
+ (row: TData, event?: React.MouseEvent) => {
+ // Call the table-specific onRowClick first (for modifier key handling)
+ onRowClick?.(row, event);
+
+ // If the table handler didn't prevent default, handle peek view
+ if (peekView && !event?.defaultPrevented) {
+ const rowId =
+ "id" in row && typeof row.id === "string" ? row.id : undefined;
+ peekView.openPeek(rowId, row);
}
- onRowClick?.(row);
},
- [peekView, onRowClick],
+ [onRowClick, peekView],
);
const hasRowClickAction = !!onRowClick || !!peekView;
@@ -460,7 +465,7 @@ interface TableBodyComponentProps<TData> {
columns: LangfuseColumnDef<TData, any>[];
data: AsyncTableData<TData[]>;
help?: { description: string; href: string };
- onRowClick?: (row: TData) => void;
+ onRowClick?: (row: TData, event?: React.MouseEvent) => void;
getRowClassName?: (row: TData) => string;
tableSnapshot?: {
tableDataUpdatedAt?: number;
@@ -477,7 +482,7 @@ function TableRowComponent<TData>({
children,
}: {
row: Row<TData>;
- onRowClick?: (row: TData) => void;
+ onRowClick?: (row: TData, event?: React.MouseEvent) => void;
getRowClassName?: (row: TData) => string;
children: React.ReactNode;
}) {
@@ -487,7 +492,7 @@ function TableRowComponent<TData>({
return (
<TableRow
data-row-index={row.index}
- onClick={() => onRowClick?.(row.original)}
+ onClick={(e) => onRowClick?.(row.original, e)}
onKeyDown={(e) => {
if (e.key === "Enter") {
onRowClick?.(row.original);
diff --git a/web/src/components/table/use-cases/observations.tsx b/web/src/components/table/use-cases/observations.tsx
index 026d33452f..dba81ded91 100644
--- a/web/src/components/table/use-cases/observations.tsx
+++ b/web/src/components/table/use-cases/observations.tsx
@@ -1143,6 +1143,34 @@ export default function ObservationsTable({
columnVisibility={columnVisibility}
onColumnVisibilityChange={setColumnVisibilityState}
rowHeight={rowHeight}
+ onRowClick={(row, event) => {
+ // Handle Command/Ctrl+click to open observation in new tab
+ if (event && (event.metaKey || event.ctrlKey)) {
+ // Prevent the default peek behavior
+ event.preventDefault();
+
+ // Construct the observation URL directly to avoid race conditions
+ const observationId = row.id;
+ const traceId = row.traceId;
+ const timestamp = row.timestamp;
+
+ if (traceId) {
+ let observationUrl = `/project/${projectId}/traces/${encodeURIComponent(traceId)}`;
+
+ const params = new URLSearchParams();
+ params.set("observation", observationId);
+ if (timestamp) {
+ params.set("timestamp", timestamp.toISOString());
+ }
+
+ observationUrl += `?${params.toString()}`;
+
+ const fullUrl = `${process.env.NEXT_PUBLIC_BASE_PATH ?? ""}${observationUrl}`;
+ window.open(fullUrl, "_blank");
+ }
+ }
+ // For normal clicks, let the data-table handle opening the peek view
+ }}
/>
</>
);
diff --git a/web/src/components/table/use-cases/traces.tsx b/web/src/components/table/use-cases/traces.tsx
index 5b773f813f..621a84149f 100644
--- a/web/src/components/table/use-cases/traces.tsx
+++ b/web/src/components/table/use-cases/traces.tsx
@@ -79,6 +79,7 @@ import { useFullTextSearch } from "@/src/components/table/use-cases/useFullTextS
import { type TableDateRange } from "@/src/utils/date-range-utils";
import { useScoreColumns } from "@/src/features/scores/hooks/useScoreColumns";
import { scoreFilters } from "@/src/features/scores/lib/scoreColumns";
+import { useRouter } from "next/router";
export type TracesTableRow = {
// Shown by default
@@ -141,6 +142,7 @@ export default function TracesTable({
externalDateRange,
limitRows,
}: TracesTableProps) {
+ const router = useRouter();
const utils = api.useUtils();
const [selectedRows, setSelectedRows] = useState<RowSelectionState>({});
const { setDetailPageList } = useDetailPageLists();
@@ -1223,6 +1225,36 @@ export default function TracesTable({
onColumnOrderChange={setColumnOrder}
rowHeight={rowHeight}
peekView={peekConfig}
+ onRowClick={(row, event) => {
+ // Handle Command/Ctrl+click to open trace in new tab
+ if (event && (event.metaKey || event.ctrlKey)) {
+ // Prevent the default peek behavior
+ event.preventDefault();
+
+ // Construct the trace URL directly to avoid race conditions
+ const traceId = row.id;
+ const timestamp = row.timestamp;
+ const display = router.query.display ?? "details";
+
+ let traceUrl = `/project/${projectId}/traces/${encodeURIComponent(traceId)}`;
+
+ const params = new URLSearchParams();
+ if (timestamp) {
+ params.set("timestamp", timestamp.toISOString());
+ }
+ if (display && typeof display === "string") {
+ params.set("display", display);
+ }
+
+ if (params.toString()) {
+ traceUrl += `?${params.toString()}`;
+ }
+
+ const fullUrl = `${process.env.NEXT_PUBLIC_BASE_PATH ?? ""}${traceUrl}`;
+ window.open(fullUrl, "_blank");
+ }
+ // For normal clicks, let the data-table handle opening the peek view
+ }}
tableName={"traces"}
/>
</>