🪢 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
refactor(web): Migrate batch actions settings table to design system (#17832)
Ben Bachem779c2e382844
diff --git a/web/src/features/batch-actions/components/BatchActionsSettingsPage.tsx b/web/src/features/batch-actions/components/BatchActionsSettingsPage.tsxindex 4cadd9c10f..917fdd3897 100644--- a/web/src/features/batch-actions/components/BatchActionsSettingsPage.tsx+++ b/web/src/features/batch-actions/components/BatchActionsSettingsPage.tsx@@ -1,8 +1,7 @@import Header from "@/src/components/layouts/header";import { Alert } from "@/src/components/design-system/Alert/Alert";-import { SettingsTableCard } from "@/src/components/layouts/settings-table-card";import { useHasProjectAccess } from "@/src/features/rbac";-import { BatchActionsTable } from "./BatchActionsTable";+import { ConnectedBatchActionsTable } from "./BatchActionsTable/ConnectedBatchActionsTable";export function BatchActionsSettingsPage(props: { projectId: string }) {const hasAccess = useHasProjectAccess({@@ -20,9 +19,7 @@ export function BatchActionsSettingsPage(props: { projectId: string }) {background.</p>{hasAccess ? (- <SettingsTableCard>- <BatchActionsTable projectId={props.projectId} />- </SettingsTableCard>+ <ConnectedBatchActionsTable projectId={props.projectId} />) : (<Alert><Alert.Title>Access Denied</Alert.Title>diff --git a/web/src/features/batch-actions/components/BatchActionsTable.tsx b/web/src/features/batch-actions/components/BatchActionsTable.tsxdeleted file mode 100644index 438972018c..0000000000--- a/web/src/features/batch-actions/components/BatchActionsTable.tsx+++ /dev/null@@ -1,186 +0,0 @@-/* eslint-disable no-nested-ternary */-import { DataTable } from "@/src/components/table/data-table";-import { type LangfuseColumnDef } from "@/src/components/table/types";-import { api } from "@/src/utils/api";-import { safeExtract } from "@/src/utils/map-utils";-import { createStatusTableColumn } from "@/src/components/design-system/table/columns/createStatusTableColumn";-import { NumberParam, useQueryParams, withDefault } from "use-query-params";-import { InfoIcon } from "lucide-react";-import {- Tooltip,- TooltipContent,- TooltipProvider,- TooltipTrigger,-} from "@/src/components/ui/tooltip";-import { createDateTableColumn } from "@/src/components/design-system/table/columns/createDateTableColumn";-import { createUserTableColumn } from "@/src/components/design-system/table/columns/createUserTableColumn";-import { createTextTableColumn } from "@/src/components/design-system/table/columns/createTextTableColumn";-import { BatchActionStatus } from "@langfuse/shared";--type BatchActionRow = {- id: string;- actionType: string;- tableName: string;- status: string;- totalCount: number | null;- processedCount: number | null;- failedCount: number | null;- createdAt: Date;- finishedAt: Date | null;- log: string | null;- user: {- name: string | null;- image: string | null;- } | null;-};--export function BatchActionsTable(props: { projectId: string }) {- const [paginationState, setPaginationState] = useQueryParams({- pageIndex: withDefault(NumberParam, 0),- pageSize: withDefault(NumberParam, 10),- });-- const batchActions = api.batchAction.all.useQuery({- projectId: props.projectId,- limit: paginationState.pageSize,- page: paginationState.pageIndex,- });-- const columns: LangfuseColumnDef<BatchActionRow>[] = [- createTextTableColumn<BatchActionRow>({- accessorKey: "actionType",- header: "Action Type",- size: 200,- mapValue: (value) =>- value- ?.split("-")- .map((word) => word.charAt(0).toUpperCase() + word.slice(1))- .join(" "),- }),- {- accessorKey: "tableName",- id: "tableName",- header: "Table",- size: 120,- cell: ({ row }) => {- const tableName = row.getValue("tableName") as string;- return <span className="capitalize">{tableName}</span>;- },- },- createStatusTableColumn<BatchActionRow, string>({- accessorKey: "status",- getStatus: (status) => {- if (status === BatchActionStatus.Queued) return "queued";- if (status === BatchActionStatus.Processing) return "processing";- if (status === BatchActionStatus.Completed) return "completed";- if (status === BatchActionStatus.Failed) return "failed";- if (status === BatchActionStatus.Partial) return "partial";- if (!status) return undefined;-- return status.toLowerCase();- },- header: "Status",- size: 110,- }),- {- accessorKey: "progress",- id: "progress",- header: "Progress",- size: 150,- cell: ({ row }) => {- const totalCount = row.original.totalCount;- const processedCount = row.original.processedCount ?? 0;- const failedCount = row.original.failedCount ?? 0;-- if (!totalCount)- return <span className="text-muted-foreground">-</span>;-- return (- <div className="space-y-1">- <div className="text-sm">- {processedCount} / {totalCount}- </div>- {failedCount > 0 && (- <div className="text-destructive text-xs">- {failedCount} failed- </div>- )}- </div>- );- },- },- createDateTableColumn<BatchActionRow>({- accessorKey: "createdAt",- header: "Created",- size: 150,- }),- createDateTableColumn<BatchActionRow>({- accessorKey: "finishedAt",- header: "Finished",- size: 150,- }),- createUserTableColumn<BatchActionRow>({- accessorKey: "user",- header: "Created By",- size: 150,- variant: "avatar",- emptyValue: "Unknown",- }),- {- accessorKey: "log",- id: "log",- header: "Log",- size: 300,- cell: ({ row }) => {- const log = row.getValue("log") as string | null;- return log ? (- <TooltipProvider>- <Tooltip>- <TooltipTrigger>- <div className="flex items-center gap-1">- <InfoIcon className="text-muted-foreground h-3 w-3" />- <span className="max-w-[250px] truncate text-xs" title={log}>- {log}- </span>- </div>- </TooltipTrigger>- <TooltipContent className="max-w-md">- <pre className="max-h-60 overflow-auto text-xs whitespace-pre-wrap">- {log}- </pre>- </TooltipContent>- </Tooltip>- </TooltipProvider>- ) : null;- },- },- ];-- return (- <DataTable- tableName="batchActions"- columns={columns}- data={- batchActions.isPending- ? { isLoading: true, isError: false }- : batchActions.isError- ? {- isLoading: false,- isError: true,- error: batchActions.error.message,- }- : {- isLoading: false,- isError: false,- data: safeExtract(batchActions.data, "batchActions", []),- }- }- pagination={{- totalCount: batchActions.data?.totalCount ?? 0,- onChange: setPaginationState,- state: paginationState,- }}- cellPadding="comfortable"- />- );-}diff --git a/web/src/features/batch-actions/components/BatchActionsTable/BatchActionsTable.stories.tsx b/web/src/features/batch-actions/components/BatchActionsTable/BatchActionsTable.stories.tsxnew file mode 100644index 0000000000..46f7d4f2f8--- /dev/null+++ b/web/src/features/batch-actions/components/BatchActionsTable/BatchActionsTable.stories.tsx@@ -0,0 +1,58 @@+import { fn } from "storybook/test";++import preview from "../../../../../.storybook/preview";+import { BatchActionsTable } from "./BatchActionsTable";++const meta = preview.meta({ component: BatchActionsTable });++export const Default = meta.story({+ args: {+ data: {+ status: "success",+ data: [+ {+ id: "batch-action-1",+ actionType: "add-to-dataset",+ tableName: "observations",+ status: "COMPLETED",+ totalCount: 10,+ processedCount: 10,+ failedCount: 0,+ createdAt: new Date("2026-09-01"),+ finishedAt: new Date("2026-09-02"),+ log: null,+ user: { name: "Ada Lovelace", image: null },+ },+ {+ id: "batch-action-2",+ actionType: "run-evaluation",+ tableName: "traces",+ status: "PARTIAL",+ totalCount: 5,+ processedCount: 4,+ failedCount: 1,+ createdAt: new Date("2026-09-03"),+ finishedAt: null,+ log: "One item failed",+ user: null,+ },+ ],+ },+ pagination: {+ totalCount: 2,+ state: { pageIndex: 0, pageSize: 10 },+ onChange: fn(),+ },+ },+});++export const Loading = meta.story({+ args: {+ data: { status: "loading" },+ pagination: {+ totalCount: 0,+ state: { pageIndex: 0, pageSize: 10 },+ onChange: fn(),+ },+ },+});diff --git a/web/src/features/batch-actions/components/BatchActionsTable/BatchActionsTable.tsx b/web/src/features/batch-actions/components/BatchActionsTable/BatchActionsTable.tsxnew file mode 100644index 0000000000..f4844fef98--- /dev/null+++ b/web/src/features/batch-actions/components/BatchActionsTable/BatchActionsTable.tsx@@ -0,0 +1,163 @@+import { useMemo } from "react";+import { SettingsTable } from "@/src/components/SettingsTable/SettingsTable";+import { CustomTooltip } from "@/src/components/design-system/CustomTooltip/CustomTooltip";+import { type TableProps } from "@/src/components/design-system/table/Table";+import { type PaginationBarProps } from "@/src/components/design-system/PaginationBar/PaginationBar";+import { type LangfuseColumnDef } from "@/src/components/table/types";+import { createStatusTableColumn } from "@/src/components/design-system/table/columns/createStatusTableColumn";+import { InfoIcon } from "lucide-react";+import { createDateTableColumn } from "@/src/components/design-system/table/columns/createDateTableColumn";+import { createUserTableColumn } from "@/src/components/design-system/table/columns/createUserTableColumn";+import { createTextTableColumn } from "@/src/components/design-system/table/columns/createTextTableColumn";+import { BatchActionStatus } from "@langfuse/shared";++export type BatchActionRow = {+ id: string;+ actionType: string;+ tableName: string;+ status: string;+ totalCount: number | null;+ processedCount: number | null;+ failedCount: number | null;+ createdAt: Date;+ finishedAt: Date | null;+ log: string | null;+ user: {+ name: string | null;+ image: string | null;+ } | null;+};++export function BatchActionsTable({+ data,+ pagination,+}: {+ data: TableProps<BatchActionRow>["data"];+ pagination: PaginationBarProps;+}) {+ const columns = useMemo<LangfuseColumnDef<BatchActionRow>[]>(+ () => [+ createTextTableColumn<BatchActionRow>({+ accessorKey: "actionType",+ header: "Action Type",+ size: 200,+ mapValue: (value) =>+ value+ ?.split("-")+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))+ .join(" "),+ }),+ createTextTableColumn<BatchActionRow>({+ accessorKey: "tableName",+ header: "Table",+ size: 120,+ mapValue: (value) =>+ value ? value.charAt(0).toUpperCase() + value.slice(1) : undefined,+ }),+ createStatusTableColumn<BatchActionRow, string>({+ accessorKey: "status",+ getStatus: (status) => {+ if (status === BatchActionStatus.Queued) return "queued";+ if (status === BatchActionStatus.Processing) return "processing";+ if (status === BatchActionStatus.Completed) return "completed";+ if (status === BatchActionStatus.Failed) return "failed";+ if (status === BatchActionStatus.Partial) return "partial";+ if (!status) return undefined;++ return status.toLowerCase();+ },+ header: "Status",+ size: 110,+ }),+ {+ accessorKey: "progress",+ id: "progress",+ header: "Progress",+ size: 150,+ cell: ({ row }) => {+ const totalCount = row.original.totalCount;+ const processedCount = row.original.processedCount ?? 0;+ const failedCount = row.original.failedCount ?? 0;++ if (!totalCount)+ return <span className="text-muted-foreground">-</span>;++ return (+ <div className="flex min-w-0 items-center gap-2 whitespace-nowrap">+ <span className="text-sm">+ {processedCount} / {totalCount}+ </span>+ {failedCount > 0 && (+ <span+ className="text-destructive truncate text-xs"+ title={`${failedCount} failed`}+ >+ {failedCount} failed+ </span>+ )}+ </div>+ );+ },+ },+ createDateTableColumn<BatchActionRow>({+ accessorKey: "createdAt",+ header: "Created",+ size: 150,+ }),+ createDateTableColumn<BatchActionRow>({+ accessorKey: "finishedAt",+ header: "Finished",+ size: 150,+ }),+ createUserTableColumn<BatchActionRow>({+ accessorKey: "user",+ header: "Created By",+ size: 150,+ variant: "avatar",+ emptyValue: "Unknown",+ }),+ {+ accessorKey: "log",+ id: "log",+ header: "Log",+ size: 300,+ cell: ({ row }) => {+ const log = row.getValue("log") as string | null;+ return log ? (+ <CustomTooltip+ content={+ <pre className="max-h-60 overflow-auto text-xs whitespace-pre-wrap">+ {log}+ </pre>+ }+ >+ {({ getTriggerProps }) => (+ <button+ type="button"+ {...getTriggerProps()}+ className="flex items-center gap-1 text-left"+ >+ <InfoIcon className="text-muted-foreground h-3 w-3" />+ <span className="max-w-[250px] truncate text-xs" title={log}>+ {log}+ </span>+ </button>+ )}+ </CustomTooltip>+ ) : null;+ },+ },+ ],+ [],+ );++ return (+ <SettingsTable+ tableName="batchActions"+ columns={columns}+ data={data}+ pagination={pagination}+ loadingRowCount={Math.max(1, Math.min(pagination.state.pageSize, 8))}+ />+ );+}diff --git a/web/src/features/batch-actions/components/BatchActionsTable/ConnectedBatchActionsTable.tsx b/web/src/features/batch-actions/components/BatchActionsTable/ConnectedBatchActionsTable.tsxnew file mode 100644index 0000000000..beebf4c74f--- /dev/null+++ b/web/src/features/batch-actions/components/BatchActionsTable/ConnectedBatchActionsTable.tsx@@ -0,0 +1,51 @@+import { useMemo } from "react";+import { NumberParam, useQueryParams, withDefault } from "use-query-params";++import { type AsyncTableData } from "@/src/components/design-system/table/Table";+import { api } from "@/src/utils/api";+import { safeExtract } from "@/src/utils/map-utils";+import { BatchActionsTable, type BatchActionRow } from "./BatchActionsTable";++export function ConnectedBatchActionsTable({+ projectId,+}: {+ projectId: string;+}) {+ const [paginationState, setPaginationState] = useQueryParams({+ pageIndex: withDefault(NumberParam, 0),+ pageSize: withDefault(NumberParam, 10),+ });++ const batchActions = api.batchAction.all.useQuery({+ projectId,+ limit: paginationState.pageSize,+ page: paginationState.pageIndex,+ });++ const tableData = useMemo<AsyncTableData<BatchActionRow[]>>(() => {+ if (batchActions.isPending) return { status: "loading" };+ if (batchActions.isError) {+ return { status: "error", error: batchActions.error.message };+ }+ return {+ status: "success",+ data: safeExtract(batchActions.data, "batchActions", []),+ };+ }, [+ batchActions.data,+ batchActions.error,+ batchActions.isError,+ batchActions.isPending,+ ]);++ return (+ <BatchActionsTable+ data={tableData}+ pagination={{+ totalCount: batchActions.data?.totalCount ?? 0,+ onChange: setPaginationState,+ state: paginationState,+ }}+ />+ );+}