Skip to content

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

feat(ui): adjustable row height on tables, better rendering of json/data table cells (#1648)

Marc Klingenf34d8fffad6d
diff --git a/web/src/components/table/use-cases/IOCell.tsx b/web/src/components/table/data-table-IOCell.tsx
similarity index 73%
rename from web/src/components/table/use-cases/IOCell.tsx
rename to web/src/components/table/data-table-IOCell.tsx
index 32b7ad733b..0966279d86 100644
--- a/web/src/components/table/use-cases/IOCell.tsx
+++ b/web/src/components/table/data-table-IOCell.tsx
@@ -5,18 +5,22 @@ import { Skeleton } from "@/src/components/ui/skeleton";
import React from "react";
export const IOCell = ({
- isLoading,
data,
+ isLoading = false,
}: {
- isLoading: boolean;
data: unknown;
+ isLoading?: boolean;
}) => {
return (
<>
{isLoading ? (
- <JsonSkeleton className="h-[250px] w-[500px] px-3 py-1" />
+ <JsonSkeleton className="h-full w-[400px] px-3 py-1" />
) : (
- <JSONView json={data} className="h-[250px] w-[500px] overflow-y-auto" />
+ <JSONView
+ json={data}
+ className="h-full w-[400px] self-stretch overflow-y-auto rounded-sm "
+ codeClassName="py-1 px-2"
+ />
)}
</>
);
@@ -40,7 +44,7 @@ export const JsonSkeleton = ({
sizingOptions[randomIntFromInterval(0, sizingOptions.length - 1)];
return (
- <div className={cn("w-[500px] rounded-md border", className)}>
+ <div className={cn("w-[400px] rounded-md border", className)}>
<div className="flex flex-col gap-1">
{[...Array<number>(numRows)].map((_, i) => (
<Skeleton className={generateRandomSize()} key={i} />
diff --git a/web/src/components/table/data-table-column-visibility-filter.tsx b/web/src/components/table/data-table-column-visibility-filter.tsx
index 8be1d13e69..c54a4c2f80 100644
--- a/web/src/components/table/data-table-column-visibility-filter.tsx
+++ b/web/src/components/table/data-table-column-visibility-filter.tsx
@@ -12,7 +12,7 @@ import {
DropdownMenuCheckboxItem,
} from "@/src/components/ui/dropdown-menu";
import { type VisibilityState } from "@tanstack/react-table";
-import { ChevronDownIcon } from "lucide-react";
+import { ChevronDown, Columns } from "lucide-react";
import { type LangfuseColumnDef } from "@/src/components/table/types";
interface DataTableColumnVisibilityFilterProps<TData, TValue> {
@@ -70,14 +70,16 @@ export function DataTableColumnVisibilityFilter<TData, TValue>({
className="select-none"
asChild
>
- <Button variant="outline" className="ml-auto">
- Columns {count <= total ? `${count}/${total}` : ""}
- <ChevronDownIcon className="ml-2 h-4 w-4" />
+ <Button variant="outline" title="Show/hide columns">
+ <Columns className="mr-2 h-4 w-4" />
+ <span className="text-xs text-gray-500">{`(${count}/${total})`}</span>
+ <ChevronDown className="ml-2 h-4 w-4" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent
align="end"
onPointerDownOutside={() => setIsOpen(false)}
+ className="max-h-96 overflow-y-auto"
>
{columns.map(
(column, index) =>
diff --git a/web/src/components/table/data-table-multi-select-actions/trace-table-multi-select-action.tsx b/web/src/components/table/data-table-multi-select-actions/trace-table-multi-select-action.tsx
index c59a762c04..3d99818a89 100644
--- a/web/src/components/table/data-table-multi-select-actions/trace-table-multi-select-action.tsx
+++ b/web/src/components/table/data-table-multi-select-actions/trace-table-multi-select-action.tsx
@@ -46,11 +46,7 @@ export function TraceTableMultiSelectAction({
<>
<DropdownMenu>
<DropdownMenuTrigger asChild>
- <Button
- variant="outline"
- className="bg-white p-2 font-medium text-black"
- disabled={selectedTraceIds.length < 1}
- >
+ <Button disabled={selectedTraceIds.length < 1}>
Actions ({selectedTraceIds.length} selected)
<ChevronDown className="h-5 w-5" />
</Button>
diff --git a/web/src/components/table/data-table-row-height-switch.tsx b/web/src/components/table/data-table-row-height-switch.tsx
new file mode 100644
index 0000000000..ea4c36fb10
--- /dev/null
+++ b/web/src/components/table/data-table-row-height-switch.tsx
@@ -0,0 +1,59 @@
+import { Tabs, TabsList, TabsTrigger } from "@/src/components/ui/tabs";
+import useLocalStorage from "@/src/components/useLocalStorage";
+import {
+ MdDensityLarge,
+ MdDensityMedium,
+ MdDensitySmall,
+} 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 /> },
+] as const;
+
+export type RowHeight = (typeof heightOptions)[number]["id"];
+
+export const getRowHeightTailwindClass = (rowHeight: RowHeight | undefined) =>
+ heightOptions.find((h) => h.id === rowHeight)?.value;
+
+export function useRowHeightLocalStorage(
+ tableName: string,
+ defaultValue: RowHeight,
+) {
+ const [rowHeight, setRowHeight, clearRowHeight] = useLocalStorage<RowHeight>(
+ `${tableName}Height`,
+ defaultValue,
+ );
+
+ return [rowHeight, setRowHeight, clearRowHeight] as const;
+}
+
+export const DataTableRowHeightSwitch = ({
+ rowHeight,
+ setRowHeight,
+}: {
+ rowHeight: RowHeight;
+ setRowHeight: (e: RowHeight) => void;
+}) => (
+ <Tabs
+ //defaultValue={height}
+ value={rowHeight}
+ onValueChange={(e) => setRowHeight(e as any)}
+ key="height"
+ >
+ <TabsList className="gap-1 border bg-transparent px-2">
+ {heightOptions.map(({ id, label, icon }) => (
+ <TabsTrigger
+ key={id}
+ value={id}
+ className="px-2 shadow-none data-[state=active]:bg-slate-200 data-[state=active]:ring-border"
+ >
+ <span role="img" aria-label={`${label} size`}>
+ {icon}
+ </span>
+ </TabsTrigger>
+ ))}
+ </TabsList>
+ </Tabs>
+);
diff --git a/web/src/components/table/data-table-toolbar.tsx b/web/src/components/table/data-table-toolbar.tsx
index f85e749ae9..4c69634d9d 100644
--- a/web/src/components/table/data-table-toolbar.tsx
+++ b/web/src/components/table/data-table-toolbar.tsx
@@ -7,6 +7,11 @@ import { PopoverFilterBuilder } from "@/src/features/filters/components/filter-b
import { type ColumnDefinition } from "@langfuse/shared";
import { type VisibilityState } from "@tanstack/react-table";
import { type LangfuseColumnDef } from "@/src/components/table/types";
+import {
+ DataTableRowHeightSwitch,
+ RowHeight,
+} from "@/src/components/table/data-table-row-height-switch";
+import { Search } from "lucide-react";
interface SearchConfig {
placeholder: string;
@@ -23,6 +28,8 @@ interface DataTableToolbarProps<TData, TValue> {
setFilterState?: Dispatch<SetStateAction<FilterState>>;
columnVisibility?: VisibilityState;
setColumnVisibility?: Dispatch<SetStateAction<VisibilityState>>;
+ rowHeight?: RowHeight;
+ setRowHeight?: Dispatch<SetStateAction<RowHeight>>;
}
export function DataTableToolbar<TData, TValue>({
@@ -34,44 +41,46 @@ export function DataTableToolbar<TData, TValue>({
setFilterState,
columnVisibility,
setColumnVisibility,
+ rowHeight,
+ setRowHeight,
}: DataTableToolbarProps<TData, TValue>) {
const [searchString, setSearchString] = useState(
searchConfig?.currentQuery ?? "",
);
return (
- <div className="my-2 flex max-w-full items-center justify-between overflow-x-auto">
- <div className="flex flex-1 items-center space-x-2">
- {searchConfig && (
- <div className="flex max-w-md items-center space-x-2">
- <Input
- autoFocus
- placeholder={searchConfig.placeholder}
- value={searchString}
- onChange={(event) => setSearchString(event.currentTarget.value)}
- onKeyDown={(event) => {
- if (event.key === "Enter") {
- searchConfig.updateQuery(searchString);
- }
- }}
- className="h-10 w-[200px] lg:w-[350px]"
- />
- <Button
- variant="outline"
- onClick={() => searchConfig.updateQuery(searchString)}
- >
- Search
- </Button>
- </div>
- )}
- {!!filterColumnDefinition && !!filterState && !!setFilterState && (
- <PopoverFilterBuilder
- columns={filterColumnDefinition}
- filterState={filterState}
- onChange={setFilterState}
+ <div className="my-2 flex flex-1 flex-wrap items-center gap-2">
+ {searchConfig && (
+ <div className="flex max-w-md items-center">
+ <Input
+ autoFocus
+ placeholder={searchConfig.placeholder}
+ value={searchString}
+ onChange={(event) => setSearchString(event.currentTarget.value)}
+ onKeyDown={(event) => {
+ if (event.key === "Enter") {
+ searchConfig.updateQuery(searchString);
+ }
+ }}
+ className="h-10 w-[200px] rounded-r-none lg:w-[250] 2xl:w-[350px]"
/>
- )}
- <div className="flex-1" />
+ <Button
+ variant="outline"
+ onClick={() => searchConfig.updateQuery(searchString)}
+ className="rounded-l-none border-l-0 p-3"
+ >
+ <Search className="h-4 w-4" />
+ </Button>
+ </div>
+ )}
+ {!!filterColumnDefinition && !!filterState && !!setFilterState && (
+ <PopoverFilterBuilder
+ columns={filterColumnDefinition}
+ filterState={filterState}
+ onChange={setFilterState}
+ />
+ )}
+ <div className="flex flex-row flex-wrap gap-2 lg:ml-auto">
{!!columnVisibility && !!setColumnVisibility && (
<DataTableColumnVisibilityFilter
columns={columns}
@@ -79,6 +88,12 @@ export function DataTableToolbar<TData, TValue>({
setColumnVisibility={setColumnVisibility}
/>
)}
+ {!!rowHeight && !!setRowHeight && (
+ <DataTableRowHeightSwitch
+ rowHeight={rowHeight}
+ setRowHeight={setRowHeight}
+ />
+ )}
{actionButtons}
</div>
</div>
diff --git a/web/src/components/table/data-table.tsx b/web/src/components/table/data-table.tsx
index cbd835cf9e..cf3f83de92 100644
--- a/web/src/components/table/data-table.tsx
+++ b/web/src/components/table/data-table.tsx
@@ -2,6 +2,10 @@
import DocPopup from "@/src/components/layouts/doc-popup";
import { DataTablePagination } from "@/src/components/table/data-table-pagination";
+import {
+ RowHeight,
+ getRowHeightTailwindClass,
+} from "@/src/components/table/data-table-row-height-switch";
import { type LangfuseColumnDef } from "@/src/components/table/types";
import { type ModelTableRow } from "@/src/components/table/use-cases/models";
import {
@@ -43,6 +47,7 @@ interface DataTableProps<TData, TValue> {
orderBy?: OrderByState;
setOrderBy?: (s: OrderByState) => void;
help?: { description: string; href: string };
+ rowHeight?: RowHeight;
}
export interface AsyncTableData<T> {
@@ -63,8 +68,10 @@ export function DataTable<TData extends object, TValue>({
help,
orderBy,
setOrderBy,
+ rowHeight,
}: DataTableProps<TData, TValue>) {
const [columnFilters, setColumnFilters] = useState<ColumnFiltersState>([]);
+ const rowheighttw = getRowHeightTailwindClass(rowHeight);
const table = useReactTable({
data: data.data ?? [],
@@ -185,10 +192,12 @@ export function DataTable<TData extends object, TValue>({
key={cell.id}
className="overflow-hidden whitespace-nowrap px-2 py-1 text-xs first:pl-2"
>
- {flexRender(
- cell.column.columnDef.cell,
- cell.getContext(),
- )}
+ <div className={cn("flex items-center", rowheighttw)}>
+ {flexRender(
+ cell.column.columnDef.cell,
+ cell.getContext(),
+ )}
+ </div>
</TableCell>
))}
</TableRow>
diff --git a/web/src/components/table/use-cases/generations.tsx b/web/src/components/table/use-cases/generations.tsx
index 4adbb029ff..586a174220 100644
--- a/web/src/components/table/use-cases/generations.tsx
+++ b/web/src/components/table/use-cases/generations.tsx
@@ -29,7 +29,7 @@ import {
} from "@/src/utils/dates";
import useColumnVisibility from "@/src/features/column-visibility/hooks/useColumnVisibility";
import { type LangfuseColumnDef } from "@/src/components/table/types";
-import { type ObservationLevel } from "@langfuse/shared";
+import { type Prisma, type ObservationLevel } from "@langfuse/shared";
import { cn } from "@/src/utils/tailwind";
import { LevelColors } from "@/src/components/level-colors";
import { usdFormatter } from "@/src/utils/numbers";
@@ -41,8 +41,9 @@ import {
import { useOrderByState } from "@/src/features/orderBy/hooks/useOrderByState";
import type Decimal from "decimal.js";
import { type ScoreSimplified } from "@/src/server/api/routers/generations/getAllQuery";
-import { IOCell } from "./IOCell";
+import { IOCell } from "../data-table-IOCell";
import { setSmallPaginationIfColumnsVisible } from "../../../features/column-visibility/hooks/setSmallPaginationIfColumnsVisible";
+import { useRowHeightLocalStorage } from "@/src/components/table/data-table-row-height-switch";
export type GenerationsTableRow = {
id: string;
@@ -62,7 +63,7 @@ export type GenerationsTableRow = {
outputCost?: Decimal;
totalCost?: Decimal;
traceName?: string;
- metadata?: string;
+ metadata?: Prisma.JsonValue;
scores?: ScoreSimplified[];
usage: {
promptTokens: number;
@@ -91,6 +92,11 @@ export default function GenerationsTable({ projectId }: GenerationsTableProps) {
pageSize: withDefault(NumberParam, 50),
});
+ const [rowHeight, setRowHeight] = useRowHeightLocalStorage(
+ "generations",
+ "s",
+ );
+
const [filterState, setFilterState] = useQueryFilterState(
[
{
@@ -510,8 +516,10 @@ export default function GenerationsTable({ projectId }: GenerationsTableProps) {
accessorKey: "metadata",
header: "Metadata",
cell: ({ row }) => {
- const values: string | undefined = row.getValue("metadata");
- return <div className="flex flex-wrap gap-x-3 gap-y-1">{values}</div>;
+ const values = row.getValue(
+ "metadata",
+ ) as GenerationsTableRow["metadata"];
+ return !!values ? <IOCell data={values} /> : null;
},
enableHiding: true,
defaultHidden: true,
@@ -577,9 +585,7 @@ export default function GenerationsTable({ projectId }: GenerationsTableProps) {
model: generation.model ?? "",
scores: generation.scores,
level: generation.level,
- metadata: generation.metadata
- ? JSON.stringify(generation.metadata)
- : undefined,
+ metadata: generation.metadata,
statusMessage: generation.statusMessage ?? undefined,
usage: {
promptTokens: generation.promptTokens,
@@ -609,14 +615,12 @@ export default function GenerationsTable({ projectId }: GenerationsTableProps) {
}}
columnVisibility={columnVisibility}
setColumnVisibility={setColumnVisibilityState}
+ rowHeight={rowHeight}
+ setRowHeight={setRowHeight}
actionButtons={
<DropdownMenu>
<DropdownMenuTrigger asChild>
- <Button
- variant="outline"
- className="ml-auto whitespace-nowrap"
- size="sm"
- >
+ <Button variant="outline" className="ml-auto whitespace-nowrap">
{filterState.length > 0 || searchQuery
? "Export selection"
: "Export all"}{" "}
@@ -669,6 +673,7 @@ export default function GenerationsTable({ projectId }: GenerationsTableProps) {
orderBy={orderByState}
columnVisibility={columnVisibility}
onColumnVisibilityChange={setColumnVisibilityState}
+ rowHeight={rowHeight}
/>
</div>
);
diff --git a/web/src/components/table/use-cases/scores.tsx b/web/src/components/table/use-cases/scores.tsx
index 3fd35f290a..640871737d 100644
--- a/web/src/components/table/use-cases/scores.tsx
+++ b/web/src/components/table/use-cases/scores.tsx
@@ -1,4 +1,6 @@
import { DataTable } from "@/src/components/table/data-table";
+import { IOCell } from "@/src/components/table/data-table-IOCell";
+import { useRowHeightLocalStorage } from "@/src/components/table/data-table-row-height-switch";
import { DataTableToolbar } from "@/src/components/table/data-table-toolbar";
import TableLink from "@/src/components/table/table-link";
import { type LangfuseColumnDef } from "@/src/components/table/types";
@@ -44,6 +46,8 @@ export default function ScoresTable({
pageSize: withDefault(NumberParam, 50),
});
+ const [rowHeight, setRowHeight] = useRowHeightLocalStorage("scores", "s");
+
const [userFilterState, setUserFilterState] = useQueryFilterState(
[],
"scores",
@@ -163,6 +167,10 @@ export default function ScoresTable({
accessorKey: "userId",
header: "User ID",
id: "userId",
+ headerTooltip: {
+ description: "The user ID associated with the trace.",
+ href: "https://langfuse.com/docs/tracing/users",
+ },
enableHiding: true,
enableSorting: true,
cell: ({ row }) => {
@@ -183,6 +191,10 @@ export default function ScoresTable({
header: "Comment",
id: "comment",
enableHiding: true,
+ cell: ({ row }) => {
+ const value = row.getValue("comment") as ScoresTableRow["comment"];
+ return value !== undefined && <IOCell data={value} />;
+ },
},
];
@@ -222,6 +234,8 @@ export default function ScoresTable({
setFilterState={setUserFilterState}
columnVisibility={columnVisibility}
setColumnVisibility={setColumnVisibility}
+ rowHeight={rowHeight}
+ setRowHeight={setRowHeight}
/>
<DataTable
columns={columns}
@@ -249,6 +263,7 @@ export default function ScoresTable({
setOrderBy={setOrderByState}
columnVisibility={columnVisibility}
onColumnVisibilityChange={setColumnVisibility}
+ rowHeight={rowHeight}
/>
</div>
);
diff --git a/web/src/components/table/use-cases/traces.tsx b/web/src/components/table/use-cases/traces.tsx
index 497acc617f..184cd61ac8 100644
--- a/web/src/components/table/use-cases/traces.tsx
+++ b/web/src/components/table/use-cases/traces.tsx
@@ -27,7 +27,7 @@ import { usdFormatter } from "@/src/utils/numbers";
import { DeleteButton } from "@/src/components/deleteButton";
import { LevelColors } from "@/src/components/level-colors";
import { cn } from "@/src/utils/tailwind";
-import { IOCell } from "./IOCell";
+import { IOCell } from "../data-table-IOCell";
import { setSmallPaginationIfColumnsVisible } from "@/src/features/column-visibility/hooks/setSmallPaginationIfColumnsVisible";
import { useDetailPageLists } from "@/src/features/navigate-detail-pages/context";
import { useOrderByState } from "@/src/features/orderBy/hooks/useOrderByState";
@@ -38,6 +38,7 @@ import {
type ObservationLevel,
type Score,
} from "@langfuse/shared";
+import { useRowHeightLocalStorage } from "@/src/components/table/data-table-row-height-switch";
export type TracesTableRow = {
bookmarked: boolean;
@@ -192,6 +193,8 @@ export default function TracesTable({
};
};
+ const [rowHeight, setRowHeight] = useRowHeightLocalStorage("traces", "s");
+
const columns: LangfuseColumnDef<TracesTableRow>[] = [
{
id: "select",
@@ -591,19 +594,25 @@ export default function TracesTable({
filterState={userFilterState}
setFilterState={setUserFilterState}
actionButtons={
- <TraceTableMultiSelectAction
- // Exclude traces that are not in the current page
- selectedTraceIds={Object.keys(selectedRows).filter((traceId) =>
- traces.data?.traces.map((t) => t.id).includes(traceId),
- )}
- projectId={projectId}
- onDeleteSuccess={() => {
- setSelectedRows({});
- }}
- />
+ Object.keys(selectedRows).filter((traceId) =>
+ traces.data?.traces.map((t) => t.id).includes(traceId),
+ ).length > 0 ? (
+ <TraceTableMultiSelectAction
+ // Exclude traces that are not in the current page
+ selectedTraceIds={Object.keys(selectedRows).filter((traceId) =>
+ traces.data?.traces.map((t) => t.id).includes(traceId),
+ )}
+ projectId={projectId}
+ onDeleteSuccess={() => {
+ setSelectedRows({});
+ }}
+ />
+ ) : null
}
columnVisibility={columnVisibility}
setColumnVisibility={setColumnVisibility}
+ rowHeight={rowHeight}
+ setRowHeight={setRowHeight}
/>
<DataTable
columns={columns}
@@ -634,6 +643,7 @@ export default function TracesTable({
setRowSelection={setSelectedRows}
columnVisibility={columnVisibility}
onColumnVisibilityChange={setColumnVisibility}
+ rowHeight={rowHeight}
/>
</div>
);
diff --git a/web/src/components/ui/code.tsx b/web/src/components/ui/code.tsx
index cb14d551dd..f22294e594 100644
--- a/web/src/components/ui/code.tsx
+++ b/web/src/components/ui/code.tsx
@@ -11,6 +11,7 @@ export function JSONView(props: {
title?: string;
className?: string;
isLoading?: boolean;
+ codeClassName?: string;
}) {
// some users ingest stringified json nested in json, parse it
const parsedJson = deepParseJson(props.json);
@@ -22,7 +23,12 @@ export function JSONView(props: {
{props.title}
</div>
) : undefined}
- <div className="flex gap-2 whitespace-pre-wrap break-words p-3 text-xs">
+ <div
+ className={cn(
+ "flex gap-2 whitespace-pre-wrap break-words p-3 text-xs",
+ props.codeClassName,
+ )}
+ >
{props.isLoading ? (
<Skeleton className="h-3 w-3/4" />
) : (
diff --git a/web/src/components/useLocalStorage.tsx b/web/src/components/useLocalStorage.tsx
index b211e9c954..005f05ade9 100644
--- a/web/src/components/useLocalStorage.tsx
+++ b/web/src/components/useLocalStorage.tsx
@@ -18,7 +18,10 @@ import { useState, useEffect } from "react";
*
* @throws Will throw an error if the stringifying the value or accessing local storage fails.
*/
-function useLocalStorage<T>(localStorageKey: string, initialValue: T) {
+function useLocalStorage<T>(
+ localStorageKey: string,
+ initialValue: T,
+): [T, React.Dispatch<React.SetStateAction<T>>, () => void] {
const [value, setValue] = useState<T>(() => {
if (typeof window === "undefined") {
return initialValue;
@@ -49,11 +52,7 @@ function useLocalStorage<T>(localStorageKey: string, initialValue: T) {
}
}, [localStorageKey, value]);
- return [value, setValue, clearValue] as [
- T,
- React.Dispatch<React.SetStateAction<T>>,
- () => void,
- ];
+ return [value, setValue, clearValue] as const;
}
export default useLocalStorage;
diff --git a/web/src/features/datasets/components/DatasetItemsTable.tsx b/web/src/features/datasets/components/DatasetItemsTable.tsx
index b2985a263c..245522feac 100644
--- a/web/src/features/datasets/components/DatasetItemsTable.tsx
+++ b/web/src/features/datasets/components/DatasetItemsTable.tsx
@@ -13,13 +13,15 @@ import { useQueryParams, withDefault, NumberParam } from "use-query-params";
import { Archive, ListTree, MoreVertical } from "lucide-react";
import { Button } from "@/src/components/ui/button";
-import { type DatasetItem, DatasetStatus } from "@langfuse/shared";
+import { type DatasetItem, DatasetStatus, type Prisma } from "@langfuse/shared";
import { cn } from "@/src/utils/tailwind";
import { type LangfuseColumnDef } from "@/src/components/table/types";
import { useDetailPageLists } from "@/src/features/navigate-detail-pages/context";
import { useEffect } from "react";
import { DataTableToolbar } from "@/src/components/table/data-table-toolbar";
import useColumnVisibility from "@/src/features/column-visibility/hooks/useColumnVisibility";
+import { useRowHeightLocalStorage } from "@/src/components/table/data-table-row-height-switch";
+import { IOCell } from "@/src/components/table/data-table-IOCell";
type RowData = {
id: string;
@@ -29,8 +31,8 @@ type RowData = {
};
status: DatasetItem["status"];
createdAt: string;
- input: string;
- expectedOutput: string;
+ input: Prisma.JsonValue;
+ expectedOutput: Prisma.JsonValue;
};
export function DatasetItemsTable({
@@ -48,6 +50,11 @@ export function DatasetItemsTable({
pageSize: withDefault(NumberParam, 50),
});
+ const [rowHeight, setRowHeight] = useRowHeightLocalStorage(
+ "datasetItems",
+ "s",
+ );
+
const items = api.datasets.itemsByDatasetId.useQuery({
projectId,
datasetId,
@@ -143,12 +150,22 @@ export function DatasetItemsTable({
header: "Input",
id: "input",
enableHiding: true,
+ cell: ({ row }) => {
+ const input = row.getValue("input") as RowData["input"];
+ return !!input ? <IOCell data={input} /> : null;
+ },
},
{
accessorKey: "expectedOutput",
header: "Expected Output",
id: "expectedOutput",
enableHiding: true,
+ cell: ({ row }) => {
+ const expectedOutput = row.getValue(
+ "expectedOutput",
+ ) as RowData["expectedOutput"];
+ return !!expectedOutput ? <IOCell data={expectedOutput} /> : null;
+ },
},
{
id: "actions",
@@ -193,16 +210,6 @@ export function DatasetItemsTable({
const convertToTableRow = (
item: RouterOutput["datasets"]["itemsByDatasetId"]["datasetItems"][number],
): RowData => {
- let input = item.input ? JSON.stringify(item.input) : "";
- input = input.length > 50 ? input.slice(0, 50) + "..." : input;
- let expectedOutput = item.expectedOutput
- ? JSON.stringify(item.expectedOutput)
- : "";
- expectedOutput =
- expectedOutput.length > 50
- ? expectedOutput.slice(0, 50) + "..."
- : expectedOutput;
-
return {
id: item.id,
source: item.sourceTraceId
@@ -213,8 +220,8 @@ export function DatasetItemsTable({
: undefined,
status: item.status,
createdAt: item.createdAt.toLocaleString(),
- input,
- expectedOutput,
+ input: item.input,
+ expectedOutput: item.expectedOutput,
};
};
@@ -229,6 +236,8 @@ export function DatasetItemsTable({
columns={columns}
columnVisibility={columnVisibility}
setColumnVisibility={setColumnVisibility}
+ rowHeight={rowHeight}
+ setRowHeight={setRowHeight}
/>
<DataTable
columns={columns}
@@ -258,6 +267,7 @@ export function DatasetItemsTable({
}}
columnVisibility={columnVisibility}
onColumnVisibilityChange={setColumnVisibility}
+ rowHeight={rowHeight}
/>
</div>
);
diff --git a/web/src/features/datasets/components/DatasetRunItemsTable.tsx b/web/src/features/datasets/components/DatasetRunItemsTable.tsx
index c6b05d55df..c8abbfe73e 100644
--- a/web/src/features/datasets/components/DatasetRunItemsTable.tsx
+++ b/web/src/features/datasets/components/DatasetRunItemsTable.tsx
@@ -9,11 +9,12 @@ import { useQueryParams, withDefault, NumberParam } from "use-query-params";
import { type Score } from "@langfuse/shared";
import { usdFormatter } from "../../../utils/numbers";
-import { IOCell } from "@/src/components/table/use-cases/IOCell";
+import { IOCell } from "@/src/components/table/data-table-IOCell";
import useColumnVisibility from "@/src/features/column-visibility/hooks/useColumnVisibility";
import { DataTableToolbar } from "@/src/components/table/data-table-toolbar";
import { useDetailPageLists } from "@/src/features/navigate-detail-pages/context";
import { useEffect } from "react";
+import { useRowHeightLocalStorage } from "@/src/components/table/data-table-row-height-switch";
type RowData = {
id: string;
@@ -56,6 +57,8 @@ export function DatasetRunItemsTable(
page: paginationState.pageIndex,
limit: paginationState.pageSize,
});
+ const [rowHeight, setRowHeight] = useRowHeightLocalStorage("traces", "m");
+
useEffect(() => {
if (runItems.isSuccess) {
setDetailPageList(
@@ -228,6 +231,8 @@ export function DatasetRunItemsTable(
columns={columns}
columnVisibility={columnVisibility}
setColumnVisibility={setColumnVisibility}
+ rowHeight={rowHeight}
+ setRowHeight={setRowHeight}
/>
<DataTable
columns={columns}
@@ -255,6 +260,7 @@ export function DatasetRunItemsTable(
}}
columnVisibility={columnVisibility}
onColumnVisibilityChange={setColumnVisibility}
+ rowHeight={rowHeight}
/>
</div>
);
diff --git a/web/src/features/datasets/components/DatasetRunsTable.tsx b/web/src/features/datasets/components/DatasetRunsTable.tsx
index cc35b42882..feba93df78 100644
--- a/web/src/features/datasets/components/DatasetRunsTable.tsx
+++ b/web/src/features/datasets/components/DatasetRunsTable.tsx
@@ -12,6 +12,9 @@ import { useEffect } from "react";
import { usdFormatter } from "../../../utils/numbers";
import { DataTableToolbar } from "@/src/components/table/data-table-toolbar";
import useColumnVisibility from "@/src/features/column-visibility/hooks/useColumnVisibility";
+import { IOCell } from "@/src/components/table/data-table-IOCell";
+import { type Prisma } from "@langfuse/shared";
+import { useRowHeightLocalStorage } from "@/src/components/table/data-table-row-height-switch";
type RowData = {
key: {
@@ -24,7 +27,7 @@ type RowData = {
avgTotalCost: string;
scores: RouterOutput["datasets"]["runsByDatasetId"]["runs"][number]["scores"];
description: string;
- metadata: string;
+ metadata: Prisma.JsonValue;
};
export function DatasetRunsTable(props: {
@@ -35,6 +38,10 @@ export function DatasetRunsTable(props: {
pageIndex: withDefault(NumberParam, 0),
pageSize: withDefault(NumberParam, 50),
});
+ const [rowHeight, setRowHeight] = useRowHeightLocalStorage(
+ "datasetRuns",
+ "s",
+ );
const runs = api.datasets.runsByDatasetId.useQuery({
projectId: props.projectId,
datasetId: props.datasetId,
@@ -131,7 +138,7 @@ export function DatasetRunsTable(props: {
enableHiding: true,
cell: ({ row }) => {
const metadata: RowData["metadata"] = row.getValue("metadata");
- return <div className="flex flex-wrap gap-x-3 gap-y-1">{metadata}</div>;
+ return !!metadata ? <IOCell data={metadata} /> : null;
},
},
];
@@ -147,7 +154,7 @@ export function DatasetRunsTable(props: {
avgTotalCost: usdFormatter(item.avgTotalCost.toNumber()),
scores: item.scores,
description: item.description ?? "",
- metadata: JSON.stringify(item.metadata),
+ metadata: item.metadata,
};
};
@@ -162,6 +169,8 @@ export function DatasetRunsTable(props: {
columns={columns}
columnVisibility={columnVisibility}
setColumnVisibility={setColumnVisibility}
+ rowHeight={rowHeight}
+ setRowHeight={setRowHeight}
/>
<DataTable
columns={columns}
@@ -189,6 +198,7 @@ export function DatasetRunsTable(props: {
}}
columnVisibility={columnVisibility}
onColumnVisibilityChange={setColumnVisibility}
+ rowHeight={rowHeight}
/>
</div>
);
diff --git a/web/src/features/datasets/components/DatasetsTable.tsx b/web/src/features/datasets/components/DatasetsTable.tsx
index 346eecbc97..78e1d43d51 100644
--- a/web/src/features/datasets/components/DatasetsTable.tsx
+++ b/web/src/features/datasets/components/DatasetsTable.tsx
@@ -159,6 +159,9 @@ export function DatasetsTable(props: { projectId: string }) {
columns={columns}
columnVisibility={columnVisibility}
setColumnVisibility={setColumnVisibility}
+ actionButtons={
+ <DatasetActionButton projectId={props.projectId} mode="create" />
+ }
/>
<DataTable
columns={columns}
diff --git a/web/src/features/filters/components/filter-builder.tsx b/web/src/features/filters/components/filter-builder.tsx
index 4c4f6079bf..d6a3e2828a 100644
--- a/web/src/features/filters/components/filter-builder.tsx
+++ b/web/src/features/filters/components/filter-builder.tsx
@@ -26,6 +26,7 @@ import {
singleFilter,
} from "@langfuse/shared";
import { NonEmptyString } from "@/src/utils/zod";
+import { cn } from "@/src/utils/tailwind";
// Has WipFilterState, passes all valid filters to parent onChange
export function PopoverFilterBuilder({
@@ -84,14 +85,14 @@ export function PopoverFilterBuilder({
>
<PopoverTrigger asChild>
<Button variant="outline">
- <Filter className="mr-3 h-4 w-4" />
- <span>Filter</span>
- {filterState.length > 0
+ <Filter className="h-4 w-4" />
+ <span className="hidden lg:ml-2 lg:inline">Filter</span>
+ {filterState.length > 0 && filterState.length < 3
? filterState.map((filter, i) => {
return (
<span
key={i}
- className="ml-3 whitespace-nowrap rounded-md bg-slate-200 px-2 py-1 text-xs"
+ className="ml-2 hidden whitespace-nowrap rounded-md bg-slate-200 px-2 py-1 text-xs lg:block"
>
{filter.column}
{filter.type === "stringObject" ||
@@ -116,6 +117,16 @@ export function PopoverFilterBuilder({
);
})
: null}
+ {filterState.length > 0 && (
+ <span
+ className={cn(
+ "ml-3 rounded-md bg-slate-200 px-2 py-1 text-xs lg:hidden",
+ filterState.length > 2 && "lg:inline",
+ )}
+ >
+ {filterState.length}
+ </span>
+ )}
</Button>
</PopoverTrigger>
<PopoverContent
diff --git a/web/src/features/tag/components/TagMananger.tsx b/web/src/features/tag/components/TagMananger.tsx
index 3fa716eee8..9410ff5073 100644
--- a/web/src/features/tag/components/TagMananger.tsx
+++ b/web/src/features/tag/components/TagMananger.tsx
@@ -49,7 +49,7 @@ const TagManager = ({
return (
<Popover onOpenChange={(open) => handlePopoverChange(open)}>
<PopoverTrigger className="select-none" asChild>
- <div className="flex flex-wrap gap-x-2 gap-y-1">
+ <div className="flex gap-x-2 gap-y-1">
<TagList selectedTags={selectedTags} isLoading={isLoading} />
</div>
</PopoverTrigger>
diff --git a/web/src/pages/project/[projectId]/datasets.tsx b/web/src/pages/project/[projectId]/datasets.tsx
index 913e3b02fe..4d90735839 100644
--- a/web/src/pages/project/[projectId]/datasets.tsx
+++ b/web/src/pages/project/[projectId]/datasets.tsx
@@ -16,9 +16,6 @@ export default function Traces() {
"Datasets in Langfuse are a collection of inputs (and expected outputs) of an LLM application. They are used to benchmark new releases before deployment to production. See docs to learn more.",
href: "https://langfuse.com/docs/datasets",
}}
- actionButtons={
- <DatasetActionButton projectId={projectId} mode="create" />
- }
/>
<DatasetsTable projectId={projectId} />
</div>