Skip to content

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

fix(table): make experiments metadata column resizable (#14512)

Nikita Kabardin015464342f10
diff --git a/web/src/components/table/data-table.tsx b/web/src/components/table/data-table.tsx
index 4af7c9cafe..1520f2594a 100644
--- a/web/src/components/table/data-table.tsx
+++ b/web/src/components/table/data-table.tsx
@@ -351,7 +351,12 @@ export function DataTable<TData extends object, TValue>({
)}
>
<div
- className="relative min-h-full w-full overflow-auto border-t"
+ // pr-2 + scrollbar-gutter:stable reserve a small gutter on the right so the
+ // last column's resize handle is never flush against the scrollbar/edge and
+ // always has some cursor room. Partial mitigation for LFE-10460: a maximized
+ // browser still clamps the cursor at the screen edge, so this guarantees room
+ // to the right, not a complete fix.
+ className="relative min-h-full w-full overflow-auto border-t pr-2 [scrollbar-gutter:stable]"
style={{ ...columnSizeVars }}
>
<Table>
diff --git a/web/src/components/table/table-view-presets/hooks/useTableViewManager.ts b/web/src/components/table/table-view-presets/hooks/useTableViewManager.ts
index 3c23d70ef5..c321338e97 100644
--- a/web/src/components/table/table-view-presets/hooks/useTableViewManager.ts
+++ b/web/src/components/table/table-view-presets/hooks/useTableViewManager.ts
@@ -38,6 +38,13 @@ interface UseTableStateProps {
filterColumnDefinition?: ColumnDefinition[];
expandableFilterColumns?: string[];
migrateFilterState?: FilterStateMigration;
+ /**
+ * Runs on a persisted saved-view `columnOrder` before it is applied, so a
+ * table whose default column position changed can reposition a stale column
+ * in pre-PR view payloads (mirrors `migrateFilterState`). Must be a pure
+ * transform; return the input unchanged to leave the order untouched.
+ */
+ migrateColumnOrder?: (columnOrder: string[]) => string[];
};
currentFilterState?: FilterState;
currentExpandedFilters?: string[];
@@ -311,8 +318,18 @@ export function useTableViewManager({
setSearchQueryRef.current(viewData.searchQuery || null);
}
- // Apply column order and visibility without validation since UI will handle gracefully
- if (viewData.columnOrder) setColumnOrder(viewData.columnOrder);
+ // Apply column order and visibility without validation since UI will handle gracefully.
+ // A saved view persists its own columnOrder snapshot, so a pre-PR view can
+ // re-introduce a stale column position even after the localStorage migration
+ // has run (the migration is one-shot and this is a separate persistence path).
+ // Run the table's opt-in columnOrder migration on the payload first so the
+ // same "only reposition a stale default" rule applies here too.
+ if (viewData.columnOrder) {
+ const migratedColumnOrder = validationContext.migrateColumnOrder
+ ? validationContext.migrateColumnOrder(viewData.columnOrder)
+ : viewData.columnOrder;
+ setColumnOrder(migratedColumnOrder);
+ }
if (viewData.columnVisibility)
setColumnVisibility(viewData.columnVisibility);
diff --git a/web/src/features/column-visibility/hooks/useColumnOrder.ts b/web/src/features/column-visibility/hooks/useColumnOrder.ts
index bb5750341d..35843e3584 100644
--- a/web/src/features/column-visibility/hooks/useColumnOrder.ts
+++ b/web/src/features/column-visibility/hooks/useColumnOrder.ts
@@ -16,9 +16,59 @@ const readStoredColumnOrder = (localStorageKey: string): string[] => {
}
};
+/**
+ * A one-time, opt-in transform of the persisted column order. Use it when a
+ * table changes its *default* column position: the reconciliation in
+ * `useColumnOrder` only splices in column IDs that are new to the app, so it
+ * never repositions a column that already exists in a returning user's stored
+ * order. A migration lets a specific table reposition such a column exactly
+ * once, guarded by `versionKey` so it never re-fights a user who later moves
+ * the column themselves.
+ *
+ * Migrations are entirely opt-in (passed per-call): tables that omit them keep
+ * the previous behavior byte-for-byte.
+ */
+export type ColumnOrderMigration = {
+ /**
+ * localStorage key for the one-time guard flag. Should be unique per table +
+ * migration, e.g. `experimentsColumnOrder-metadataReorder-v1-${projectId}`.
+ */
+ versionKey: string;
+ /**
+ * Pure transform applied to the reconciled column order. Must not mutate its
+ * input. Return the input unchanged to skip (the flag is still set so it does
+ * not retry on every mount).
+ */
+ apply: (columnOrder: string[]) => string[];
+};
+
+const hasRunMigration = (versionKey: string): boolean => {
+ if (typeof window === "undefined") {
+ return true; // never run migrations server-side
+ }
+ try {
+ return localStorage.getItem(versionKey) !== null;
+ } catch (error) {
+ console.error("Error reading migration flag from local storage", error);
+ return true;
+ }
+};
+
+const markMigrationRun = (versionKey: string): void => {
+ if (typeof window === "undefined") {
+ return;
+ }
+ try {
+ localStorage.setItem(versionKey, "1");
+ } catch (error) {
+ console.error("Error writing migration flag to local storage", error);
+ }
+};
+
function useColumnOrder<TData>(
localStorageKey: string,
columns: LangfuseColumnDef<TData>[],
+ migrations?: ColumnOrderMigration[],
) {
const [columnOrder, setColumnOrder] = useLocalStorage<string[]>(
localStorageKey,
@@ -29,7 +79,7 @@ function useColumnOrder<TData>(
const appColumnIds = columns.map((c) => c.accessorKey);
const storedColumnIds = readStoredColumnOrder(localStorageKey);
- const finalColumnOrder: string[] = storedColumnIds.filter((id) =>
+ let finalColumnOrder: string[] = storedColumnIds.filter((id) =>
appColumnIds.includes(id),
);
@@ -39,11 +89,20 @@ function useColumnOrder<TData>(
}
});
+ // Apply any opt-in one-time migrations (e.g. repositioning a column whose
+ // default slot changed). Each runs at most once, guarded by its versionKey.
+ migrations?.forEach((migration) => {
+ if (!hasRunMigration(migration.versionKey)) {
+ finalColumnOrder = migration.apply(finalColumnOrder);
+ markMigrationRun(migration.versionKey);
+ }
+ });
+
// Compare the new order with the current order to avoid unnecessary updates
if (JSON.stringify(finalColumnOrder) !== JSON.stringify(columnOrder)) {
setColumnOrder(finalColumnOrder);
}
- }, [columns, localStorageKey, columnOrder, setColumnOrder]);
+ }, [columns, localStorageKey, columnOrder, setColumnOrder, migrations]);
return [columnOrder, setColumnOrder] as const;
}
diff --git a/web/src/features/experiments/components/table/ExperimentsTable.tsx b/web/src/features/experiments/components/table/ExperimentsTable.tsx
index 38dabf1d86..e548971fc5 100644
--- a/web/src/features/experiments/components/table/ExperimentsTable.tsx
+++ b/web/src/features/experiments/components/table/ExperimentsTable.tsx
@@ -62,6 +62,32 @@ import {
import { ExperimentChartsGrid } from "../ExperimentChartsGrid";
import { useExperimentChartsAccordion } from "../../hooks/useExperimentChartsAccordion";
+/**
+ * LFE-10460: the metadata column's default position moved from last to right
+ * after `description`. Both persistence paths (localStorage replay and saved
+ * table views) snapshot the pre-PR order with metadata trailing, so this pure
+ * transform repositions it to its new default slot ONLY when it is currently
+ * the last column (the stale pre-PR default). If a user has manually moved
+ * metadata anywhere else, their layout is left untouched.
+ *
+ * Reused as both the one-time `useColumnOrder` migration (localStorage path)
+ * and the `migrateColumnOrder` transform on saved-view payloads.
+ */
+const repositionTrailingMetadata = (order: string[]): string[] => {
+ const lastIndex = order.length - 1;
+ // Only act on the stale default: metadata sitting as the last column.
+ if (order[lastIndex] !== "metadata") return order;
+ // New default slot: immediately after the `description` column, matching the
+ // JS column definition (select, name, description, metadata...).
+ const descriptionIndex = order.indexOf("description");
+ const targetIndex = descriptionIndex === -1 ? 0 : descriptionIndex + 1;
+ if (targetIndex === lastIndex) return order; // already in place
+ const next = [...order];
+ next.splice(lastIndex, 1); // remove trailing metadata
+ next.splice(targetIndex, 0, "metadata"); // insert at new default slot
+ return next;
+};
+
export default function ExperimentsTable({
projectId,
defaultFilter,
@@ -287,6 +313,21 @@ export default function ExperimentsTable({
) : undefined;
},
},
+ {
+ // Placed here (right after the identifying name/description columns) rather
+ // than last so it is never the trailing column. As the last column its right
+ // resize handle sat flush against the table edge and could not be dragged
+ // wider in a maximized browser (LFE-10460).
+ accessorKey: "metadata",
+ id: "metadata",
+ header: getExperimentsColumnName("metadata"),
+ size: 100,
+ enableHiding: true,
+ cell: ({ row }) => {
+ const value: Record<string, string> = row.getValue("metadata");
+ return <IOTableCell data={value} singleLine={rowHeight === "s"} />;
+ },
+ },
{
accessorKey: "itemCount",
id: "itemCount",
@@ -460,17 +501,6 @@ export default function ExperimentsTable({
},
columns: experimentScoreColumns,
},
- {
- accessorKey: "metadata",
- id: "metadata",
- header: getExperimentsColumnName("metadata"),
- size: 100,
- enableHiding: true,
- cell: ({ row }) => {
- const value: Record<string, string> = row.getValue("metadata");
- return <IOTableCell data={value} singleLine={rowHeight === "s"} />;
- },
- },
];
const [columnVisibility, setColumnVisibilityState] =
@@ -479,9 +509,28 @@ export default function ExperimentsTable({
columns,
);
+ // One-time migration for LFE-10460 on the localStorage replay path:
+ // useColumnOrder replays a returning user's stored order verbatim and never
+ // repositions an existing column, so without this metadata would stay the
+ // trailing column and the resize bug would persist. Guarded by a version flag
+ // so it runs once (won't re-fight a user who later moves metadata themselves).
+ // The saved-view persistence path is covered separately via
+ // `validationContext.migrateColumnOrder` below — both reuse
+ // `repositionTrailingMetadata`.
+ const columnOrderMigrations = useMemo(
+ () => [
+ {
+ versionKey: `experimentsColumnOrder-metadataReorder-v1-${projectId}`,
+ apply: repositionTrailingMetadata,
+ },
+ ],
+ [projectId],
+ );
+
const [columnOrder, setColumnOrder] = useColumnOrder<ExperimentsTableRow>(
`experimentsColumnOrder-${projectId}`,
columns,
+ columnOrderMigrations,
);
const { isLoading: isViewLoading, ...viewControllers } = useTableViewManager({
@@ -498,6 +547,11 @@ export default function ExperimentsTable({
columns,
filterColumnDefinition: filterConfig.columnDefinitions,
expandableFilterColumns: filterConfig.facets.map((facet) => facet.column),
+ // A pre-PR saved view persists its own metadata-last column order, which
+ // would otherwise re-introduce LFE-10460 after applying the view (the
+ // localStorage migration is one-shot and doesn't reach this path). Reuse
+ // the same "only reposition a stale default" transform here.
+ migrateColumnOrder: repositionTrailingMetadata,
},
currentFilterState: queryFilter.explicitFilterState,
currentExpandedFilters: queryFilter.expanded,