Skip to content

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

fix(table): polish cell typography, folder icon, and resize-vs-sort (LFE-8169) (#14524)

Nikita Kabardin9f3e8a470a67
diff --git a/web/src/components/table/data-table.stories.tsx b/web/src/components/table/data-table.stories.tsx
index c2596e2c39..b119a2bfc3 100644
--- a/web/src/components/table/data-table.stories.tsx
+++ b/web/src/components/table/data-table.stories.tsx
@@ -47,7 +47,14 @@ import {
import { formatIntervalSeconds } from "@/src/utils/dates";
import { numberFormatter, usdFormatter } from "@/src/utils/numbers";
import { cn } from "@/src/utils/tailwind";
-import { Copy, InfoIcon, MoreVertical, Trash } from "lucide-react";
+import {
+ Copy,
+ InfoIcon,
+ ListTree,
+ MoreVertical,
+ PlusCircle,
+ Trash,
+} from "lucide-react";
// =============================================================================
// FIDELITY GOAL
@@ -1361,3 +1368,126 @@ function FolderRowsStory() {
export const WithFolderRows = meta.story({
render: () => <FolderRowsStory />,
});
+
+// -----------------------------------------------------------------------------
+// 9. Inline icon cells (alignment regression harness)
+// -----------------------------------------------------------------------------
+// Trailing/leading icons next to cell text are a supported pattern (the
+// "Provided Model Name" create-affordance, ListTree source links, folder rows).
+// They must NOT shift the text baseline relative to plain rows. This story puts
+// every variant in one column so any vertical-alignment regression is obvious:
+// - plain TableIdOrName (no icon)
+// - TableIdOrName + trailing PlusCircle — mirrors features/models
+// ProvidedModelNameCell: the name is wrapped in `inline-flex items-center`
+// with the icon as a `shrink-0` adornment, so it lands on the same baseline
+// as the no-icon rows.
+// - TableLink with a leading icon (ListTree)
+// - FolderBreadcrumbLink (Folder icon)
+// A second plain-text column shows the row stays aligned across the table.
+
+type IconCellRow = {
+ id: string;
+ name: string;
+ kind: "plain" | "createModel" | "link" | "folder";
+ detail: string;
+};
+
+const ICON_CELL_ROWS: IconCellRow[] = [
+ { id: "1", name: "gpt-4o-mini", kind: "plain", detail: "resolved" },
+ { id: "2", name: "gpt-3.5-turbo", kind: "createModel", detail: "unmatched" },
+ {
+ id: "3",
+ name: "claude-3-5-sonnet",
+ kind: "createModel",
+ detail: "unmatched",
+ },
+ {
+ id: "4",
+ name: "text-embedding-3-large",
+ kind: "plain",
+ detail: "resolved",
+ },
+ { id: "5", name: "obs-7c1f-typography", kind: "link", detail: "source" },
+ { id: "6", name: "shared-prompts", kind: "folder", detail: "folder" },
+ {
+ id: "7",
+ name: "gpt-4.1-judge-pipeline",
+ kind: "createModel",
+ detail: "unmatched",
+ },
+];
+
+const iconCellColumns: LangfuseColumnDef<IconCellRow>[] = [
+ {
+ accessorKey: "name",
+ id: "name",
+ header: "Provided Model Name",
+ size: 260,
+ cell: ({ row }) => {
+ const { name, kind } = row.original;
+ switch (kind) {
+ case "createModel":
+ // Faithful to ProvidedModelNameCell: same TableIdOrName + trailing
+ // icon, in a native <button> trigger (keyboard-activatable).
+ return (
+ <button
+ type="button"
+ className="inline-flex max-w-full cursor-pointer items-center gap-1 text-left"
+ >
+ <TableIdOrName value={name} className="min-w-0" />
+ <PlusCircle className="h-3.5 w-3.5 shrink-0" />
+ </button>
+ );
+ case "link":
+ return (
+ <TableLink
+ path="#"
+ value={name}
+ icon={
+ <span className="flex flex-row items-center gap-1">
+ <ListTree className="h-3.5 w-3.5 shrink-0" />
+ {name}
+ </span>
+ }
+ />
+ );
+ case "folder":
+ return <FolderBreadcrumbLink name={name} onClick={() => {}} />;
+ case "plain":
+ default:
+ return (
+ <span className="inline-flex max-w-full items-center">
+ <TableIdOrName value={name} className="min-w-0" />
+ </span>
+ );
+ }
+ },
+ },
+ {
+ accessorKey: "detail",
+ id: "detail",
+ header: "Status",
+ size: 120,
+ cell: ({ getValue }) => getValue<string>(),
+ },
+];
+
+function InlineIconCellsStory() {
+ const data: AsyncTableData<IconCellRow[]> = {
+ isLoading: false,
+ isError: false,
+ data: ICON_CELL_ROWS,
+ };
+ return (
+ <DataTable<IconCellRow, unknown>
+ tableName="story-inline-icon-cells"
+ columns={iconCellColumns}
+ data={data}
+ rowHeight="s"
+ />
+ );
+}
+
+export const WithInlineIconCells = meta.story({
+ render: () => <InlineIconCellsStory />,
+});
diff --git a/web/src/components/table/data-table.tsx b/web/src/components/table/data-table.tsx
index 1520f2594a..ee55fa1208 100644
--- a/web/src/components/table/data-table.tsx
+++ b/web/src/components/table/data-table.tsx
@@ -4,6 +4,8 @@ import React, {
useState,
useMemo,
useCallback,
+ useRef,
+ useEffect,
type CSSProperties,
} from "react";
import DocPopup from "@/src/components/layouts/doc-popup";
@@ -220,6 +222,45 @@ export function DataTable<TData extends object, TValue>({
const { columnSizing, setColumnSizing } = useColumnSizing(tableName);
+ // Releasing a column-resize drag fires a synthetic `click` on the underlying
+ // header (the resize handle is a child of <TableHead>), which would otherwise
+ // toggle the column sort. We stamp the resized column + time when a resize
+ // ends and ignore a header click only on that same column within a short
+ // window after it — so a deliberate sort click on a *different* header right
+ // after a resize is not dropped. The stamp is set from a document listener
+ // registered on resize start, so it fires before the click regardless of
+ // where the pointer is released.
+ const lastColumnResizeEndRef = useRef<{ columnId: string; at: number }>({
+ columnId: "",
+ at: 0,
+ });
+ // Removes the in-flight resize listener pair; cleared once it has run so we
+ // never leak listeners if the table unmounts mid-drag.
+ const activeResizeCleanupRef = useRef<(() => void) | null>(null);
+ const beginColumnResize = useCallback(
+ (columnId: string, handler: (event: unknown) => void) =>
+ (event: React.MouseEvent | React.TouchEvent) => {
+ handler(event);
+ // Drop any listener pair still attached from a prior resize.
+ activeResizeCleanupRef.current?.();
+ const onResizeEnd = () => {
+ lastColumnResizeEndRef.current = { columnId, at: Date.now() };
+ cleanup();
+ };
+ const cleanup = () => {
+ document.removeEventListener("mouseup", onResizeEnd);
+ document.removeEventListener("touchend", onResizeEnd);
+ activeResizeCleanupRef.current = null;
+ };
+ activeResizeCleanupRef.current = cleanup;
+ document.addEventListener("mouseup", onResizeEnd);
+ document.addEventListener("touchend", onResizeEnd);
+ },
+ [],
+ );
+ // Detach any in-flight resize listeners if the table unmounts mid-drag.
+ useEffect(() => () => activeResizeCleanupRef.current?.(), []);
+
// Infer column pinning state from column properties
const columnPinning = useMemo<ColumnPinningState>(
() => ({
@@ -393,6 +434,17 @@ export function DataTable<TData extends object, TValue>({
onClick={(event) => {
event.preventDefault();
+ // Ignore the click synthesized when this column's own
+ // resize drag is released over its header (other
+ // headers stay clickable during that window).
+ const lastResize = lastColumnResizeEndRef.current;
+ if (
+ lastResize.columnId === header.column.id &&
+ Date.now() - lastResize.at < 250
+ ) {
+ return;
+ }
+
if (!setOrderBy || !columnDef.id || !sortingEnabled) {
return;
}
@@ -428,7 +480,7 @@ export function DataTable<TData extends object, TValue>({
>
{header.isPlaceholder ? null : (
<div className="flex items-center select-none">
- <span className="truncate">
+ <span className="truncate leading-normal">
{flexRender(
header.column.columnDef.header,
header.getContext(),
@@ -452,8 +504,14 @@ export function DataTable<TData extends object, TValue>({
e.stopPropagation();
}}
onDoubleClick={() => header.column.resetSize()}
- onMouseDown={header.getResizeHandler()}
- onTouchStart={header.getResizeHandler()}
+ onMouseDown={beginColumnResize(
+ header.column.id,
+ header.getResizeHandler(),
+ )}
+ onTouchStart={beginColumnResize(
+ header.column.id,
+ header.getResizeHandler(),
+ )}
className={cn(
"bg-secondary absolute top-0 right-0 h-full w-1.5 cursor-col-resize touch-none opacity-0 select-none group-hover:opacity-100",
header.column.getIsResizing() &&
@@ -748,7 +806,7 @@ function TableBodyComponent<TData>({
)}
>
{isStringCell && isSmallRowHeight ? (
- <div className="min-w-0 truncate leading-none">
+ <div className="min-w-0 truncate leading-normal">
{flexRender(
cell.column.columnDef.cell,
cell.getContext(),
diff --git a/web/src/components/table/table-link.tsx b/web/src/components/table/table-link.tsx
index 8d68b24298..0f1ff8e0d7 100644
--- a/web/src/components/table/table-link.tsx
+++ b/web/src/components/table/table-link.tsx
@@ -28,16 +28,15 @@ export default function TableLink({
return (
<Link
className={cn(
- "text-accent-dark-blue hover:text-primary-accent/60 inline-block max-w-full text-xs font-semibold",
+ "text-accent-dark-blue hover:text-primary-accent/60 inline-block max-w-full text-xs leading-normal font-semibold",
className,
- icon && "max-h-4",
)}
href={path}
title={title || value}
prefetch={false}
onClick={handleClick}
>
- <span className="inline-block max-w-full overflow-hidden text-nowrap text-ellipsis">
+ <span className="inline-block max-w-full overflow-hidden align-middle leading-normal text-nowrap text-ellipsis">
{icon ? <span className="inline-block">{icon}</span> : value}
</span>
</Link>
diff --git a/web/src/components/table/use-cases/observations.tsx b/web/src/components/table/use-cases/observations.tsx
index a285c89877..006ccdb735 100644
--- a/web/src/components/table/use-cases/observations.tsx
+++ b/web/src/components/table/use-cases/observations.tsx
@@ -69,8 +69,8 @@ import {
BreakdownTooltip,
calculateAggregatedUsage,
} from "@/src/components/trace/components/_shared/BreakdownToolTip";
-import { InfoIcon, PlusCircle } from "lucide-react";
-import { UpsertModelFormDialog } from "@/src/features/models/components/UpsertModelFormDialog";
+import { InfoIcon } from "lucide-react";
+import { ProvidedModelNameCell } from "@/src/features/models/components/ProvidedModelNameCell";
import { LocalIsoDate } from "@/src/components/LocalIsoDate";
import { Badge } from "@/src/components/ui/badge";
import TableIdOrName from "@/src/components/table/table-id";
@@ -924,36 +924,13 @@ export default function ObservationsTable({
const model = row.getValue("model") as string;
const modelId = row.getValue("modelId") as string | undefined;
- if (!model) return null;
-
- return modelId ? (
- <TableIdOrName value={model} />
- ) : (
- <UpsertModelFormDialog
- action="create"
+ return (
+ <ProvidedModelNameCell
+ modelName={model}
+ modelId={modelId}
projectId={projectId}
- prefilledModelData={{
- modelName: model,
- prices:
- Object.keys(row.original.usageDetails).length > 0
- ? Object.keys(row.original.usageDetails)
- .filter((key) => key != "total")
- .reduce(
- (acc, key) => {
- acc[key] = 0.000001;
- return acc;
- },
- {} as Record<string, number>,
- )
- : undefined,
- }}
- className="cursor-pointer"
- >
- <span className="flex items-center gap-1">
- <span>{model}</span>
- <PlusCircle className="h-3 w-3" />
- </span>
- </UpsertModelFormDialog>
+ usageDetails={row.original.usageDetails}
+ />
);
},
},
diff --git a/web/src/components/ui/IOTableCell.tsx b/web/src/components/ui/IOTableCell.tsx
index e036e10168..b46edcd09b 100644
--- a/web/src/components/ui/IOTableCell.tsx
+++ b/web/src/components/ui/IOTableCell.tsx
@@ -42,7 +42,7 @@ const IOTableCellContent = ({
return singleLine ? (
<div
className={cn(
- "h-full w-full self-stretch truncate overflow-hidden overflow-y-auto",
+ "h-full w-full self-stretch truncate overflow-hidden overflow-y-auto rounded-sm",
paddingClassName,
className,
)}
@@ -59,7 +59,10 @@ const IOTableCellContent = ({
`...[truncated ${stringifiedJson.length - IO_TABLE_CHAR_LIMIT} characters]`,
true, // greedy mode for double-escaped Unicode (e.g., \\uXXXX)
)}
- className={cn("h-full w-full self-stretch", className)}
+ className={cn(
+ "h-full w-full self-stretch overflow-hidden rounded-sm",
+ className,
+ )}
codeClassName={cn("min-h-0 h-full overflow-y-auto", paddingClassName)}
collapseStringsAfterLength={null} // in table, show full strings as row height is fixed
borderless
@@ -73,7 +76,10 @@ const IOTableCellContent = ({
json={
stringifiedJson ? decodeUnicodeEscapesOnly(stringifiedJson, true) : data
}
- className={cn("h-full w-full self-stretch", className)}
+ className={cn(
+ "h-full w-full self-stretch overflow-hidden rounded-sm",
+ className,
+ )}
codeClassName={cn("min-h-0 h-full overflow-y-auto", paddingClassName)}
collapseStringsAfterLength={null} // in table, show full strings as row height is fixed
borderless
@@ -104,7 +110,7 @@ export const IOTableCell = ({
borderless
numRows={singleLine ? 1 : undefined}
className={cn(
- "h-full w-full overflow-hidden",
+ "h-full w-full overflow-hidden rounded-sm",
paddingClassName,
className,
)}
diff --git a/web/src/features/events/components/EventsTable.tsx b/web/src/features/events/components/EventsTable.tsx
index 5c04da3103..4609dccdc3 100644
--- a/web/src/features/events/components/EventsTable.tsx
+++ b/web/src/features/events/components/EventsTable.tsx
@@ -51,8 +51,8 @@ import { usePeekTableState } from "@/src/components/table/peek/contexts/PeekTabl
import useColumnOrder from "@/src/features/column-visibility/hooks/useColumnOrder";
import { BatchExportTableButton } from "@/src/components/BatchExportTableButton";
import { BreakdownTooltip } from "@/src/components/trace/components/_shared/BreakdownToolTip";
-import { InfoIcon, LightbulbIcon, PlusCircle } from "lucide-react";
-import { UpsertModelFormDialog } from "@/src/features/models/components/UpsertModelFormDialog";
+import { InfoIcon, LightbulbIcon } from "lucide-react";
+import { ProvidedModelNameCell } from "@/src/features/models/components/ProvidedModelNameCell";
import { LocalIsoDate } from "@/src/components/LocalIsoDate";
import { Badge } from "@/src/components/ui/badge";
import { type RowSelectionState } from "@tanstack/react-table";
@@ -1161,36 +1161,13 @@ export default function ObservationsEventsTable({
const model = row.getValue("providedModelName") as string;
const modelId = row.getValue("modelId") as string | undefined;
- if (!model) return null;
-
- return modelId ? (
- <TableIdOrName value={model} />
- ) : (
- <UpsertModelFormDialog
- action="create"
+ return (
+ <ProvidedModelNameCell
+ modelName={model}
+ modelId={modelId}
projectId={projectId}
- prefilledModelData={{
- modelName: model,
- prices:
- Object.keys(row.original.usageDetails).length > 0
- ? Object.keys(row.original.usageDetails)
- .filter((key) => key != "total")
- .reduce(
- (acc, key) => {
- acc[key] = 0.000001;
- return acc;
- },
- {} as Record<string, number>,
- )
- : undefined,
- }}
- className="cursor-pointer"
- >
- <span className="flex items-center gap-1">
- <span>{model}</span>
- <PlusCircle className="h-3 w-3" />
- </span>
- </UpsertModelFormDialog>
+ usageDetails={row.original.usageDetails}
+ />
);
},
},
diff --git a/web/src/features/folders/components/FolderBreadcrumbLink.tsx b/web/src/features/folders/components/FolderBreadcrumbLink.tsx
index 5729708a01..ccf7374f27 100644
--- a/web/src/features/folders/components/FolderBreadcrumbLink.tsx
+++ b/web/src/features/folders/components/FolderBreadcrumbLink.tsx
@@ -14,7 +14,7 @@ export const FolderBreadcrumbLink = ({
value={name} // To satisfy table-link, fallback
icon={
<div className="flex flex-row items-center gap-1">
- <Folder className="h-4 w-4" />
+ <Folder className="h-3.5 w-3.5 shrink-0" />
{name}
</div>
}
diff --git a/web/src/features/models/components/ProvidedModelNameCell.tsx b/web/src/features/models/components/ProvidedModelNameCell.tsx
new file mode 100644
index 0000000000..b03e113a3a
--- /dev/null
+++ b/web/src/features/models/components/ProvidedModelNameCell.tsx
@@ -0,0 +1,76 @@
+import { PlusCircle } from "lucide-react";
+import TableIdOrName from "@/src/components/table/table-id";
+import { UpsertModelFormDialog } from "@/src/features/models/components/UpsertModelFormDialog";
+
+/**
+ * Renders the "Provided Model Name" cell shared by the generations and events
+ * tables. When the model resolves to a definition it is a plain name; when it
+ * does not, the name carries a trailing "add model definition" affordance.
+ *
+ * Both states render the name through {@link TableIdOrName} so typography and
+ * vertical alignment stay identical row-to-row — the trailing icon is a
+ * `shrink-0` adornment that never shifts the text baseline. The trigger is a
+ * `role="button"` and stops click propagation so opening the dialog does not
+ * also open the table's peek view.
+ */
+export function ProvidedModelNameCell({
+ modelName,
+ modelId,
+ projectId,
+ usageDetails,
+}: {
+ modelName: string | undefined;
+ modelId: string | undefined;
+ projectId: string;
+ usageDetails: Record<string, number>;
+}) {
+ if (!modelName) return null;
+
+ // Both states wrap the name in the same inline-flex so the text sits at an
+ // identical baseline whether or not the trailing affordance is present.
+ if (modelId) {
+ return (
+ <span className="inline-flex max-w-full items-center">
+ <TableIdOrName value={modelName} className="min-w-0" />
+ </span>
+ );
+ }
+
+ const prices =
+ Object.keys(usageDetails).length > 0
+ ? Object.keys(usageDetails)
+ .filter((key) => key !== "total")
+ .reduce(
+ (acc, key) => {
+ acc[key] = 0.000001;
+ return acc;
+ },
+ {} as Record<string, number>,
+ )
+ : undefined;
+
+ return (
+ <UpsertModelFormDialog
+ action="create"
+ projectId={projectId}
+ prefilledModelData={{ modelName, prices }}
+ className="cursor-pointer"
+ >
+ {/*
+ Native <button> (not a styled span): DialogTrigger's Slot only forwards
+ onClick, so Enter/Space activation must come from the element itself.
+ A real button also matches the table row's interactive-skip selector, so
+ activating it never opens the row's peek view.
+ */}
+ <button
+ type="button"
+ title={`Add a model definition for "${modelName}"`}
+ onClick={(e) => e.stopPropagation()}
+ className="inline-flex max-w-full cursor-pointer items-center gap-1 text-left"
+ >
+ <TableIdOrName value={modelName} className="min-w-0" />
+ <PlusCircle className="h-3.5 w-3.5 shrink-0" />
+ </button>
+ </UpsertModelFormDialog>
+ );
+}