Skip to content

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

feat(compare-runs): Allow for variable row height on compare view (#6400)

marliessophie5a2fef1fe961
diff --git a/web/src/components/table/data-table-row-height-switch.tsx b/web/src/components/table/data-table-row-height-switch.tsx
index 9b492e176b..ecbe518d93 100644
--- a/web/src/components/table/data-table-row-height-switch.tsx
+++ b/web/src/components/table/data-table-row-height-switch.tsx
@@ -18,15 +18,27 @@ import {
} from "react-icons/md";
const heightOptions = [
- { id: "s", label: "Small", value: "h-6", icon: <MdDensitySmall /> },
- { id: "m", label: "Medium", value: "h-24", icon: <MdDensityMedium /> },
- { id: "l", label: "Large", value: "h-64", icon: <MdDensityLarge /> },
+ { id: "s", label: "Small", icon: <MdDensitySmall /> },
+ { id: "m", label: "Medium", icon: <MdDensityMedium /> },
+ { id: "l", label: "Large", icon: <MdDensityLarge /> },
] as const;
+const defaultHeights: Record<RowHeight, string> = {
+ s: "h-6",
+ m: "h-24",
+ l: "h-64",
+};
+
export type RowHeight = (typeof heightOptions)[number]["id"];
+export type CustomHeights = Record<RowHeight, string>;
-export const getRowHeightTailwindClass = (rowHeight: RowHeight | undefined) =>
- heightOptions.find((h) => h.id === rowHeight)?.value;
+export const getRowHeightTailwindClass = (
+ rowHeight?: RowHeight,
+ customHeights?: CustomHeights,
+) => {
+ if (!rowHeight) return undefined;
+ return customHeights?.[rowHeight] || defaultHeights[rowHeight];
+};
export function useRowHeightLocalStorage(
tableName: string,
diff --git a/web/src/components/table/data-table.tsx b/web/src/components/table/data-table.tsx
index da43d6f55d..eb67f23273 100644
--- a/web/src/components/table/data-table.tsx
+++ b/web/src/components/table/data-table.tsx
@@ -4,6 +4,7 @@ import React, { useState, useMemo, useCallback } from "react";
import DocPopup from "@/src/components/layouts/doc-popup";
import { DataTablePagination } from "@/src/components/table/data-table-pagination";
import {
+ type CustomHeights,
type RowHeight,
getRowHeightTailwindClass,
} from "@/src/components/table/data-table-row-height-switch";
@@ -54,6 +55,7 @@ interface DataTableProps<TData, TValue> {
setOrderBy?: (s: OrderByState) => void;
help?: { description: string; href: string };
rowHeight?: RowHeight;
+ customRowHeights?: CustomHeights;
className?: string;
shouldRenderGroupHeaders?: boolean;
onRowClick?: (row: TData) => void;
@@ -107,6 +109,7 @@ export function DataTable<TData extends object, TValue>({
orderBy,
setOrderBy,
rowHeight,
+ customRowHeights,
className,
shouldRenderGroupHeaders = false,
onRowClick,
@@ -114,7 +117,7 @@ export function DataTable<TData extends object, TValue>({
pinFirstColumn = false,
}: DataTableProps<TData, TValue>) {
const [columnFilters, setColumnFilters] = useState<ColumnFiltersState>([]);
- const rowheighttw = getRowHeightTailwindClass(rowHeight);
+ const rowheighttw = getRowHeightTailwindClass(rowHeight, customRowHeights);
const capture = usePostHogClientCapture();
const flattedColumnsByGroup = useMemo(() => {
const flatColumnsByGroup = new Map<string, string[]>();
diff --git a/web/src/features/datasets/components/DatasetCompareRunsTable.tsx b/web/src/features/datasets/components/DatasetCompareRunsTable.tsx
index d2fbbe1741..318563be67 100644
--- a/web/src/features/datasets/components/DatasetCompareRunsTable.tsx
+++ b/web/src/features/datasets/components/DatasetCompareRunsTable.tsx
@@ -27,8 +27,9 @@ import { useQueryClient } from "@tanstack/react-query";
import _ from "lodash";
import { useDatasetComparePeekState } from "@/src/components/table/peek/hooks/useDatasetComparePeekState";
import { PeekDatasetCompareDetail } from "@/src/components/table/peek/peek-dataset-compare-detail";
-import { useDatasetComparePeekNavigation } from "@/src/components/table/peek/hooks/useDatasetComparePeekNavigation";
+import { useRowHeightLocalStorage } from "@/src/components/table/data-table-row-height-switch";
import { useDetailPageLists } from "@/src/features/navigate-detail-pages/context";
+import { useDatasetComparePeekNavigation } from "@/src/components/table/peek/hooks/useDatasetComparePeekNavigation";
export type RunMetrics = {
id: string;
@@ -117,8 +118,10 @@ export function DatasetCompareRunsTable(props: {
>({});
const queryClient = useQueryClient();
const { setDetailPageList } = useDetailPageLists();
-
- const rowHeight = "l";
+ const [rowHeight, setRowHeight] = useRowHeightLocalStorage(
+ "datasetCompareRuns",
+ "m",
+ );
const [paginationState, setPaginationState] = useQueryParams({
pageIndex: withDefault(NumberParam, 0),
@@ -389,6 +392,7 @@ export function DatasetCompareRunsTable(props: {
columnVisibility={columnVisibility}
setColumnVisibility={setColumnVisibility}
rowHeight={rowHeight}
+ setRowHeight={setRowHeight}
actionButtons={
<DropdownMenu open={isMetricsDropdownOpen}>
<DropdownMenuTrigger asChild>
@@ -456,6 +460,11 @@ export function DatasetCompareRunsTable(props: {
state: paginationState,
}}
rowHeight={rowHeight}
+ customRowHeights={{
+ s: "h-48",
+ m: "h-64",
+ l: "h-96",
+ }}
peekView={{
itemType: "DATASET_ITEM",
urlPathname,