Skip to content

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

refactor(web): Migrate all tables to `@tanstack/react-table` (#17076)

Ben Bachem4810332fc1b1
diff --git a/web/.storybook/docs/ThemeTokens/Color.tsx b/web/.storybook/docs/ThemeTokens/Color.tsx
index 7a7f60a21d..1fe65465ab 100644
--- a/web/.storybook/docs/ThemeTokens/Color.tsx
+++ b/web/.storybook/docs/ThemeTokens/Color.tsx
@@ -211,7 +211,7 @@ function InteractionStatesSection({ ctx }: { ctx: TokenContext }) {
state="Hover · row"
classes="hover:bg-muted/50"
tokens="--muted at 50%"
- seenIn="TableRow (ui/table.tsx)"
+ seenIn="DataTable / SimpleDataTable"
sample={
<div
className="flex flex-col rounded-md border text-xs"
@@ -231,7 +231,7 @@ function InteractionStatesSection({ ctx }: { ctx: TokenContext }) {
state="Selected · row"
classes="data-[state=selected]:bg-muted"
tokens="--muted"
- seenIn="TableRow (ui/table.tsx)"
+ seenIn="DataTable / SimpleDataTable"
sample={
<div
className="flex flex-col rounded-md border text-xs"
diff --git a/web/src/components/table/data-table.tsx b/web/src/components/table/data-table.tsx
index 0d8ff19ffc..a56bf7cbe2 100644
--- a/web/src/components/table/data-table.tsx
+++ b/web/src/components/table/data-table.tsx
@@ -56,6 +56,7 @@ 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";
+
import { useAnimatedBusy } from "@/src/hooks/useAnimatedBusy";
import {
type TableSelectionStoreLike,
@@ -490,6 +491,8 @@ export function DataTable<TData extends object, TValue>({
"group p-1 first:pl-2",
sortingEnabled && "cursor-pointer",
getPinningClasses(header.column),
+ columnDef.headerClassName,
+ columnDef.hideBelowMd && "hidden md:table-cell",
)}
style={{
...getCommonPinningStyles(header.column),
@@ -894,6 +897,8 @@ function TableBodyComponent<TData>({
(rowHeight ?? "s") === "s" && "whitespace-nowrap",
getPinningClasses(column),
getCellBackgroundClassName(columnDef.cellBackground),
+ columnDef.cellClassName,
+ columnDef.hideBelowMd && "hidden md:table-cell",
)}
style={{
...getCommonPinningStyles(column),
@@ -959,6 +964,8 @@ function TableBodyComponent<TData>({
isSmallRowHeight && "whitespace-nowrap",
getPinningClasses(cell.column),
getCellBackgroundClassName(columnDef.cellBackground),
+ columnDef.cellClassName,
+ columnDef.hideBelowMd && "hidden md:table-cell",
)}
style={{
...getCommonPinningStyles(cell.column),
diff --git a/web/src/components/table/simple-data-table.clienttest.tsx b/web/src/components/table/simple-data-table.clienttest.tsx
new file mode 100644
index 0000000000..0ba072d650
--- /dev/null
+++ b/web/src/components/table/simple-data-table.clienttest.tsx
@@ -0,0 +1,101 @@
+import { fireEvent, render, screen } from "@testing-library/react";
+import { describe, expect, it, vi } from "vitest";
+
+import { type LangfuseColumnDef } from "@/src/components/table/types";
+import { SimpleDataTable } from "./simple-data-table";
+
+const columns: LangfuseColumnDef<{ id: string; name: string }>[] = [
+ {
+ accessorKey: "name",
+ header: "Name",
+ cell: ({ row }) => (
+ <div data-row-click-ignore>
+ <button type="button">{row.original.name}</button>
+ </div>
+ ),
+ },
+];
+
+describe("SimpleDataTable", () => {
+ it("activates clickable rows without intercepting nested controls", () => {
+ const onRowClick = vi.fn();
+
+ render(
+ <SimpleDataTable
+ columns={columns}
+ data={[{ id: "row-1", name: "Nested action" }]}
+ isLoading={false}
+ noResults={null}
+ onRowClick={onRowClick}
+ getRowLabel={(row) => `Open ${row.name}`}
+ />,
+ );
+
+ const button = screen.getByRole("button", { name: "Nested action" });
+ const row = button.closest("tr");
+
+ expect(row).not.toBeNull();
+ expect(row).not.toHaveAttribute("role", "button");
+ expect(row).toHaveAccessibleName("Open Nested action");
+ expect(row).toHaveAttribute("aria-keyshortcuts", "Enter Space");
+
+ fireEvent.click(button);
+ fireEvent.keyDown(button, { key: "Enter" });
+ expect(onRowClick).not.toHaveBeenCalled();
+
+ fireEvent.keyDown(row!, { key: "Enter" });
+ fireEvent.keyDown(row!, { key: " " });
+ expect(onRowClick).toHaveBeenCalledTimes(2);
+ });
+
+ it("exposes selected rows to assistive technology", () => {
+ render(
+ <SimpleDataTable
+ columns={columns}
+ data={[{ id: "row-1", name: "Selected row" }]}
+ isLoading={false}
+ noResults={null}
+ selectedRowId="row-1"
+ onRowClick={vi.fn()}
+ getRowLabel={(row) => `Select ${row.name}`}
+ />,
+ );
+
+ expect(
+ screen.getByRole("row", { name: "Select Selected row" }),
+ ).toHaveAttribute("aria-selected", "true");
+ });
+
+ it("hides responsive columns consistently", () => {
+ const responsiveColumns: LangfuseColumnDef<{
+ id: string;
+ name: string;
+ detail: string;
+ }>[] = [
+ { accessorKey: "name", header: "Name" },
+ {
+ accessorKey: "detail",
+ header: "Detail",
+ hideBelowMd: true,
+ },
+ ];
+
+ render(
+ <SimpleDataTable
+ columns={responsiveColumns}
+ data={[{ id: "row-1", name: "Name value", detail: "Detail value" }]}
+ isLoading={false}
+ noResults={null}
+ />,
+ );
+
+ expect(screen.getByRole("columnheader", { name: "Detail" })).toHaveClass(
+ "hidden",
+ "md:table-cell",
+ );
+ expect(screen.getByRole("cell", { name: "Detail value" })).toHaveClass(
+ "hidden",
+ "md:table-cell",
+ );
+ });
+});
diff --git a/web/src/components/table/simple-data-table.tsx b/web/src/components/table/simple-data-table.tsx
new file mode 100644
index 0000000000..e33d55de6f
--- /dev/null
+++ b/web/src/components/table/simple-data-table.tsx
@@ -0,0 +1,216 @@
+import {
+ flexRender,
+ getCoreRowModel,
+ useReactTable,
+ type Row,
+} from "@tanstack/react-table";
+import { Fragment, type ReactNode } from "react";
+
+import { Skeleton } from "@/src/components/ui/skeleton";
+import { type LangfuseColumnDef } from "@/src/components/table/types";
+import { cn } from "@/src/utils/tailwind";
+
+const ROW_CLICK_IGNORE_SELECTOR = "[data-row-click-ignore]";
+
+const shouldIgnoreRowClickTarget = (target: EventTarget | null) =>
+ target instanceof Element &&
+ Boolean(target.closest(ROW_CLICK_IGNORE_SELECTOR));
+
+export function SimpleDataTable<TData extends object>({
+ columns,
+ data,
+ isLoading,
+ noResults,
+ presentation = "default",
+ bodyTone = "default",
+ rowVariant = "default",
+ selectedRowId,
+ onRowClick,
+ getRowLabel,
+ renderDetailRow,
+}: {
+ columns: LangfuseColumnDef<TData>[];
+ data: TData[];
+ isLoading: boolean;
+ noResults: ReactNode;
+ presentation?: "default" | "dense" | "wide";
+ bodyTone?: "default" | "muted";
+ rowVariant?:
+ | "default"
+ | "muted-hover"
+ | "primary-hover"
+ | "primary-hover-static"
+ | "review";
+ selectedRowId?: string | null;
+ renderDetailRow?: (row: Row<TData>) => ReactNode;
+} & (
+ | {
+ onRowClick?: undefined;
+ getRowLabel?: undefined;
+ }
+ | {
+ onRowClick: (row: TData) => void;
+ getRowLabel: (row: TData) => string;
+ }
+)) {
+ const table = useReactTable({
+ data,
+ columns,
+ getCoreRowModel: getCoreRowModel(),
+ getRowId: (row, index) =>
+ "id" in row && typeof row.id === "string" ? row.id : String(index),
+ });
+ const visibleColumns = table.getVisibleLeafColumns();
+
+ return (
+ <table
+ className={cn(
+ "w-full table-fixed caption-bottom border-separate border-spacing-0 space-y-4 overflow-auto text-sm",
+ presentation === "wide" && "min-w-[60rem] table-auto",
+ )}
+ >
+ <thead
+ className={cn(
+ "[&_tr]:border-b",
+ presentation === "dense" && "bg-background sticky top-0 z-10",
+ )}
+ >
+ {table.getHeaderGroups().map((headerGroup) => (
+ <tr
+ key={headerGroup.id}
+ className="hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors"
+ >
+ {headerGroup.headers.map((header) => (
+ <th
+ key={header.id}
+ className={cn(
+ "bg-background text-muted-foreground relative h-10 border-b px-2 text-left align-middle font-bold [&:has([role=checkbox])]:pr-0",
+ header.column.columnDef.hideBelowMd && "hidden md:table-cell",
+ )}
+ style={
+ header.column.columnDef.size === undefined
+ ? undefined
+ : { width: header.getSize() }
+ }
+ >
+ {header.isPlaceholder
+ ? null
+ : flexRender(
+ header.column.columnDef.header,
+ header.getContext(),
+ )}
+ </th>
+ ))}
+ </tr>
+ ))}
+ </thead>
+ <tbody
+ className={cn(
+ "text-xs [&_tr:last-child]:border-0",
+ bodyTone === "muted" && "text-muted-foreground",
+ )}
+ >
+ {isLoading ? (
+ Array.from({ length: 3 }).map((_, rowIndex) => (
+ <tr
+ key={`loading-row-${rowIndex}`}
+ aria-hidden="true"
+ className="hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors"
+ >
+ {visibleColumns.map((column) => {
+ const loadingCell = column.columnDef.loadingCell;
+ return (
+ <td
+ key={column.id}
+ className={cn(
+ "h-full overflow-hidden border-b align-middle [&:has([role=checkbox])]:pr-0 [:last-child_>_&]:border-b-0",
+ column.columnDef.hideBelowMd && "hidden md:table-cell",
+ column.columnDef.cellPadding === "compact"
+ ? "px-2 py-0"
+ : "p-2",
+ column.columnDef.cellPadding === "none" && "p-0",
+ )}
+ >
+ {typeof loadingCell === "function" ? (
+ loadingCell()
+ ) : loadingCell !== undefined ? (
+ loadingCell
+ ) : (
+ <Skeleton className="h-4 w-1/2" />
+ )}
+ </td>
+ );
+ })}
+ </tr>
+ ))
+ ) : table.getRowModel().rows.length === 0 ? (
+ <tr className="hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors">
+ <td
+ colSpan={visibleColumns.length}
+ className="h-full border-b p-2 text-center align-middle [&:has([role=checkbox])]:pr-0 [:last-child_>_&]:border-b-0"
+ >
+ {noResults}
+ </td>
+ </tr>
+ ) : (
+ table.getRowModel().rows.map((row) => (
+ <Fragment key={row.id}>
+ <tr
+ className={cn(
+ "hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",
+ onRowClick &&
+ "focus-visible:outline-primary cursor-pointer focus-visible:outline-2 focus-visible:outline-offset-[-2px]",
+ presentation === "dense" && "text-xs",
+ rowVariant === "muted-hover" && "hover:bg-muted",
+ (rowVariant === "primary-hover" ||
+ rowVariant === "primary-hover-static") &&
+ "hover:bg-primary-foreground",
+ rowVariant === "primary-hover-static" && "cursor-default",
+ rowVariant === "review" && "group/row",
+ selectedRowId === row.id && "bg-muted",
+ )}
+ onClick={(event) => {
+ if (shouldIgnoreRowClickTarget(event.target)) return;
+ onRowClick?.(row.original);
+ }}
+ onKeyDown={(event) => {
+ if (event.key !== "Enter" && event.key !== " ") return;
+ if (shouldIgnoreRowClickTarget(event.target)) return;
+
+ event.preventDefault();
+ onRowClick?.(row.original);
+ }}
+ tabIndex={onRowClick ? 0 : undefined}
+ aria-keyshortcuts={onRowClick ? "Enter Space" : undefined}
+ aria-label={getRowLabel?.(row.original)}
+ aria-selected={
+ selectedRowId === undefined
+ ? undefined
+ : selectedRowId === row.id
+ }
+ >
+ {row.getVisibleCells().map((cell) => (
+ <td
+ key={cell.id}
+ className={cn(
+ "h-full overflow-hidden border-b align-middle [&:has([role=checkbox])]:pr-0 [:last-child_>_&]:border-b-0",
+ cell.column.columnDef.hideBelowMd &&
+ "hidden md:table-cell",
+ cell.column.columnDef.cellPadding === "compact"
+ ? "px-2 py-0"
+ : "p-2",
+ cell.column.columnDef.cellPadding === "none" && "p-0",
+ )}
+ >
+ {flexRender(cell.column.columnDef.cell, cell.getContext())}
+ </td>
+ ))}
+ </tr>
+ {renderDetailRow?.(row)}
+ </Fragment>
+ ))
+ )}
+ </tbody>
+ </table>
+ );
+}
diff --git a/web/src/components/table/types.ts b/web/src/components/table/types.ts
index 4717c4b332..4daf83c140 100644
--- a/web/src/components/table/types.ts
+++ b/web/src/components/table/types.ts
@@ -30,6 +30,9 @@ declare module "@tanstack/react-table" {
loadingCell?: React.ReactNode | (() => React.ReactNode);
cellPadding?: DataTableCellPadding;
cellBackground?: DataTableCellBackground;
+ cellClassName?: string;
+ headerClassName?: string;
+ hideBelowMd?: boolean;
}
}
diff --git a/web/src/components/ui/PrettyJsonView.tsx b/web/src/components/ui/PrettyJsonView.tsx
index 744ed440aa..de571b9db9 100644
--- a/web/src/components/ui/PrettyJsonView.tsx
+++ b/web/src/components/ui/PrettyJsonView.tsx
@@ -1,5 +1,12 @@
/* eslint-disable @repo/no-style-props */
-import { useMemo, useState, useEffect, useRef, useCallback, memo } from "react";
+import React, {
+ useMemo,
+ useState,
+ useEffect,
+ useRef,
+ useCallback,
+ memo,
+} from "react";
import { cn } from "@/src/utils/tailwind";
import { deepParseJson } from "@langfuse/shared";
import { decodeUnicodeInJson } from "@/src/utils/decodeUnicodeInJson";
@@ -30,14 +37,6 @@ import { type LangfuseColumnDef } from "@/src/components/table/types";
// Custom expanded state type that allows false ("user intentionally collapsed all")
type LangfuseExpandedState = ExpandedState | false;
-import {
- Table,
- TableBody,
- TableCell,
- TableHead,
- TableHeader,
- TableRow,
-} from "@/src/components/ui/table";
import { ChatMlArraySchema } from "@/src/components/schemas/ChatMlSchema";
import { MarkdownView } from "@/src/components/ui/MarkdownViewer";
import {
@@ -49,6 +48,7 @@ import {
StringOrMarkdownSchema,
containsAnyMarkdown,
} from "@/src/components/schemas/MarkdownSchema";
+
import { useMarkdownRenderCharacterLimit } from "@/src/hooks/useMarkdownRenderCharacterLimit";
import {
convertRowIdToKeyPath,
@@ -367,7 +367,7 @@ const JsonTableRowComponent = memo(
});
return (
- <TableRow
+ <tr
ref={
rowIndex === 0 && row.original.level === 0
? topLevelRowRef
@@ -376,6 +376,7 @@ const JsonTableRowComponent = memo(
data-observation-id={row.id}
{...rowClickProps}
className={cn(
+ "hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",
isExpandable ? "cursor-pointer" : "",
row.original.level === 0 && stickyTopLevelKey
? "bg-background sticky z-10 shadow-xs"
@@ -389,18 +390,18 @@ const JsonTableRowComponent = memo(
}
>
{row.getVisibleCells().map((cell) => (
- <TableCell
+ <td
key={cell.id}
className={cn(
- "px-2 py-1 align-top whitespace-normal",
+ "h-full border-b px-2 py-1 align-top whitespace-normal [&:has([role=checkbox])]:pr-0 [:last-child_>_&]:border-b-0",
toneClasses?.cell,
)}
style={{ width: `${cell.column.columnDef.size}%` }}
>
{flexRender(cell.column.columnDef.cell, cell.getContext())}
- </TableCell>
+ </td>
))}
- </TableRow>
+ </tr>
);
},
);
@@ -688,22 +689,23 @@ function JsonPrettyTable({
return (
<div className={cn("w-full", !noBorder && "rounded-sm border")}>
- <Table>
- <TableHeader>
+ <table className="w-full table-fixed caption-bottom border-separate border-spacing-0 space-y-4 overflow-auto text-sm">
+ <thead className="[&_tr]:border-b">
{table.getHeaderGroups().map((headerGroup, index) => (
- <TableRow
+ <tr
key={headerGroup.id}
ref={index === 0 ? headerRef : undefined}
className={cn(
+ "hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",
stickyTopLevelKey ? "sticky top-0 z-20" : "",
toneClasses?.row,
)}
>
{headerGroup.headers.map((header) => (
- <TableHead
+ <th
key={header.id}
className={cn(
- "h-8 px-2 py-1",
+ "text-muted-foreground relative h-8 border-b px-2 py-1 text-left align-middle font-bold [&:has([role=checkbox])]:pr-0",
stickyTopLevelKey ? "bg-background" : "bg-transparent",
toneClasses?.cell,
)}
@@ -715,12 +717,12 @@ function JsonPrettyTable({
header.column.columnDef.header,
header.getContext(),
)}
- </TableHead>
+ </th>
))}
- </TableRow>
+ </tr>
))}
- </TableHeader>
- <TableBody>
+ </thead>
+ <tbody className="text-xs [&_tr:last-child]:border-0">
{table.getRowModel().rows.map((row, rowIndex) => (
<JsonTableRowComponent
key={row.id}
@@ -739,8 +741,8 @@ function JsonPrettyTable({
toneClasses={toneClasses}
/>
))}
- </TableBody>
- </Table>
+ </tbody>
+ </table>
</div>
);
}
diff --git a/web/src/components/ui/table.tsx b/web/src/components/ui/table.tsx
index d844c89519..937a6d34a8 100644
--- a/web/src/components/ui/table.tsx
+++ b/web/src/components/ui/table.tsx
@@ -1,10 +1,7 @@
/* eslint-disable @repo/no-style-props, @repo/no-margin-on-root-elements */
import * as React from "react";
-import { Button } from "@/src/components/ui/button";
-import { useCopyToClipboard } from "@/src/hooks/useCopyToClipboard";
import { cn } from "@/src/utils/tailwind";
-import { Check, Copy } from "lucide-react";
type TableDensity = "compact" | "comfortable";
@@ -105,59 +102,6 @@ const TableCell = React.forwardRef<
));
TableCell.displayName = "TableCell";
-type TableCellWithCopyButtonProps =
- React.TdHTMLAttributes<HTMLTableCellElement> & {
- text: string;
- density?: TableDensity;
- copyButtonLabel?: string;
- };
-
-const TableCellWithCopyButton = React.forwardRef<
- HTMLTableCellElement,
- TableCellWithCopyButtonProps
->(({ text, copyButtonLabel, className, ...props }, ref) => {
- const { copy, isCopied } = useCopyToClipboard();
-
- return (
- <TableCell
- ref={ref}
- className={cn("relative min-w-0 pr-10", className)}
- title={text}
- {...props}
- >
- {text}
- <Button
- variant="ghost"
- size="icon-xs"
- className="absolute top-1/2 right-2 -translate-y-1/2"
- title={copyButtonLabel ?? "Copy to clipboard"}
- aria-label={copyButtonLabel ?? "Copy to clipboard"}
- onClick={async (event) => {
- event.preventDefault();
- const button = event.currentTarget;
- try {
- await copy(text);
- } catch {
- // Clipboard writes can be rejected when the browser denies permission.
- }
-
- if (button) {
- // The original button might no longer be in the DOM if React re-rendered the component after the state update.
- button.focus();
- }
- }}
- >
- {isCopied ? (
- <Check className="h-3 w-3" />
- ) : (
- <Copy className="h-3 w-3" />
- )}
- </Button>
- </TableCell>
- );
-});
-TableCellWithCopyButton.displayName = "TableCellWithCopyButton";
-
const TableCaption = React.forwardRef<
HTMLTableCaptionElement,
React.HTMLAttributes<HTMLTableCaptionElement>
@@ -178,5 +122,4 @@ export {
TableHead,
TableRow,
TableCell,
- TableCellWithCopyButton,
};
diff --git a/web/src/ee/features/sso-settings/components/SSOSettings.tsx b/web/src/ee/features/sso-settings/components/SSOSettings.tsx
index 154de6bc93..274515e709 100644
--- a/web/src/ee/features/sso-settings/components/SSOSettings.tsx
+++ b/web/src/ee/features/sso-settings/components/SSOSettings.tsx
@@ -16,6 +16,9 @@ import { Badge } from "@/src/components/ui/badge";
import { Button } from "@/src/components/ui/button";
import { Card } from "@/src/components/ui/card";
import { Checkbox } from "@/src/components/design-system/Checkbox/Checkbox";
+import { createTextTableColumn } from "@/src/components/design-system/table/columns/createTextTableColumn";
+import { SimpleDataTable } from "@/src/components/table/simple-data-table";
+import { type LangfuseColumnDef } from "@/src/components/table/types";
import { SelectInput } from "@/src/components/design-system/SelectInput/SelectInput";
import {
Dialog,
@@ -36,15 +39,6 @@ import {
FormMessage,
} from "@/src/components/ui/form";
import { Input } from "@/src/components/ui/input";
-import {
- Table,
- TableBody,
- TableCell,
- TableCellWithCopyButton,
- TableHead,
- TableHeader,
- TableRow,
-} from "@/src/components/ui/table";
import Header from "@/src/components/layouts/header";
import { useHasEntitlement } from "@/src/features/entitlements";
import { useHasOrganizationAccess } from "@/src/features/rbac";
@@ -52,10 +46,11 @@ import { VerifiedDomainsSettings } from "@/src/ee/features/verified-domains/comp
import { SsoProviderSchema } from "@/src/ee/features/multi-tenant-sso/types";
import { api } from "@/src/utils/api";
import { zodResolver } from "@hookform/resolvers/zod";
-import { AlertCircle, TrashIcon } from "lucide-react";
+import { AlertCircle, Check, Copy, TrashIcon } from "lucide-react";
import { useEffect, useMemo, useState } from "react";
import { useForm } from "react-hook-form";
import { z } from "zod";
+import { useCopyToClipboard } from "@/src/hooks/useCopyToClipboard";
const SSO_PROVIDERS: ReadonlyArray<{
id: SsoProviderSchema["authProvider"];
@@ -119,6 +114,11 @@ type SsoConfigRow = {
updatedAt: Date;
};
+type SsoConfigTableRow = {
+ domain: string;
+ config: SsoConfigRow | null;
+};
+
export const SSOSettings = ({ orgId }: { orgId: string }) => {
const hasEntitlement = useHasEntitlement("cloud-multi-tenant-sso");
const hasAccess = useHasOrganizationAccess({
@@ -187,12 +187,17 @@ function SsoConfigsTable({ orgId }: { orgId: string }) {
const ssoConfigsQuery = api.ssoConfig.get.useQuery({ orgId });
const verifiedDomains = useMemo(
- () => verifiedDomainsQuery.data?.filter((d) => d.verifiedAt != null) ?? [],
+ () =>
+ verifiedDomainsQuery.data?.filter(
+ (domain: { verifiedAt: Date | null }) => domain.verifiedAt != null,
+ ) ?? [],
[verifiedDomainsQuery.data],
);
const configByDomain = useMemo(() => {
const map = new Map<string, SsoConfigRow>();
- ssoConfigsQuery.data?.forEach((cfg) => map.set(cfg.domain, cfg));
+ ssoConfigsQuery.data?.forEach((config: SsoConfigRow) =>
+ map.set(config.domain, config),
+ );
return map;
}, [ssoConfigsQuery.data]);
@@ -206,68 +211,70 @@ function SsoConfigsTable({ orgId }: { orgId: string }) {
);
}
- return (
- <Card className="mb-4 overflow-hidden">
- <Table>
- <TableHeader>
- <TableRow>
- <TableHead className="text-primary pl-2.5">Domain</TableHead>
- <TableHead className="text-primary">Provider</TableHead>
- <TableHead className="text-primary hidden md:table-cell">
- Updated
- </TableHead>
- <TableHead />
- </TableRow>
- </TableHeader>
- <TableBody className="text-muted-foreground">
- {verifiedDomains.map((row) => (
- <SsoConfigRow
- key={row.domain}
- orgId={orgId}
- domain={row.domain}
- config={configByDomain.get(row.domain) ?? null}
- />
- ))}
- </TableBody>
- </Table>
- </Card>
+ const data: SsoConfigTableRow[] = verifiedDomains.map(
+ (domain: { domain: string }) => ({
+ domain: domain.domain,
+ config: configByDomain.get(domain.domain) ?? null,
+ }),
);
-}
-function SsoConfigRow({
- orgId,
- domain,
- config,
-}: {
- orgId: string;
- domain: string;
- config: SsoConfigRow | null;
-}) {
- return (
- <TableRow className="hover:bg-primary-foreground">
- <TableCell density="comfortable" className="font-mono">
- {domain}
- </TableCell>
- <TableCell density="comfortable">
- {config ? (
- <Badge variant="default">{providerLabel(config.authProvider)}</Badge>
+ const columns: LangfuseColumnDef<SsoConfigTableRow>[] = [
+ createTextTableColumn<SsoConfigTableRow>({
+ accessorKey: "domain",
+ header: "Domain",
+ }),
+ {
+ accessorKey: "config",
+ header: "Provider",
+ cell: ({ row }) =>
+ row.original.config ? (
+ <Badge variant="default">
+ {providerLabel(row.original.config.authProvider)}
+ </Badge>
) : (
<Badge variant="secondary">Not configured</Badge>
- )}
- </TableCell>
- <TableCell density="comfortable" className="hidden md:table-cell">
- {config ? config.updatedAt.toLocaleDateString() : "—"}
- </TableCell>
- <TableCell
- density="comfortable"
- className="flex items-center justify-end gap-2"
- >
- <SsoConfigDialog orgId={orgId} domain={domain} existing={config} />
- {config ? (
- <DeleteSsoConfigButton orgId={orgId} domain={domain} />
- ) : null}
- </TableCell>
- </TableRow>
+ ),
+ },
+ {
+ accessorKey: "config",
+ id: "updatedAt",
+ header: "Updated",
+ hideBelowMd: true,
+ cell: ({ row }) =>
+ row.original.config
+ ? row.original.config.updatedAt.toLocaleDateString()
+ : "—",
+ },
+ {
+ accessorKey: "domain",
+ id: "actions",
+ header: "",
+ cell: ({ row }) => (
+ <div className="flex items-center justify-end gap-2">
+ <SsoConfigDialog
+ orgId={orgId}
+ domain={row.original.domain}
+ existing={row.original.config}
+ />
+ {row.original.config ? (
+ <DeleteSsoConfigButton orgId={orgId} domain={row.original.domain} />
+ ) : null}
+ </div>
+ ),
+ },
+ ];
+
+ return (
+ <Card className="mb-4 overflow-hidden">
+ <SimpleDataTable
+ columns={columns}
+ data={data}
+ isLoading={false}
+ noResults={null}
+ bodyTone="muted"
+ rowVariant="primary-hover"
+ />
+ </Card>
);
}
@@ -632,26 +639,26 @@ function SsoConfigDialog({
}
function CallbackUrlPanel({ callbackUrl }: { callbackUrl: string }) {
+ const columns: LangfuseColumnDef<{ url: string }>[] = [
+ {
+ accessorKey: "url",
+ header: "URL",
+ cell: ({ getValue }) => (
+ <CopyableCallbackUrl value={getValue<string>()} />
+ ),
+ },
+ ];
+
return (
<div>
<p className="mb-2 text-sm font-bold">Callback URL</p>
<Card className="overflow-hidden">
- <Table>
- <TableHeader>
- <TableRow>
- <TableHead>URL</TableHead>
- </TableRow>
- </TableHeader>
- <TableBody>
- <TableRow>
- <TableCellWithCopyButton
- density="comfortable"
- text={callbackUrl}
- className="py-3 font-mono break-all"
- />
- </TableRow>
- </TableBody>
- </Table>
+ <SimpleDataTable
+ columns={columns}
+ data={[{ url: callbackUrl }]}
+ isLoading={false}
+ noResults={null}
+ />
</Card>
<p className="text-muted-foreground mt-2 text-xs">
Add this URL as an authorized redirect URI in your identity provider.
@@ -660,6 +667,35 @@ function CallbackUrlPanel({ callbackUrl }: { callbackUrl: string }) {
);
}
+function CopyableCallbackUrl({ value }: { value: string }) {
+ const { copy, isCopied } = useCopyToClipboard();
+
+ return (
+ <div className="relative pr-8 font-mono break-all">
+ <span>{value}</span>
+ <Button
+ variant="ghost"
+ size="icon-xs"
+ className="absolute top-1/2 right-0 -translate-y-1/2"
+ title="Copy to clipboard"
+ aria-label="Copy to clipboard"
+ onClick={async (event) => {
+ event.preventDefault();
+ const button = event.currentTarget;
+ await copy(value).catch(() => undefined);
+ button.focus();
+ }}
+ >
+ {isCopied ? (
+ <Check className="h-3 w-3" />
+ ) : (
+ <Copy className="h-3 w-3" />
+ )}
+ </Button>
+ </div>
+ );
+}
+
function DeleteSsoConfigButton({
orgId,
domain,
diff --git a/web/src/ee/features/verified-domains/components/VerifiedDomainsSettings.tsx b/web/src/ee/features/verified-domains/components/VerifiedDomainsSettings.tsx
index 56123d2374..e2ab775357 100644
--- a/web/src/ee/features/verified-domains/components/VerifiedDomainsSettings.tsx
+++ b/web/src/ee/features/verified-domains/components/VerifiedDomainsSettings.tsx
@@ -15,6 +15,9 @@ import {
import { Badge } from "@/src/components/ui/badge";
import { Button } from "@/src/components/ui/button";
import { Card } from "@/src/components/ui/card";
+import { SimpleDataTable } from "@/src/components/table/simple-data-table";
+import { type LangfuseColumnDef } from "@/src/components/table/types";
+import { createTextTableColumn } from "@/src/components/design-system/table/columns/createTextTableColumn";
import {
Dialog,
DialogBody,
@@ -33,24 +36,23 @@ import {
FormMessage,
} from "@/src/components/ui/form";
import { Input } from "@/src/components/ui/input";
-import {
- Table,
- TableBody,
- TableCell,
- TableCellWithCopyButton,
- TableHead,
- TableHeader,
- TableRow,
-} from "@/src/components/ui/table";
import Header from "@/src/components/layouts/header";
import { useHasEntitlement } from "@/src/features/entitlements";
import { useHasOrganizationAccess } from "@/src/features/rbac";
import { api } from "@/src/utils/api";
import { zodResolver } from "@hookform/resolvers/zod";
-import { AlertCircle, ChevronRight, TrashIcon } from "lucide-react";
+import { type Row } from "@tanstack/react-table";
+import {
+ AlertCircle,
+ Check,
+ ChevronRight,
+ Copy,
+ TrashIcon,
+} from "lucide-react";
import { useState } from "react";
import { useForm } from "react-hook-form";
import { z } from "zod";
+import { useCopyToClipboard } from "@/src/hooks/useCopyToClipboard";
const addDomainSchema = z.object({
domain: z
@@ -134,38 +136,99 @@ export const VerifiedDomainsSettings = ({ orgId }: { orgId: string }) => {
function DomainsTable({ orgId }: { orgId: string }) {
const query = api.verifiedDomain.list.useQuery({ orgId });
+ const [collapsedRows, setCollapsedRows] = useState<Set<string>>(new Set());
+
+ const columns: LangfuseColumnDef<DomainRowData>[] = [
+ {
+ accessorKey: "domain",
+ header: "Domain",
+ cell: ({ row }) =>
+ !row.original.verifiedAt ? (
+ <button
+ type="button"
+ onClick={() =>
+ setCollapsedRows((current) => {
+ const next = new Set(current);
+ if (next.has(row.original.id)) next.delete(row.original.id);
+ else next.add(row.original.id);
+ return next;
+ })
+ }
+ className="flex items-center gap-1"
+ >
+ <ChevronRight
+ className={`h-3 w-3 transition-transform ${
+ collapsedRows.has(row.original.id) ? "" : "rotate-90"
+ }`}
+ />
+ {row.original.domain}
+ </button>
+ ) : (
+ row.original.domain
+ ),
+ },
+ {
+ accessorKey: "verifiedAt",
+ header: "Status",
+ cell: ({ row }) =>
+ row.original.verifiedAt ? (
+ <Badge variant="default">Verified</Badge>
+ ) : (
+ <Badge variant="secondary">Pending verification</Badge>
+ ),
+ },
+ {
+ accessorKey: "createdAt",
+ header: "Added",
+ hideBelowMd: true,
+ cell: ({ row }) => row.original.createdAt.toLocaleDateString(),
+ },
+ {
+ accessorKey: "id",
+ id: "actions",
+ header: "",
+ cell: ({ row }) => (
+ <div className="flex items-center justify-end gap-2">
+ <DomainActions orgId={orgId} row={row.original} />
+ </div>
+ ),
+ },
+ ];
+
+ const renderDetailRow = (row: Row<DomainRowData>) =>
+ !row.original.verifiedAt && !collapsedRows.has(row.original.id) ? (
+ <tr className="bg-muted/30 hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors">
+ <td
+ colSpan={4}
+ className="h-full border-b px-2 py-4 align-middle [&:has([role=checkbox])]:pr-0 [:last-child_>_&]:border-b-0"
+ >
+ <DnsInstructions
+ recordHost={row.original.recordHost}
+ recordValue={row.original.recordValue}
+ />
+ </td>
+ </tr>
+ ) : null;
return (
<Card className="mb-4 overflow-hidden">
- <Table>
- <TableHeader>
- <TableRow>
- <TableHead className="text-primary pl-2.5">Domain</TableHead>
- <TableHead className="text-primary">Status</TableHead>
- <TableHead className="text-primary hidden md:table-cell">
- Added
- </TableHead>
- <TableHead />
- </TableRow>
- </TableHeader>
- <TableBody className="text-muted-foreground">
- {query.data && query.data.length === 0 ? (
- <TableRow>
- <TableCell
- density="comfortable"
- colSpan={4}
- className="py-12 text-center text-sm"
- >
- No domains added yet
- </TableCell>
- </TableRow>
+ <SimpleDataTable
+ columns={columns}
+ data={query.data ?? []}
+ isLoading={query.isLoading}
+ noResults={
+ query.isError ? (
+ <div className="text-destructive py-10 text-sm">
+ Failed to load verified domains. Please try again.
+ </div>
) : (
- query.data?.map((row) => (
- <DomainRow key={row.id} orgId={orgId} row={row} />
- ))
- )}
- </TableBody>
- </Table>
+ <div className="py-10 text-sm">No domains added yet</div>
+ )
+ }
+ bodyTone="muted"
+ rowVariant="primary-hover"
+ renderDetailRow={renderDetailRow}
+ />
</Card>
);
}
@@ -179,8 +242,7 @@ type DomainRowData = {
recordValue: string;
};
-function DomainRow({ orgId, row }: { orgId: string; row: DomainRowData }) {
- const [expanded, setExpanded] = useState(!row.verifiedAt);
+function DomainActions({ orgId, row }: { orgId: string; row: DomainRowData }) {
const utils = api.useUtils();
const verifyMutation = api.verifiedDomain.verify.useMutation({
@@ -199,66 +261,21 @@ function DomainRow({ orgId, row }: { orgId: string; row: DomainRowData }) {
return (
<>
- <TableRow className="hover:bg-primary-foreground">
- <TableCell density="comfortable" className="font-mono">
- {!row.verifiedAt ? (
- <button
- type="button"
- onClick={() => setExpanded((v) => !v)}
- className="flex items-center gap-1"
- >
- <ChevronRight
- className={`h-3 w-3 transition-transform ${
- expanded ? "rotate-90" : ""
- }`}
- />
- {row.domain}
- </button>
- ) : (
- row.domain
- )}
- </TableCell>
- <TableCell density="comfortable">
- {row.verifiedAt ? (
- <Badge variant="default">Verified</Badge>
- ) : (
- <Badge variant="secondary">Pending verification</Badge>
- )}
- </TableCell>
- <TableCell density="comfortable" className="hidden md:table-cell">
- {row.createdAt.toLocaleDateString()}
- </TableCell>
- <TableCell
- density="comfortable"
- className="flex items-center justify-end gap-2"
+ {!row.verifiedAt && (
+ <Button
+ size="sm"
+ onClick={() => verifyMutation.mutate({ orgId, id: row.id })}
+ loading={verifyMutation.isPending}
>
- {!row.verifiedAt && (
- <Button
- size="sm"
- onClick={() => verifyMutation.mutate({ orgId, id: row.id })}
- loading={verifyMutation.isPending}
- >
- Verify
- </Button>
- )}
- <DeleteDomainButton
- orgId={orgId}
- id={row.id}
- domain={row.domain}
- verified={Boolean(row.verifiedAt)}
- />
- </TableCell>
- </TableRow>
- {!row.verifiedAt && expanded && (
- <TableRow className="bg-muted/30">
- <TableCell colSpan={4} className="py-4">
- <DnsInstructions
- recordHost={row.recordHost}
- recordValue={row.recordValue}
- />
- </TableCell>
- </TableRow>
+ Verify
+ </Button>
)}
+ <DeleteDomainButton
+ orgId={orgId}
+ id={row.id}
+ domain={row.domain}
+ verified={Boolean(row.verifiedAt)}
+ />
</>
);
}
@@ -270,38 +287,41 @@ function DnsInstructions({
recordHost: string;
recordValue: string;
}) {
+ const columns: LangfuseColumnDef<{
+ type: string;
+ host: string;
+ value: string;
+ }>[] = [
+ createTextTableColumn({
+ accessorKey: "type",
+ header: "Type",
+ size: 64,
+ }),
+ {
+ accessorKey: "host",
+ header: "Host",
+ size: 216,
+ cell: ({ getValue }) => <CopyableText value={getValue<string>()} />,
+ },
+ {
+ accessorKey: "value",
+ header: "Value",
+ cell: ({ getValue }) => <CopyableText value={getValue<string>()} />,
+ },
+ ];
+
return (
<div className="space-y-3">
<p className="text-sm font-bold">
Add the following TXT record to your DNS provider:
</p>
<Card className="overflow-hidden">
- <Table>
- <TableHeader>
- <TableRow>
- <TableHead className="w-16">Type</TableHead>
- <TableHead className="w-54">Host</TableHead>
- <TableHead>Value</TableHead>
- </TableRow>
- </TableHeader>
- <TableBody>
- <TableRow>
- <TableCell density="comfortable" className="w-16 font-mono">
- TXT
- </TableCell>
- <TableCellWithCopyButton
- density="comfortable"
- text={recordHost}
- className="w-54 py-3 font-mono break-all"
- />
- <TableCellWithCopyButton
- density="comfortable"
- text={recordValue}
- className="py-3 font-mono break-all"
- />
- </TableRow>
- </TableBody>
- </Table>
+ <SimpleDataTable
+ columns={columns}
+ data={[{ type: "TXT", host: recordHost, value: recordValue }]}
+ isLoading={false}
+ noResults={null}
+ />
</Card>
<p className="text-muted-foreground text-xs">
DNS changes may take up to 24h to propagate. After adding the record,
@@ -311,6 +331,35 @@ function DnsInstructions({
);
}
+function CopyableText({ value }: { value: string }) {
+ const { copy, isCopied } = useCopyToClipboard();
+
+ return (
+ <div className="relative min-w-0 pr-8 font-mono break-all">
+ <span title={value}>{value}</span>
+ <Button
+ variant="ghost"
+ size="icon-xs"
+ className="absolute top-1/2 right-2 -translate-y-1/2"
+ title="Copy to clipboard"
+ aria-label="Copy to clipboard"
+ onClick={async (event) => {
+ event.preventDefault();
+ const button = event.currentTarget;
+ await copy(value).catch(() => undefined);
+ button.focus();
+ }}
+ >
+ {isCopied ? (
+ <Check className="h-3 w-3" />
+ ) : (
+ <Copy className="h-3 w-3" />
+ )}
+ </Button>
+ </div>
+ );
+}
+
function AddDomainButton({ orgId }: { orgId: string }) {
const [open, setOpen] = useState(false);
const utils = api.useUtils();
diff --git a/web/src/features/chart-view-prototype/components/MockEventsTable.tsx b/web/src/features/chart-view-prototype/components/MockEventsTable.tsx
index 29979d88b8..7b94b1b0ec 100644
--- a/web/src/features/chart-view-prototype/components/MockEventsTable.tsx
+++ b/web/src/features/chart-view-prototype/components/MockEventsTable.tsx
@@ -1,13 +1,9 @@
import React from "react";
-import {
- Table,
- TableBody,
- TableCell,
- TableHead,
- TableHeader,
- TableRow,
-} from "@/src/components/ui/table";
import { Badge } from "@/src/components/ui/badge";
+import { SimpleDataTable } from "@/src/components/table/simple-data-table";
+import { type LangfuseColumnDef } from "@/src/components/table/types";
+import { createNumberTableColumn } from "@/src/components/design-system/table/columns/createNumberTableColumn";
+import { createTextTableColumn } from "@/src/components/design-system/table/columns/createTextTableColumn";
import { cn } from "@/src/utils/tailwind";
import { type ObservationLevel, type PrototypeEvent } from "../types";
@@ -33,6 +29,84 @@ const formatTime = (iso: string): string =>
second: "2-digit",
});
+const compactColumn = {
+ cellPadding: "compact" as const,
+};
+
+const columns: LangfuseColumnDef<PrototypeEvent>[] = [
+ {
+ ...compactColumn,
+ accessorKey: "type",
+ header: "Type",
+ cell: ({ getValue }) =>
+ getValue<PrototypeEvent["type"]>() ? (
+ <Badge variant="outline" className="font-mono text-[10px]">
+ {getValue<PrototypeEvent["type"]>()}
+ </Badge>
+ ) : null,
+ },
+ createTextTableColumn<PrototypeEvent>({
+ ...compactColumn,
+ accessorKey: "name",
+ header: "Name",
+ cellClassName: "font-bold",
+ }),
+ createTextTableColumn<PrototypeEvent, PrototypeEvent["model"]>({
+ ...compactColumn,
+ accessorKey: "model",
+ header: "Model",
+ mapValue: (model) => model ?? "–",
+ cellClassName: "text-muted-foreground font-mono",
+ }),
+ {
+ ...compactColumn,
+ accessorKey: "level",
+ header: "Status",
+ cell: ({ getValue }) => {
+ const level = getValue<ObservationLevel>();
+ return level ? (
+ <Badge
+ className={cn("border-transparent text-[10px]", LEVEL_CLASS[level])}
+ >
+ {level}
+ </Badge>
+ ) : null;
+ },
+ },
+ createNumberTableColumn<PrototypeEvent>({
+ ...compactColumn,
+ accessorKey: "latencyMs",
+ header: "Latency",
+ formatter: formatLatency,
+ headerClassName: "text-right",
+ cellClassName: "text-right font-mono",
+ }),
+ createNumberTableColumn<PrototypeEvent>({
+ ...compactColumn,
+ accessorKey: "totalCost",
+ header: "Cost",
+ formatter: formatCost,
+ headerClassName: "text-right",
+ cellClassName: "text-right font-mono",
+ }),
+ createNumberTableColumn<PrototypeEvent>({
+ ...compactColumn,
+ accessorKey: "totalTokens",
+ header: "Tokens",
+ formatter: (tokens) => tokens.toLocaleString(),
+ headerClassName: "text-right",
+ cellClassName: "text-right font-mono",
+ }),
+ createTextTableColumn<PrototypeEvent>({
+ ...compactColumn,
+ accessorKey: "startTime",
+ header: "Time",
+ mapValue: (time) => (time ? formatTime(time) : undefined),
+ headerClassName: "text-right",
+ cellClassName: "text-muted-foreground text-right font-mono",
+ }),
+];
+
/**
* A representative stand-in for the v4 events table — the "table" side of the
* toggle. Deliberately a lightweight, view-only table (not the full virtualized
@@ -49,57 +123,13 @@ export const MockEventsTable = React.memo(function MockEventsTable({
return (
<div className="flex h-full flex-col overflow-hidden">
<div className="min-h-0 flex-1 overflow-auto">
- <Table>
- <TableHeader className="bg-background sticky top-0 z-10">
- <TableRow>
- <TableHead className="h-8">Type</TableHead>
- <TableHead className="h-8">Name</TableHead>
- <TableHead className="h-8">Model</TableHead>
- <TableHead className="h-8">Status</TableHead>
- <TableHead className="h-8 text-right">Latency</TableHead>
- <TableHead className="h-8 text-right">Cost</TableHead>
- <TableHead className="h-8 text-right">Tokens</TableHead>
- <TableHead className="h-8 text-right">Time</TableHead>
- </TableRow>
- </TableHeader>
- <TableBody>
- {rows.map((e) => (
- <TableRow key={e.id} className="text-xs">
- <TableCell className="py-1.5">
- <Badge variant="outline" className="font-mono text-[10px]">
- {e.type}
- </Badge>
- </TableCell>
- <TableCell className="py-1.5 font-bold">{e.name}</TableCell>
- <TableCell className="text-muted-foreground py-1.5 font-mono">
- {e.model ?? "–"}
- </TableCell>
- <TableCell className="py-1.5">
- <Badge
- className={cn(
- "border-transparent text-[10px]",
- LEVEL_CLASS[e.level],
- )}
- >
- {e.level}
- </Badge>
- </TableCell>
- <TableCell className="py-1.5 text-right font-mono">
- {formatLatency(e.latencyMs)}
- </TableCell>
- <TableCell className="py-1.5 text-right font-mono">
- {formatCost(e.totalCost)}
- </TableCell>
- <TableCell className="py-1.5 text-right font-mono">
- {e.totalTokens.toLocaleString()}
- </TableCell>
- <TableCell className="text-muted-foreground py-1.5 text-right font-mono">
- {formatTime(e.startTime)}
- </TableCell>
- </TableRow>
- ))}
- </TableBody>
- </Table>
+ <SimpleDataTable
+ columns={columns}
+ data={rows}
+ isLoading={false}
+ noResults={null}
+ presentation="dense"
+ />
</div>
<div className="text-muted-foreground border-t px-3 py-1.5 text-xs">
Showing {rows.length} of {events.length.toLocaleString()} events
diff --git a/web/src/features/dashboard/components/SelectDashboardDialog.tsx b/web/src/features/dashboard/components/SelectDashboardDialog.tsx
index 274e3da50b..ca34da2331 100644
--- a/web/src/features/dashboard/components/SelectDashboardDialog.tsx
+++ b/web/src/features/dashboard/components/SelectDashboardDialog.tsx
@@ -1,5 +1,5 @@
import React, { useState } from "react";
-import { api } from "@/src/utils/api";
+import { api, type RouterOutputs } from "@/src/utils/api";
import {
Dialog,
DialogContent,
@@ -9,14 +9,36 @@ import {
DialogBody,
} from "@/src/components/ui/dialog";
import { Button } from "@/src/components/ui/button";
-import {
- Table,
- TableHeader,
- TableRow,
- TableHead,
- TableBody,
- TableCell,
-} from "@/src/components/ui/table";
+import { SimpleDataTable } from "@/src/components/table/simple-data-table";
+import { createTextTableColumn } from "@/src/components/design-system/table/columns/createTextTableColumn";
+import { type LangfuseColumnDef } from "@/src/components/table/types";
+
+type Dashboard =
+ RouterOutputs["dashboard"]["allDashboards"]["dashboards"][number];
+
+const columns: LangfuseColumnDef<Dashboard>[] = [
+ createTextTableColumn<Dashboard>({
+ accessorKey: "name",
+ header: "Name",
+ }),
+ {
+ accessorKey: "description",
+ header: "Description",
+ cell: ({ getValue }) => {
+ const description = getValue<string>();
+ return (
+ <span className="block truncate" title={description}>
+ {description}
+ </span>
+ );
+ },
+ },
+ {
+ accessorKey: "updatedAt",
+ header: "Updated",
+ cell: ({ getValue }) => getValue<Date>().toLocaleString(),
+ },
+];
export interface SelectDashboardDialogProps {
open: boolean;
@@ -83,42 +105,22 @@ export function SelectDashboardDialog({
No dashboards found.
</div>
) : (
- <Table>
- <TableHeader>
- <TableRow>
- <TableHead>Name</TableHead>
- <TableHead>Description</TableHead>
- <TableHead>Updated</TableHead>
- </TableRow>
- </TableHeader>
- <TableBody>
- {dashboards.data?.dashboards
- .filter((d) => d.owner === "PROJECT")
- .map((d) => (
- <TableRow
- key={d.id}
- onClick={() => setSelectedDashboardId(d.id)}
- className={`hover:bg-muted cursor-pointer ${
- selectedDashboardId === d.id ? "bg-muted" : ""
- }`}
- >
- <TableCell density="comfortable" className="font-bold">
- {d.name}
- </TableCell>
- <TableCell
- density="comfortable"
- className="truncate"
- title={d.description}
- >
- {d.description}
- </TableCell>
- <TableCell density="comfortable">
- {new Date(d.updatedAt).toLocaleString()}
- </TableCell>
- </TableRow>
- ))}
- </TableBody>
- </Table>
+ <SimpleDataTable
+ columns={columns}
+ data={
+ dashboards.data?.dashboards.filter(
+ (dashboard: Dashboard) => dashboard.owner === "PROJECT",
+ ) ?? []
+ }
+ isLoading={false}
+ noResults={null}
+ rowVariant="muted-hover"
+ selectedRowId={selectedDashboardId}
+ onRowClick={(dashboard) => setSelectedDashboardId(dashboard.id)}
+ getRowLabel={(dashboard) =>
+ `Select dashboard ${dashboard.name}`
+ }
+ />
)}
</div>
</DialogBody>
diff --git a/web/src/features/public-api/components/ApiKeyList.tsx b/web/src/features/public-api/components/ApiKeyList.tsx
index 321c3986f9..4184492cc4 100644
--- a/web/src/features/public-api/components/ApiKeyList.tsx
+++ b/web/src/features/public-api/components/ApiKeyList.tsx
@@ -5,15 +5,9 @@ import { Card } from "@/src/components/ui/card";
import { CodeView } from "@/src/components/ui/CodeJsonViewer";
import { Input } from "@/src/components/ui/input";
import { ConfirmDialog } from "@/src/components/ui/confirm-dialog";
-import {
- Table,
- TableBody,
- TableCell,
- TableCellWithCopyButton,
- TableHead,
- TableHeader,
- TableRow,
-} from "@/src/components/ui/table";
+import { SimpleDataTable } from "@/src/components/table/simple-data-table";
+import { type LangfuseColumnDef } from "@/src/components/table/types";
+import { createTextTableColumn } from "@/src/components/design-system/table/columns/createTextTableColumn";
import { usePostHogClientCapture } from "@/src/features/posthog-analytics";
import { CreateApiKeyButton } from "@/src/features/public-api/components/CreateApiKeyButton";
import {
@@ -21,13 +15,18 @@ import {
useHasProjectAccess,
} from "@/src/features/rbac";
import { api, reportNonTrpcError } from "@/src/utils/api";
-import { TrashIcon } from "lucide-react";
+import { Check, Copy, TrashIcon } from "lucide-react";
import { useState } from "react";
import { Alert } from "@/src/components/design-system/Alert/Alert";
import startCase from "lodash/startCase";
import { useLangfuseEnvCode } from "@/src/features/public-api/hooks/useLangfuseEnvCode";
+import { useCopyToClipboard } from "@/src/hooks/useCopyToClipboard";
+import { type RouterOutput } from "@/src/utils/types";
type ApiKeyScope = "project" | "organization";
+type ApiKeyRow =
+ | RouterOutput["projectApiKeys"]["byProjectId"][number]
+ | RouterOutput["organizationApiKeys"]["byOrganizationId"][number];
type ApiKeyEntity = { id: string; note: string | null };
type ApiKeyCreator = {
createdByUser: {
@@ -80,6 +79,51 @@ export function ApiKeyList(props: { entityId: string; scope: ApiKeyScope }) {
const apiKeysQuery =
props.scope === "project" ? projectApiKeysQuery : organizationApiKeysQuery;
+ const columns: LangfuseColumnDef<ApiKeyRow>[] = [
+ createTextTableColumn<ApiKeyRow, Date>({
+ accessorKey: "createdAt",
+ header: "Created",
+ mapValue: (value) => value?.toLocaleDateString(),
+ hideBelowMd: true,
+ }),
+ {
+ accessorKey: "createdByUser",
+ header: "Created By",
+ hideBelowMd: true,
+ cell: ({ row }) => <ApiKeyCreatedBy apiKey={row.original} />,
+ },
+ {
+ accessorKey: "note",
+ header: "Note",
+ cell: ({ row }) => (
+ <ApiKeyNote apiKey={row.original} entityId={entityId} scope={scope} />
+ ),
+ },
+ {
+ accessorKey: "publicKey",
+ header: "Public Key",
+ cell: ({ row }) => <PublicKeyCell publicKey={row.original.publicKey} />,
+ },
+ {
+ accessorKey: "displaySecretKey",
+ header: "Secret Key",
+ cell: ({ getValue }) => (
+ <span className="font-mono">{getValue<string>()}</span>
+ ),
+ },
+ {
+ accessorKey: "id",
+ header: "",
+ cell: ({ row }) => (
+ <DeleteApiKeyButton
+ entityId={entityId}
+ apiKeyId={row.original.id}
+ scope={scope}
+ />
+ ),
+ },
+ ];
+
if (!hasAccess) {
return (
<div>
@@ -117,87 +161,60 @@ export function ApiKeyList(props: { entityId: string; scope: ApiKeyScope }) {
copiedToClipboardMessage="Secrets are not included, create a new key to copy them."
/>
<Card className="mb-4 overflow-hidden">
- <Table>
- <TableHeader>
- <TableRow>
- <TableHead className="text-primary hidden md:table-cell">
- Created
- </TableHead>
- <TableHead className="text-primary hidden md:table-cell">
- Created By
- </TableHead>
- <TableHead className="text-primary">Note</TableHead>
- <TableHead className="text-primary">Public Key</TableHead>
- <TableHead className="text-primary">Secret Key</TableHead>
- {/* <TableHead className="text-primary">Last used</TableHead> */}
- <TableHead />
- </TableRow>
- </TableHeader>
- <TableBody className="text-muted-foreground">
- {apiKeysQuery.data?.length === 0 ? (
- <TableRow>
- <TableCell
- density="comfortable"
- colSpan={6}
- className="text-center"
- >
- None
- </TableCell>
- </TableRow>
+ <SimpleDataTable
+ columns={columns}
+ data={apiKeysQuery.data ?? []}
+ isLoading={apiKeysQuery.isLoading}
+ noResults={
+ apiKeysQuery.isError ? (
+ <span className="text-destructive">
+ Failed to load API keys. Please try again.
+ </span>
) : (
- apiKeysQuery.data?.map((apiKey) => (
- <TableRow
- key={apiKey.id}
- className="hover:bg-primary-foreground"
- >
- <TableCell
- density="comfortable"
- className="hidden md:table-cell"
- >
- {apiKey.createdAt.toLocaleDateString()}
- </TableCell>
- <TableCell
- density="comfortable"
- className="hidden md:table-cell"
- >
- <ApiKeyCreatedBy apiKey={apiKey} />
- </TableCell>
- <TableCell density="comfortable">
- <ApiKeyNote
- apiKey={apiKey}
- entityId={entityId}
- scope={scope}
- />
- </TableCell>
- <TableCellWithCopyButton
- density="comfortable"
- text={apiKey.publicKey}
- className="truncate font-mono"
- title={apiKey.publicKey}
- />
- <TableCell density="comfortable" className="font-mono">
- {apiKey.displaySecretKey}
- </TableCell>
- {/* <TableCell>
- {apiKey.lastUsedAt?.toLocaleDateString() ?? "Never"}
- </TableCell> */}
- <TableCell density="comfortable">
- <DeleteApiKeyButton
- entityId={entityId}
- apiKeyId={apiKey.id}
- scope={scope}
- />
- </TableCell>
- </TableRow>
- ))
- )}
- </TableBody>
- </Table>
+ "None"
+ )
+ }
+ bodyTone="muted"
+ rowVariant="primary-hover"
+ />
</Card>
</div>
);
}
+function PublicKeyCell({ publicKey }: { publicKey: string }) {
+ const { copy, isCopied } = useCopyToClipboard();
+
+ return (
+ <div className="relative min-w-0 truncate pr-8 font-mono" title={publicKey}>
+ <span>{publicKey}</span>
+ <Button
+ variant="ghost"
+ size="icon-xs"
+ className="absolute top-1/2 right-2 -translate-y-1/2"
+ title="Copy to clipboard"
+ aria-label="Copy to clipboard"
+ onClick={async (event) => {
+ event.preventDefault();
+ const button = event.currentTarget;
+ try {
+ await copy(publicKey);
+ } catch {
+ // Clipboard failures are intentionally silent.
+ }
+ button.focus();
+ }}
+ >
+ {isCopied ? (
+ <Check className="h-3 w-3" />
+ ) : (
+ <Copy className="h-3 w-3" />
+ )}
+ </Button>
+ </div>
+ );
+}
+
// show dialog to let user confirm that this is a destructive action
function DeleteApiKeyButton(props: {
entityId: string;
diff --git a/web/src/features/public-api/components/LLMApiKeyList.tsx b/web/src/features/public-api/components/LLMApiKeyList.tsx
index 42dedd2521..ad7215accd 100644
--- a/web/src/features/public-api/components/LLMApiKeyList.tsx
+++ b/web/src/features/public-api/components/LLMApiKeyList.tsx
@@ -5,19 +5,17 @@ import Header from "@/src/components/layouts/header";
import { Button } from "@/src/components/ui/button";
import { Card } from "@/src/components/ui/card";
import { ConfirmDialog } from "@/src/components/ui/confirm-dialog";
-import {
- Table,
- TableBody,
- TableCell,
- TableHead,
- TableHeader,
- TableRow,
-} from "@/src/components/ui/table";
+import { SimpleDataTable } from "@/src/components/table/simple-data-table";
+import { type LangfuseColumnDef } from "@/src/components/table/types";
+import { createTextTableColumn } from "@/src/components/design-system/table/columns/createTextTableColumn";
import { usePostHogClientCapture } from "@/src/features/posthog-analytics";
import { api, reportNonTrpcError } from "@/src/utils/api";
import { Alert } from "@/src/components/design-system/Alert/Alert";
import { CreateLLMApiKeyDialog } from "./CreateLLMApiKeyDialog";
import { UpdateLLMApiKeyDialog } from "./UpdateLLMApiKeyDialog";
+import { type RouterOutput } from "@/src/utils/types";
+
+type LlmApiKeyRow = RouterOutput["llmApiKey"]["all"]["data"][number];
export function LlmApiKeyList(props: { projectId: string }) {
const [editingKeyId, setEditingKeyId] = useState<string | null>(null);
@@ -49,6 +47,79 @@ export function LlmApiKeyList(props: { projectId: string }) {
(key) => key.extraHeaderKeys.length > 0,
);
+ const columns: LangfuseColumnDef<LlmApiKeyRow>[] = [
+ {
+ accessorKey: "provider",
+ header: "Provider",
+ cell: ({ getValue }) => (
+ <span className="font-mono">{getValue<string>()}</span>
+ ),
+ },
+ {
+ accessorKey: "adapter",
+ header: "Adapter",
+ cell: ({ getValue }) => (
+ <span className="font-mono">{getValue<string>()}</span>
+ ),
+ },
+ {
+ accessorKey: "baseURL",
+ header: "Base URL",
+ cell: ({ getValue }) => (
+ <div className="max-w-md overflow-auto font-mono">
+ {getValue<string | null>() ?? "default"}
+ </div>
+ ),
+ },
+ {
+ accessorKey: "displaySecretKey",
+ header: "API Key",
+ cell: ({ getValue }) => (
+ <span className="font-mono">{getValue<string>()}</span>
+ ),
+ },
+ ...(hasExtraHeaderKeys
+ ? [
+ createTextTableColumn<LlmApiKeyRow, string[]>({
+ accessorKey: "extraHeaderKeys",
+ header: "Extra headers",
+ mapValue: (value) => value?.join(", "),
+ }),
+ ]
+ : []),
+ {
+ accessorKey: "id",
+ header: "",
+ cell: ({ row }) => {
+ const apiKey = row.original;
+ return (
+ <div data-row-click-ignore className="flex justify-end space-x-2">
+ {hasUpdateAccess && (
+ <UpdateLLMApiKeyDialog
+ apiKey={apiKey}
+ projectId={props.projectId}
+ open={editingKeyId === apiKey.id}
+ onOpenChange={(open: boolean) => {
+ if (open) {
+ setEditingKeyId(apiKey.id);
+ } else {
+ setEditingKeyId(null);
+ }
+ }}
+ />
+ )}
+ {hasDeleteAccess && (
+ <DeleteApiKeyButton
+ projectId={props.projectId}
+ apiKeyId={apiKey.id}
+ />
+ )}
+ </div>
+ );
+ },
+ },
+ ];
+
if (!hasAccess) {
return (
<div>
@@ -71,96 +142,24 @@ export function LlmApiKeyList(props: { projectId: string }) {
Your provider will charge based on usage.
</p>
<Card className="mb-4 overflow-auto">
- <Table>
- <TableHeader>
- <TableRow>
- <TableHead className="text-primary md:table-cell">
- Provider
- </TableHead>
- <TableHead className="text-primary md:table-cell">
- Adapter
- </TableHead>
- <TableHead className="text-primary md:table-cell">
- Base URL
- </TableHead>
- <TableHead className="text-primary">API Key</TableHead>
- {hasExtraHeaderKeys ? (
- <TableHead className="text-primary">Extra headers</TableHead>
- ) : null}
- <TableHead />
- </TableRow>
- </TableHeader>
- <TableBody className="text-muted-foreground">
- {apiKeys.data?.data.length === 0 ? (
- <TableRow>
- <TableCell
- density="comfortable"
- colSpan={6}
- className="text-center"
- >
- None
- </TableCell>
- </TableRow>
+ <SimpleDataTable
+ columns={columns}
+ data={apiKeys.data?.data ?? []}
+ isLoading={apiKeys.isLoading}
+ noResults={
+ apiKeys.isError ? (
+ <span className="text-destructive">
+ Failed to load LLM connections. Please try again.
+ </span>
) : (
- apiKeys.data?.data.map((apiKey) => (
- <TableRow
- key={apiKey.id}
- className="hover:bg-primary-foreground cursor-default"
- onClick={() => setEditingKeyId(apiKey.id)}
- >
- <TableCell density="comfortable" className="font-mono">
- {apiKey.provider}
- </TableCell>
- <TableCell density="comfortable" className="font-mono">
- {apiKey.adapter}
- </TableCell>
- <TableCell
- density="comfortable"
- className="max-w-md overflow-auto font-mono"
- >
- {apiKey.baseURL ?? "default"}
- </TableCell>
- <TableCell density="comfortable" className="font-mono">
- {apiKey.displaySecretKey}
- </TableCell>
- {hasExtraHeaderKeys ? (
- <TableCell density="comfortable">
- {" "}
- {apiKey.extraHeaderKeys.join(", ")}{" "}
- </TableCell>
- ) : null}
- <TableCell density="comfortable" className="text-right">
- <div
- className="flex justify-end space-x-2"
- onClick={(e) => e.stopPropagation()}
- >
- {hasUpdateAccess && (
- <UpdateLLMApiKeyDialog
- apiKey={apiKey}
- projectId={props.projectId}
- open={editingKeyId === apiKey.id}
- onOpenChange={(open: boolean) => {
- if (open) {
- setEditingKeyId(apiKey.id);
- } else {
- setEditingKeyId(null);
- }
- }}
- />
- )}
- {hasDeleteAccess && (
- <DeleteApiKeyButton
- projectId={props.projectId}
- apiKeyId={apiKey.id}
- />
- )}
- </div>
- </TableCell>
- </TableRow>
- ))
- )}
- </TableBody>
- </Table>
+ "None"
+ )
+ }
+ bodyTone="muted"
+ rowVariant="primary-hover-static"
+ onRowClick={(apiKey) => setEditingKeyId(apiKey.id)}
+ getRowLabel={(apiKey) => `Edit ${apiKey.provider} connection`}
+ />
</Card>
<CreateLLMApiKeyDialog open={open} setOpen={setOpen} />
</div>
diff --git a/web/src/features/v4-migration/V4MigrationStatusPage.tsx b/web/src/features/v4-migration/V4MigrationStatusPage.tsx
index d48a0621fa..44dc3f7760 100644
--- a/web/src/features/v4-migration/V4MigrationStatusPage.tsx
+++ b/web/src/features/v4-migration/V4MigrationStatusPage.tsx
@@ -6,14 +6,9 @@ import { useSession } from "next-auth/react";
import { ArrowRight } from "lucide-react";
import ContainerPage from "@/src/components/layouts/container-page";
import { Card } from "@/src/components/ui/card";
-import {
- Table,
- TableBody,
- TableCell,
- TableHead,
- TableHeader,
- TableRow,
-} from "@/src/components/ui/table";
+import { SimpleDataTable } from "@/src/components/table/simple-data-table";
+import { type LangfuseColumnDef } from "@/src/components/table/types";
+import { createTextTableColumn } from "@/src/components/design-system/table/columns/createTextTableColumn";
import {
useCopyMigrationPrompt,
useHasV4MigrationDeadline,
@@ -99,10 +94,10 @@ function StatusPill({ readiness }: { readiness: ProjectMigrationReadiness }) {
if (readiness === "partner-managed") {
return (
<a
+ data-row-click-ignore
href={PARTNER_INTEGRATION_FAQ_URL}
target="_blank"
rel="noopener noreferrer"
- onClick={(event) => event.stopPropagation()}
className="bg-muted text-muted-foreground inline-flex w-fit shrink-0 items-center rounded-full px-2 py-0.5 text-xs font-bold whitespace-nowrap hover:underline"
title="Upgrade is handled by your integration partner"
>
@@ -133,7 +128,7 @@ type OrderBy = { column: SortKey; order: "ASC" | "DESC" } | null;
// Header styling and none → DESC → ASC → none sort cycle copied from the
// trace table (DataTable); sorting here is client-side over the static rows.
-function SortableHead({
+function SortableHeader({
label,
column,
orderBy,
@@ -145,8 +140,8 @@ function SortableHead({
onSort: (column: SortKey) => void;
}) {
return (
- <TableHead
- className="group cursor-pointer px-2"
+ <div
+ className="-mx-2 flex h-10 w-[calc(100%+1rem)] items-center px-2"
onClick={() => onSort(column)}
>
<div className="flex items-center select-none">
@@ -159,7 +154,7 @@ function SortableHead({
</span>
)}
</div>
- </TableHead>
+ </div>
);
}
@@ -298,6 +293,119 @@ function OrgStatusSection({
})
: rows;
+ const sortableHeader = (label: string, column: SortKey) => (
+ <SortableHeader
+ label={label}
+ column={column}
+ orderBy={orderBy}
+ onSort={handleSort}
+ />
+ );
+
+ const columnOptions = {
+ cellPadding: "comfortable" as const,
+ };
+
+ const columns: LangfuseColumnDef<(typeof rows)[number]>[] = [
+ {
+ ...columnOptions,
+ accessorKey: "name",
+ size: 192,
+ header: () => sortableHeader("Project", "name"),
+ cell: ({ row }) => (
+ <Link
+ data-row-click-ignore
+ href={`/project/${row.original.id}/traces`}
+ className="block truncate font-bold hover:underline"
+ title={row.original.name}
+ onClick={() => {
+ if (!row.original.status.forceV3Experience) {
+ openProjectMigration(row.original, row.original.readiness);
+ }
+ }}
+ >
+ {row.original.name}
+ </Link>
+ ),
+ },
+ {
+ ...columnOptions,
+ accessorKey: "readiness",
+ header: () => sortableHeader("Status", "status"),
+ cell: ({ row }) => <StatusPill readiness={row.original.readiness} />,
+ },
+ {
+ ...columnOptions,
+ accessorKey: "sdk",
+ header: () => sortableHeader("SDK", "sdk"),
+ cell: ({ row }) =>
+ row.original.status.sdk.status === "latest" ? (
+ <span className="text-foreground-tertiary">Latest</span>
+ ) : row.original.status.sdk.status === "otel_realtime" ? (
+ <span className="text-foreground-tertiary">OTel real-time</span>
+ ) : row.original.status.sdk.status === "no_data" ? (
+ <span className="text-foreground-tertiary">No data detected</span>
+ ) : row.original.status.sdk.status === "checking" ? (
+ <span className="text-foreground-tertiary">Checking…</span>
+ ) : row.original.status.sdk.status === "unknown" ? (
+ <span className="text-foreground-tertiary">Unknown</span>
+ ) : row.original.status.sdk.status === "otel_header_required" ? (
+ <span>
+ {row.original.status.sdk.delayedOtelIngestionCount} OTel header{" "}
+ {row.original.status.sdk.delayedOtelIngestionCount === 1
+ ? "required"
+ : "issues"}
+ </span>
+ ) : row.original.status.sdk.status === "error" ? (
+ <span className="text-foreground-tertiary">Unavailable</span>
+ ) : (
+ <span>{row.original.status.sdk.upgradeRequiredCount} outdated</span>
+ ),
+ },
+ {
+ ...columnOptions,
+ accessorKey: "evals",
+ header: () => sortableHeader("Affected Evals", "evals"),
+ cell: ({ row }) => <AffectedCell count={row.original.status.evals} />,
+ },
+ {
+ ...columnOptions,
+ accessorKey: "experiments",
+ header: () => sortableHeader("Affected Experiments", "experiments"),
+ cell: ({ row }) => (
+ <MigrationActionCell state={row.original.status.experiments} />
+ ),
+ },
+ {
+ ...columnOptions,
+ accessorKey: "apis",
+ header: () => sortableHeader("Affected APIs", "apis"),
+ cell: ({ row }) => <AffectedCell count={row.original.status.apis} />,
+ },
+ {
+ ...columnOptions,
+ accessorKey: "exports",
+ header: () => sortableHeader("Affected Exports", "exports"),
+ cell: ({ row }) => <AffectedCell count={row.original.status.exports} />,
+ },
+ createTextTableColumn<(typeof rows)[number]>({
+ ...columnOptions,
+ accessorKey: "lastTraceLabel",
+ header: () => sortableHeader("Last trace", "lastTrace"),
+ }),
+ {
+ accessorKey: "id",
+ header: "",
+ size: 96,
+ cellPadding: "comfortable",
+ cell: () => (
+ <span className="text-dark-blue flex items-center justify-end gap-1 whitespace-nowrap opacity-0 transition-opacity group-hover/row:opacity-100">
+ Review <ArrowRight className="h-3 w-3 shrink-0" />
+ </span>
+ ),
+ },
+ ];
+
if (rows.length === 0) return null;
return (
@@ -307,156 +415,16 @@ function OrgStatusSection({
</h3>
<Card className="overflow-hidden">
<div className="overflow-x-auto">
- <Table className="min-w-[60rem] table-auto">
- <TableHeader>
- <TableRow>
- <SortableHead
- label="Project"
- column="name"
- orderBy={orderBy}
- onSort={handleSort}
- />
- <SortableHead
- label="Status"
- column="status"
- orderBy={orderBy}
- onSort={handleSort}
- />
- <SortableHead
- label="SDK"
- column="sdk"
- orderBy={orderBy}
- onSort={handleSort}
- />
- <SortableHead
- label="Affected Evals"
- column="evals"
- orderBy={orderBy}
- onSort={handleSort}
- />
- <SortableHead
- label="Affected Experiments"
- column="experiments"
- orderBy={orderBy}
- onSort={handleSort}
- />
- <SortableHead
- label="Affected APIs"
- column="apis"
- orderBy={orderBy}
- onSort={handleSort}
- />
- <SortableHead
- label="Affected Exports"
- column="exports"
- orderBy={orderBy}
- onSort={handleSort}
- />
- <SortableHead
- label="Last trace"
- column="lastTrace"
- orderBy={orderBy}
- onSort={handleSort}
- />
- <TableHead className="w-24" />
- </TableRow>
- </TableHeader>
- <TableBody>
- {sortedRows.map((row) => {
- const { readiness } = row;
- return (
- <TableRow
- key={row.id}
- className="group/row cursor-pointer"
- onClick={() => handleRowClick(row, readiness)}
- >
- <TableCell density="comfortable" className="max-w-48">
- <Link
- href={`/project/${row.id}/traces`}
- className="block truncate font-bold hover:underline"
- title={row.name}
- onClick={(event) => {
- event.stopPropagation();
- // Forced-v3 projects have no migration panel.
- if (!row.status.forceV3Experience) {
- openProjectMigration(row, readiness);
- }
- }}
- >
- {row.name}
- </Link>
- </TableCell>
- <TableCell
- density="comfortable"
- className="overflow-hidden"
- >
- <StatusPill readiness={readiness} />
- </TableCell>
- <TableCell density="comfortable">
- {row.status.sdk.status === "latest" ? (
- <span className="text-foreground-tertiary">Latest</span>
- ) : row.status.sdk.status === "otel_realtime" ? (
- <span className="text-foreground-tertiary">
- OTel real-time
- </span>
- ) : row.status.sdk.status === "no_data" ? (
- <span className="text-foreground-tertiary">
- No data detected
- </span>
- ) : row.status.sdk.status === "checking" ? (
- <span className="text-foreground-tertiary">
- Checking…
- </span>
- ) : row.status.sdk.status === "unknown" ? (
- <span className="text-foreground-tertiary">
- Unknown
- </span>
- ) : row.status.sdk.status === "otel_header_required" ? (
- <span>
- {row.status.sdk.delayedOtelIngestionCount} OTel header{" "}
- {row.status.sdk.delayedOtelIngestionCount === 1
- ? "required"
- : "issues"}
- </span>
- ) : row.status.sdk.status === "error" ? (
- <span className="text-foreground-tertiary">
- Unavailable
- </span>
- ) : (
- <span>
- {row.status.sdk.upgradeRequiredCount} outdated
- </span>
- )}
- </TableCell>
- <TableCell density="comfortable">
- <AffectedCell count={row.status.evals} />
- </TableCell>
- <TableCell density="comfortable">
- <MigrationActionCell state={row.status.experiments} />
- </TableCell>
- <TableCell density="comfortable">
- <AffectedCell count={row.status.apis} />
- </TableCell>
- <TableCell density="comfortable">
- <AffectedCell count={row.status.exports} />
- </TableCell>
- <TableCell
- density="comfortable"
- className="text-muted-foreground truncate"
- title={row.lastTraceLabel}
- >
- {row.lastTraceLabel}
- </TableCell>
- <TableCell density="comfortable">
- <span className="text-dark-blue flex items-center justify-end gap-1 whitespace-nowrap opacity-0 transition-opacity group-hover/row:opacity-100">
- Review <ArrowRight className="h-3 w-3 shrink-0" />
- </span>
- </TableCell>
- </TableRow>
- );
- })}
- </TableBody>
- </Table>
+ <SimpleDataTable
+ columns={columns}
+ data={sortedRows}
+ isLoading={false}
+ noResults={null}
+ presentation="wide"
+ rowVariant="review"
+ onRowClick={(row) => handleRowClick(row, row.readiness)}
+ getRowLabel={(row) => `Review ${row.name}`}
+ />
</div>
</Card>
</div>
diff --git a/web/src/features/web-callouts/components/WebCalloutSettingsPage.tsx b/web/src/features/web-callouts/components/WebCalloutSettingsPage.tsx
index 72c8bcc848..cf9cae7ff3 100644
--- a/web/src/features/web-callouts/components/WebCalloutSettingsPage.tsx
+++ b/web/src/features/web-callouts/components/WebCalloutSettingsPage.tsx
@@ -7,7 +7,10 @@ import { useFieldArray, useForm } from "react-hook-form";
import { z } from "zod";
import { ActionButton } from "@/src/components/ActionButton";
-import { StatusBadge } from "@/src/components/ui/StatusBadge/StatusBadge";
+import { createStatusTableColumn } from "@/src/components/design-system/table/columns/createStatusTableColumn";
+import { createTextTableColumn } from "@/src/components/design-system/table/columns/createTextTableColumn";
+import { SimpleDataTable } from "@/src/components/table/simple-data-table";
+import { type LangfuseColumnDef } from "@/src/components/table/types";
import { Alert } from "@/src/components/design-system/Alert/Alert";
import { Button } from "@/src/components/ui/button";
import { Card } from "@/src/components/ui/card";
@@ -32,14 +35,6 @@ import {
} from "@/src/components/ui/form";
import { Input } from "@/src/components/ui/input";
import { Switch } from "@/src/components/design-system/Switch/Switch";
-import {
- Table,
- TableBody,
- TableCell,
- TableHead,
- TableHeader,
- TableRow,
-} from "@/src/components/ui/table";
import {
Tooltip,
TooltipContent,
@@ -156,9 +151,11 @@ export function WebCalloutSettingsPage(props: { projectId: string }) {
const canCreateEndpoint = !configuredEndpoint;
const addEndpointDisabledReason = endpoints.isLoading
? "Loading callout endpoint configuration."
- : !canCreateEndpoint
- ? "Currently you can only create one callout per project."
- : undefined;
+ : endpoints.isError
+ ? "Could not load the callout endpoint configuration."
+ : !canCreateEndpoint
+ ? "Currently you can only create one callout per project."
+ : undefined;
const openCreateDialog = () => {
setEditingEndpoint(null);
@@ -170,6 +167,71 @@ export function WebCalloutSettingsPage(props: { projectId: string }) {
setDialogOpen(true);
};
+ const columns: LangfuseColumnDef<WebCalloutEndpoint>[] = [
+ createTextTableColumn<WebCalloutEndpoint>({
+ accessorKey: "name",
+ header: "Name",
+ }),
+ {
+ accessorKey: "url",
+ header: "Endpoint",
+ size: 576,
+ cell: ({ getValue }) => {
+ const url = getValue<string>();
+ return (
+ <span className="font-mono break-all" title={url}>
+ {url}
+ </span>
+ );
+ },
+ },
+ {
+ accessorKey: "toastMessage",
+ header: "Toast Message",
+ cell: ({ row }) => <ToastMessageCell endpoint={row.original} />,
+ },
+ {
+ accessorKey: "requestHeaderKeys",
+ header: "Headers",
+ cell: ({ row }) => <HeaderList endpoint={row.original} />,
+ },
+ createStatusTableColumn<WebCalloutEndpoint, boolean>({
+ accessorKey: "enabled",
+ header: "Status",
+ getStatus: (enabled) => (enabled ? "active" : "disabled"),
+ }),
+ {
+ accessorKey: "id",
+ header: "",
+ cell: ({ row }) => (
+ <div className="flex justify-end gap-1">
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button
+ variant="ghost"
+ size="icon"
+ onClick={() => openEditDialog(row.original)}
+ >
+ <Pencil className="h-4 w-4" />
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent>Edit endpoint</TooltipContent>
+ </Tooltip>
+ <DeleteEndpointButton
+ endpoint={row.original}
+ onDelete={(id) => {
+ deleteMutation.mutate({
+ projectId: props.projectId,
+ id,
+ });
+ }}
+ loading={deleteMutation.isPending}
+ />
+ </div>
+ ),
+ },
+ ];
+
return (
<div>
<p className="text-primary mb-4 text-sm">
@@ -208,82 +270,22 @@ export function WebCalloutSettingsPage(props: { projectId: string }) {
</div>
<Card className="overflow-auto">
- <Table>
- <TableHeader>
- <TableRow>
- <TableHead className="text-primary">Name</TableHead>
- <TableHead className="text-primary">Endpoint</TableHead>
- <TableHead className="text-primary">Toast Message</TableHead>
- <TableHead className="text-primary">Headers</TableHead>
- <TableHead className="text-primary">Status</TableHead>
- <TableHead />
- </TableRow>
- </TableHeader>
- <TableBody>
- {endpoints.data?.length === 0 ? (
- <TableRow>
- <TableCell
- density="comfortable"
- colSpan={6}
- className="text-muted-foreground text-center"
- >
- No callout endpoint configured.
- </TableCell>
- </TableRow>
+ <SimpleDataTable
+ columns={columns}
+ data={endpoints.data ?? []}
+ isLoading={endpoints.isLoading}
+ noResults={
+ endpoints.isError ? (
+ <span className="text-destructive">
+ Failed to load the callout endpoint. Please try again.
+ </span>
) : (
- endpoints.data?.map((endpoint) => (
- <TableRow key={endpoint.id}>
- <TableCell density="comfortable" className="font-bold">
- {endpoint.name}
- </TableCell>
- <TableCell
- density="comfortable"
- className="max-w-xl font-mono break-all"
- >
- {endpoint.url}
- </TableCell>
- <TableCell density="comfortable">
- <ToastMessageCell endpoint={endpoint} />
- </TableCell>
- <TableCell density="comfortable">
- <HeaderList endpoint={endpoint} />
- </TableCell>
- <TableCell density="comfortable">
- <StatusBadge
- type={endpoint.enabled ? "active" : "disabled"}
- />
- </TableCell>
- <TableCell density="comfortable" className="text-right">
- <div className="flex justify-end gap-1">
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- variant="ghost"
- size="icon"
- onClick={() => openEditDialog(endpoint)}
- >
- <Pencil className="h-4 w-4" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>Edit endpoint</TooltipContent>
- </Tooltip>
- <DeleteEndpointButton
- endpoint={endpoint}
- onDelete={(id) => {
- deleteMutation.mutate({
- projectId: props.projectId,
- id,
- });
- }}
- loading={deleteMutation.isPending}
- />
- </div>
- </TableCell>
- </TableRow>
- ))
- )}
- </TableBody>
- </Table>
+ <span className="text-muted-foreground">
+ No callout endpoint configured.
+ </span>
+ )
+ }
+ />
</Card>
</div>
);
@@ -658,7 +660,7 @@ const endpointToFormValues = (
url: endpoint?.url ?? "",
enabled: endpoint?.enabled ?? true,
toastMessage: endpoint?.toastMessage ?? "Callout sent",
- headers: (endpoint?.requestHeaderKeys ?? []).map((name) => ({
+ headers: (endpoint?.requestHeaderKeys ?? []).map((name: string) => ({
name,
value: "",
})),
@@ -684,7 +686,7 @@ const hasExistingHeaderName = (
return (
endpoint?.requestHeaderKeys.some(
- (headerName) => headerName.toLowerCase() === normalizedName,
+ (headerName: string) => headerName.toLowerCase() === normalizedName,
) ?? false
);
};
diff --git a/web/src/features/widgets/chart-library/PivotTable.tsx b/web/src/features/widgets/chart-library/PivotTable.tsx
index 85bb22068b..e547ff03d8 100644
--- a/web/src/features/widgets/chart-library/PivotTable.tsx
+++ b/web/src/features/widgets/chart-library/PivotTable.tsx
@@ -22,14 +22,6 @@
import React, { useMemo, useCallback, useState, useEffect } from "react";
import { cn } from "@/src/utils/tailwind";
-import {
- Table,
- TableHeader,
- TableBody,
- TableHead,
- TableRow,
- TableCell,
-} from "@/src/components/ui/table";
import {
transformToPivotTable,
extractDimensionValues,
@@ -44,6 +36,7 @@ import {
import { type ChartProps } from "@/src/features/widgets/chart-library/chart-props";
import { valueFormatter } from "@/src/features/widgets/chart-library/utils";
import { formatMetricName } from "@/src/features/widgets/utils";
+
import { type OrderByState } from "@langfuse/shared";
/**
@@ -76,13 +69,18 @@ const StaticHeader: React.FC<{
className?: string;
}> = ({ label, className }) => {
return (
- <TableHead className={cn("p-1", className)}>
+ <th
+ className={cn(
+ "bg-background text-muted-foreground relative h-10 border-b p-1 text-left align-middle font-bold [&:has([role=checkbox])]:pr-0",
+ className,
+ )}
+ >
<div className="flex items-center select-none">
<span className="truncate" title={label}>
{label}
</span>
</div>
- </TableHead>
+ </th>
);
};
@@ -110,8 +108,12 @@ const SortableHeader: React.FC<{
);
return (
- <TableHead
- className={cn("group/header cursor-pointer p-1 select-none", className)}
+ <th
+ className={cn(
+ "bg-background text-muted-foreground relative h-10 border-b p-1 text-left align-middle font-bold [&:has([role=checkbox])]:pr-0",
+ "group/header cursor-pointer select-none",
+ className,
+ )}
onClick={handleClick}
>
<div
@@ -139,7 +141,7 @@ const SortableHeader: React.FC<{
{/* Visual indicator that appears on hover - matches traces table behavior */}
<div className="bg-secondary pointer-events-none absolute top-0 right-0 h-full w-1.5 touch-none opacity-0 select-none group-hover/header:opacity-100" />
</div>
- </TableHead>
+ </th>
);
};
@@ -153,17 +155,17 @@ const PivotTableRowComponent: React.FC<{
units?: (string | undefined)[];
}> = ({ row, metrics, units }) => {
return (
- <TableRow
+ <tr
className={cn(
- "hover:bg-muted/30 border-b transition-colors",
+ "data-[state=selected]:bg-muted hover:bg-muted/30 border-b transition-colors",
row.isSubtotal && "bg-muted/30",
row.isTotal && "bg-muted/50",
)}
>
{/* Dimension column with indentation and styling */}
- <TableCell
+ <td
className={cn(
- "p-2 align-middle font-normal",
+ "h-full border-b p-2 align-middle font-normal [&:has([role=checkbox])]:pr-0 [:last-child_>_&]:border-b-0",
// Apply indentation based on level using explicit Tailwind classes
row.level === 1 && "pl-6", // 1.5rem indentation for level 1
row.level === 2 && "pl-10", // 2.5rem indentation for level 2
@@ -177,21 +179,21 @@ const PivotTableRowComponent: React.FC<{
}}
>
{row.label}
- </TableCell>
+ </td>
{/* Metric columns */}
{metrics.map((metric, i) => (
- <TableCell
+ <td
key={metric}
className={cn(
- "p-2 text-right align-middle tabular-nums",
+ "h-full border-b p-2 text-right align-middle tabular-nums [&:has([role=checkbox])]:pr-0 [:last-child_>_&]:border-b-0",
(row.isSubtotal || row.isTotal) && "font-bold",
)}
>
{valueFormatter(row.values[metric], units?.[i])}
- </TableCell>
+ </td>
))}
- </TableRow>
+ </tr>
);
};
@@ -373,9 +375,9 @@ export const PivotTable: React.FC<PivotTableProps> = ({
return (
<div className="h-full overflow-auto px-5 pb-2">
- <Table>
- <TableHeader className="sticky top-0 z-10">
- <TableRow>
+ <table className="w-full table-fixed caption-bottom border-separate border-spacing-0 space-y-4 overflow-auto text-sm">
+ <thead className="sticky top-0 z-10 [&_tr]:border-b">
+ <tr className="hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors">
{/* Dimension column header */}
<StaticHeader
label={
@@ -398,10 +400,10 @@ export const PivotTable: React.FC<PivotTableProps> = ({
rightAlign={true}
/>
))}
- </TableRow>
- </TableHeader>
+ </tr>
+ </thead>
- <TableBody>
+ <tbody className="text-xs [&_tr:last-child]:border-0">
{sortedRows.map((row) => (
<PivotTableRowComponent
key={row.id}
@@ -410,8 +412,8 @@ export const PivotTable: React.FC<PivotTableProps> = ({
units={units}
/>
))}
- </TableBody>
- </Table>
+ </tbody>
+ </table>
</div>
);
};