Skip to content

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

feat(tables): let rows use a custom height (#18445)

Nikita Kabardina1ade6eb7286
diff --git a/.agents/skills/seed-test-data/SKILL.md b/.agents/skills/seed-test-data/SKILL.md
index 2f64cb5484..e2cbf4ffda 100644
--- a/.agents/skills/seed-test-data/SKILL.md
+++ b/.agents/skills/seed-test-data/SKILL.md
@@ -61,8 +61,10 @@ this.
For a v4 experiment with chat messages and nested JSON input/output, run
`pnpm run seed -- experiment-io`. It creates one dataset, one experiment, and
-three items, then prints the experiment results link. Set `NEXTAUTH_URL` to
-your local app URL when using a port other than 3000.
+three items, then prints the experiment results link. Add `--compare` for a
+second run on that dataset whose chat output is long enough to need a taller
+comparison row. Set `NEXTAUTH_URL` to your local app URL when using a port
+other than 3000.
For Topics discovery and later assignment, run `pnpm run seed -- topics`.
For the 100-trace Intent/Issues evaluation, run
diff --git a/packages/shared/scripts/seeder/AGENTS.md b/packages/shared/scripts/seeder/AGENTS.md
index 4bc4bda781..37dbe8316b 100644
--- a/packages/shared/scripts/seeder/AGENTS.md
+++ b/packages/shared/scripts/seeder/AGENTS.md
@@ -32,6 +32,7 @@ pnpm run seed -- topics --batch all # 12 discovery + 3 assignment traces for To
pnpm run seed -- topics --batch evaluation --id-prefix topics-eval-s42 # 100 diverse requests, tool failures and successful outcomes
pnpm run seed -- custom-models --v4 # project-level model definitions (tiered + single-tier, one price at 0) + a trace whose generations link to them, plus one unpriced model
pnpm run seed -- experiment-io # one v4 experiment with three chat/nested JSON items for the Formatted/JSON switch
+pnpm run seed -- experiment-io --compare # same dataset plus a second run with a long chat output, for the comparison table
NEXTAUTH_URL=https://pr-<N>.preview.langfuse.com pnpm run seed -- evaluator-gallery --count 200 # project-owned evaluators via the seeded public API key
```
diff --git a/packages/shared/scripts/seeder/scenarios/experiment-io.ts b/packages/shared/scripts/seeder/scenarios/experiment-io.ts
index 73264995c8..47d4ff85ac 100644
--- a/packages/shared/scripts/seeder/scenarios/experiment-io.ts
+++ b/packages/shared/scripts/seeder/scenarios/experiment-io.ts
@@ -73,6 +73,31 @@ const ITEMS: {
},
];
+/** Long enough that the Large preset still clips it, short of the 1000-character list truncation. */
+const LONG_CHAT_OUTPUT = [
+ {
+ role: "assistant",
+ content: [
+ "## Hiking checklist",
+ "",
+ "A weekend in the hills needs more than a water bottle. Pack this before you leave, then read it once more at the trailhead. The point of writing it down is that you can check every line without opening another screen.",
+ "",
+ "- Bring two liters of water and a salty snack.",
+ "- Download the map while you still have a signal.",
+ "- Pack a rain jacket even when the morning looks clear.",
+ "- Tell someone your route and when you expect to be back.",
+ "- Wear boots you have already walked in.",
+ "- Carry a small light in case the return runs long.",
+ "- Keep a spare layer at the top of the bag.",
+ "- Turn back if the weather changes faster than the forecast.",
+ "- Leave the summit when you still have daylight for the descent.",
+ "- Note the last water source on the way up, not on the way down.",
+ "- Start down while you can still see the trail markers.",
+ "- Empty your pockets of trash before you reach the car.",
+ ].join("\n"),
+ },
+];
+
export const experimentIoScenario: ScenarioDefinition = {
name: "experiment-io",
description:
@@ -85,29 +110,57 @@ export const experimentIoScenario: ScenarioDefinition = {
default: true,
description: "write v4 events (required by experiment results)",
},
+ {
+ flag: "compare",
+ type: "boolean",
+ default: false,
+ description:
+ "write a second run on the same dataset whose chat output is long enough to need a taller comparison row",
+ },
],
run: async (ctx, params): Promise<SeedSummary> => {
const startedAt = Date.now();
const timestamp = utcDayStartMs();
+ const compare = params.compare === true;
const datasetId = `${ctx.idPrefix}-dataset`;
const experimentId = `${ctx.idPrefix}-experiment`;
+ const comparisonExperimentId = `${ctx.idPrefix}-experiment-b`;
const experimentName = `Structured I/O (${ctx.idPrefix})`;
- const traceIds = ITEMS.map((item) => `${ctx.idPrefix}-trace-${item.name}`);
+ const runs = compare
+ ? [
+ { id: experimentId, name: experimentName },
+ {
+ id: comparisonExperimentId,
+ name: `${experimentName} long output`,
+ },
+ ]
+ : [{ id: experimentId, name: experimentName }];
+ const traceIds = runs.flatMap((_, runIndex) =>
+ ITEMS.map(
+ (item) =>
+ `${ctx.idPrefix}-trace-${runIndex === 0 ? "" : "b-"}${item.name}`,
+ ),
+ );
// A fixed version lets re-runs update these synthetic items in place.
const validFrom = new Date(0);
const counts = {
datasets: 1,
- experiments: 1,
+ experiments: runs.length,
datasetItems: ITEMS.length,
- events: ITEMS.length,
+ events: ITEMS.length * runs.length,
};
+ const baselineId = compare ? comparisonExperimentId : experimentId;
const links = [
- `${ctx.baseUrl}/project/${ctx.projectId}/experiments/results?baseline=${encodeURIComponent(experimentId)}`,
+ `${ctx.baseUrl}/project/${ctx.projectId}/experiments/results?baseline=${encodeURIComponent(baselineId)}${compare ? `&c=${encodeURIComponent(experimentId)}&layout=grid` : ""}`,
];
const verified: Record<string, number> = {};
if (!ctx.dryRun) {
- ctx.log("writing one experiment with three structured I/O items");
+ ctx.log(
+ compare
+ ? "writing two experiments on one dataset, one with a long chat output"
+ : "writing one experiment with three structured I/O items",
+ );
await prisma.$transaction(async (tx) => {
const dataset = {
id: datasetId,
@@ -120,19 +173,21 @@ export const experimentIoScenario: ScenarioDefinition = {
create: dataset,
update: dataset,
});
- const experiment = {
- id: experimentId,
- projectId: ctx.projectId,
- datasetId,
- name: experimentName,
- };
- await tx.datasetRuns.upsert({
- where: {
- id_projectId: { id: experimentId, projectId: ctx.projectId },
- },
- create: experiment,
- update: experiment,
- });
+ for (const run of runs) {
+ const experiment = {
+ id: run.id,
+ projectId: ctx.projectId,
+ datasetId,
+ name: run.name,
+ };
+ await tx.datasetRuns.upsert({
+ where: {
+ id_projectId: { id: run.id, projectId: ctx.projectId },
+ },
+ create: experiment,
+ update: experiment,
+ });
+ }
for (const item of ITEMS) {
const data = {
id: `${ctx.idPrefix}-item-${item.name}`,
@@ -156,59 +211,76 @@ export const experimentIoScenario: ScenarioDefinition = {
}
});
- const events = ITEMS.map((item, index) => {
- const spanId = `${ctx.idPrefix}-span-${item.name}`;
- const input = JSON.stringify(item.input);
- const output = JSON.stringify(item.output);
- const startTime =
- timestamp + index * 1000 + jitter(ctx.seed, index, 100);
- return createEvent({
- id: spanId,
- span_id: spanId,
- trace_id: traceIds[index],
- parent_span_id: "",
- project_id: ctx.projectId,
- environment: ctx.environment,
- name: `experiment-io-${item.name}`,
- trace_name: `experiment-io-${item.name}`,
- type: "SPAN",
- input,
- output,
- provided_model_name: null,
- provided_usage_details: {},
- usage_details: {},
- provided_cost_details: {},
- cost_details: {},
- experiment_id: experimentId,
- experiment_name: experimentName,
- experiment_dataset_id: datasetId,
- experiment_item_id: `${ctx.idPrefix}-item-${item.name}`,
- experiment_item_version: toClickhouseDateTime(validFrom),
- experiment_item_root_span_id: spanId,
- experiment_item_expected_output: JSON.stringify(item.expectedOutput),
- start_time: startTime,
- end_time: startTime + 500,
- created_at: startTime,
- updated_at: startTime,
- event_ts: startTime,
- event_bytes: Buffer.byteLength(input) + Buffer.byteLength(output),
- });
- });
+ const events = runs.flatMap((run, runIndex) =>
+ ITEMS.map((item, index) => {
+ const spanId = `${ctx.idPrefix}-span-${runIndex === 0 ? "" : "b-"}${item.name}`;
+ const input = JSON.stringify(item.input);
+ const output = JSON.stringify(
+ compare && runIndex === 1 && item.name === "chat"
+ ? LONG_CHAT_OUTPUT
+ : item.output,
+ );
+ const startTime =
+ timestamp +
+ runIndex * 60_000 +
+ index * 1000 +
+ jitter(ctx.seed, runIndex * ITEMS.length + index, 100);
+ return createEvent({
+ id: spanId,
+ span_id: spanId,
+ trace_id: traceIds[runIndex * ITEMS.length + index],
+ parent_span_id: "",
+ project_id: ctx.projectId,
+ environment: ctx.environment,
+ name: `experiment-io-${item.name}`,
+ trace_name: `experiment-io-${item.name}`,
+ type: "SPAN",
+ input,
+ output,
+ provided_model_name: null,
+ provided_usage_details: {},
+ usage_details: {},
+ provided_cost_details: {},
+ cost_details: {},
+ experiment_id: run.id,
+ experiment_name: run.name,
+ experiment_dataset_id: datasetId,
+ experiment_item_id: `${ctx.idPrefix}-item-${item.name}`,
+ experiment_item_version: toClickhouseDateTime(validFrom),
+ experiment_item_root_span_id: spanId,
+ experiment_item_expected_output: JSON.stringify(
+ item.expectedOutput,
+ ),
+ start_time: startTime,
+ end_time: startTime + 500,
+ created_at: startTime,
+ updated_at: startTime,
+ event_ts: startTime,
+ event_bytes: Buffer.byteLength(input) + Buffer.byteLength(output),
+ });
+ }),
+ );
await createEventsCh(events);
verified.datasets = await prisma.dataset.count({
where: { id: datasetId, projectId: ctx.projectId },
});
verified.experiments = await prisma.datasetRuns.count({
- where: { id: experimentId, projectId: ctx.projectId },
+ where: {
+ id: { in: runs.map((run) => run.id) },
+ projectId: ctx.projectId,
+ },
});
verified.datasetItems = await prisma.datasetItem.count({
where: { datasetId, projectId: ctx.projectId, validFrom },
});
verified.events = await countRows(
"events_full",
- "project_id = {projectId: String} AND experiment_id = {experimentId: String} AND span_id = experiment_item_root_span_id AND isValidJSON(input) AND isValidJSON(output)",
- { projectId: ctx.projectId, experimentId },
+ "project_id = {projectId: String} AND experiment_id IN {experimentIds: Array(String)} AND span_id = experiment_item_root_span_id AND isValidJSON(input) AND isValidJSON(output)",
+ {
+ projectId: ctx.projectId,
+ experimentIds: runs.map((run) => run.id),
+ },
"uniqExact(span_id)",
);
for (const [entity, expected] of Object.entries(counts)) {
diff --git a/packages/shared/src/server/repositories/experiments.ts b/packages/shared/src/server/repositories/experiments.ts
index c1f15172c3..75d4a399ed 100644
--- a/packages/shared/src/server/repositories/experiments.ts
+++ b/packages/shared/src/server/repositories/experiments.ts
@@ -1424,16 +1424,36 @@ export type ExperimentItemBatchIO = {
outputs: ExperimentOutputData[]; // From ALL experiments
};
+/** Upper bound for an explicit experiment I/O read. Matches the events batch. */
+const MAX_EXPERIMENT_BATCH_IO_CHAR_LIMIT = 10_000;
+
+/**
+ * Positive integer char cap for an expanded read, or undefined when the caller
+ * wants the default pre-truncated table.
+ */
+const expandedIoCharLimit = (limit: number | undefined): number | undefined => {
+ if (limit === undefined || !Number.isFinite(limit)) return undefined;
+ return Math.min(
+ MAX_EXPERIMENT_BATCH_IO_CHAR_LIMIT,
+ Math.max(1, Math.trunc(limit)),
+ );
+};
+
/**
* Get batch IO data for experiment items.
* Returns input/expectedOutput from base experiment, and output from all experiments.
- * All text fields are truncated to EXPERIMENT_IO_TRUNCATE_LENGTH characters.
+ *
+ * Without `ioCharLimit`, input and output come from the pre-truncated events
+ * table and expected output is capped at EXPERIMENT_IO_TRUNCATE_LENGTH. With
+ * `ioCharLimit`, all three fields are read from the full event text and capped
+ * at that many characters.
*/
export const getExperimentItemsBatchIO = async (props: {
projectId: string;
itemIds: string[];
baseExperimentId?: string;
compExperimentIds: string[];
+ ioCharLimit?: number;
}): Promise<ExperimentItemBatchIO[]> => {
const { projectId, itemIds, baseExperimentId, compExperimentIds } = props;
@@ -1446,12 +1466,19 @@ export const getExperimentItemsBatchIO = async (props: {
...compExperimentIds,
];
+ const expandedLimit = expandedIoCharLimit(props.ioCharLimit);
const queryBuilder = eventsExperimentsRootSpans({
projectId,
experimentIds: allExperimentIds,
experimentItemIds: itemIds,
- })
- .selectIO(true, env.LANGFUSE_SERVER_SIDE_IO_CHAR_LIMIT)
+ });
+ if (expandedLimit !== undefined) {
+ // The pre-truncated table only keeps a short head of input and output, so
+ // a taller row has to read the full event text before applying its cap.
+ queryBuilder.forceFullTable();
+ }
+ queryBuilder
+ .selectIO(true, expandedLimit ?? env.LANGFUSE_SERVER_SIDE_IO_CHAR_LIMIT)
.selectRaw(
"leftUTF8(e.experiment_item_expected_output, {truncateLength: UInt32}) as expected_output",
"e.experiment_item_id as item_id",
@@ -1473,7 +1500,7 @@ export const getExperimentItemsBatchIO = async (props: {
query,
params: {
...params,
- truncateLength: EXPERIMENT_IO_TRUNCATE_LENGTH,
+ truncateLength: expandedLimit ?? EXPERIMENT_IO_TRUNCATE_LENGTH,
},
tags: { projectId },
preferredClickhouseService: "EventsReadOnly",
diff --git a/web/src/__tests__/server/repositories/experiment-items-repository.servertest.ts b/web/src/__tests__/server/repositories/experiment-items-repository.servertest.ts
index 5e15f5144c..75e7e4e3bf 100644
--- a/web/src/__tests__/server/repositories/experiment-items-repository.servertest.ts
+++ b/web/src/__tests__/server/repositories/experiment-items-repository.servertest.ts
@@ -1628,6 +1628,68 @@ describe("Clickhouse Experiment Items Repository Test", () => {
).toBe(true);
});
+ it("reads past the preview when an expanded char limit is requested", async () => {
+ // The default read stays on the pre-truncated table, which is not enough
+ // to fill a tall comparison row. An explicit limit has to come back from
+ // the full event text, capped at the requested length.
+ const baselineExpId = randomUUID();
+ const datasetId = randomUUID();
+ const itemId = randomUUID();
+ const rootId = randomUUID();
+
+ const longInput = "A".repeat(2000);
+ const longExpectedOutput = "B".repeat(2000);
+ const longOutput = "C".repeat(2000);
+
+ await createEventsCh([
+ createExperimentEvent({
+ project_id: projectId,
+ trace_id: randomUUID(),
+ span_id: rootId,
+ experimentId: baselineExpId,
+ experimentName: "baseline-exp",
+ datasetId,
+ itemId,
+ experimentItemRootSpanId: rootId,
+ input: longInput,
+ experiment_item_expected_output: longExpectedOutput,
+ output: longOutput,
+ start_time: Date.now() * 1000,
+ }),
+ ]);
+
+ const preview = await getExperimentItemsBatchIO({
+ projectId,
+ itemIds: [itemId],
+ baseExperimentId: baselineExpId,
+ compExperimentIds: [],
+ });
+ expect(preview[0].input!.length).toBeLessThan(2000);
+ expect(preview[0].outputs[0].output!.length).toBeLessThan(2000);
+
+ const expanded = await getExperimentItemsBatchIO({
+ projectId,
+ itemIds: [itemId],
+ baseExperimentId: baselineExpId,
+ compExperimentIds: [],
+ ioCharLimit: 2000,
+ });
+ expect(expanded[0].input).toBe(longInput);
+ expect(expanded[0].expectedOutput).toBe(longExpectedOutput);
+ expect(expanded[0].outputs[0].output).toBe(longOutput);
+
+ const capped = await getExperimentItemsBatchIO({
+ projectId,
+ itemIds: [itemId],
+ baseExperimentId: baselineExpId,
+ compExperimentIds: [],
+ ioCharLimit: 500,
+ });
+ expect(capped[0].input).toHaveLength(500);
+ expect(capped[0].expectedOutput).toHaveLength(500);
+ expect(capped[0].outputs[0].output).toHaveLength(500);
+ });
+
it("passes a payload of the four characters null through untouched", async () => {
// A native experiment writes I/O through stringifyValue, which returns a
// string unchanged — so an expected output that legitimately IS the
diff --git a/web/src/components/design-system/table/columns/createIOTableColumn.stories.tsx b/web/src/components/design-system/table/columns/createIOTableColumn.stories.tsx
index 39ffc06507..341caa1854 100644
--- a/web/src/components/design-system/table/columns/createIOTableColumn.stories.tsx
+++ b/web/src/components/design-system/table/columns/createIOTableColumn.stories.tsx
@@ -66,6 +66,9 @@ function IOTableColumnStory({
data={data}
hidePagination
cellPadding="none"
+ // Inside a data table the row height decides single-line vs JSON.
+ // Large is this table's expanded height, so the multi-line story stays a preview.
+ rowHeight={config.singleLine ? "s" : "l"}
/>
);
}
diff --git a/web/src/components/design-system/table/columns/createIOTableColumn.tsx b/web/src/components/design-system/table/columns/createIOTableColumn.tsx
index 8d8cd55b2e..74e113f1c2 100644
--- a/web/src/components/design-system/table/columns/createIOTableColumn.tsx
+++ b/web/src/components/design-system/table/columns/createIOTableColumn.tsx
@@ -7,6 +7,7 @@ import {
type IOTableCellVariant,
} from "@/src/components/design-system/table/components/IOTableCell/IOTableCell";
import { ConnectedIOTableCell } from "@/src/components/table/ConnectedIOTableCell";
+import { useBoundRowHeightIO } from "@/src/components/table/data-table-row-height-switch";
import { type DataTableCellBackground } from "@/src/components/table/types";
import {
createTableColumn,
@@ -21,9 +22,71 @@ const ioCellBackgrounds = {
output: "green",
} satisfies Record<IOTableCellVariant, DataTableCellBackground | undefined>;
+function IOColumnCell({
+ compact = false,
+ data,
+ enableExpandOnHover = false,
+ followRowHeight = true,
+ isLoading = false,
+ renderMediaReference,
+ singleLine = false,
+}: {
+ compact?: boolean;
+ data?: unknown;
+ enableExpandOnHover?: boolean;
+ followRowHeight?: boolean;
+ isLoading?: boolean;
+ renderMediaReference?: IOTableCellMediaRenderer;
+ singleLine?: boolean;
+}) {
+ // The column paints input/output color on the table cell. The inner preview
+ // stays uncolored so the two backgrounds do not stack.
+ const bound = useBoundRowHeightIO(
+ followRowHeight,
+ singleLine,
+ enableExpandOnHover,
+ );
+ const cellProps = {
+ enableExpandOnHover: bound.enableExpandOnHover,
+ singleLine: bound.singleLine,
+ size: compact ? ("compact" as const) : ("default" as const),
+ };
+
+ if (renderMediaReference) {
+ return isLoading ? (
+ <IOTableCell
+ {...cellProps}
+ isLoading
+ renderMediaReference={renderMediaReference}
+ />
+ ) : (
+ <IOTableCell
+ {...cellProps}
+ data={data}
+ renderMediaReference={renderMediaReference}
+ />
+ );
+ }
+
+ return isLoading ? (
+ <ConnectedIOTableCell
+ {...cellProps}
+ followRowHeight={followRowHeight}
+ isLoading
+ />
+ ) : (
+ <ConnectedIOTableCell
+ {...cellProps}
+ data={data}
+ followRowHeight={followRowHeight}
+ />
+ );
+}
+
export function createIOTableColumn<TData extends RowData, TValue = unknown>({
compact = false,
enableExpandOnHover = false,
+ followRowHeight = true,
getCell,
renderMediaReference,
singleLine = false,
@@ -33,29 +96,32 @@ export function createIOTableColumn<TData extends RowData, TValue = unknown>({
cellBackground?: never;
compact?: boolean;
enableExpandOnHover?: boolean;
+ /**
+ * Defaults to true: a data table's row height chooses text vs the JSON
+ * preview, including while a drag is in progress. Pass false to keep
+ * `singleLine` in charge inside a data table. Outside a data table,
+ * `singleLine` is used either way. `enableExpandOnHover` applies only
+ * while the row is compact.
+ */
+ followRowHeight?: boolean;
getCell?: (
value: TValue | null | undefined,
context: CellContext<TData, TValue | null | undefined>,
) => IOTableColumnCell<TValue>;
renderMediaReference?: IOTableCellMediaRenderer;
+ /** Fallback when the cell is outside a data table, or when `followRowHeight` is false. */
singleLine?: boolean;
variant?: IOTableCellVariant;
}) {
const cellProps = {
+ compact,
enableExpandOnHover,
+ followRowHeight,
+ renderMediaReference,
singleLine,
- size: compact ? ("compact" as const) : ("default" as const),
};
- const loadingCell = renderMediaReference ? (
- <IOTableCell
- {...cellProps}
- isLoading
- renderMediaReference={renderMediaReference}
- />
- ) : (
- <ConnectedIOTableCell {...cellProps} isLoading />
- );
+ const loadingCell = <IOColumnCell {...cellProps} isLoading />;
return createTableColumn<TData, TValue>({
...options,
@@ -84,15 +150,7 @@ export function createIOTableColumn<TData extends RowData, TValue = unknown>({
// An empty `cell` is passed through rather than short-circuited to a
// blank: the cell owns what "empty" looks like, so every table that uses
// it shows the same placeholder.
- return renderMediaReference ? (
- <IOTableCell
- {...cellProps}
- data={cell}
- renderMediaReference={renderMediaReference}
- />
- ) : (
- <ConnectedIOTableCell {...cellProps} data={cell} />
- );
+ return <IOColumnCell {...cellProps} data={cell} />;
},
});
}
diff --git a/web/src/components/design-system/table/columns/createTagsTableColumn.stories.tsx b/web/src/components/design-system/table/columns/createTagsTableColumn.stories.tsx
index 7c779aff11..3d67856a04 100644
--- a/web/src/components/design-system/table/columns/createTagsTableColumn.stories.tsx
+++ b/web/src/components/design-system/table/columns/createTagsTableColumn.stories.tsx
@@ -4,6 +4,7 @@ import {
DataTable,
type AsyncTableData,
} from "@/src/components/table/data-table";
+import { type RowHeight } from "@/src/components/table/data-table-row-height-switch";
import { createTagsTableColumn } from "./createTagsTableColumn";
type Row = {
@@ -26,6 +27,8 @@ function TagsTableColumnStory({
}),
];
+ // Inside a data table the row height decides wrapping. Large wraps; Small does not.
+ const rowHeight: RowHeight = shouldWrap ? "l" : "s";
return (
<DataTable
tableName="tags-column-story"
@@ -33,6 +36,7 @@ function TagsTableColumnStory({
data={data}
hidePagination
cellPadding="comfortable"
+ rowHeight={rowHeight}
/>
);
}
diff --git a/web/src/components/design-system/table/columns/createTagsTableColumn.tsx b/web/src/components/design-system/table/columns/createTagsTableColumn.tsx
index f6e7e4f2af..ed4d0fe435 100644
--- a/web/src/components/design-system/table/columns/createTagsTableColumn.tsx
+++ b/web/src/components/design-system/table/columns/createTagsTableColumn.tsx
@@ -2,6 +2,7 @@
import { type RowData } from "@tanstack/react-table";
import { Skeleton } from "@/src/components/ui/skeleton";
+import { useCompactRows } from "@/src/components/table/data-table-row-height-switch";
import { TagList } from "@/src/features/tag";
import { cn } from "@/src/utils/tailwind";
import {
@@ -9,10 +10,40 @@ import {
type TableColumnOptions,
} from "./utils/createTableColumn";
+function TagsCell({
+ followRowHeight,
+ shouldWrap,
+ tags,
+}: {
+ followRowHeight: boolean;
+ shouldWrap: boolean;
+ tags: string[];
+}) {
+ // Inside a data table the row height wins, including a drag still in
+ // progress. `shouldWrap` is the fallback when that context is absent,
+ // and the only value used when `followRowHeight` is false.
+ const compact = useCompactRows(!shouldWrap);
+ const wrap = followRowHeight ? !compact : shouldWrap;
+ return (
+ <div className={cn("flex gap-x-2 gap-y-1", wrap && "flex-wrap")}>
+ <TagList selectedTags={tags} isLoading={false} />
+ </div>
+ );
+}
+
export function createTagsTableColumn<TData extends RowData>({
+ followRowHeight = true,
shouldWrap,
...options
}: TableColumnOptions<TData, string[]> & {
+ /**
+ * Defaults to true: tags wrap once the row reaches that table's Medium
+ * height. Pass false to keep `shouldWrap` in charge inside a data table.
+ */
+ followRowHeight?: boolean;
+ /**
+ * Used outside a data table, and inside one when `followRowHeight` is false.
+ */
shouldWrap: boolean;
}) {
return createTableColumn<TData, string[]>({
@@ -20,9 +51,11 @@ export function createTagsTableColumn<TData extends RowData>({
loadingCell: <Skeleton className="h-4 w-1/2" />,
renderCell: (tags) =>
tags && tags.length > 0 ? (
- <div className={cn("flex gap-x-2 gap-y-1", shouldWrap && "flex-wrap")}>
- <TagList selectedTags={tags} isLoading={false} />
- </div>
+ <TagsCell
+ followRowHeight={followRowHeight}
+ shouldWrap={shouldWrap}
+ tags={tags}
+ />
) : null,
});
}
diff --git a/web/src/components/table/ConnectedIOTableCell.tsx b/web/src/components/table/ConnectedIOTableCell.tsx
index a403902c9a..bab8fcae2f 100644
--- a/web/src/components/table/ConnectedIOTableCell.tsx
+++ b/web/src/components/table/ConnectedIOTableCell.tsx
@@ -1,6 +1,7 @@
import { memo } from "react";
import { IOTableCell } from "@/src/components/design-system/table/components/IOTableCell/IOTableCell";
+import { useBoundRowHeightIO } from "@/src/components/table/data-table-row-height-switch";
import { MediaReferenceTag } from "@/src/components/ui/media/MediaReferenceTag";
import { type MediaDescriptor } from "@/src/components/ui/media/mediaUtils";
@@ -10,7 +11,14 @@ type WithoutMediaRenderer<Props> = Props extends unknown
type ConnectedIOTableCellProps = WithoutMediaRenderer<
Parameters<typeof IOTableCell>[0]
->;
+> & {
+ /**
+ * Follow the table's row height. Defaults to true. Pass false to keep
+ * `singleLine` in charge, including inside a data table. Outside a data
+ * table, `singleLine` is used either way.
+ */
+ followRowHeight?: boolean;
+};
const renderMediaReference = (descriptor: MediaDescriptor) => (
<MediaReferenceTag descriptor={descriptor} />
@@ -25,9 +33,14 @@ const renderMediaReference = (descriptor: MediaDescriptor) => (
export const ConnectedIOTableCell = memo(function ConnectedIOTableCell(
props: ConnectedIOTableCellProps,
) {
+ const bound = useBoundRowHeightIO(
+ props.followRowHeight ?? true,
+ props.singleLine,
+ props.enableExpandOnHover,
+ );
const presentationProps = {
- enableExpandOnHover: props.enableExpandOnHover,
- singleLine: props.singleLine,
+ enableExpandOnHover: bound.enableExpandOnHover,
+ singleLine: bound.singleLine,
size: props.size,
variant: props.variant,
};
diff --git a/web/src/components/table/DataTable.stories.tsx b/web/src/components/table/DataTable.stories.tsx
index 70a9a98fa5..b6cf966d2b 100644
--- a/web/src/components/table/DataTable.stories.tsx
+++ b/web/src/components/table/DataTable.stories.tsx
@@ -15,7 +15,11 @@ import {
type AsyncTableData,
} from "@/src/components/table/data-table";
import { type LangfuseColumnDef } from "@/src/components/table/types";
-import { type RowHeight } from "@/src/components/table/data-table-row-height-switch";
+import {
+ resolveRowHeightRendering,
+ useRowHeightRendering,
+ type RowHeight,
+} from "@/src/components/table/data-table-row-height-switch";
import { Badge } from "@/src/components/ui/badge";
import { Button } from "@/src/components/ui/button";
import { Checkbox } from "@/src/components/design-system/Checkbox/Checkbox";
@@ -231,13 +235,40 @@ function loadedTraceData(count = 20): AsyncTableData<TraceRow[]> {
// -----------------------------------------------------------------------------
// Mirrors the visible-by-default Traces columns. The action/selection
// cells use the standalone visual components (see FIDELITY GOAL note). The IO
-// cells use the same IOTableCell variants + the
-// `singleLine = rowHeight === "s"` rule the real table applies.
+// cells use the same IOTableCell variants. Single-line text versus the JSON
+// preview comes from the row's resolved height: below Medium it is one line,
+// at Medium and above it is the preview. A drag uses that same height.
+
+function StoryTraceInputCell({
+ data,
+ loading = false,
+}: {
+ data?: TraceRow["input"];
+ loading?: boolean;
+}) {
+ const live = useRowHeightRendering();
+ const singleLine = live?.compact ?? false;
+ return loading ? (
+ <IOTableCell
+ isLoading
+ singleLine={singleLine}
+ renderMediaReference={renderMediaReference}
+ />
+ ) : (
+ <IOTableCell
+ data={data}
+ singleLine={singleLine}
+ enableExpandOnHover={singleLine}
+ renderMediaReference={renderMediaReference}
+ />
+ );
+}
function buildTraceColumns(
rowHeight: RowHeight,
): LangfuseColumnDef<TraceRow>[] {
- const singleLine = rowHeight === "s";
+ const rendering = resolveRowHeightRendering({ preset: rowHeight });
+ const singleLine = rendering.compact;
return [
{
// Row-selection checkbox column (each real table authors its own; the
@@ -286,28 +317,15 @@ function buildTraceColumns(
id: "input",
size: 400,
cellBackground: "gray",
- loadingCell: () => (
- <IOTableCell
- isLoading
- singleLine={singleLine}
- renderMediaReference={renderMediaReference}
- />
- ),
- cell: ({ row }) => (
- <IOTableCell
- data={row.original.input}
- singleLine={singleLine}
- enableExpandOnHover={singleLine}
- renderMediaReference={renderMediaReference}
- />
- ),
+ loadingCell: () => <StoryTraceInputCell loading />,
+ cell: ({ row }) => <StoryTraceInputCell data={row.original.input} />,
},
createIOTableColumn<TraceRow>({
accessorKey: "output",
header: "Output",
size: 400,
singleLine,
- enableExpandOnHover: singleLine,
+ enableExpandOnHover: true,
variant: "output",
}),
{
@@ -411,14 +429,14 @@ function buildTraceColumns(
description: "Group traces with tags.",
href: "https://langfuse.com/docs/observability/features/tags",
},
- shouldWrap: rowHeight !== "s",
+ shouldWrap: !singleLine,
}),
createIOTableColumn<TraceRow>({
accessorKey: "metadata",
header: "Metadata",
size: 400,
singleLine,
- enableExpandOnHover: singleLine,
+ enableExpandOnHover: true,
}),
createIdTableColumn<TraceRow>({
accessorKey: "userId",
diff --git a/web/src/components/table/data-table-row-height-switch.clienttest.tsx b/web/src/components/table/data-table-row-height-switch.clienttest.tsx
new file mode 100644
index 0000000000..0bf33ea390
--- /dev/null
+++ b/web/src/components/table/data-table-row-height-switch.clienttest.tsx
@@ -0,0 +1,274 @@
+import { fireEvent, render, renderHook, screen } from "@testing-library/react";
+import { type ReactNode } from "react";
+import {
+ anchoredScrollTop,
+ clampCustomRowHeightPx,
+ getRowHeightIOCharLimit,
+ isCompactRowHeight,
+ mediumRowHeightPx,
+ resolveRowHeightRendering,
+ resolveStoredRowHeight,
+ RowHeightRenderingProvider,
+ useAdjustableRowHeight,
+ useBoundRowHeightIO,
+} from "@/src/components/table/data-table-row-height-switch";
+
+const STORAGE_KEY = "experiment-items-compactHeight";
+
+describe("resolveStoredRowHeight", () => {
+ it("keeps a previously saved preset string", () => {
+ expect(resolveStoredRowHeight("l", "s")).toEqual({
+ preset: "l",
+ mode: "preset",
+ customPx: null,
+ });
+ });
+
+ it("restores a free height without dropping the preset it replaced", () => {
+ expect(
+ resolveStoredRowHeight(
+ { preset: "m", mode: "custom", customPx: 640 },
+ "s",
+ ),
+ ).toEqual({ preset: "m", mode: "custom", customPx: 640 });
+ });
+
+ it("falls back when the stored value cannot be a height", () => {
+ expect(resolveStoredRowHeight({ mode: "custom" }, "s")).toEqual({
+ preset: "s",
+ mode: "preset",
+ customPx: null,
+ });
+ expect(resolveStoredRowHeight("tall", "m")).toEqual({
+ preset: "m",
+ mode: "preset",
+ customPx: null,
+ });
+ });
+
+ it("clamps a free height into the supported range", () => {
+ expect(clampCustomRowHeightPx(10)).toBe(28);
+ expect(clampCustomRowHeightPx(10, 96)).toBe(96);
+ expect(clampCustomRowHeightPx(9000)).toBe(4000);
+ expect(
+ resolveStoredRowHeight({ preset: "s", mode: "custom", customPx: 12 }, "s")
+ .customPx,
+ ).toBe(28);
+ });
+
+ it("keeps a row's top edge and stays inside the scroller", () => {
+ expect(
+ anchoredScrollTop({
+ scrollTop: 100,
+ rowTop: 300,
+ anchorTop: 180,
+ scrollHeight: 2000,
+ clientHeight: 400,
+ }),
+ ).toBe(220);
+ // The list got shorter, so the old offset is past the new maximum.
+ expect(
+ anchoredScrollTop({
+ scrollTop: 400,
+ rowTop: 700,
+ anchorTop: 200,
+ scrollHeight: 900,
+ clientHeight: 800,
+ }),
+ ).toBe(100);
+ expect(
+ anchoredScrollTop({
+ scrollTop: 40,
+ rowTop: 10,
+ anchorTop: 200,
+ scrollHeight: 900,
+ clientHeight: 800,
+ }),
+ ).toBe(0);
+ });
+});
+
+function HeightHarness() {
+ const height = useAdjustableRowHeight("experiment-items-compact", "s");
+ return (
+ <div>
+ <span data-testid="mode">{height.mode}</span>
+ <span data-testid="preset">{height.preset}</span>
+ <span data-testid="px">{height.activeHeightPx ?? "none"}</span>
+ <button type="button" onClick={() => height.setCustomPx(800)}>
+ drag
+ </button>
+ <button type="button" onClick={() => height.setPreset("m")}>
+ medium
+ </button>
+ <button type="button" onClick={() => height.selectCustom()}>
+ custom
+ </button>
+ </div>
+ );
+}
+
+describe("isCompactRowHeight", () => {
+ it("keeps preset Small on one line and Medium and Large expanded", () => {
+ expect(isCompactRowHeight("s", "preset")).toBe(true);
+ expect(isCompactRowHeight("m", "preset")).toBe(false);
+ expect(isCompactRowHeight("l", "preset")).toBe(false);
+ });
+
+ it("returns a dragged height to one line once it drops below Medium", () => {
+ expect(mediumRowHeightPx()).toBe(96);
+ expect(isCompactRowHeight("s", "custom", 48)).toBe(true);
+ expect(isCompactRowHeight("l", "custom", 95)).toBe(true);
+ expect(isCompactRowHeight("s", "custom", 96)).toBe(false);
+ expect(isCompactRowHeight("m", "custom", 208)).toBe(false);
+ expect(getRowHeightIOCharLimit("s", "custom", 48)).toBeUndefined();
+ expect(getRowHeightIOCharLimit("s", "custom", 96)).toBe(2000);
+ });
+
+ it("uses the table's own Medium height when that preset is taller", () => {
+ const heights = { s: "h-48", m: "h-64", l: "h-96" } as const;
+ expect(mediumRowHeightPx(heights)).toBe(256);
+ expect(isCompactRowHeight("s", "custom", 192, heights)).toBe(true);
+ expect(isCompactRowHeight("s", "custom", 256, heights)).toBe(false);
+ expect(isCompactRowHeight("s", "preset", null, heights)).toBe(true);
+ expect(isCompactRowHeight("m", "preset", null, heights)).toBe(false);
+ });
+});
+
+describe("resolveRowHeightRendering", () => {
+ it("maps each preset through its pixel height", () => {
+ expect(resolveRowHeightRendering({ preset: "s" })).toEqual({
+ heightPx: 28,
+ compact: true,
+ expandedRead: false,
+ });
+ expect(resolveRowHeightRendering({ preset: "m" })).toEqual({
+ heightPx: 96,
+ compact: false,
+ expandedRead: true,
+ });
+ expect(resolveRowHeightRendering({ preset: "l" })).toEqual({
+ heightPx: 256,
+ compact: false,
+ expandedRead: true,
+ });
+ });
+
+ it("renders a dragged height the same as the preset of that height", () => {
+ const medium = resolveRowHeightRendering({ preset: "m" });
+ const draggedToMedium = resolveRowHeightRendering({
+ preset: "s",
+ previewPx: medium.heightPx,
+ });
+ expect(draggedToMedium).toEqual(medium);
+
+ const small = resolveRowHeightRendering({ preset: "s" });
+ const draggedToSmall = resolveRowHeightRendering({
+ preset: "l",
+ customPx: 256,
+ previewPx: small.heightPx,
+ });
+ expect(draggedToSmall).toEqual(small);
+ });
+
+ it("crosses Medium the same way while growing and shrinking", () => {
+ expect(
+ resolveRowHeightRendering({ preset: "s", previewPx: 95 }).compact,
+ ).toBe(true);
+ expect(
+ resolveRowHeightRendering({ preset: "s", previewPx: 96 }).compact,
+ ).toBe(false);
+ expect(
+ resolveRowHeightRendering({ preset: "l", customPx: 256, previewPx: 95 })
+ .compact,
+ ).toBe(true);
+ expect(getRowHeightIOCharLimit("m", "preset")).toBe(2000);
+ expect(getRowHeightIOCharLimit("s", "preset")).toBeUndefined();
+ });
+
+ it("uses a table whose Medium preset is not the default 96px", () => {
+ const list = { s: "h-24", m: "h-48", l: "h-96" } as const;
+ const medium = resolveRowHeightRendering({ preset: "m" }, list);
+ expect(medium).toEqual({
+ heightPx: 192,
+ compact: false,
+ expandedRead: true,
+ });
+ expect(
+ resolveRowHeightRendering({ preset: "s", previewPx: 192 }, list),
+ ).toEqual(medium);
+ expect(
+ resolveRowHeightRendering({ preset: "l", previewPx: 191 }, list).compact,
+ ).toBe(true);
+ });
+});
+
+function CompactTable({ children }: { children: ReactNode }) {
+ return (
+ <RowHeightRenderingProvider compact expandedRead={false}>
+ {children}
+ </RowHeightRenderingProvider>
+ );
+}
+
+describe("useBoundRowHeightIO", () => {
+ it("follows a compact row by default and keeps singleLine when opted out", () => {
+ const following = renderHook(() => useBoundRowHeightIO(true, false, true), {
+ wrapper: CompactTable,
+ });
+ expect(following.result.current).toEqual({
+ singleLine: true,
+ enableExpandOnHover: true,
+ });
+
+ const optedOut = renderHook(() => useBoundRowHeightIO(false, false, true), {
+ wrapper: CompactTable,
+ });
+ expect(optedOut.result.current).toEqual({
+ singleLine: false,
+ enableExpandOnHover: true,
+ });
+ });
+
+ it("keeps singleLine outside a data table even when following", () => {
+ const { result } = renderHook(() => useBoundRowHeightIO(true, false, true));
+ expect(result.current).toEqual({
+ singleLine: false,
+ enableExpandOnHover: true,
+ });
+ });
+});
+
+describe("useAdjustableRowHeight", () => {
+ afterEach(() => {
+ localStorage.clear();
+ });
+
+ it("loads a legacy preset and remembers a dragged height across preset changes", () => {
+ localStorage.setItem(STORAGE_KEY, JSON.stringify("l"));
+ render(<HeightHarness />);
+
+ expect(screen.getByTestId("mode")).toHaveTextContent("preset");
+ expect(screen.getByTestId("preset")).toHaveTextContent("l");
+ expect(screen.getByTestId("px")).toHaveTextContent("none");
+
+ fireEvent.click(screen.getByRole("button", { name: "drag" }));
+ expect(screen.getByTestId("mode")).toHaveTextContent("custom");
+ expect(screen.getByTestId("px")).toHaveTextContent("800");
+ expect(JSON.parse(localStorage.getItem(STORAGE_KEY) ?? "")).toEqual({
+ preset: "l",
+ mode: "custom",
+ customPx: 800,
+ });
+
+ fireEvent.click(screen.getByRole("button", { name: "medium" }));
+ expect(screen.getByTestId("mode")).toHaveTextContent("preset");
+ expect(screen.getByTestId("preset")).toHaveTextContent("m");
+ expect(screen.getByTestId("px")).toHaveTextContent("none");
+
+ fireEvent.click(screen.getByRole("button", { name: "custom" }));
+ expect(screen.getByTestId("mode")).toHaveTextContent("custom");
+ expect(screen.getByTestId("preset")).toHaveTextContent("m");
+ expect(screen.getByTestId("px")).toHaveTextContent("800");
+ });
+});
diff --git a/web/src/components/table/data-table-row-height-switch.tsx b/web/src/components/table/data-table-row-height-switch.tsx
index 35e1da8d1c..73c82bfcef 100644
--- a/web/src/components/table/data-table-row-height-switch.tsx
+++ b/web/src/components/table/data-table-row-height-switch.tsx
@@ -12,6 +12,13 @@ import {
import useLocalStorage from "@/src/components/useLocalStorage";
import { usePostHogClientCapture } from "@/src/features/posthog-analytics";
import { Rows3, Rows2, Rows4 } from "lucide-react";
+import {
+ createContext,
+ useCallback,
+ useContext,
+ useMemo,
+ type ReactNode,
+} from "react";
const ROW_HEIGHT_OPTIONS = [
{ id: "s", label: "Small", icon: <Rows4 className="icon-base" /> },
@@ -29,16 +36,336 @@ export type RowHeight = (typeof ROW_HEIGHT_OPTIONS)[number]["id"];
export type CustomHeights = Record<RowHeight, string>;
/**
- * Chars of Input/Output a taller row needs to fill its cells. Small shows a
- * single truncated line, so it stays on the cheap pre-truncated read; Medium
- * and Large have room for far more text than that (LFE-14586). Sized to fill a
- * Large row even at a generously widened column.
+ * Shortest free height on the default table. It is the Small preset (`h-7`),
+ * so a drag can land on Small. A table with a taller Small uses that height
+ * as its own floor.
+ */
+const MIN_CUSTOM_ROW_HEIGHT_PX = 28;
+export const MAX_CUSTOM_ROW_HEIGHT_PX = 4_000;
+
+const ROW_HEIGHT_IDS = new Set<string>(
+ ROW_HEIGHT_OPTIONS.map((option) => option.id),
+);
+
+/**
+ * Persisted row height for one table. A bare preset is what every table stored
+ * before a free height existed. After a drag, the object keeps that preset so
+ * it can be restored without dropping the free height.
+ */
+export type StoredRowHeight =
+ | RowHeight
+ | {
+ preset: RowHeight;
+ mode: "preset" | "custom";
+ customPx: number | null;
+ };
+
+export type ResolvedRowHeight = {
+ preset: RowHeight;
+ mode: "preset" | "custom";
+ /** Last free height, whether or not it is the one on screen. */
+ customPx: number | null;
+};
+
+/** Menu state for a table that lets the user drag a free height. */
+export type CustomRowHeightControl = {
+ /** True while the free height is what the table shows. */
+ active: boolean;
+ /** Last free height. Null until the user drags a row. */
+ rememberedPx: number | null;
+ onSelect: () => void;
+};
+
+const isRowHeight = (value: unknown): value is RowHeight =>
+ typeof value === "string" && ROW_HEIGHT_IDS.has(value);
+
+/**
+ * Scroll offset that keeps a row's top edge at `anchorTop` after every row
+ * takes the committed height. Near the end of the list the maximum offset
+ * shrinks with the rows, so the result stays inside the scroller.
+ */
+export function anchoredScrollTop({
+ scrollTop,
+ rowTop,
+ anchorTop,
+ scrollHeight,
+ clientHeight,
+}: {
+ scrollTop: number;
+ rowTop: number;
+ anchorTop: number;
+ scrollHeight: number;
+ clientHeight: number;
+}): number {
+ const maxScroll = Math.max(0, scrollHeight - clientHeight);
+ const next = scrollTop + (rowTop - anchorTop);
+ if (!Number.isFinite(next)) {
+ return Math.min(maxScroll, Math.max(0, scrollTop));
+ }
+ return Math.min(maxScroll, Math.max(0, next));
+}
+
+export function clampCustomRowHeightPx(
+ heightPx: number,
+ minPx: number = MIN_CUSTOM_ROW_HEIGHT_PX,
+): number {
+ const floor = Number.isFinite(minPx)
+ ? Math.round(minPx)
+ : MIN_CUSTOM_ROW_HEIGHT_PX;
+ if (!Number.isFinite(heightPx)) return floor;
+ return Math.min(
+ MAX_CUSTOM_ROW_HEIGHT_PX,
+ Math.max(floor, Math.round(heightPx)),
+ );
+}
+
+export function resolveStoredRowHeight(
+ stored: unknown,
+ fallbackPreset: RowHeight,
+): ResolvedRowHeight {
+ if (isRowHeight(stored)) {
+ return { preset: stored, mode: "preset", customPx: null };
+ }
+
+ if (!stored || typeof stored !== "object") {
+ return { preset: fallbackPreset, mode: "preset", customPx: null };
+ }
+
+ const record = stored as Record<string, unknown>;
+ const preset = isRowHeight(record.preset) ? record.preset : fallbackPreset;
+ const customPx =
+ typeof record.customPx === "number"
+ ? clampCustomRowHeightPx(record.customPx)
+ : null;
+ const mode =
+ record.mode === "custom" && customPx != null ? "custom" : "preset";
+
+ return { preset, mode, customPx };
+}
+
+/**
+ * Chars of Input/Output a taller row needs to fill its cells. A compact row
+ * shows a single truncated line, so it stays on the cheap pre-truncated read.
+ * Taller rows have room for far more text than that. Sized to fill a Large
+ * row even at a generously widened column.
*/
const EXPANDED_ROW_IO_CHAR_LIMIT = 2_000;
-/** Undefined for Small, which keeps the default truncated read. */
-export const getRowHeightIOCharLimit = (rowHeight: RowHeight) =>
- rowHeight === "s" ? undefined : EXPANDED_ROW_IO_CHAR_LIMIT;
+/** Pixel height of a Tailwind `h-*` step at the default 16px root. */
+const TAILWIND_HEIGHT_STEP_PX = 4;
+
+const PRESET_HEIGHT_FALLBACK_PX: Record<RowHeight, number> = {
+ s: 28,
+ m: 96,
+ l: 256,
+};
+
+function tailwindHeightClassToPx(
+ heightClass: string | undefined,
+ fallback: number,
+): number {
+ const steps = heightClass
+ ? /^h-(\d+(?:\.\d+)?)$/.exec(heightClass)?.[1]
+ : undefined;
+ if (steps == null) return fallback;
+ return Number(steps) * TAILWIND_HEIGHT_STEP_PX;
+}
+
+/** Pixel height of one preset on this table. */
+function rowHeightPresetPx(
+ preset: RowHeight,
+ customHeights?: CustomHeights,
+): number {
+ return tailwindHeightClassToPx(
+ customHeights?.[preset] ?? defaultHeights[preset],
+ PRESET_HEIGHT_FALLBACK_PX[preset],
+ );
+}
+
+/**
+ * Pixel height of this table's Medium preset. A dragged height uses that
+ * line to decide between a truncated line and a wrapped preview.
+ */
+export function mediumRowHeightPx(customHeights?: CustomHeights): number {
+ return rowHeightPresetPx("m", customHeights);
+}
+
+/** Shortest height a drag on this table can commit. Matches its Small preset. */
+export function minCustomRowHeightPx(customHeights?: CustomHeights): number {
+ return rowHeightPresetPx("s", customHeights);
+}
+
+/**
+ * Preset whose pixel height is `heightPx`, if any. A drag that lands on one
+ * selects that preset, so the row is the preset and not a copy of it.
+ */
+export function rowHeightPresetForPx(
+ heightPx: number,
+ customHeights?: CustomHeights,
+): RowHeight | null {
+ const rounded = Math.round(heightPx);
+ for (const preset of ["s", "m", "l"] as const) {
+ if (rowHeightPresetPx(preset, customHeights) === rounded) return preset;
+ }
+ return null;
+}
+
+/**
+ * How a row paints input and output, derived only from a pixel height.
+ * Below this table's Medium preset the cell is one truncated line and the
+ * table keeps the short read. At Medium and above it is the scrollable JSON
+ * preview and the table asks for the longer read.
+ */
+export type RowHeightRendering = {
+ heightPx: number;
+ compact: boolean;
+ expandedRead: boolean;
+};
+
+/**
+ * One height in, one rendering out. A preset contributes its pixel height.
+ * A free height contributes its pixels. A drag preview replaces both, so a
+ * preview sitting on Medium's pixel height renders as Medium, and shrinking
+ * back below that line returns to the truncated line.
+ */
+function heightOnScreen(
+ state: {
+ preset: RowHeight;
+ customPx?: number | null;
+ previewPx?: number | null;
+ },
+ customHeights?: CustomHeights,
+): number {
+ if (state.previewPx != null) return state.previewPx;
+ if (state.customPx != null) return state.customPx;
+ return rowHeightPresetPx(state.preset, customHeights);
+}
+
+export function resolveRowHeightRendering(
+ state: {
+ preset: RowHeight;
+ /** Free height currently shown. Omit while a preset is showing. */
+ customPx?: number | null;
+ /** Live drag or keyboard preview. Replaces the committed height. */
+ previewPx?: number | null;
+ },
+ customHeights?: CustomHeights,
+): RowHeightRendering {
+ const heightPx = heightOnScreen(state, customHeights);
+ const compact = heightPx < rowHeightPresetPx("m", customHeights);
+ return {
+ heightPx,
+ compact,
+ expandedRead: !compact,
+ };
+}
+
+const RowHeightRenderingContext = createContext<Pick<
+ RowHeightRendering,
+ "compact" | "expandedRead"
+> | null>(null);
+
+/**
+ * Publishes the rendering of the height on screen, including a drag still
+ * in progress. The value changes only when the row crosses Medium, so cells
+ * do not re-render on every pixel.
+ */
+export function RowHeightRenderingProvider({
+ compact,
+ expandedRead,
+ children,
+}: {
+ compact: boolean;
+ expandedRead: boolean;
+ children: ReactNode;
+}) {
+ const value = useMemo(
+ () => ({ compact, expandedRead }),
+ [compact, expandedRead],
+ );
+ return (
+ <RowHeightRenderingContext.Provider value={value}>
+ {children}
+ </RowHeightRenderingContext.Provider>
+ );
+}
+
+/** Null outside a data table. Inside one, the height on screen, drag included. */
+export function useRowHeightRendering() {
+ return useContext(RowHeightRenderingContext);
+}
+
+/**
+ * Compact flag for cells that are not input/output. A drag still in
+ * progress wins over the committed fallback.
+ */
+export function useCompactRows(fallback: boolean): boolean {
+ const live = useRowHeightRendering();
+ return live ? live.compact : fallback;
+}
+
+/**
+ * Input/output props after applying the live row height. Following is the
+ * default inside a data table. Pass false to keep `singleLine` in charge.
+ * Outside a data table, `singleLine` is used either way.
+ * `enableExpandOnHover` is on only while the row is compact.
+ */
+export function useBoundRowHeightIO(
+ followRowHeight = true,
+ singleLine: boolean | undefined,
+ enableExpandOnHover: boolean | undefined,
+): {
+ singleLine: boolean | undefined;
+ enableExpandOnHover: boolean | undefined;
+} {
+ const live = useRowHeightRendering();
+ if (followRowHeight === false || !live) {
+ return { singleLine, enableExpandOnHover };
+ }
+ return {
+ singleLine: live.compact,
+ enableExpandOnHover: Boolean(enableExpandOnHover) && live.compact,
+ };
+}
+
+/**
+ * One truncated line, or the JSON preview.
+ * Presets and free heights both resolve to pixels, then use the same line:
+ * below this table's Medium height the row stays truncated, and at Medium
+ * or taller it shows the preview. Growing and shrinking cross that line the
+ * same way.
+ */
+export function isCompactRowHeight(
+ rowHeight: RowHeight,
+ mode: "preset" | "custom",
+ heightPx?: number | null,
+ customHeights?: CustomHeights,
+): boolean {
+ return resolveRowHeightRendering(
+ {
+ preset: rowHeight,
+ customPx: mode === "custom" ? (heightPx ?? null) : null,
+ },
+ customHeights,
+ ).compact;
+}
+
+/** Undefined while the row shows one truncated line; otherwise the expanded read. */
+export const getRowHeightIOCharLimit = (
+ rowHeight: RowHeight,
+ mode: "preset" | "custom" = "preset",
+ heightPx?: number | null,
+ customHeights?: CustomHeights,
+) =>
+ resolveRowHeightRendering(
+ {
+ preset: rowHeight,
+ customPx: mode === "custom" ? (heightPx ?? null) : null,
+ },
+ customHeights,
+ ).expandedRead
+ ? EXPANDED_ROW_IO_CHAR_LIMIT
+ : undefined;
export const getRowHeightTailwindClass = (
rowHeight?: RowHeight,
@@ -52,12 +379,83 @@ export function useRowHeightLocalStorage(
tableName: string,
defaultValue: RowHeight,
) {
- const [rowHeight, setRowHeight, clearRowHeight] = useLocalStorage<RowHeight>(
+ const adjustable = useAdjustableRowHeight(tableName, defaultValue);
+
+ return [adjustable.preset, adjustable.setPreset, adjustable] as const;
+}
+
+/**
+ * Preset plus an optional free height, in the same per-table localStorage key
+ * as `useRowHeightLocalStorage`. A previously saved preset string still loads.
+ */
+export function useAdjustableRowHeight(
+ tableName: string,
+ defaultPreset: RowHeight,
+) {
+ const [stored, setStored] = useLocalStorage<StoredRowHeight>(
`${tableName}Height`,
- defaultValue,
+ defaultPreset,
+ );
+ const resolved = resolveStoredRowHeight(stored, defaultPreset);
+
+ const setPreset = useCallback(
+ (preset: RowHeight) => {
+ setStored((current) => {
+ const previous = resolveStoredRowHeight(current, defaultPreset);
+ return { preset, mode: "preset", customPx: previous.customPx };
+ });
+ },
+ [defaultPreset, setStored],
+ );
+
+ const setCustomPx = useCallback(
+ (heightPx: number) => {
+ setStored((current) => {
+ const previous = resolveStoredRowHeight(current, defaultPreset);
+ return {
+ preset: previous.preset,
+ mode: "custom",
+ customPx: clampCustomRowHeightPx(heightPx),
+ };
+ });
+ },
+ [defaultPreset, setStored],
);
- return [rowHeight, setRowHeight, clearRowHeight] as const;
+ const selectCustom = useCallback(() => {
+ setStored((current) => {
+ const previous = resolveStoredRowHeight(current, defaultPreset);
+ if (previous.customPx == null) return previous.preset;
+ return {
+ preset: previous.preset,
+ mode: "custom",
+ customPx: previous.customPx,
+ };
+ });
+ }, [defaultPreset, setStored]);
+
+ return {
+ preset: resolved.preset,
+ mode: resolved.mode,
+ customPx: resolved.customPx,
+ activeHeightPx: resolved.mode === "custom" ? resolved.customPx : null,
+ setPreset,
+ setCustomPx,
+ selectCustom,
+ };
+}
+
+/** Menu props for the row-height switch. Custom stays hidden until a drag. */
+export function customRowHeightMenu(adjustable: {
+ mode: "preset" | "custom";
+ customPx: number | null;
+ selectCustom: () => void;
+}): CustomRowHeightControl {
+ return {
+ active: adjustable.mode === "custom",
+ rememberedPx: adjustable.customPx,
+ onSelect: adjustable.selectCustom,
+ };
}
export const DataTableRowHeightSwitch = ({
@@ -65,17 +463,28 @@ export const DataTableRowHeightSwitch = ({
setRowHeight,
tableName = "unknown",
isV4 = false,
+ customRowHeight,
}: {
rowHeight: RowHeight;
setRowHeight: (e: RowHeight) => void;
tableName?: string;
isV4?: boolean;
+ /**
+ * Pass this wherever the switch is shown. Custom stays hidden until a row
+ * has been dragged.
+ */
+ customRowHeight?: CustomRowHeightControl;
}) => {
const capture = usePostHogClientCapture();
+ const customActive = customRowHeight?.active === true;
return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
- <Button variant="outline" size="icon" title="Row height">
+ <Button
+ variant="outline"
+ size="icon"
+ title={customActive ? "Row height: Custom" : "Row height"}
+ >
<Rows3 className="icon-base text-icon-foreground" />
</Button>
</DropdownMenuTrigger>
@@ -86,7 +495,7 @@ export const DataTableRowHeightSwitch = ({
{ROW_HEIGHT_OPTIONS.map(({ id, label }) => (
<DropdownMenuCheckboxItem
key={id}
- checked={rowHeight === id}
+ checked={!customActive && rowHeight === id}
onClick={(e) => {
// Prevent closing the dropdown menu to allow the user to adjust their selection
e.preventDefault();
@@ -101,6 +510,26 @@ export const DataTableRowHeightSwitch = ({
{label}
</DropdownMenuCheckboxItem>
))}
+ {customRowHeight?.rememberedPx != null && (
+ <>
+ <DropdownMenuSeparator />
+ <DropdownMenuCheckboxItem
+ checked={customActive}
+ onClick={(e) => {
+ e.preventDefault();
+ if (customActive) return;
+ capture("table:row_height_switch_select", {
+ rowHeight: "custom",
+ tableName,
+ isV4,
+ });
+ customRowHeight.onSelect();
+ }}
+ >
+ {`Custom (${customRowHeight.rememberedPx}px)`}
+ </DropdownMenuCheckboxItem>
+ </>
+ )}
</DropdownMenuContent>
</DropdownMenuPortal>
</DropdownMenu>
diff --git a/web/src/components/table/data-table-toolbar.clienttest.tsx b/web/src/components/table/data-table-toolbar.clienttest.tsx
index 0d5a587052..85beb06a8c 100644
--- a/web/src/components/table/data-table-toolbar.clienttest.tsx
+++ b/web/src/components/table/data-table-toolbar.clienttest.tsx
@@ -1,4 +1,4 @@
-import { fireEvent, render, screen } from "@testing-library/react";
+import { act, fireEvent, render, screen } from "@testing-library/react";
import { vi } from "vitest";
import type { ColumnDefinition } from "@langfuse/shared";
import { ExperimentDisplaySettings } from "@/src/features/experiments";
@@ -280,6 +280,113 @@ describe("DataTableToolbar presentation controls", () => {
expect(screen.getByRole("button", { name: "Display" })).toBeVisible();
});
+ function openRowHeightMenu() {
+ const button = screen.getByRole("button", { name: /Row height/ });
+ act(() => {
+ // Radix opens the menu on pointerdown. jsdom has no PointerEvent, so
+ // this is a MouseEvent that still carries button and coordinates.
+ button.dispatchEvent(
+ new MouseEvent("pointerdown", {
+ bubbles: true,
+ cancelable: true,
+ button: 0,
+ clientX: 1,
+ clientY: 1,
+ }),
+ );
+ });
+ }
+
+ it("keeps the row-height menu to the presets unless a free height is enabled", () => {
+ render(<DataTableToolbar {...settingsProps} />);
+ openRowHeightMenu();
+
+ expect(
+ screen.getByRole("menuitemcheckbox", { name: "Small" }),
+ ).toBeChecked();
+ expect(
+ screen.queryByRole("menuitemcheckbox", { name: /^Custom/ }),
+ ).not.toBeInTheDocument();
+ });
+
+ it("shows Custom as its own row-height state and restores it from the menu", () => {
+ const setRowHeight = vi.fn();
+ const onSelect = vi.fn();
+ render(
+ <DataTableToolbar
+ {...settingsProps}
+ rowHeight="l"
+ setRowHeight={setRowHeight}
+ customRowHeight={{
+ active: true,
+ rememberedPx: 640,
+ onSelect,
+ }}
+ />,
+ );
+ openRowHeightMenu();
+
+ expect(
+ screen.getByRole("menuitemcheckbox", { name: "Custom (640px)" }),
+ ).toBeChecked();
+ expect(
+ screen.getByRole("menuitemcheckbox", { name: "Large" }),
+ ).not.toBeChecked();
+
+ fireEvent.click(screen.getByRole("menuitemcheckbox", { name: "Small" }));
+ expect(setRowHeight).toHaveBeenCalledExactlyOnceWith("s");
+
+ fireEvent.click(
+ screen.getByRole("menuitemcheckbox", { name: "Custom (640px)" }),
+ );
+ // Already the active height, so choosing it again is a no-op.
+ expect(onSelect).not.toHaveBeenCalled();
+ });
+
+ it("returns to a remembered custom height from the menu", () => {
+ const onSelect = vi.fn();
+ render(
+ <DataTableToolbar
+ {...settingsProps}
+ rowHeight="m"
+ customRowHeight={{
+ active: false,
+ rememberedPx: 800,
+ onSelect,
+ }}
+ />,
+ );
+ openRowHeightMenu();
+
+ expect(
+ screen.getByRole("menuitemcheckbox", { name: "Medium" }),
+ ).toBeChecked();
+ const custom = screen.getByRole("menuitemcheckbox", {
+ name: "Custom (800px)",
+ });
+ expect(custom).not.toBeChecked();
+ fireEvent.click(custom);
+ expect(onSelect).toHaveBeenCalledOnce();
+ });
+
+ it("hides Custom until a row has been dragged", () => {
+ render(
+ <DataTableToolbar
+ {...settingsProps}
+ customRowHeight={{
+ active: false,
+ rememberedPx: null,
+ onSelect: vi.fn(),
+ }}
+ />,
+ );
+ openRowHeightMenu();
+
+ expect(
+ screen.queryByRole("menuitemcheckbox", { name: /^Custom/ }),
+ ).not.toBeInTheDocument();
+ });
+
it("opens legacy filters and search together in the mobile sheet", () => {
captureSpy.mockClear();
const filterColumns: ColumnDefinition[] = [
diff --git a/web/src/components/table/data-table-toolbar.tsx b/web/src/components/table/data-table-toolbar.tsx
index 66be6d4110..3a42e264b2 100644
--- a/web/src/components/table/data-table-toolbar.tsx
+++ b/web/src/components/table/data-table-toolbar.tsx
@@ -31,6 +31,7 @@ import {
import { type LangfuseColumnDef } from "@/src/components/table/types";
import {
DataTableRowHeightSwitch,
+ type CustomRowHeightControl,
type RowHeight,
} from "@/src/components/table/data-table-row-height-switch";
import { usePostHogClientCapture } from "@/src/features/posthog-analytics";
@@ -152,7 +153,12 @@ interface DataTableToolbarProps<TData, TValue> {
columnOrder?: ColumnOrderState;
setColumnOrder?: Dispatch<SetStateAction<ColumnOrderState>>;
rowHeight?: RowHeight;
- setRowHeight?: Dispatch<SetStateAction<RowHeight>>;
+ setRowHeight?: (rowHeight: RowHeight) => void;
+ /**
+ * Free height alongside the presets. Pass it wherever the switch is shown.
+ * Custom stays hidden until a row has been dragged.
+ */
+ customRowHeight?: CustomRowHeightControl;
columnsWithCustomSelect?: string[];
timeRange?: TimeRange;
setTimeRange?: (timeRange: TimeRange) => void;
@@ -356,6 +362,7 @@ export function DataTableToolbar<TData, TValue>({
setColumnOrder,
rowHeight,
setRowHeight,
+ customRowHeight,
columnsWithCustomSelect,
timeRange,
setTimeRange,
@@ -722,6 +729,7 @@ export function DataTableToolbar<TData, TValue>({
<DataTableRowHeightSwitch
rowHeight={rowHeight}
setRowHeight={setRowHeight}
+ customRowHeight={customRowHeight}
tableName={analyticsTableName}
isV4={analyticsIsV4}
/>
diff --git a/web/src/components/table/data-table.clienttest.tsx b/web/src/components/table/data-table.clienttest.tsx
index ec35d79ab2..0e1e390542 100644
--- a/web/src/components/table/data-table.clienttest.tsx
+++ b/web/src/components/table/data-table.clienttest.tsx
@@ -1,6 +1,11 @@
-import { fireEvent, render, screen } from "@testing-library/react";
+import { act, fireEvent, render, screen } from "@testing-library/react";
import { useState } from "react";
import { DataTable } from "@/src/components/table/data-table";
+import {
+ useRowHeightRendering,
+ type RowHeight,
+ type CustomHeights,
+} from "@/src/components/table/data-table-row-height-switch";
import { type LangfuseColumnDef } from "@/src/components/table/types";
import { type OrderByState } from "@langfuse/shared";
@@ -12,7 +17,7 @@ vi.mock("posthog-js/react", () => ({
usePostHog: () => ({ capture: vi.fn() }),
}));
-type Row = { scoreName: string; status: string };
+type Row = { scoreName: string; status: string; mode: number };
const columns: LangfuseColumnDef<Row>[] = [
{
@@ -29,8 +34,8 @@ const columns: LangfuseColumnDef<Row>[] = [
];
const rows: Row[] = [
- { scoreName: "zeta-score", status: "ACTIVE" },
- { scoreName: "alpha-score", status: "ACTIVE" },
+ { scoreName: "zeta-score", status: "ACTIVE", mode: 0 },
+ { scoreName: "alpha-score", status: "ACTIVE", mode: 1 },
];
function SortableTable({ initialOrderBy }: { initialOrderBy: OrderByState }) {
@@ -94,3 +99,729 @@ describe("DataTable column sorting affordances", () => {
expect(statusHeader).not.toHaveTextContent("sorted descending");
});
});
+
+describe("DataTable custom row height", () => {
+ // jsdom has no PointerEvent, so pointer helpers fall back to Event and
+ // drop clientY. A MouseEvent under that name keeps the drag coordinates.
+ class PointerEventPolyfill extends MouseEvent {
+ pointerId: number;
+ constructor(
+ type: string,
+ params: MouseEventInit & { pointerId?: number } = {},
+ ) {
+ super(type, params);
+ this.pointerId = params.pointerId ?? 1;
+ }
+ }
+
+ beforeAll(() => {
+ Object.defineProperty(globalThis, "PointerEvent", {
+ configurable: true,
+ writable: true,
+ value: PointerEventPolyfill,
+ });
+ });
+
+ const pointAt = (handle: HTMLElement, type: string, clientY: number) => {
+ handle.dispatchEvent(
+ new PointerEventPolyfill(type, {
+ bubbles: true,
+ cancelable: true,
+ button: 0,
+ pointerId: 1,
+ clientY,
+ }),
+ );
+ };
+
+ const rect = (height: number, top = 0): DOMRect =>
+ ({
+ x: 0,
+ y: top,
+ top,
+ left: 0,
+ bottom: top + height,
+ right: 100,
+ width: 100,
+ height,
+ toJSON: () => ({}),
+ }) as DOMRect;
+
+ const rowBoxes = (index: number) => [
+ ...document.querySelectorAll<HTMLElement>(
+ `tr[data-row-index="${index}"] [data-row-height]`,
+ ),
+ ];
+
+ afterEach(() => {
+ vi.restoreAllMocks();
+ });
+
+ function renderResizableTable(
+ onCustomRowHeightChange: (heightPx: number) => void = vi.fn(),
+ customRowHeightPx?: number,
+ ) {
+ render(
+ <DataTable
+ tableName="experiment-items"
+ columns={columns}
+ hidePagination
+ rowHeight="m"
+ customRowHeightPx={customRowHeightPx}
+ onCustomRowHeightChange={onCustomRowHeightChange}
+ data={{ isLoading: false, isError: false, data: rows }}
+ />,
+ );
+ }
+
+ it("centers a 6px hit area on the row border, 3px on each side", () => {
+ renderResizableTable();
+
+ const handles = [
+ ...document.querySelectorAll<HTMLElement>("[data-row-resize-handle]"),
+ ];
+ const edge = (name: string) =>
+ handles.filter((el) => el.dataset.rowResizeEdge === name);
+
+ // Two columns. The first row owns the 3px above its border. The second
+ // row owns the 3px below that border, and a 6px strip on its own bottom
+ // edge because nothing follows it.
+ expect(edge("above")).toHaveLength(2);
+ expect(edge("below")).toHaveLength(2);
+ expect(edge("last")).toHaveLength(2);
+ for (const el of edge("above")) {
+ expect(el).toHaveStyle({ height: "3px", bottom: "-1px" });
+ }
+ for (const el of edge("below")) {
+ expect(el).toHaveStyle({ height: "3px", top: "0px" });
+ }
+ for (const el of edge("last")) {
+ expect(el).toHaveStyle({ height: "6px", bottom: "-3px" });
+ expect(el).toHaveAttribute("aria-hidden", "true");
+ }
+ expect(screen.getAllByRole("slider", { name: "Row height" })).toHaveLength(
+ 1,
+ );
+ });
+
+ it("resizes the row above when the pointer starts on the lower half of its border", () => {
+ vi.spyOn(HTMLElement.prototype, "getBoundingClientRect").mockImplementation(
+ () => rect(96),
+ );
+ renderResizableTable();
+
+ const lowerHalf = document.querySelector<HTMLElement>(
+ 'tr[data-row-index="1"] [data-row-resize-edge="below"]',
+ );
+ expect(lowerHalf).not.toBeNull();
+ act(() => {
+ pointAt(lowerHalf!, "pointerdown", 100);
+ pointAt(lowerHalf!, "pointermove", 180);
+ });
+
+ for (const box of rowBoxes(0)) {
+ expect(box).toHaveStyle({ height: "176px" });
+ }
+ for (const box of rowBoxes(1)) {
+ expect(box).toHaveStyle({ height: "96px", maxHeight: "96px" });
+ }
+ });
+
+ it("does not render a row resize handle for tables that only use presets", () => {
+ render(
+ <SortableTable initialOrderBy={{ column: "scoreName", order: "ASC" }} />,
+ );
+
+ expect(
+ screen.queryByRole("slider", { name: "Row height" }),
+ ).not.toBeInTheDocument();
+ });
+
+ it("previews the dragged row only, then commits one height for the table", () => {
+ vi.spyOn(HTMLElement.prototype, "getBoundingClientRect").mockImplementation(
+ () => rect(96),
+ );
+ const onCustomRowHeightChange = vi.fn();
+ renderResizableTable(onCustomRowHeightChange);
+
+ const handle = screen.getByRole("slider", { name: "Row height" });
+ act(() => {
+ pointAt(handle, "pointerdown", 100);
+ pointAt(handle, "pointermove", 220);
+ });
+
+ // Both columns of the dragged row follow the pointer. The other row waits.
+ expect(rowBoxes(0)).toHaveLength(2);
+ for (const box of rowBoxes(0)) {
+ expect(box).toHaveStyle({ height: "216px" });
+ }
+ for (const box of rowBoxes(1)) {
+ expect(box).toHaveStyle({ height: "96px", maxHeight: "96px" });
+ }
+
+ act(() => {
+ pointAt(handle, "pointerup", 220);
+ });
+ expect(onCustomRowHeightChange).toHaveBeenCalledExactlyOnceWith(216);
+ });
+
+ it("shrinks a Small row back to Small in the same drag", () => {
+ vi.spyOn(HTMLElement.prototype, "getBoundingClientRect").mockImplementation(
+ () => rect(28),
+ );
+ const onCustomRowHeightChange = vi.fn();
+ const onSelectRowHeight = vi.fn();
+ render(
+ <DataTable
+ tableName="traces"
+ columns={columns}
+ hidePagination
+ rowHeight="s"
+ onCustomRowHeightChange={onCustomRowHeightChange}
+ onSelectRowHeight={onSelectRowHeight}
+ data={{ isLoading: false, isError: false, data: rows }}
+ />,
+ );
+
+ const handle = screen.getByRole("slider", { name: "Row height" });
+ expect(handle).toHaveAttribute("aria-valuemin", "28");
+ act(() => {
+ pointAt(handle, "pointerdown", 100);
+ pointAt(handle, "pointermove", 240);
+ });
+ for (const box of rowBoxes(0)) {
+ expect(box).toHaveStyle({ height: "168px" });
+ }
+ for (const box of rowBoxes(1)) {
+ expect(box).toHaveStyle({ height: "28px", maxHeight: "28px" });
+ }
+
+ act(() => {
+ pointAt(handle, "pointermove", -40);
+ });
+ for (const box of rowBoxes(0)) {
+ expect(box).toHaveStyle({ height: "28px", maxHeight: "28px" });
+ }
+ for (const box of rowBoxes(1)) {
+ expect(box).toHaveStyle({ height: "28px", maxHeight: "28px" });
+ }
+
+ act(() => {
+ pointAt(handle, "pointerup", -40);
+ });
+ expect(onCustomRowHeightChange).not.toHaveBeenCalled();
+ expect(onSelectRowHeight).not.toHaveBeenCalled();
+ for (const box of document.querySelectorAll("[data-row-height]")) {
+ expect(box).toHaveClass("h-7");
+ }
+ });
+
+ it("selects Small when a second drag shrinks a free height down to it", () => {
+ vi.spyOn(HTMLElement.prototype, "getBoundingClientRect").mockImplementation(
+ () => rect(168),
+ );
+ const onCustomRowHeightChange = vi.fn();
+ const onSelectRowHeight = vi.fn();
+ render(
+ <DataTable
+ tableName="traces"
+ columns={columns}
+ hidePagination
+ rowHeight="s"
+ customRowHeightPx={168}
+ onCustomRowHeightChange={onCustomRowHeightChange}
+ onSelectRowHeight={onSelectRowHeight}
+ data={{ isLoading: false, isError: false, data: rows }}
+ />,
+ );
+
+ const handle = screen.getByRole("slider", { name: "Row height" });
+ act(() => {
+ pointAt(handle, "pointerdown", 400);
+ pointAt(handle, "pointermove", 0);
+ });
+ for (const box of rowBoxes(0)) {
+ expect(box).toHaveStyle({ height: "28px", maxHeight: "28px" });
+ }
+ for (const box of rowBoxes(1)) {
+ expect(box).toHaveStyle({ height: "168px", maxHeight: "168px" });
+ }
+
+ act(() => {
+ pointAt(handle, "pointerup", 0);
+ });
+ expect(onCustomRowHeightChange).not.toHaveBeenCalled();
+ expect(onSelectRowHeight).toHaveBeenCalledExactlyOnceWith("s");
+ });
+
+ it("uses a taller Small preset as the floor instead of the default 28px", () => {
+ vi.spyOn(HTMLElement.prototype, "getBoundingClientRect").mockImplementation(
+ () => rect(332),
+ );
+ const onCustomRowHeightChange = vi.fn();
+ const onSelectRowHeight = vi.fn();
+ render(
+ <DataTable
+ tableName="experiment-grid"
+ columns={columns}
+ hidePagination
+ rowHeight="m"
+ customRowHeightPx={332}
+ customRowHeights={{ s: "h-48", m: "h-64", l: "h-96" }}
+ onCustomRowHeightChange={onCustomRowHeightChange}
+ onSelectRowHeight={onSelectRowHeight}
+ data={{ isLoading: false, isError: false, data: rows }}
+ />,
+ );
+
+ const handle = screen.getByRole("slider", { name: "Row height" });
+ expect(handle).toHaveAttribute("aria-valuemin", "192");
+ act(() => {
+ pointAt(handle, "pointerdown", 500);
+ pointAt(handle, "pointermove", 0);
+ });
+ for (const box of rowBoxes(0)) {
+ expect(box).toHaveStyle({ height: "192px", maxHeight: "192px" });
+ }
+ for (const box of rowBoxes(1)) {
+ expect(box).toHaveStyle({ height: "332px", maxHeight: "332px" });
+ }
+
+ act(() => {
+ pointAt(handle, "pointerup", 0);
+ });
+ expect(onCustomRowHeightChange).not.toHaveBeenCalled();
+ expect(onSelectRowHeight).toHaveBeenCalledExactlyOnceWith("s");
+ });
+
+ it("shrinks a custom height back below Medium and returns string cells to one line", () => {
+ vi.spyOn(HTMLElement.prototype, "getBoundingClientRect").mockImplementation(
+ () => rect(208),
+ );
+ const onCustomRowHeightChange = vi.fn();
+ renderResizableTable(onCustomRowHeightChange, 208);
+
+ expect(screen.getByText("zeta-score")).not.toHaveClass("truncate");
+
+ const handle = screen.getByRole("slider", { name: "Row height" });
+ act(() => {
+ pointAt(handle, "pointerdown", 400);
+ pointAt(handle, "pointermove", 240);
+ });
+
+ for (const box of rowBoxes(0)) {
+ expect(box).toHaveStyle({ height: "48px", maxHeight: "48px" });
+ }
+ for (const box of rowBoxes(1)) {
+ expect(box).toHaveStyle({ height: "208px", maxHeight: "208px" });
+ }
+ expect(screen.getByText("zeta-score")).toHaveClass("truncate");
+ expect(screen.getByText("alpha-score")).not.toHaveClass("truncate");
+
+ act(() => {
+ pointAt(handle, "pointerup", 240);
+ });
+ expect(onCustomRowHeightChange).toHaveBeenCalledExactlyOnceWith(48);
+ });
+
+ it("leaves the preset in place when the row edge is pressed without moving", () => {
+ vi.spyOn(HTMLElement.prototype, "getBoundingClientRect").mockImplementation(
+ () => rect(192),
+ );
+ const onCustomRowHeightChange = vi.fn();
+ renderResizableTable(onCustomRowHeightChange);
+
+ const handle = screen.getByRole("slider", { name: "Row height" });
+ act(() => {
+ pointAt(handle, "pointerdown", 40);
+ pointAt(handle, "pointerup", 40);
+ });
+
+ expect(onCustomRowHeightChange).not.toHaveBeenCalled();
+ expect(document.querySelector("[data-row-height]")).not.toHaveStyle({
+ height: "192px",
+ });
+ });
+
+ it("grows every cell together when the row-height slider is stepped down", () => {
+ vi.spyOn(HTMLElement.prototype, "getBoundingClientRect").mockImplementation(
+ () => rect(96),
+ );
+ const onCustomRowHeightChange = vi.fn();
+ renderResizableTable(onCustomRowHeightChange);
+
+ const handle = screen.getByRole("slider", { name: "Row height" });
+ expect(handle).toHaveAttribute("aria-orientation", "vertical");
+ expect(handle).toHaveAttribute("aria-valuenow", "96");
+ act(() => {
+ fireEvent.keyDown(handle, { key: "ArrowDown" });
+ fireEvent.keyDown(handle, { key: "ArrowDown" });
+ });
+
+ expect(onCustomRowHeightChange).not.toHaveBeenCalled();
+ expect(handle).toHaveAttribute("aria-valuenow", "128");
+ for (const box of rowBoxes(0)) {
+ expect(box).toHaveStyle({ height: "128px" });
+ }
+ for (const box of rowBoxes(1)) {
+ expect(box).toHaveStyle({ height: "96px", maxHeight: "96px" });
+ }
+
+ act(() => {
+ fireEvent.keyUp(handle, { key: "ArrowDown" });
+ });
+ expect(onCustomRowHeightChange).toHaveBeenCalledExactlyOnceWith(128);
+ });
+
+ function ModeProbe() {
+ const rendering = useRowHeightRendering();
+ return (
+ <span data-testid="row-mode">
+ {rendering?.compact ? "compact" : "expanded"}
+ </span>
+ );
+ }
+
+ const modeColumns: LangfuseColumnDef<Row>[] = [
+ ...columns,
+ {
+ accessorKey: "mode",
+ id: "mode",
+ header: "Mode",
+ cell: () => <ModeProbe />,
+ },
+ ];
+
+ it("switches the cell mode at Medium while the drag is still in progress", () => {
+ vi.spyOn(HTMLElement.prototype, "getBoundingClientRect").mockImplementation(
+ () => rect(28),
+ );
+ const onCustomRowHeightChange = vi.fn();
+ render(
+ <DataTable
+ tableName="experiment-items"
+ columns={modeColumns}
+ hidePagination
+ rowHeight="s"
+ onCustomRowHeightChange={onCustomRowHeightChange}
+ data={{ isLoading: false, isError: false, data: rows }}
+ />,
+ );
+
+ expect(screen.getAllByTestId("row-mode")[0]).toHaveTextContent("compact");
+ expect(screen.getByText("zeta-score")).toHaveClass("truncate");
+
+ const handle = screen.getByRole("slider", { name: "Row height" });
+ act(() => {
+ pointAt(handle, "pointerdown", 0);
+ pointAt(handle, "pointermove", 68);
+ });
+
+ expect(onCustomRowHeightChange).not.toHaveBeenCalled();
+ expect(screen.getAllByTestId("row-mode")[0]).toHaveTextContent("expanded");
+ expect(screen.getAllByTestId("row-mode")[1]).toHaveTextContent("compact");
+ expect(screen.getByText("zeta-score")).not.toHaveClass("truncate");
+ expect(screen.getByText("alpha-score")).toHaveClass("truncate");
+ for (const box of rowBoxes(0)) {
+ expect(box).toHaveStyle({ height: "96px" });
+ }
+ for (const box of rowBoxes(1)) {
+ expect(box).toHaveStyle({ height: "28px", maxHeight: "28px" });
+ }
+
+ act(() => {
+ pointAt(handle, "pointermove", 20);
+ });
+ expect(screen.getAllByTestId("row-mode")[0]).toHaveTextContent("compact");
+ expect(screen.getAllByTestId("row-mode")[1]).toHaveTextContent("compact");
+ expect(screen.getByText("zeta-score")).toHaveClass("truncate");
+ });
+
+ it("paints a committed custom height of Medium the same as the Medium preset", () => {
+ const { rerender } = render(
+ <DataTable
+ tableName="experiment-items"
+ columns={modeColumns}
+ hidePagination
+ rowHeight="m"
+ data={{ isLoading: false, isError: false, data: rows }}
+ />,
+ );
+ expect(screen.getAllByTestId("row-mode")[0]).toHaveTextContent("expanded");
+
+ rerender(
+ <DataTable
+ tableName="experiment-items"
+ columns={modeColumns}
+ hidePagination
+ rowHeight="s"
+ customRowHeightPx={96}
+ onCustomRowHeightChange={vi.fn()}
+ data={{ isLoading: false, isError: false, data: rows }}
+ />,
+ );
+ expect(screen.getAllByTestId("row-mode")[0]).toHaveTextContent("expanded");
+ for (const box of document.querySelectorAll("[data-row-height]")) {
+ expect(box).toHaveStyle({ height: "96px" });
+ }
+
+ rerender(
+ <DataTable
+ tableName="experiment-items"
+ columns={modeColumns}
+ hidePagination
+ rowHeight="l"
+ customRowHeightPx={95}
+ onCustomRowHeightChange={vi.fn()}
+ data={{ isLoading: false, isError: false, data: rows }}
+ />,
+ );
+ expect(screen.getAllByTestId("row-mode")[0]).toHaveTextContent("compact");
+ });
+
+ const listHeights: CustomHeights = { s: "h-24", m: "h-48", l: "h-96" };
+ const gridHeights: CustomHeights = { s: "h-48", m: "h-64", l: "h-96" };
+
+ function renderSizedTable({
+ heights,
+ rowHeight = "m",
+ customRowHeightPx,
+ onCustomRowHeightChange = vi.fn(),
+ onSelectRowHeight = vi.fn(),
+ }: {
+ heights?: CustomHeights;
+ rowHeight?: RowHeight;
+ customRowHeightPx?: number;
+ onCustomRowHeightChange?: (heightPx: number) => void;
+ onSelectRowHeight?: (rowHeight: RowHeight) => void;
+ }) {
+ render(
+ <DataTable
+ tableName="experiment-items"
+ columns={columns}
+ hidePagination
+ rowHeight={rowHeight}
+ customRowHeightPx={customRowHeightPx}
+ customRowHeights={heights}
+ onCustomRowHeightChange={onCustomRowHeightChange}
+ onSelectRowHeight={onSelectRowHeight}
+ data={{ isLoading: false, isError: false, data: rows }}
+ />,
+ );
+ }
+
+ it("shrinks an experiment list row from Medium to that table's Small", () => {
+ vi.spyOn(HTMLElement.prototype, "getBoundingClientRect").mockImplementation(
+ () => rect(192),
+ );
+ const onCustomRowHeightChange = vi.fn();
+ const onSelectRowHeight = vi.fn();
+ renderSizedTable({
+ heights: listHeights,
+ onCustomRowHeightChange,
+ onSelectRowHeight,
+ });
+
+ const handle = document.querySelector<HTMLElement>(
+ 'tr[data-row-index="1"] [data-row-resize-edge="last"]',
+ );
+ expect(handle).not.toBeNull();
+ expect(screen.getByRole("slider", { name: "Row height" })).toHaveAttribute(
+ "aria-valuemin",
+ "96",
+ );
+ act(() => {
+ pointAt(handle!, "pointerdown", 400);
+ pointAt(handle!, "pointermove", 0);
+ });
+ for (const box of rowBoxes(1)) {
+ expect(box).toHaveStyle({ height: "96px", maxHeight: "96px" });
+ }
+ for (const box of rowBoxes(0)) {
+ expect(box).toHaveStyle({ height: "192px", maxHeight: "192px" });
+ }
+
+ act(() => {
+ pointAt(handle!, "pointerup", 0);
+ });
+ expect(onCustomRowHeightChange).not.toHaveBeenCalled();
+ expect(onSelectRowHeight).toHaveBeenCalledExactlyOnceWith("s");
+ });
+
+ it("shrinks an experiment grid row from Medium to that table's Small", () => {
+ vi.spyOn(HTMLElement.prototype, "getBoundingClientRect").mockImplementation(
+ () => rect(256),
+ );
+ const onCustomRowHeightChange = vi.fn();
+ const onSelectRowHeight = vi.fn();
+ renderSizedTable({
+ heights: gridHeights,
+ onCustomRowHeightChange,
+ onSelectRowHeight,
+ });
+
+ const handle = screen.getByRole("slider", { name: "Row height" });
+ expect(handle).toHaveAttribute("aria-valuemin", "192");
+ act(() => {
+ pointAt(handle, "pointerdown", 400);
+ pointAt(handle, "pointermove", 0);
+ });
+ for (const box of rowBoxes(0)) {
+ expect(box).toHaveStyle({ height: "192px", maxHeight: "192px" });
+ }
+ for (const box of rowBoxes(1)) {
+ expect(box).toHaveStyle({ height: "256px", maxHeight: "256px" });
+ }
+
+ act(() => {
+ pointAt(handle, "pointerup", 0);
+ });
+ expect(onCustomRowHeightChange).not.toHaveBeenCalled();
+ expect(onSelectRowHeight).toHaveBeenCalledExactlyOnceWith("s");
+ });
+
+ it("shrinks a custom experiment height down to Small", () => {
+ vi.spyOn(HTMLElement.prototype, "getBoundingClientRect").mockImplementation(
+ () => rect(300),
+ );
+ const onSelectRowHeight = vi.fn();
+ renderSizedTable({
+ heights: listHeights,
+ customRowHeightPx: 300,
+ onSelectRowHeight,
+ });
+
+ const handle = screen.getByRole("slider", { name: "Row height" });
+ act(() => {
+ pointAt(handle, "pointerdown", 500);
+ pointAt(handle, "pointermove", 0);
+ });
+ for (const box of rowBoxes(0)) {
+ expect(box).toHaveStyle({ height: "96px", maxHeight: "96px" });
+ }
+ for (const box of rowBoxes(1)) {
+ expect(box).toHaveStyle({ height: "300px", maxHeight: "300px" });
+ }
+
+ act(() => {
+ pointAt(handle, "pointerup", 0);
+ });
+ expect(onSelectRowHeight).toHaveBeenCalledExactlyOnceWith("s");
+ });
+
+ function CommittedHeightTable() {
+ const [preset, setPreset] = useState<RowHeight>("m");
+ const [px, setPx] = useState<number | undefined>(undefined);
+ return (
+ <DataTable
+ tableName="traces"
+ columns={columns}
+ hidePagination
+ rowHeight={preset}
+ customRowHeightPx={px}
+ onCustomRowHeightChange={setPx}
+ onSelectRowHeight={(next) => {
+ setPreset(next);
+ setPx(undefined);
+ }}
+ data={{ isLoading: false, isError: false, data: rows }}
+ />
+ );
+ }
+
+ function installStackedRects(fallback: number) {
+ const heightOf = (el: HTMLElement) => {
+ const parsed = Number.parseFloat(el.style.height);
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
+ };
+ vi.spyOn(HTMLElement.prototype, "getBoundingClientRect").mockImplementation(
+ function (this: HTMLElement) {
+ if (this.tagName === "TR") {
+ const rows = this.parentElement
+ ? [
+ ...this.parentElement.querySelectorAll<HTMLElement>(
+ "tr[data-row-index]",
+ ),
+ ]
+ : [];
+ let top = 0;
+ for (const row of rows) {
+ if (row === this) break;
+ const box = row.querySelector<HTMLElement>("[data-row-height]");
+ top += box ? heightOf(box) : fallback;
+ }
+ const own = this.querySelector<HTMLElement>("[data-row-height]");
+ return rect(own ? heightOf(own) : fallback, top);
+ }
+ if (this.hasAttribute("data-row-height")) return rect(heightOf(this));
+ return rect(fallback);
+ },
+ );
+ }
+
+ function prepareScroller(
+ scrollHeight: number,
+ clientHeight: number,
+ scrollTop: number,
+ ) {
+ const node = document.querySelector("table")?.parentElement as HTMLElement;
+ Object.defineProperty(node, "scrollHeight", {
+ configurable: true,
+ value: scrollHeight,
+ });
+ Object.defineProperty(node, "clientHeight", {
+ configurable: true,
+ value: clientHeight,
+ });
+ node.scrollTop = scrollTop;
+ return node;
+ }
+
+ it("keeps the dragged row's top edge after every row takes the new height", () => {
+ installStackedRects(96);
+ render(<CommittedHeightTable />);
+ const scroller = prepareScroller(5000, 400, 120);
+ const handle = document.querySelector<HTMLElement>(
+ 'tr[data-row-index="1"] [data-row-resize-edge="last"]',
+ );
+
+ act(() => {
+ pointAt(handle!, "pointerdown", 100);
+ pointAt(handle!, "pointermove", 204);
+ });
+ for (const box of rowBoxes(0)) {
+ expect(box).toHaveStyle({ height: "96px" });
+ }
+ for (const box of rowBoxes(1)) {
+ expect(box).toHaveStyle({ height: "200px" });
+ }
+
+ act(() => {
+ pointAt(handle!, "pointerup", 204);
+ });
+ for (const box of [...rowBoxes(0), ...rowBoxes(1)]) {
+ expect(box).toHaveStyle({ height: "200px", maxHeight: "200px" });
+ }
+ // The row above grew by 104px, so the scroller follows by the same amount.
+ expect(scroller.scrollTop).toBe(224);
+ });
+
+ it("clamps the anchor when the list cannot scroll far enough", () => {
+ installStackedRects(96);
+ render(<CommittedHeightTable />);
+ const scroller = prepareScroller(1000, 900, 50);
+ const handle = document.querySelector<HTMLElement>(
+ 'tr[data-row-index="1"] [data-row-resize-edge="last"]',
+ );
+
+ act(() => {
+ pointAt(handle!, "pointerdown", 0);
+ pointAt(handle!, "pointerup", 400);
+ });
+
+ for (const box of rowBoxes(0)) {
+ expect(box).toHaveStyle({ height: "496px" });
+ }
+ expect(scroller.scrollTop).toBe(100);
+ });
+});
diff --git a/web/src/components/table/data-table.tsx b/web/src/components/table/data-table.tsx
index 27030e1609..a7d7a56c18 100644
--- a/web/src/components/table/data-table.tsx
+++ b/web/src/components/table/data-table.tsx
@@ -8,6 +8,7 @@ import React, {
useCallback,
useRef,
useEffect,
+ useLayoutEffect,
type CSSProperties,
type UIEventHandler,
} from "react";
@@ -18,7 +19,14 @@ import { getPlainTextFromReactNode } from "@/src/utils/react-node-plain-text";
import {
type CustomHeights,
type RowHeight,
+ MAX_CUSTOM_ROW_HEIGHT_PX,
+ RowHeightRenderingProvider,
+ anchoredScrollTop,
+ clampCustomRowHeightPx,
getRowHeightTailwindClass,
+ minCustomRowHeightPx,
+ resolveRowHeightRendering,
+ rowHeightPresetForPx,
} from "@/src/components/table/data-table-row-height-switch";
import { Skeleton } from "@/src/components/ui/skeleton";
import {
@@ -119,6 +127,21 @@ interface DataTableProps<TData, TValue> {
noResultsMessage?: React.ReactNode;
rowHeight?: RowHeight;
customRowHeights?: CustomHeights;
+ /**
+ * Free height in pixels. When set, it replaces the preset class on every
+ * row, so a drag in one run column stays aligned with the others.
+ */
+ customRowHeightPx?: number | null;
+ /**
+ * Dragging a row edge commits a free height. Omit on tables that should
+ * stay on presets, including embedded previews that force a small row.
+ */
+ onCustomRowHeightChange?: (heightPx: number) => void;
+ /**
+ * Called when a drag ends on a preset's pixel height. The row then uses
+ * that preset. Without this, the same height is stored as a free height.
+ */
+ onSelectRowHeight?: (rowHeight: RowHeight) => void;
className?: string;
shouldRenderGroupHeaders?: boolean;
onRowClick?: (row: TData, event?: React.MouseEvent) => void;
@@ -246,6 +269,9 @@ export function DataTable<TData extends object, TValue>({
setOrderBy,
rowHeight,
customRowHeights,
+ customRowHeightPx,
+ onCustomRowHeightChange,
+ onSelectRowHeight,
className,
shouldRenderGroupHeaders = false,
onRowClick,
@@ -261,7 +287,39 @@ export function DataTable<TData extends object, TValue>({
}: DataTableProps<TData, TValue>) {
const [columnFilters, setColumnFilters] = useState<ColumnFiltersState>([]);
const rowheighttw = getRowHeightTailwindClass(rowHeight, customRowHeights);
+ const rowHeightPx = customRowHeightPx ?? undefined;
+ const rowResizeEnabled = onCustomRowHeightChange != null;
+ const onCustomRowHeightChangeRef = useRef(onCustomRowHeightChange);
+ onCustomRowHeightChangeRef.current = onCustomRowHeightChange;
+ const onSelectRowHeightRef = useRef(onSelectRowHeight);
+ onSelectRowHeightRef.current = onSelectRowHeight;
+ const customRowHeightsRef = useRef(customRowHeights);
+ customRowHeightsRef.current = customRowHeights;
const capture = usePostHogClientCapture();
+ const rowHeightScrollRef = useRef<HTMLDivElement>(null);
+ const commitCustomRowHeight = useCallback(
+ (heightPx: number) => {
+ const matched = rowHeightPresetForPx(
+ heightPx,
+ customRowHeightsRef.current,
+ );
+ if (matched && onSelectRowHeightRef.current) {
+ capture("table:row_height_switch_select", {
+ rowHeight: matched,
+ tableName,
+ });
+ onSelectRowHeightRef.current(matched);
+ return;
+ }
+ capture("table:row_height_switch_select", {
+ rowHeight: "custom",
+ heightPx,
+ tableName,
+ });
+ onCustomRowHeightChangeRef.current?.(heightPx);
+ },
+ [capture, tableName],
+ );
const flattedColumnsByGroup = useMemo(() => {
const flatColumnsByGroup = new Map<string, string[]>();
@@ -453,6 +511,7 @@ export function DataTable<TData extends object, TValue>({
)}
>
<div
+ ref={rowHeightScrollRef}
// When the final visible column can be resized, reserve a small gutter so
// its handle is never flush against the scrollbar or edge and always has
// some cursor room. Partial mitigation for LFE-10460: a maximized browser
@@ -460,6 +519,8 @@ export function DataTable<TData extends object, TValue>({
className={cn(
"relative min-h-full w-full overflow-auto border-t [scrollbar-gutter:stable]",
table.getVisibleLeafColumns().at(-1)?.getCanResize() && "pr-2",
+ // Room for the last row's resize strip, which hangs 3px below the table.
+ onCustomRowHeightChange != null && "pb-[3px]",
)}
style={{ ...columnSizeVars }}
onScroll={onScroll}
@@ -641,6 +702,11 @@ export function DataTable<TData extends object, TValue>({
table={table}
rowheighttw={rowheighttw}
rowHeight={rowHeight}
+ rowHeightPx={rowHeightPx}
+ customRowHeights={customRowHeights}
+ rowResizeEnabled={rowResizeEnabled}
+ onCommitRowHeight={commitCustomRowHeight}
+ scrollContainerRef={rowHeightScrollRef}
columns={columns}
data={data}
help={help}
@@ -663,6 +729,11 @@ export function DataTable<TData extends object, TValue>({
table={table}
rowheighttw={rowheighttw}
rowHeight={rowHeight}
+ rowHeightPx={rowHeightPx}
+ customRowHeights={customRowHeights}
+ rowResizeEnabled={rowResizeEnabled}
+ onCommitRowHeight={commitCustomRowHeight}
+ scrollContainerRef={rowHeightScrollRef}
columns={columns}
data={data}
help={help}
@@ -800,6 +871,12 @@ interface TableBodyComponentProps<TData> {
table: ReturnType<typeof useReactTable<TData>>;
rowheighttw?: string;
rowHeight?: RowHeight;
+ rowHeightPx?: number;
+ customRowHeights?: CustomHeights;
+ rowResizeEnabled?: boolean;
+ onCommitRowHeight?: (heightPx: number) => void;
+ /** Scroller whose scrollTop keeps the dragged row in place after commit. */
+ scrollContainerRef?: React.RefObject<HTMLDivElement | null>;
columns: LangfuseColumnDef<TData, any>[];
data: AsyncTableData<TData[]>;
help?: { description: string; href: string };
@@ -877,10 +954,71 @@ function TableRowComponent<TData>({
);
}
+/** Each side of the 6px strip centered on the row's bottom border. */
+const ROW_RESIZE_HALF_PX = 3;
+const ROW_BORDER_PX = 1;
+
+type RowResizeEdge = "above" | "below" | "last";
+
+function rowResizeHandleStyle(edge: RowResizeEdge): CSSProperties {
+ if (edge === "below") return { top: 0, height: ROW_RESIZE_HALF_PX };
+ if (edge === "last") {
+ return { bottom: -ROW_RESIZE_HALF_PX, height: ROW_RESIZE_HALF_PX * 2 };
+ }
+ // Ends on the outer edge of the 1px border, so 3px sits above that line.
+ return { bottom: -ROW_BORDER_PX, height: ROW_RESIZE_HALF_PX };
+}
+
+function rowHeightFrameProps({
+ rowheighttw,
+ heightPx,
+ presetClass,
+ compact,
+ topAlignCells,
+ measure,
+ clipContent = false,
+}: {
+ rowheighttw?: string;
+ /** Pixel lock. A drag, a free height, and a preset while resize is on. */
+ heightPx?: number;
+ /** Keep the Tailwind height class. True while this row shows its preset. */
+ presetClass: boolean;
+ compact: boolean;
+ topAlignCells: boolean;
+ measure: boolean;
+ clipContent?: boolean;
+}): {
+ className: string;
+ style?: CSSProperties;
+ "data-row-height"?: string;
+} {
+ return {
+ className: cn(
+ "flex",
+ compact && !topAlignCells ? "items-center" : "items-start",
+ !compact && "py-1",
+ presetClass ? rowheighttw : "min-h-0 overflow-hidden",
+ clipContent && "w-full min-w-0 overflow-hidden",
+ ),
+ // height and maxHeight together: a table cell treats a lone height as a
+ // minimum, so content can hold a row open after the handle asks it to shrink.
+ style:
+ heightPx != null
+ ? { height: heightPx, maxHeight: heightPx, minHeight: 0 }
+ : undefined,
+ ...(measure ? { "data-row-height": "" } : {}),
+ };
+}
+
function TableBodyComponent<TData>({
table,
rowheighttw,
rowHeight,
+ rowHeightPx,
+ customRowHeights,
+ rowResizeEnabled = false,
+ onCommitRowHeight,
+ scrollContainerRef,
columns,
data,
help,
@@ -901,89 +1039,308 @@ function TableBodyComponent<TData>({
1,
Math.min(tableState.pagination?.pageSize ?? 8, 8),
);
+ const dragRef = useRef<{
+ pointerId: number;
+ startY: number;
+ startHeight: number;
+ rowIndex: number;
+ } | null>(null);
+ const [preview, setPreview] = useState<{
+ rowIndex: number;
+ px: number;
+ } | null>(null);
+ const committedRendering = resolveRowHeightRendering(
+ {
+ preset: rowHeight ?? "s",
+ customPx: rowHeightPx ?? null,
+ },
+ customRowHeights,
+ );
+ const previewCommitRef = useRef<number | null>(null);
+ const keyGestureStartRef = useRef<number | null>(null);
+ const anchorRef = useRef<{ rowIndex: number; top: number } | null>(null);
+ const [anchorEpoch, setAnchorEpoch] = useState(0);
+ const tableBodyRef = useRef<HTMLTableSectionElement>(null);
+ const [measuredPx, setMeasuredPx] = useState<number | undefined>(undefined);
+ const minRowHeightPx = minCustomRowHeightPx(customRowHeights);
+ const announcedPx = preview?.px ?? rowHeightPx ?? measuredPx;
+
+ const rememberRowAnchor = (rowIndex: number) => {
+ const row = tableBodyRef.current?.querySelector<HTMLElement>(
+ `tr[data-row-index="${rowIndex}"]`,
+ );
+ if (!row) {
+ anchorRef.current = null;
+ return;
+ }
+ anchorRef.current = {
+ rowIndex,
+ top: row.getBoundingClientRect().top,
+ };
+ };
+
+ // After the shared height lands, rows above the dragged one move it. Put
+ // its top edge back, including when the list's maximum scroll shrinks.
+ useLayoutEffect(() => {
+ const anchor = anchorRef.current;
+ if (!anchor) return;
+ anchorRef.current = null;
+ const scroller = scrollContainerRef?.current;
+ const row = tableBodyRef.current?.querySelector<HTMLElement>(
+ `tr[data-row-index="${anchor.rowIndex}"]`,
+ );
+ if (!scroller || !row) return;
+ scroller.scrollTop = anchoredScrollTop({
+ scrollTop: scroller.scrollTop,
+ rowTop: row.getBoundingClientRect().top,
+ anchorTop: anchor.top,
+ scrollHeight: scroller.scrollHeight,
+ clientHeight: scroller.clientHeight,
+ });
+ }, [anchorEpoch, rowHeight, rowHeightPx, scrollContainerRef]);
+
+ useLayoutEffect(() => {
+ if (!rowResizeEnabled) return;
+ const sized =
+ tableBodyRef.current?.querySelector<HTMLElement>("[data-row-height]");
+ const height = sized?.getBoundingClientRect().height;
+ if (height == null || height <= 0) return;
+ const rounded = Math.round(height);
+ setMeasuredPx((current) => (current === rounded ? current : rounded));
+ }, [rowResizeEnabled, rowHeight, rowModelRows.length, data.isLoading]);
+
+ const onResizePointerDown = (event: React.PointerEvent<HTMLDivElement>) => {
+ // button is 0 for a primary press. Some pointers report -1 until the
+ // button is known; only an explicit non-primary button should bail.
+ if (event.button > 0) return;
+ event.preventDefault();
+ event.stopPropagation();
+ // The lower half lives in the next row. Its target is the row above
+ // the border, not the row that contains the element.
+ const rowIndex = Number(event.currentTarget.dataset.rowResizeTarget ?? "");
+ if (!Number.isInteger(rowIndex) || rowIndex < 0) return;
+ const sized = tableBodyRef.current?.querySelector<HTMLElement>(
+ `tr[data-row-index="${rowIndex}"] [data-row-height]`,
+ );
+ const startHeight = sized?.getBoundingClientRect().height;
+ if (startHeight == null || startHeight <= 0) return;
+ dragRef.current = {
+ pointerId: event.pointerId,
+ startY: event.clientY,
+ startHeight,
+ rowIndex,
+ };
+ try {
+ event.currentTarget.setPointerCapture(event.pointerId);
+ } catch {
+ // Capture can fail when the pointer id is unknown. Moves fired on
+ // the handle still update the height.
+ }
+ };
+
+ const onResizePointerMove = (event: React.PointerEvent<HTMLDivElement>) => {
+ const drag = dragRef.current;
+ if (!drag || event.pointerId !== drag.pointerId) return;
+ event.preventDefault();
+ setPreview({
+ rowIndex: drag.rowIndex,
+ px: clampCustomRowHeightPx(
+ drag.startHeight + (event.clientY - drag.startY),
+ minRowHeightPx,
+ ),
+ });
+ };
+
+ const finishResize = (event: React.PointerEvent<HTMLDivElement>) => {
+ const drag = dragRef.current;
+ if (!drag || event.pointerId !== drag.pointerId) return;
+ dragRef.current = null;
+ const next = clampCustomRowHeightPx(
+ drag.startHeight + (event.clientY - drag.startY),
+ minRowHeightPx,
+ );
+ setPreview(null);
+ if (next === Math.round(drag.startHeight)) {
+ anchorRef.current = null;
+ return;
+ }
+ rememberRowAnchor(drag.rowIndex);
+ setAnchorEpoch((epoch) => epoch + 1);
+ onCommitRowHeight?.(next);
+ };
+
+ const commitKeyboardResize = () => {
+ const next = previewCommitRef.current;
+ const start = keyGestureStartRef.current;
+ if (next == null && start == null) return;
+ previewCommitRef.current = null;
+ keyGestureStartRef.current = null;
+ setPreview(null);
+ if (next == null || start == null || next === Math.round(start)) {
+ anchorRef.current = null;
+ return;
+ }
+ // The slider lives on the first row.
+ rememberRowAnchor(0);
+ setAnchorEpoch((epoch) => epoch + 1);
+ onCommitRowHeight?.(next);
+ };
+
+ const onResizeKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {
+ if (event.key !== "ArrowDown" && event.key !== "ArrowUp") return;
+ event.preventDefault();
+ event.stopPropagation();
+ const sized = event.currentTarget
+ .closest("td")
+ ?.querySelector<HTMLElement>("[data-row-height]");
+ const fallback =
+ preview?.px ??
+ rowHeightPx ??
+ measuredPx ??
+ sized?.getBoundingClientRect().height ??
+ minRowHeightPx;
+ const current = previewCommitRef.current ?? fallback;
+ if (keyGestureStartRef.current == null) {
+ keyGestureStartRef.current = current;
+ }
+ const delta = event.key === "ArrowDown" ? 16 : -16;
+ const next = clampCustomRowHeightPx(current + delta, minRowHeightPx);
+ previewCommitRef.current = next;
+ setPreview({ rowIndex: 0, px: next });
+ };
+
+ const renderingForRow = (rowIndex: number) => {
+ if (preview == null || preview.rowIndex !== rowIndex) {
+ return { rendering: committedRendering, previewing: false };
+ }
+ return {
+ previewing: true,
+ rendering: resolveRowHeightRendering(
+ {
+ preset: rowHeight ?? "s",
+ customPx: rowHeightPx ?? null,
+ previewPx: preview.px,
+ },
+ customRowHeights,
+ ),
+ };
+ };
+
+ const framePropsFor = (
+ rendering: typeof committedRendering,
+ previewing: boolean,
+ measure: boolean,
+ ) =>
+ rowHeightFrameProps({
+ rowheighttw,
+ heightPx:
+ previewing || rowHeightPx != null || rowResizeEnabled
+ ? rendering.heightPx
+ : undefined,
+ presetClass: !previewing && rowHeightPx == null,
+ compact: rendering.compact,
+ topAlignCells,
+ measure,
+ clipContent: rowResizeEnabled,
+ });
return (
- <TableBody>
+ <TableBody ref={tableBodyRef}>
{data.isLoading || !data.data ? (
- Array.from({ length: skeletonRowCount }).map((_, rowIndex) => (
- <TableRow key={`loading-row-${rowIndex}`} aria-hidden="true">
- {visibleColumns.map((column, columnIndex) => {
- const columnDef = column.columnDef as LangfuseColumnDef<TData>;
-
- return (
- <TableCell
- key={`${column.id}-loading-cell-${rowIndex}`}
- className={cn(
- "overflow-hidden border-b text-xs first:pl-2",
- getCellPaddingClassName(
- columnDef.cellPadding ?? cellPadding,
- ),
- (rowHeight ?? "s") === "s" && "whitespace-nowrap",
- getPinningClasses(column),
- getCellBackgroundClassName(columnDef.cellBackground),
- columnDef.cellClassName,
- columnDef.hideBelowMd && "hidden md:table-cell",
- )}
- style={{
- ...getCommonPinningStyles(column),
- width: columnDef.isFlexWidth
- ? "auto"
- : `calc(var(--col-${column.id}-size) * 1px)`,
- }}
- >
- <div
+ <RowHeightRenderingProvider
+ compact={committedRendering.compact}
+ expandedRead={committedRendering.expandedRead}
+ >
+ {Array.from({ length: skeletonRowCount }).map((_, rowIndex) => (
+ <TableRow key={`loading-row-${rowIndex}`} aria-hidden="true">
+ {visibleColumns.map((column, columnIndex) => {
+ const columnDef = column.columnDef as LangfuseColumnDef<TData>;
+
+ return (
+ <TableCell
+ key={`${column.id}-loading-cell-${rowIndex}`}
className={cn(
- "flex",
- (rowHeight ?? "s") === "s" && !topAlignCells
- ? "items-center"
- : "items-start",
- (rowHeight ?? "s") !== "s" && "py-1",
- rowheighttw,
+ "overflow-hidden border-b text-xs first:pl-2",
+ getCellPaddingClassName(
+ columnDef.cellPadding ?? cellPadding,
+ ),
+ committedRendering.compact && "whitespace-nowrap",
+ getPinningClasses(column),
+ getCellBackgroundClassName(columnDef.cellBackground),
+ columnDef.cellClassName,
+ columnDef.hideBelowMd && "hidden md:table-cell",
)}
+ style={{
+ ...getCommonPinningStyles(column),
+ width: columnDef.isFlexWidth
+ ? "auto"
+ : `calc(var(--col-${column.id}-size) * 1px)`,
+ }}
>
- {(() => {
- const loadingCell = columnDef.loadingCell;
+ <div {...framePropsFor(committedRendering, false, false)}>
+ {(() => {
+ const loadingCell = columnDef.loadingCell;
- if (typeof loadingCell === "function") {
- return loadingCell();
- }
+ if (typeof loadingCell === "function") {
+ return loadingCell();
+ }
- if (loadingCell !== undefined) {
- return loadingCell;
- }
+ if (loadingCell !== undefined) {
+ return loadingCell;
+ }
- return (
- <Skeleton
- className={cn(
- "h-4 w-1/2",
- "min-w-[3rem]",
- (rowIndex + columnIndex) % 4 === 0 && "w-3/4",
- (rowIndex + columnIndex) % 4 === 1 && "w-1/2",
- (rowIndex + columnIndex) % 4 === 2 && "w-2/3",
- (rowIndex + columnIndex) % 4 === 3 && "w-5/6",
- )}
- />
- );
- })()}
- </div>
- </TableCell>
- );
- })}
- </TableRow>
- ))
+ return (
+ <Skeleton
+ className={cn(
+ "h-4 w-1/2",
+ "min-w-[3rem]",
+ (rowIndex + columnIndex) % 4 === 0 && "w-3/4",
+ (rowIndex + columnIndex) % 4 === 1 && "w-1/2",
+ (rowIndex + columnIndex) % 4 === 2 && "w-2/3",
+ (rowIndex + columnIndex) % 4 === 3 && "w-5/6",
+ )}
+ />
+ );
+ })()}
+ </div>
+ </TableCell>
+ );
+ })}
+ </TableRow>
+ ))}
+ </RowHeightRenderingProvider>
) : rowModelRows.length ? (
rowModelRows.map((row) => {
- const cells = row.getVisibleCells().map((cell) => {
+ const { rendering, previewing } = renderingForRow(row.index);
+ const cells = row.getVisibleCells().map((cell, cellIndex) => {
const cellValue = cell.getValue();
const isStringCell = typeof cellValue === "string";
- const isSmallRowHeight = (rowHeight ?? "s") === "s";
+ const isSmallRowHeight = rendering.compact;
const columnDef = cell.column.columnDef as LangfuseColumnDef<TData>;
+ const isLastRow = row.index === rowModelRows.length - 1;
+ const isPrimaryHandle = row.index === 0 && cellIndex === 0;
+ // Each border has a 6px strip: 3px in the row above and 3px at
+ // the top of the next row. The lower half lives in the next row
+ // so the rest of that row still receives clicks. Both halves
+ // resize the row above the line. The last row's strip hangs 3px
+ // below its own bottom edge.
+ const resizeEdges: RowResizeEdge[] = [];
+ if (rowResizeEnabled && row.index > 0) resizeEdges.push("below");
+ if (rowResizeEnabled && isLastRow) resizeEdges.push("last");
+ else if (rowResizeEnabled) resizeEdges.push("above");
+ const primaryEdge: RowResizeEdge | null = isPrimaryHandle
+ ? isLastRow
+ ? "last"
+ : "above"
+ : null;
return (
<TableCell
key={cell.id}
className={cn(
- "overflow-hidden border-b text-xs first:pl-2",
+ "border-b text-xs first:pl-2",
+ rowResizeEnabled ? "overflow-visible" : "overflow-hidden",
+ rowResizeEnabled && "relative",
getCellPaddingClassName(columnDef.cellPadding ?? cellPadding),
isSmallRowHeight && "whitespace-nowrap",
getPinningClasses(cell.column),
@@ -999,14 +1356,7 @@ function TableBodyComponent<TData>({
}}
>
<div
- className={cn(
- "flex",
- isSmallRowHeight && !topAlignCells
- ? "items-center"
- : "items-start",
- !isSmallRowHeight && "py-1",
- rowheighttw,
- )}
+ {...framePropsFor(rendering, previewing, rowResizeEnabled)}
>
{isStringCell && isSmallRowHeight ? (
<div
@@ -1034,25 +1384,72 @@ function TableBodyComponent<TData>({
flexRender(cell.column.columnDef.cell, cell.getContext())
)}
</div>
+ {resizeEdges.map((edge) => {
+ const primary = edge === primaryEdge;
+ return (
+ <div
+ key={edge}
+ data-row-resize-handle=""
+ data-row-resize-edge={edge}
+ data-row-resize-target={
+ edge === "below" ? row.index - 1 : row.index
+ }
+ role={primary ? "slider" : undefined}
+ aria-orientation={primary ? "vertical" : undefined}
+ aria-label={primary ? "Row height" : undefined}
+ aria-valuemin={primary ? minRowHeightPx : undefined}
+ aria-valuemax={
+ primary ? MAX_CUSTOM_ROW_HEIGHT_PX : undefined
+ }
+ aria-valuenow={primary ? announcedPx : undefined}
+ aria-hidden={primary ? undefined : true}
+ tabIndex={primary ? 0 : undefined}
+ onPointerDown={onResizePointerDown}
+ onPointerMove={onResizePointerMove}
+ onPointerUp={finishResize}
+ onPointerCancel={finishResize}
+ onKeyDown={primary ? onResizeKeyDown : undefined}
+ onKeyUp={primary ? commitKeyboardResize : undefined}
+ onBlur={primary ? commitKeyboardResize : undefined}
+ onClick={(event) => {
+ event.preventDefault();
+ event.stopPropagation();
+ }}
+ style={rowResizeHandleStyle(edge)}
+ className={cn(
+ // Invisible. The row-resize cursor is the pointer
+ // affordance; keyboard focus keeps a hairline ring.
+ "absolute inset-x-0 z-[1] cursor-row-resize touch-none bg-transparent select-none",
+ primary &&
+ "focus-visible:ring-ring focus-visible:ring-1 focus-visible:outline-none focus-visible:ring-inset",
+ )}
+ />
+ );
+ })}
</TableCell>
);
});
- return renderRow ? (
- <React.Fragment key={row.id}>
- {renderRow({ row, children: cells })}
- </React.Fragment>
- ) : (
- <TableRowComponent
+ return (
+ <RowHeightRenderingProvider
key={row.id}
- row={row}
- onRowClick={onRowClick}
- getRowClassName={getRowClassName}
- highlightAllRows={highlightAllRows}
- selectionStore={selectionStore}
+ compact={rendering.compact}
+ expandedRead={rendering.expandedRead}
>
- {cells}
- </TableRowComponent>
+ {renderRow ? (
+ renderRow({ row, children: cells })
+ ) : (
+ <TableRowComponent
+ row={row}
+ onRowClick={onRowClick}
+ getRowClassName={getRowClassName}
+ highlightAllRows={highlightAllRows}
+ selectionStore={selectionStore}
+ >
+ {cells}
+ </TableRowComponent>
+ )}
+ </RowHeightRenderingProvider>
);
})
) : (
@@ -1105,6 +1502,9 @@ const MemoizedTableBody = React.memo(TableBodyComponent, (prev, next) => {
if (prev.data.isLoading !== next.data.isLoading) return false;
if (prev.rowheighttw !== next.rowheighttw) return false;
if (prev.rowHeight !== next.rowHeight) return false;
+ if (prev.rowHeightPx !== next.rowHeightPx) return false;
+ if (prev.customRowHeights !== next.customRowHeights) return false;
+ if (prev.rowResizeEnabled !== next.rowResizeEnabled) return false;
if (prev.highlightAllRows !== next.highlightAllRows) return false;
if (prev.selectionStore !== next.selectionStore) return false;
if (prev.cellPadding !== next.cellPadding) return false;
diff --git a/web/src/components/table/shouldIgnoreRowClickTarget.ts b/web/src/components/table/shouldIgnoreRowClickTarget.ts
index 8e0e3cdb81..64ae3bacfb 100644
--- a/web/src/components/table/shouldIgnoreRowClickTarget.ts
+++ b/web/src/components/table/shouldIgnoreRowClickTarget.ts
@@ -3,7 +3,7 @@
* must leave them alone.
*/
const INTERACTIVE_ROW_CLICK_SELECTOR =
- "a, button, input, select, textarea, summary, [role='button'], [role='link']";
+ "a, button, input, select, textarea, summary, [role='button'], [role='link'], [data-row-resize-handle]";
/**
* Whether a click landed on a real control rather than on the row's body.
diff --git a/web/src/ee/features/audit-log-viewer/AuditLogsTable/AuditLogsTable.tsx b/web/src/ee/features/audit-log-viewer/AuditLogsTable/AuditLogsTable.tsx
index 2094d46a4a..e2450265bb 100644
--- a/web/src/ee/features/audit-log-viewer/AuditLogsTable/AuditLogsTable.tsx
+++ b/web/src/ee/features/audit-log-viewer/AuditLogsTable/AuditLogsTable.tsx
@@ -13,7 +13,10 @@ import {
SettingsTable,
type SettingsTableToolbarAction,
} from "@/src/components/SettingsTable/SettingsTable";
-import { type RowHeight } from "@/src/components/table/data-table-row-height-switch";
+import {
+ resolveRowHeightRendering,
+ type RowHeight,
+} from "@/src/components/table/data-table-row-height-switch";
import { type LangfuseColumnDef } from "@/src/components/table/types";
import { type RouterOutputs } from "@/src/utils/api";
@@ -95,14 +98,16 @@ export function AuditLogsTable({
header: "Before",
size: 300,
getCell: (value) => value || undefined,
- singleLine: rowHeight === "s",
+ singleLine: resolveRowHeightRendering({ preset: rowHeight })
+ .compact,
}),
createIOTableColumn<AuditLogRow>({
accessorKey: "after",
header: "After",
size: 300,
getCell: (value) => value || undefined,
- singleLine: rowHeight === "s",
+ singleLine: resolveRowHeightRendering({ preset: rowHeight })
+ .compact,
}),
createButtonTableColumn<AuditLogRow, AuditLogRow["id"]>({
accessorFn: (row) => row.id,
diff --git a/web/src/features/annotation-queues/components/AnnotationQueueItemsTable.tsx b/web/src/features/annotation-queues/components/AnnotationQueueItemsTable.tsx
index be06175a1b..fee9be4603 100644
--- a/web/src/features/annotation-queues/components/AnnotationQueueItemsTable.tsx
+++ b/web/src/features/annotation-queues/components/AnnotationQueueItemsTable.tsx
@@ -10,7 +10,10 @@ import {
useColumnVisibility,
} from "@/src/features/column-visibility";
import { type AnnotationQueueStatus } from "@langfuse/shared";
-import { useRowHeightLocalStorage } from "@/src/components/table/data-table-row-height-switch";
+import {
+ customRowHeightMenu,
+ useRowHeightLocalStorage,
+} from "@/src/components/table/data-table-row-height-switch";
import { ListTree, Trash } from "lucide-react";
import { DropdownIndicator } from "@/src/components/design-system/DropdownIndicator/DropdownIndicator";
import { type RouterOutput } from "@/src/utils/types";
@@ -207,7 +210,10 @@ export function AnnotationQueueItemsTable({
});
const [selectedRows, setSelectedRows] = useState<RowSelectionState>({});
- const [rowHeight, setRowHeight] = useRowHeightLocalStorage("queueItems", "s");
+ const [rowHeight, setRowHeight, rowHeights] = useRowHeightLocalStorage(
+ "queueItems",
+ "s",
+ );
const items = api.annotationQueueItems.itemsByQueueId.useQuery({
projectId,
queueId,
@@ -451,6 +457,7 @@ export function AnnotationQueueItemsTable({
setColumnOrder={setColumnOrder}
rowHeight={rowHeight}
setRowHeight={setRowHeight}
+ customRowHeight={customRowHeightMenu(rowHeights)}
actionButtons={[
selectedItems.length > 0 ? (
<QueueItemTableMultiSelectAction
@@ -501,6 +508,9 @@ export function AnnotationQueueItemsTable({
columnOrder={columnOrder}
onColumnOrderChange={setColumnOrder}
rowHeight={rowHeight}
+ customRowHeightPx={rowHeights.activeHeightPx}
+ onCustomRowHeightChange={rowHeights.setCustomPx}
+ onSelectRowHeight={setRowHeight}
/>
</>
);
diff --git a/web/src/features/annotation-queues/components/AnnotationQueuesTable.tsx b/web/src/features/annotation-queues/components/AnnotationQueuesTable.tsx
index 62976f1694..9a02b15b2c 100644
--- a/web/src/features/annotation-queues/components/AnnotationQueuesTable.tsx
+++ b/web/src/features/annotation-queues/components/AnnotationQueuesTable.tsx
@@ -10,7 +10,12 @@ import {
useColumnVisibility,
} from "@/src/features/column-visibility";
import { DataTableToolbar } from "@/src/components/table/data-table-toolbar";
-import { useRowHeightLocalStorage } from "@/src/components/table/data-table-row-height-switch";
+import {
+ customRowHeightMenu,
+ isCompactRowHeight,
+ useCompactRows,
+ useRowHeightLocalStorage,
+} from "@/src/components/table/data-table-row-height-switch";
import { CreateOrEditAnnotationQueueButton } from "@/src/features/annotation-queues/components/CreateOrEditAnnotationQueueButton";
import { ClipboardPen, Lock } from "lucide-react";
import { Button } from "@/src/components/ui/button";
@@ -37,11 +42,40 @@ type RowData = {
isAssigned: boolean;
};
+function AnnotationQueueScoreConfigs({
+ fallbackCompact,
+ scoreConfigs,
+}: {
+ fallbackCompact: boolean;
+ scoreConfigs: RowData["scoreConfigs"];
+}) {
+ const compact = useCompactRows(fallbackCompact);
+ return (
+ <span
+ className={cn(
+ "grid h-full items-center overflow-auto",
+ compact && "leading-3",
+ )}
+ >
+ {scoreConfigs
+ .map(
+ (config) => `${getScoreDataTypeIcon(config.dataType)} ${config.name}`,
+ )
+ .join(", ")}
+ </span>
+ );
+}
+
export function AnnotationQueuesTable({ projectId }: { projectId: string }) {
- const [rowHeight, setRowHeight] = useRowHeightLocalStorage(
+ const [rowHeight, setRowHeight, rowHeights] = useRowHeightLocalStorage(
"annotationQueues",
"s",
);
+ const compactRows = isCompactRowHeight(
+ rowHeight,
+ rowHeights.mode,
+ rowHeights.activeHeightPx,
+ );
const [paginationState, setPaginationState] = useQueryParams({
pageIndex: withDefault(NumberParam, 0),
@@ -111,19 +145,10 @@ export function AnnotationQueuesTable({ projectId }: { projectId: string }) {
row.getValue("scoreConfigs");
return (
- <span
- className={cn(
- "grid h-full items-center overflow-auto",
- rowHeight === "s" && "leading-3",
- )}
- >
- {scoreConfigs
- .map(
- (config) =>
- `${getScoreDataTypeIcon(config.dataType)} ${config.name}`,
- )
- .join(", ")}
- </span>
+ <AnnotationQueueScoreConfigs
+ fallbackCompact={compactRows}
+ scoreConfigs={scoreConfigs}
+ />
);
},
},
@@ -220,6 +245,7 @@ export function AnnotationQueuesTable({ projectId }: { projectId: string }) {
setColumnOrder={setColumnOrder}
rowHeight={rowHeight}
setRowHeight={setRowHeight}
+ customRowHeight={customRowHeightMenu(rowHeights)}
/>
<DataTable
tableName="annotationQueues"
@@ -251,6 +277,9 @@ export function AnnotationQueuesTable({ projectId }: { projectId: string }) {
columnOrder={columnOrder}
onColumnOrderChange={setColumnOrder}
rowHeight={rowHeight}
+ customRowHeightPx={rowHeights.activeHeightPx}
+ onCustomRowHeightChange={rowHeights.setCustomPx}
+ onSelectRowHeight={setRowHeight}
getRowClassName={(row) =>
row.isAssigned ? "bg-primary/5 border-l-4 border-l-primary/40" : ""
}
diff --git a/web/src/features/automations/components/AutomationExecutionsTable.tsx b/web/src/features/automations/components/AutomationExecutionsTable.tsx
index 60e820d940..6334d1a775 100644
--- a/web/src/features/automations/components/AutomationExecutionsTable.tsx
+++ b/web/src/features/automations/components/AutomationExecutionsTable.tsx
@@ -8,7 +8,10 @@ import { createIOTableColumn } from "@/src/components/design-system/table/column
import { useQueryParams, withDefault, NumberParam } from "use-query-params";
import { formatDistanceToNow } from "date-fns";
import { formatIntervalSeconds } from "@/src/utils/dates";
-import { useRowHeightLocalStorage } from "@/src/components/table/data-table-row-height-switch";
+import {
+ customRowHeightMenu,
+ useRowHeightLocalStorage,
+} from "@/src/components/table/data-table-row-height-switch";
import { ActionExecutionStatus } from "@langfuse/shared";
import { type Status } from "@/src/components/ui/StatusBadge/StatusBadge";
@@ -44,7 +47,7 @@ export const AutomationExecutionsTable: React.FC<
pageSize: withDefault(NumberParam, 50),
});
- const [rowHeight, setRowHeight] = useRowHeightLocalStorage(
+ const [rowHeight, setRowHeight, rowHeights] = useRowHeightLocalStorage(
"automation-executions",
"s",
);
@@ -159,6 +162,7 @@ export const AutomationExecutionsTable: React.FC<
columns={columns}
rowHeight={rowHeight}
setRowHeight={setRowHeight}
+ customRowHeight={customRowHeightMenu(rowHeights)}
/>
<DataTable
tableName="automationExecutions"
@@ -174,6 +178,9 @@ export const AutomationExecutionsTable: React.FC<
state: paginationState,
}}
rowHeight={rowHeight}
+ customRowHeightPx={rowHeights.activeHeightPx}
+ onCustomRowHeightChange={rowHeights.setCustomPx}
+ onSelectRowHeight={setRowHeight}
/>
</>
);
diff --git a/web/src/features/datasets/components/DatasetCompareRunsTable.tsx b/web/src/features/datasets/components/DatasetCompareRunsTable.tsx
index 6ea8985ff8..404680c7b6 100644
--- a/web/src/features/datasets/components/DatasetCompareRunsTable.tsx
+++ b/web/src/features/datasets/components/DatasetCompareRunsTable.tsx
@@ -12,7 +12,10 @@ import { useEffect, useMemo } from "react";
import { usePaginationState } from "@/src/hooks/usePaginationState";
import { api } from "@/src/utils/api";
import { Checkbox } from "@/src/components/design-system/Checkbox/Checkbox";
-import { useRowHeightLocalStorage } from "@/src/components/table/data-table-row-height-switch";
+import {
+ customRowHeightMenu,
+ useRowHeightLocalStorage,
+} from "@/src/components/table/data-table-row-height-switch";
import { useDetailPageLists } from "@/src/features/navigate-detail-pages";
import {
DatasetCompareFieldsProvider,
@@ -46,7 +49,7 @@ function DatasetCompareRunsTableInternal(props: {
convertToColumnFilterList,
} = useColumnFilterState();
const { setDetailPageList } = useDetailPageLists();
- const [rowHeight, setRowHeight] = useRowHeightLocalStorage(
+ const [rowHeight, setRowHeight, rowHeights] = useRowHeightLocalStorage(
"datasetCompareRuns",
"m",
);
@@ -198,6 +201,7 @@ function DatasetCompareRunsTableInternal(props: {
setColumnVisibility={setColumnVisibility}
rowHeight={rowHeight}
setRowHeight={setRowHeight}
+ customRowHeight={customRowHeightMenu(rowHeights)}
additionalColumnSettings={{
isDefault:
isFieldSelected("output") &&
@@ -268,6 +272,9 @@ function DatasetCompareRunsTableInternal(props: {
state: paginationState,
}}
rowHeight={rowHeight}
+ customRowHeightPx={rowHeights.activeHeightPx}
+ onCustomRowHeightChange={rowHeights.setCustomPx}
+ onSelectRowHeight={setRowHeight}
customRowHeights={{
s: "h-48",
m: "h-64",
diff --git a/web/src/features/datasets/components/DatasetIOCells.tsx b/web/src/features/datasets/components/DatasetIOCells.tsx
index eac2445d41..95e7857995 100644
--- a/web/src/features/datasets/components/DatasetIOCells.tsx
+++ b/web/src/features/datasets/components/DatasetIOCells.tsx
@@ -1,5 +1,6 @@
import { api } from "@/src/utils/api";
import { ConnectedIOTableCell } from "@/src/components/table/ConnectedIOTableCell";
+import { useBoundRowHeightIO } from "@/src/components/table/data-table-row-height-switch";
import { useTrpcError } from "@/src/hooks/useTrpcError";
import { NotFoundCard } from "@/src/features/datasets/components/NotFoundCard";
@@ -22,6 +23,7 @@ export const DatasetItemIOCell = ({
datasetItemVersion?: Date;
singleLine?: boolean;
}) => {
+ const bound = useBoundRowHeightIO(true, singleLine, false);
const datasetItem = api.datasets.itemById.useQuery(
{
projectId: projectId,
@@ -33,7 +35,7 @@ export const DatasetItemIOCell = ({
);
if (datasetItem.isLoading) {
- return <ConnectedIOTableCell isLoading singleLine={singleLine} />;
+ return <ConnectedIOTableCell isLoading singleLine={bound.singleLine} />;
}
return (
@@ -43,7 +45,7 @@ export const DatasetItemIOCell = ({
? datasetItem.data?.expectedOutput
: datasetItem.data?.input
}
- singleLine={singleLine}
+ singleLine={bound.singleLine}
/>
);
};
@@ -63,6 +65,7 @@ export const TraceObservationIOCell = ({
fromTimestamp: Date;
singleLine?: boolean;
}) => {
+ const bound = useBoundRowHeightIO(true, singleLine, false);
// Subtract 1 day from the fromTimestamp as a buffer in case the trace happened before the run
const fromTimestampModified = new Date(
fromTimestamp.getTime() - 24 * 60 * 60 * 1000,
@@ -105,19 +108,19 @@ export const TraceObservationIOCell = ({
return (
<NotFoundCard
itemType={!!observationId ? "observation" : "trace"}
- singleLine={singleLine}
+ singleLine={bound.singleLine}
/>
);
}
if (isLoading || !data) {
- return <ConnectedIOTableCell isLoading singleLine={singleLine} />;
+ return <ConnectedIOTableCell isLoading singleLine={bound.singleLine} />;
}
return (
<ConnectedIOTableCell
data={io === "output" ? data.output : data.input}
- singleLine={singleLine}
+ singleLine={bound.singleLine}
/>
);
};
diff --git a/web/src/features/datasets/components/DatasetItemsTable.tsx b/web/src/features/datasets/components/DatasetItemsTable.tsx
index ced8a82acf..eac2f9c672 100644
--- a/web/src/features/datasets/components/DatasetItemsTable.tsx
+++ b/web/src/features/datasets/components/DatasetItemsTable.tsx
@@ -26,7 +26,11 @@ import {
useColumnOrder,
useColumnVisibility,
} from "@/src/features/column-visibility";
-import { useRowHeightLocalStorage } from "@/src/components/table/data-table-row-height-switch";
+import {
+ customRowHeightMenu,
+ isCompactRowHeight,
+ useRowHeightLocalStorage,
+} from "@/src/components/table/data-table-row-height-switch";
import { createIOTableColumn } from "@/src/components/design-system/table/columns/createIOTableColumn";
import { usePostHogClientCapture } from "@/src/features/posthog-analytics";
import { createStatusTableColumn } from "@/src/components/design-system/table/columns/createStatusTableColumn";
@@ -76,10 +80,15 @@ export function DatasetItemsTable({
pageSize: withDefault(NumberParam, 50),
});
- const [rowHeight, setRowHeight] = useRowHeightLocalStorage(
+ const [rowHeight, setRowHeight, rowHeights] = useRowHeightLocalStorage(
"datasetItems",
"m",
);
+ const compactRows = isCompactRowHeight(
+ rowHeight,
+ rowHeights.mode,
+ rowHeights.activeHeightPx,
+ );
const [filterState, setFilterState] = useQueryFilterState(
[],
@@ -223,14 +232,14 @@ export function DatasetItemsTable({
header: "Input",
size: 200,
enableHiding: true,
- singleLine: rowHeight === "s",
+ singleLine: compactRows,
}),
createIOTableColumn<RowData>({
accessorKey: "expectedOutput",
header: "Expected Output",
size: 200,
enableHiding: true,
- singleLine: rowHeight === "s",
+ singleLine: compactRows,
variant: "output",
}),
createIOTableColumn<RowData>({
@@ -238,7 +247,7 @@ export function DatasetItemsTable({
header: "Metadata",
size: 200,
enableHiding: true,
- singleLine: rowHeight === "s",
+ singleLine: compactRows,
}),
createDropdownTableColumn<RowData, string>({
id: "actions",
@@ -397,6 +406,7 @@ export function DatasetItemsTable({
setColumnOrder={setColumnOrder}
rowHeight={rowHeight}
setRowHeight={setRowHeight}
+ customRowHeight={customRowHeightMenu(rowHeights)}
mobileSearch={searchBar}
actionButtons={[menuItems, batchExportButton].filter(Boolean)}
/>
@@ -430,6 +440,9 @@ export function DatasetItemsTable({
columnOrder={columnOrder}
onColumnOrderChange={setColumnOrder}
rowHeight={rowHeight}
+ customRowHeightPx={rowHeights.activeHeightPx}
+ onCustomRowHeightChange={rowHeights.setCustomPx}
+ onSelectRowHeight={setRowHeight}
/>
<EditDatasetItemDialog
open={editDialogOpen}
diff --git a/web/src/features/datasets/components/DatasetRunItemsByItemTable.tsx b/web/src/features/datasets/components/DatasetRunItemsByItemTable.tsx
index 1f0f62a38d..06a00e5be7 100644
--- a/web/src/features/datasets/components/DatasetRunItemsByItemTable.tsx
+++ b/web/src/features/datasets/components/DatasetRunItemsByItemTable.tsx
@@ -13,7 +13,11 @@ import {
import { DataTableToolbar } from "@/src/components/table/data-table-toolbar";
import { useDetailPageLists } from "@/src/features/navigate-detail-pages";
import { useEffect, useMemo } from "react";
-import { useRowHeightLocalStorage } from "@/src/components/table/data-table-row-height-switch";
+import {
+ customRowHeightMenu,
+ isCompactRowHeight,
+ useRowHeightLocalStorage,
+} from "@/src/components/table/data-table-row-height-switch";
import { ListTree } from "lucide-react";
import { scoreFilters, useScoreColumns } from "@/src/features/scores";
import { createDateTableColumn } from "@/src/components/design-system/table/columns/createDateTableColumn";
@@ -44,7 +48,15 @@ export function DatasetRunItemsByItemTable(props: {
limit: paginationState.pageSize,
});
- const [rowHeight, setRowHeight] = useRowHeightLocalStorage("traces", "m");
+ const [rowHeight, setRowHeight, rowHeights] = useRowHeightLocalStorage(
+ "traces",
+ "m",
+ );
+ const compactRows = isCompactRowHeight(
+ rowHeight,
+ rowHeights.mode,
+ rowHeights.activeHeightPx,
+ );
useEffect(() => {
if (runItems.isSuccess) {
@@ -99,7 +111,7 @@ export function DatasetRunItemsByItemTable(props: {
observationId={trace.observationId}
io="input"
fromTimestamp={runAt}
- singleLine={rowHeight === "s"}
+ singleLine={compactRows}
/>
) : null;
},
@@ -123,7 +135,7 @@ export function DatasetRunItemsByItemTable(props: {
observationId={trace.observationId}
io="output"
fromTimestamp={runAt}
- singleLine={rowHeight === "s"}
+ singleLine={compactRows}
/>
) : null;
},
@@ -141,7 +153,7 @@ export function DatasetRunItemsByItemTable(props: {
datasetId={props.datasetId}
datasetItemId={props.datasetItemId}
io="expectedOutput"
- singleLine={rowHeight === "s"}
+ singleLine={compactRows}
/>
),
},
@@ -237,6 +249,7 @@ export function DatasetRunItemsByItemTable(props: {
setColumnOrder={setColumnOrder}
rowHeight={rowHeight}
setRowHeight={setRowHeight}
+ customRowHeight={customRowHeightMenu(rowHeights)}
/>
<DataTable
tableName="datasetRunItems"
@@ -266,6 +279,9 @@ export function DatasetRunItemsByItemTable(props: {
columnOrder={columnOrder}
onColumnOrderChange={setColumnOrder}
rowHeight={rowHeight}
+ customRowHeightPx={rowHeights.activeHeightPx}
+ onCustomRowHeightChange={rowHeights.setCustomPx}
+ onSelectRowHeight={setRowHeight}
/>
</>
);
diff --git a/web/src/features/datasets/components/DatasetRunItemsByRunTable.tsx b/web/src/features/datasets/components/DatasetRunItemsByRunTable.tsx
index eafa897a75..95a906f674 100644
--- a/web/src/features/datasets/components/DatasetRunItemsByRunTable.tsx
+++ b/web/src/features/datasets/components/DatasetRunItemsByRunTable.tsx
@@ -13,7 +13,11 @@ import {
import { DataTableToolbar } from "@/src/components/table/data-table-toolbar";
import { useDetailPageLists } from "@/src/features/navigate-detail-pages";
import { useEffect, useMemo } from "react";
-import { useRowHeightLocalStorage } from "@/src/components/table/data-table-row-height-switch";
+import {
+ customRowHeightMenu,
+ isCompactRowHeight,
+ useRowHeightLocalStorage,
+} from "@/src/components/table/data-table-row-height-switch";
import { ListTree } from "lucide-react";
import { scoreFilters, useScoreColumns } from "@/src/features/scores";
import { Skeleton } from "@/src/components/ui/skeleton";
@@ -42,7 +46,15 @@ export function DatasetRunItemsByRunTable(props: {
pageSize: withDefault(NumberParam, 20),
});
- const [rowHeight, setRowHeight] = useRowHeightLocalStorage("traces", "m");
+ const [rowHeight, setRowHeight, rowHeights] = useRowHeightLocalStorage(
+ "traces",
+ "m",
+ );
+ const compactRows = isCompactRowHeight(
+ rowHeight,
+ rowHeights.mode,
+ rowHeights.activeHeightPx,
+ );
const [userFilterState, setUserFilterState] = useQueryFilterState(
[],
@@ -205,7 +217,7 @@ export function DatasetRunItemsByRunTable(props: {
observationId={trace.observationId}
io="input"
fromTimestamp={runAt}
- singleLine={rowHeight === "s"}
+ singleLine={compactRows}
/>
) : null;
},
@@ -229,7 +241,7 @@ export function DatasetRunItemsByRunTable(props: {
observationId={trace.observationId}
io="output"
fromTimestamp={runAt}
- singleLine={rowHeight === "s"}
+ singleLine={compactRows}
/>
) : null;
},
@@ -250,7 +262,7 @@ export function DatasetRunItemsByRunTable(props: {
datasetItemId={datasetItemId}
datasetItemVersion={row.original.datasetItemVersion}
io="expectedOutput"
- singleLine={rowHeight === "s"}
+ singleLine={compactRows}
/>
) : null;
},
@@ -291,6 +303,7 @@ export function DatasetRunItemsByRunTable(props: {
setColumnOrder={setColumnOrder}
rowHeight={rowHeight}
setRowHeight={setRowHeight}
+ customRowHeight={customRowHeightMenu(rowHeights)}
/>
<DataTable
tableName="datasetRunItems"
@@ -320,6 +333,9 @@ export function DatasetRunItemsByRunTable(props: {
columnOrder={columnOrder}
onColumnOrderChange={setColumnOrder}
rowHeight={rowHeight}
+ customRowHeightPx={rowHeights.activeHeightPx}
+ onCustomRowHeightChange={rowHeights.setCustomPx}
+ onSelectRowHeight={setRowHeight}
/>
</>
);
diff --git a/web/src/features/datasets/components/DatasetRunsTable.tsx b/web/src/features/datasets/components/DatasetRunsTable.tsx
index 2c6716ff3d..275a02ad2a 100644
--- a/web/src/features/datasets/components/DatasetRunsTable.tsx
+++ b/web/src/features/datasets/components/DatasetRunsTable.tsx
@@ -22,7 +22,11 @@ import {
} from "@langfuse/shared";
import { useQueryFilterState } from "@/src/features/filters";
import { useDebounce } from "@/src/hooks/useDebounce";
-import { useRowHeightLocalStorage } from "@/src/components/table/data-table-row-height-switch";
+import {
+ customRowHeightMenu,
+ isCompactRowHeight,
+ useRowHeightLocalStorage,
+} from "@/src/components/table/data-table-row-height-switch";
import { createIOTableColumn } from "@/src/components/design-system/table/columns/createIOTableColumn";
import { Columns3, Trash } from "lucide-react";
import { DropdownIndicator } from "@/src/components/design-system/DropdownIndicator/DropdownIndicator";
@@ -182,10 +186,15 @@ function DatasetRunsTableInternal(
props.projectId,
);
- const [rowHeight, setRowHeight] = useRowHeightLocalStorage(
+ const [rowHeight, setRowHeight, rowHeights] = useRowHeightLocalStorage(
"datasetRuns",
"s",
);
+ const compactRows = isCompactRowHeight(
+ rowHeight,
+ rowHeights.mode,
+ rowHeights.activeHeightPx,
+ );
// Add panel size state with default size of 30%
const [chartsPanelSize, setChartsPanelSize] = useSessionStorage<number>(
@@ -487,7 +496,7 @@ function DatasetRunsTableInternal(
size: 200,
enableHiding: true,
getCell: (value) => value || undefined,
- singleLine: rowHeight === "s",
+ singleLine: compactRows,
}),
createDropdownTableColumn<DatasetRunRowData, DatasetRunRowData["id"]>({
id: "actions",
@@ -662,6 +671,7 @@ function DatasetRunsTableInternal(
setColumnOrder={setColumnOrder}
rowHeight={rowHeight}
setRowHeight={setRowHeight}
+ customRowHeight={customRowHeightMenu(rowHeights)}
actionButtons={[
Object.keys(selectedRows).filter((runId) =>
runs.data?.runs.map((run) => run.id).includes(runId),
@@ -709,6 +719,9 @@ function DatasetRunsTableInternal(
columnOrder={columnOrder}
onColumnOrderChange={setColumnOrder}
rowHeight={rowHeight}
+ customRowHeightPx={rowHeights.activeHeightPx}
+ onCustomRowHeightChange={rowHeights.setCustomPx}
+ onSelectRowHeight={setRowHeight}
rowSelection={selectedRows}
setRowSelection={setSelectedRows}
/>
@@ -728,6 +741,7 @@ function DatasetRunsTableInternal(
setColumnOrder={setColumnOrder}
rowHeight={rowHeight}
setRowHeight={setRowHeight}
+ customRowHeight={customRowHeightMenu(rowHeights)}
actionButtons={[
Object.keys(selectedRows).filter((runId) =>
runs.data?.runs.map((run) => run.id).includes(runId),
@@ -774,6 +788,9 @@ function DatasetRunsTableInternal(
columnOrder={columnOrder}
onColumnOrderChange={setColumnOrder}
rowHeight={rowHeight}
+ customRowHeightPx={rowHeights.activeHeightPx}
+ onCustomRowHeightChange={rowHeights.setCustomPx}
+ onSelectRowHeight={setRowHeight}
rowSelection={selectedRows}
setRowSelection={setSelectedRows}
/>
diff --git a/web/src/features/datasets/components/DatasetsTable.tsx b/web/src/features/datasets/components/DatasetsTable.tsx
index a9b5d62895..7b3ae5ac36 100644
--- a/web/src/features/datasets/components/DatasetsTable.tsx
+++ b/web/src/features/datasets/components/DatasetsTable.tsx
@@ -24,7 +24,12 @@ import {
BatchExportTableName,
} from "@langfuse/shared";
import { createIOTableColumn } from "@/src/components/design-system/table/columns/createIOTableColumn";
-import { useRowHeightLocalStorage } from "@/src/components/table/data-table-row-height-switch";
+import {
+ type CustomRowHeightControl,
+ customRowHeightMenu,
+ isCompactRowHeight,
+ useRowHeightLocalStorage,
+} from "@/src/components/table/data-table-row-height-switch";
import { createDateTableColumn } from "@/src/components/design-system/table/columns/createDateTableColumn";
import { createFolderKeyTableColumn } from "@/src/components/design-system/table/columns/createFolderKeyTableColumn";
import { createNumberTableColumn } from "@/src/components/design-system/table/columns/createNumberTableColumn";
@@ -187,6 +192,7 @@ function DatasetsTableToolbar({
paginationState,
projectId,
rowHeight,
+ customRowHeight,
searchQuery,
setColumnOrder,
setColumnVisibility,
@@ -203,6 +209,7 @@ function DatasetsTableToolbar({
paginationState: { pageIndex: number; pageSize: number };
projectId: string;
rowHeight: ReturnType<typeof useRowHeightLocalStorage>[0];
+ customRowHeight: CustomRowHeightControl;
searchQuery: string | null;
setColumnOrder: ReturnType<typeof useColumnOrder<DatasetTableRow>>[1];
setColumnVisibility: ReturnType<
@@ -230,6 +237,7 @@ function DatasetsTableToolbar({
setColumnOrder={setColumnOrder}
rowHeight={rowHeight}
setRowHeight={setRowHeight}
+ customRowHeight={customRowHeight}
searchConfig={{
metadataSearchFields: ["Name"],
updateQuery: setSearchQuery,
@@ -271,7 +279,15 @@ function DatasetsTableToolbar({
export function DatasetsTable(props: { projectId: string }) {
const { setDetailPageList } = useDetailPageLists();
- const [rowHeight, setRowHeight] = useRowHeightLocalStorage("datasets", "s");
+ const [rowHeight, setRowHeight, rowHeights] = useRowHeightLocalStorage(
+ "datasets",
+ "s",
+ );
+ const compactRows = isCompactRowHeight(
+ rowHeight,
+ rowHeights.mode,
+ rowHeights.activeHeightPx,
+ );
const [datasetsTableStore] = useState(() => createDatasetsTableStore());
const {
@@ -432,7 +448,7 @@ export function DatasetsTable(props: { projectId: string }) {
enableHiding: true,
size: 300,
getCell: (value) => value || undefined,
- singleLine: rowHeight === "s",
+ singleLine: compactRows,
}),
{
id: "actions",
@@ -621,6 +637,7 @@ export function DatasetsTable(props: { projectId: string }) {
setColumnOrder={handleColumnOrderChange}
rowHeight={rowHeight}
setRowHeight={setRowHeight}
+ customRowHeight={customRowHeightMenu(rowHeights)}
currentFolderPath={currentFolderPath}
paginationState={paginationState}
projectId={props.projectId}
@@ -660,6 +677,9 @@ export function DatasetsTable(props: { projectId: string }) {
columnOrder={columnOrder}
onColumnOrderChange={handleColumnOrderChange}
rowHeight={rowHeight}
+ customRowHeightPx={rowHeights.activeHeightPx}
+ onCustomRowHeightChange={rowHeights.setCustomPx}
+ onSelectRowHeight={setRowHeight}
/>
</>
);
diff --git a/web/src/features/evals/components/eval-log.tsx b/web/src/features/evals/components/eval-log.tsx
index 3805a60bf7..0904497a33 100644
--- a/web/src/features/evals/components/eval-log.tsx
+++ b/web/src/features/evals/components/eval-log.tsx
@@ -3,6 +3,8 @@ import { createStatusTableColumn } from "@/src/components/design-system/table/co
import { DataTable } from "@/src/components/table/data-table";
import {
type CustomHeights,
+ customRowHeightMenu,
+ isCompactRowHeight,
useRowHeightLocalStorage,
} from "@/src/components/table/data-table-row-height-switch";
import { DataTableToolbar } from "@/src/components/table/data-table-toolbar";
@@ -68,7 +70,16 @@ export default function EvalLogTable({
projectId: string;
jobConfigurationId?: string;
}) {
- const [rowHeight, setRowHeight] = useRowHeightLocalStorage("evalLogs", "s");
+ const [rowHeight, setRowHeight, rowHeights] = useRowHeightLocalStorage(
+ "evalLogs",
+ "s",
+ );
+ const compactRows = isCompactRowHeight(
+ rowHeight,
+ rowHeights.mode,
+ rowHeights.activeHeightPx,
+ evalLogRowHeights,
+ );
const [paginationState, setPaginationState] = useQueryParams({
pageIndex: withDefault(NumberParam, 0),
pageSize: withDefault(NumberParam, 50),
@@ -142,7 +153,7 @@ export default function EvalLogTable({
enableHiding: true,
cellPadding: "none",
compact: true,
- singleLine: rowHeight === "s",
+ singleLine: compactRows,
}),
createIOTableColumn<JobExecutionRow>({
accessorKey: "error",
@@ -150,7 +161,7 @@ export default function EvalLogTable({
enableHiding: true,
cellPadding: "none",
compact: true,
- singleLine: rowHeight === "s",
+ singleLine: compactRows,
}),
createLinkTableColumn<JobExecutionRow>({
accessorKey: "traceId",
@@ -286,6 +297,7 @@ export default function EvalLogTable({
setColumnOrder={setColumnOrder}
rowHeight={rowHeight}
setRowHeight={setRowHeight}
+ customRowHeight={customRowHeightMenu(rowHeights)}
filterState={queryFilter.filterState}
/>
}
@@ -327,6 +339,9 @@ export default function EvalLogTable({
onColumnOrderChange={setColumnOrder}
customRowHeights={evalLogRowHeights}
rowHeight={rowHeight}
+ customRowHeightPx={rowHeights.activeHeightPx}
+ onCustomRowHeightChange={rowHeights.setCustomPx}
+ onSelectRowHeight={setRowHeight}
/>
</div>
</SearchableTableFilterLayout>
diff --git a/web/src/features/evals/v2/components/Evaluators/Testing/components/SampleObservationSelectorBase/SampleObservationSelectorBase.tsx b/web/src/features/evals/v2/components/Evaluators/Testing/components/SampleObservationSelectorBase/SampleObservationSelectorBase.tsx
index 1b05d4409e..3e33c4aba5 100644
--- a/web/src/features/evals/v2/components/Evaluators/Testing/components/SampleObservationSelectorBase/SampleObservationSelectorBase.tsx
+++ b/web/src/features/evals/v2/components/Evaluators/Testing/components/SampleObservationSelectorBase/SampleObservationSelectorBase.tsx
@@ -18,7 +18,10 @@ import { createIOTableColumn } from "@/src/components/design-system/table/column
import { createTextTableColumn } from "@/src/components/design-system/table/columns/createTextTableColumn";
import { DataTable } from "@/src/components/table/data-table";
import { DataTableColumnVisibilityFilter } from "@/src/components/table/data-table-column-visibility-filter";
-import { useRowHeightLocalStorage } from "@/src/components/table/data-table-row-height-switch";
+import {
+ resolveRowHeightRendering,
+ useRowHeightLocalStorage,
+} from "@/src/components/table/data-table-row-height-switch";
import type { LangfuseColumnDef } from "@/src/components/table/types";
import { Button } from "@/src/components/ui/button";
import { Skeleton } from "@/src/components/ui/skeleton";
@@ -431,8 +434,8 @@ export function SampleObservationSelectorBase(
if (!io && observationIOPending) return { type: "loading" };
return io?.input;
},
- singleLine: rowHeight === "s",
- enableExpandOnHover: rowHeight === "s",
+ singleLine: resolveRowHeightRendering({ preset: rowHeight }).compact,
+ enableExpandOnHover: true,
variant: "input",
}),
createIOTableColumn<SampleObservation>({
@@ -445,8 +448,8 @@ export function SampleObservationSelectorBase(
if (!io && observationIOPending) return { type: "loading" };
return io?.output;
},
- singleLine: rowHeight === "s",
- enableExpandOnHover: rowHeight === "s",
+ singleLine: resolveRowHeightRendering({ preset: rowHeight }).compact,
+ enableExpandOnHover: true,
variant: "output",
}),
createIOTableColumn<SampleObservation>({
@@ -459,8 +462,8 @@ export function SampleObservationSelectorBase(
if (!io && observationIOPending) return { type: "loading" };
return io?.metadata;
},
- singleLine: rowHeight === "s",
- enableExpandOnHover: rowHeight === "s",
+ singleLine: resolveRowHeightRendering({ preset: rowHeight }).compact,
+ enableExpandOnHover: true,
}),
createTextTableColumn<SampleObservation>({
accessorKey: "environment",
diff --git a/web/src/features/evals/v2/components/Rules/RulesTable/RulesTable.tsx b/web/src/features/evals/v2/components/Rules/RulesTable/RulesTable.tsx
index a7527bbefb..b3e0e208bf 100644
--- a/web/src/features/evals/v2/components/Rules/RulesTable/RulesTable.tsx
+++ b/web/src/features/evals/v2/components/Rules/RulesTable/RulesTable.tsx
@@ -12,7 +12,10 @@ import {
import { SearchableTableFilterLayout } from "@/src/components/table/resizable-filter-layout";
import { TablePeekViewEvaluatorConfigDetail } from "@/src/components/table/peek/peek-evaluator-config-detail";
import { usePeekNavigation } from "@/src/components/table/peek/hooks/usePeekNavigation";
-import { useRowHeightLocalStorage } from "@/src/components/table/data-table-row-height-switch";
+import {
+ customRowHeightMenu,
+ useRowHeightLocalStorage,
+} from "@/src/components/table/data-table-row-height-switch";
import { createTableSelectionStore } from "@/src/components/table/table-selection-store";
import type { LangfuseColumnDef } from "@/src/components/table/types";
import { SingleLineOverflowList } from "@/src/components/SingleLineOverflowList";
@@ -125,7 +128,7 @@ export function RulesTable({
column: "createdAt",
order: "DESC",
});
- const [rowHeight, setRowHeight] = useRowHeightLocalStorage(
+ const [rowHeight, setRowHeight, rowHeights] = useRowHeightLocalStorage(
"evaluationRulesV2",
"s",
);
@@ -567,6 +570,7 @@ export function RulesTable({
setColumnOrder={handleColumnOrderChange}
rowHeight={rowHeight}
setRowHeight={setRowHeight}
+ customRowHeight={customRowHeightMenu(rowHeights)}
filterState={filterState}
orderByState={orderBy}
viewConfig={{
@@ -606,6 +610,9 @@ export function RulesTable({
columnOrder={columnOrder}
onColumnOrderChange={handleColumnOrderChange}
rowHeight={rowHeight}
+ customRowHeightPx={rowHeights.activeHeightPx}
+ onCustomRowHeightChange={rowHeights.setCustomPx}
+ onSelectRowHeight={setRowHeight}
orderBy={orderBy}
setOrderBy={handleOrderByChange}
pagination={{
diff --git a/web/src/features/evals/v2/components/Rules/RulesTable/components/RulesTableToolbar/RulesTableToolbar.tsx b/web/src/features/evals/v2/components/Rules/RulesTable/components/RulesTableToolbar/RulesTableToolbar.tsx
index 3edd9f1773..978e2ebbba 100644
--- a/web/src/features/evals/v2/components/Rules/RulesTable/components/RulesTableToolbar/RulesTableToolbar.tsx
+++ b/web/src/features/evals/v2/components/Rules/RulesTable/components/RulesTableToolbar/RulesTableToolbar.tsx
@@ -7,7 +7,10 @@ import type {
} from "@/src/features/evals/v2/types/rules";
import type { ColumnOrderState, VisibilityState } from "@tanstack/react-table";
import { type Dispatch, type SetStateAction, type ComponentProps } from "react";
-import type { RowHeight } from "@/src/components/table/data-table-row-height-switch";
+import type {
+ CustomRowHeightControl,
+ RowHeight,
+} from "@/src/components/table/data-table-row-height-switch";
import type { FilterState, OrderByState } from "@langfuse/shared";
export function RulesTableToolbar({
@@ -24,6 +27,7 @@ export function RulesTableToolbar({
setColumnOrder,
rowHeight,
setRowHeight,
+ customRowHeight,
filterState,
orderByState,
viewConfig,
@@ -40,7 +44,8 @@ export function RulesTableToolbar({
columnOrder: ColumnOrderState;
setColumnOrder: Dispatch<SetStateAction<ColumnOrderState>>;
rowHeight: RowHeight;
- setRowHeight: Dispatch<SetStateAction<RowHeight>>;
+ setRowHeight: (rowHeight: RowHeight) => void;
+ customRowHeight: CustomRowHeightControl;
filterState: FilterState;
orderByState: OrderByState;
viewConfig: NonNullable<
@@ -73,6 +78,7 @@ export function RulesTableToolbar({
setColumnOrder={setColumnOrder}
rowHeight={rowHeight}
setRowHeight={setRowHeight}
+ customRowHeight={customRowHeight}
/>
);
}
diff --git a/web/src/features/evals/v2/pages/EvaluatorsPage.tsx b/web/src/features/evals/v2/pages/EvaluatorsPage.tsx
index 49c5272e31..ae146070bb 100644
--- a/web/src/features/evals/v2/pages/EvaluatorsPage.tsx
+++ b/web/src/features/evals/v2/pages/EvaluatorsPage.tsx
@@ -13,7 +13,10 @@ import { StringParam, useQueryParam, withDefault } from "use-query-params";
import { useStore } from "zustand";
import Page from "@/src/components/layouts/page";
import { DataTable } from "@/src/components/table/data-table";
-import { useRowHeightLocalStorage } from "@/src/components/table/data-table-row-height-switch";
+import {
+ customRowHeightMenu,
+ useRowHeightLocalStorage,
+} from "@/src/components/table/data-table-row-height-switch";
import { DataTableToolbar } from "@/src/components/table/data-table-toolbar";
import {
DataTableControls,
@@ -188,7 +191,7 @@ export default function EvaluatorsPage() {
column: "updatedAt",
order: "DESC",
});
- const [rowHeight, setRowHeight] = useRowHeightLocalStorage(
+ const [rowHeight, setRowHeight, rowHeights] = useRowHeightLocalStorage(
"evaluatorsV2",
"s",
);
@@ -730,6 +733,7 @@ export default function EvaluatorsPage() {
setColumnOrder={handleColumnOrderChange}
rowHeight={rowHeight}
setRowHeight={setRowHeight}
+ customRowHeight={customRowHeightMenu(rowHeights)}
filterState={filterState}
orderByState={orderBy}
currentSearchQuery={searchQuery ?? ""}
@@ -790,6 +794,9 @@ export default function EvaluatorsPage() {
columnOrder={columnOrder}
onColumnOrderChange={handleColumnOrderChange}
rowHeight={rowHeight}
+ customRowHeightPx={rowHeights.activeHeightPx}
+ onCustomRowHeightChange={rowHeights.setCustomPx}
+ onSelectRowHeight={setRowHeight}
orderBy={orderBy}
setOrderBy={handleOrderByChange}
onRowClick={(row) =>
diff --git a/web/src/features/events/components/EventsTable.tsx b/web/src/features/events/components/EventsTable.tsx
index 74ec76a066..abdb77a811 100644
--- a/web/src/features/events/components/EventsTable.tsx
+++ b/web/src/features/events/components/EventsTable.tsx
@@ -81,7 +81,9 @@ import {
} from "@/src/utils/observationCost";
import { useOrderByState } from "@/src/features/orderBy";
import {
+ customRowHeightMenu,
getRowHeightIOCharLimit,
+ isCompactRowHeight,
useRowHeightLocalStorage,
} from "@/src/components/table/data-table-row-height-switch";
import { useTableDateRange } from "@/src/hooks/useTableDateRange";
@@ -364,10 +366,15 @@ export default function ObservationsEventsTable({
const [paginationState, setPaginationState] = usePaginationState(1, 50);
- const [rowHeight, setRowHeight] = useRowHeightLocalStorage(
+ const [rowHeight, setRowHeight, rowHeights] = useRowHeightLocalStorage(
"observations",
"s",
);
+ const compactRows = isCompactRowHeight(
+ rowHeight,
+ rowHeights.mode,
+ rowHeights.activeHeightPx,
+ );
const [orderByState, setOrderByState] = useOrderByState({
column: "startTime",
@@ -950,7 +957,11 @@ export default function ObservationsEventsTable({
// In chart mode the table is hidden and the chart runs its own aggregate
// query — don't also run the expensive row + batched-I/O fetches.
rowsEnabled: !chartActive,
- ioCharLimit: getRowHeightIOCharLimit(rowHeight),
+ ioCharLimit: getRowHeightIOCharLimit(
+ rowHeight,
+ rowHeights.mode,
+ rowHeights.activeHeightPx,
+ ),
});
useApplyAppRootFallback({
@@ -1264,7 +1275,7 @@ export default function ObservationsEventsTable({
size: 300,
getCell: (value, { row }) =>
isIoPending(row.original.id) ? { type: "loading" } : value || undefined,
- singleLine: rowHeight === "s",
+ singleLine: compactRows,
enableHiding: true,
}),
createIOTableColumn<EventsTableRow>({
@@ -1273,7 +1284,7 @@ export default function ObservationsEventsTable({
size: 300,
getCell: (value, { row }) =>
isIoPending(row.original.id) ? { type: "loading" } : value || undefined,
- singleLine: rowHeight === "s",
+ singleLine: compactRows,
variant: "output",
enableHiding: true,
}),
@@ -1287,7 +1298,7 @@ export default function ObservationsEventsTable({
},
getCell: (value, { row }) =>
isIoPending(row.original.id) ? { type: "loading" } : value || undefined,
- singleLine: rowHeight === "s",
+ singleLine: compactRows,
enableHiding: true,
}),
createStatusTableColumn<EventsTableRow, ObservationLevelType>({
@@ -1317,7 +1328,7 @@ export default function ObservationsEventsTable({
enableHiding: true,
defaultHidden: true,
getCell: (value) => value || undefined,
- singleLine: rowHeight === "s",
+ singleLine: compactRows,
}),
createDurationTableColumn<EventsTableRow>({
accessorKey: "latency",
@@ -1564,7 +1575,7 @@ export default function ObservationsEventsTable({
header: getEventsColumnName("traceTags"),
size: 250,
enableHiding: true,
- shouldWrap: rowHeight !== "s",
+ shouldWrap: !compactRows,
}),
{
accessorKey: "scores",
@@ -2080,6 +2091,7 @@ export default function ObservationsEventsTable({
orderByState={orderByState}
rowHeight={rowHeight}
setRowHeight={setRowHeight}
+ customRowHeight={customRowHeightMenu(rowHeights)}
timeRange={showControlsInPageHeader ? undefined : timeRange}
setTimeRange={showControlsInPageHeader ? undefined : setTimeRange}
viewModeToggle={
@@ -2342,6 +2354,11 @@ export default function ObservationsEventsTable({
columnVisibility={columnVisibility}
onColumnVisibilityChange={handleColumnVisibilityChange}
rowHeight={rowHeight}
+ customRowHeightPx={rowHeights.activeHeightPx}
+ onCustomRowHeightChange={
+ hideControls ? undefined : rowHeights.setCustomPx
+ }
+ onSelectRowHeight={hideControls ? undefined : setRowHeight}
onRowClick={(row, event) => {
// Handle Command/Ctrl+click to open observation in new tab
if (event && (event.metaKey || event.ctrlKey)) {
diff --git a/web/src/features/experiments/components/table/ExperimentCompareTable.tsx b/web/src/features/experiments/components/table/ExperimentCompareTable.tsx
index 229437e812..85dfa7f152 100644
--- a/web/src/features/experiments/components/table/ExperimentCompareTable.tsx
+++ b/web/src/features/experiments/components/table/ExperimentCompareTable.tsx
@@ -14,7 +14,7 @@ import { type LangfuseColumnDef } from "@/src/components/table/types";
import { type ExperimentItemsTableRow } from "./types";
import { type ReactNode } from "react";
-const LIST_VIEW_ROW_HEIGHTS = {
+export const LIST_VIEW_ROW_HEIGHTS = {
s: "h-24", // 96px - increased density
m: "h-48", // 192px
l: "h-96", // 384px
@@ -48,6 +48,12 @@ type ExperimentCompareTableProps = {
columnVisibility: VisibilityState;
onColumnVisibilityChange: OnChangeFn<VisibilityState>;
rowHeight: RowHeight;
+ /** Free height in pixels. Null while a preset is active. */
+ customRowHeightPx?: number | null;
+ /** Dragging a row edge sets one height for every run column. */
+ onCustomRowHeightChange?: (heightPx: number) => void;
+ /** Selects a preset when a drag lands on that preset's height. */
+ onSelectRowHeight?: (rowHeight: RowHeight) => void;
peekView?: DataTablePeekViewProps;
noResultsMessage?: ReactNode;
highlightAllRows?: boolean;
@@ -69,6 +75,9 @@ export const ExperimentCompareTable = ({
columnVisibility,
onColumnVisibilityChange,
rowHeight,
+ customRowHeightPx,
+ onCustomRowHeightChange,
+ onSelectRowHeight,
peekView,
noResultsMessage,
highlightAllRows,
@@ -106,6 +115,9 @@ export const ExperimentCompareTable = ({
onColumnVisibilityChange={onColumnVisibilityChange}
rowHeight={rowHeight}
customRowHeights={LIST_VIEW_ROW_HEIGHTS}
+ customRowHeightPx={customRowHeightPx}
+ onCustomRowHeightChange={onCustomRowHeightChange}
+ onSelectRowHeight={onSelectRowHeight}
topAlignCells
highlightAllRows={highlightAllRows}
/>
diff --git a/web/src/features/experiments/components/table/ExperimentGridCell.tsx b/web/src/features/experiments/components/table/ExperimentGridCell.tsx
index 68cee2c018..920b066955 100644
--- a/web/src/features/experiments/components/table/ExperimentGridCell.tsx
+++ b/web/src/features/experiments/components/table/ExperimentGridCell.tsx
@@ -592,7 +592,7 @@ export const ExperimentGridCell = ({
},
] satisfies CellRowDef<GridCellData>[])
: []),
- // Output section
+ // Output section. Display chooses text or JSON. Row height does not.
{
accessorKey: "output",
header: "Output",
@@ -601,12 +601,14 @@ export const ExperimentGridCell = ({
<ConnectedIOTableCell
isLoading
variant="output"
+ followRowHeight={false}
singleLine={singleLine}
/>
) : (
<ConnectedIOTableCell
data={data.output ?? null}
variant="output"
+ followRowHeight={false}
singleLine={singleLine}
/>
),
diff --git a/web/src/features/experiments/components/table/ExperimentGridView.tsx b/web/src/features/experiments/components/table/ExperimentGridView.tsx
index d07bb80991..670e9a5524 100644
--- a/web/src/features/experiments/components/table/ExperimentGridView.tsx
+++ b/web/src/features/experiments/components/table/ExperimentGridView.tsx
@@ -29,7 +29,7 @@ import { useHasProjectAccess } from "@/src/features/rbac";
import { usePostHogClientCapture } from "@/src/features/posthog-analytics";
// Grid view row heights (matching DatasetCompareRunsTable)
-const GRID_VIEW_ROW_HEIGHTS = {
+export const GRID_VIEW_ROW_HEIGHTS = {
s: "h-48", // 192px
m: "h-64", // 256px
l: "h-96", // 384px
@@ -53,6 +53,12 @@ type ExperimentGridViewProps = {
*/
ioLoading: boolean;
rowHeight: RowHeight;
+ /** Free height in pixels. Null while a preset is active. */
+ customRowHeightPx?: number | null;
+ /** Dragging a row edge sets one height for every run column. */
+ onCustomRowHeightChange?: (heightPx: number) => void;
+ /** Selects a preset when a drag lands on that preset's height. */
+ onSelectRowHeight?: (rowHeight: RowHeight) => void;
/** Whether any item in view has an expected output worth a column. */
showExpectedOutput: boolean;
observationScoreOrder: string[];
@@ -88,6 +94,9 @@ export const ExperimentGridView = ({
isLoading,
ioLoading,
rowHeight,
+ customRowHeightPx,
+ onCustomRowHeightChange,
+ onSelectRowHeight,
showExpectedOutput,
observationScoreOrder,
traceScoreOrder,
@@ -333,6 +342,8 @@ export const ExperimentGridView = ({
size: 200,
getCell: (value) =>
ioLoading ? { type: "loading" } : value || undefined,
+ // Display chooses text or JSON. Row height does not.
+ followRowHeight: false,
singleLine,
variant: "output",
}),
@@ -364,6 +375,9 @@ export const ExperimentGridView = ({
pagination={pagination}
rowHeight={rowHeight}
customRowHeights={GRID_VIEW_ROW_HEIGHTS}
+ customRowHeightPx={customRowHeightPx}
+ onCustomRowHeightChange={onCustomRowHeightChange}
+ onSelectRowHeight={onSelectRowHeight}
topAlignCells
peekView={peekView}
columnVisibility={columnVisibility}
diff --git a/web/src/features/experiments/components/table/ExperimentInputCell.tsx b/web/src/features/experiments/components/table/ExperimentInputCell.tsx
index c43d6201e3..806b33f834 100644
--- a/web/src/features/experiments/components/table/ExperimentInputCell.tsx
+++ b/web/src/features/experiments/components/table/ExperimentInputCell.tsx
@@ -50,10 +50,19 @@ export function ExperimentInputCell({
<ArrowUpRight className="icon-base" aria-hidden />
</Link>
) : null}
+ {/* Display chooses text or JSON. Row height does not. */}
{isLoading ? (
- <ConnectedIOTableCell isLoading singleLine={singleLine} />
+ <ConnectedIOTableCell
+ isLoading
+ followRowHeight={false}
+ singleLine={singleLine}
+ />
) : (
- <ConnectedIOTableCell data={input ?? null} singleLine={singleLine} />
+ <ConnectedIOTableCell
+ data={input ?? null}
+ followRowHeight={false}
+ singleLine={singleLine}
+ />
)}
</div>
);
diff --git a/web/src/features/experiments/components/table/ExperimentItemsTable.tsx b/web/src/features/experiments/components/table/ExperimentItemsTable.tsx
index 850bb749c9..608ac2c842 100644
--- a/web/src/features/experiments/components/table/ExperimentItemsTable.tsx
+++ b/web/src/features/experiments/components/table/ExperimentItemsTable.tsx
@@ -44,7 +44,11 @@ import {
} from "@/src/features/experiments/lib/analytics";
import { type ColumnGroupTogglePayload } from "@/src/components/table/data-table-column-visibility-filter";
import { useOrderByState } from "@/src/features/orderBy";
-import { useRowHeightLocalStorage } from "@/src/components/table/data-table-row-height-switch";
+import {
+ customRowHeightMenu,
+ getRowHeightIOCharLimit,
+ useAdjustableRowHeight,
+} from "@/src/components/table/data-table-row-height-switch";
import {
useColumnOrder,
useColumnVisibility,
@@ -54,7 +58,10 @@ import { usdFormatter, latencyFormatter } from "@/src/utils/numbers";
import { type RowSelectionState } from "@tanstack/react-table";
import { createIOTableColumn } from "@/src/components/design-system/table/columns/createIOTableColumn";
import { usePeekNavigation } from "@/src/components/table/peek/hooks/usePeekNavigation";
-import { ExperimentGridView } from "./ExperimentGridView";
+import {
+ ExperimentGridView,
+ GRID_VIEW_ROW_HEIGHTS,
+} from "./ExperimentGridView";
import { useDetailPageLists } from "@/src/features/navigate-detail-pages";
import { useTableViewManager } from "@/src/components/table/table-view-presets/hooks/useTableViewManager";
import { useTableViewFilterChange } from "@/src/components/table/table-view-presets/hooks/useTableViewFilterChange";
@@ -86,7 +93,10 @@ import {
withPresentScoreKeys,
} from "@/src/features/scores";
import { Skeleton } from "@/src/components/ui/skeleton";
-import { ExperimentCompareTable } from "./ExperimentCompareTable";
+import {
+ ExperimentCompareTable,
+ LIST_VIEW_ROW_HEIGHTS,
+} from "./ExperimentCompareTable";
import { useExperimentItemsScoreCache } from "@/src/features/experiments/hooks/useExperimentItemsScoreCache";
import { useExperimentNames } from "@/src/features/experiments/hooks/useExperimentNames";
import {
@@ -357,6 +367,7 @@ const StackedOutputRow = ({
/>
<ConnectedIOTableCell
data={output}
+ followRowHeight={false}
singleLine={singleLine}
variant="output"
/>
@@ -399,6 +410,7 @@ const ExpectedMatchChip = ({ matches }: { matches: boolean }) => (
/**
* Cell component that renders stacked output values for each experiment.
+ * Display chooses text or JSON. Row height does not.
*/
const StackedOutputCell = ({
outputs,
@@ -448,6 +460,7 @@ const StackedOutputCell = ({
<ConnectedIOTableCell
isLoading={false}
data={expectedOutput ?? null}
+ followRowHeight={false}
singleLine={singleLine}
/>
</div>
@@ -487,7 +500,11 @@ const StackedOutputCell = ({
{isLoading ? (
<div className="flex h-full min-h-0 min-w-0 items-start">
<span className="bg-muted mt-0.5 mr-2 block h-4 w-0.5 shrink-0 rounded-full" />
- <ConnectedIOTableCell isLoading singleLine={singleLine} />
+ <ConnectedIOTableCell
+ isLoading
+ followRowHeight={false}
+ singleLine={singleLine}
+ />
</div>
) : out?.output ? (
<StackedOutputRow
@@ -620,10 +637,13 @@ export default function ExperimentItemsTable({
limit: "pageSize",
});
- const [rowHeight, setRowHeight] = useRowHeightLocalStorage(
- "experiment-items-compact",
- "s",
- );
+ const {
+ preset: rowHeight,
+ activeHeightPx,
+ setPreset: setRowHeight,
+ setCustomPx,
+ ...adjustableRowHeight
+ } = useAdjustableRowHeight("experiment-items-compact", "s");
const ioSingleLine = ioRenderMode === "text";
const [orderByState, setOrderByState] = useOrderByState({
@@ -784,6 +804,15 @@ export default function ExperimentItemsTable({
[filterTargets, defaultFilterTargetExperimentId],
);
+ // A compact row stays on the short preview. Medium, Large, and a dragged
+ // height at or above this layout's Medium preset ask for the expanded read.
+ const ioCharLimit = getRowHeightIOCharLimit(
+ rowHeight,
+ adjustableRowHeight.mode,
+ activeHeightPx,
+ layout === "grid" ? GRID_VIEW_ROW_HEIGHTS : LIST_VIEW_ROW_HEIGHTS,
+ );
+
// Use the custom hook for experiment items data fetching
const { items, totalCount, dataUpdatedAt, ioLoading, isTotalCountLoading } =
useExperimentItemsTableData({
@@ -800,6 +829,7 @@ export default function ExperimentItemsTable({
limit: paginationState.pageSize,
},
itemVisibility,
+ ioCharLimit,
});
const { rows: scoreRows, scoreColumns: scoreColumnDefs } =
@@ -1296,6 +1326,8 @@ export default function ExperimentItemsTable({
defaultHidden: true,
// An empty expected output used to render as two literal quote characters.
getCell: (value) => (ioLoading ? { type: "loading" } : value || undefined),
+ // Display chooses text or JSON. Row height does not.
+ followRowHeight: false,
singleLine: ioSingleLine,
variant: "output",
}) as LangfuseColumnDef<ExperimentItemsTableRow>;
@@ -1345,6 +1377,8 @@ export default function ExperimentItemsTable({
size: 300,
enableHiding: true,
getCell: (value) => (ioLoading ? { type: "loading" } : (value ?? null)),
+ // Display chooses text or JSON. Row height does not.
+ followRowHeight: false,
singleLine: ioSingleLine,
}),
// The scores sit between the item's input and its outputs: the input says
@@ -2055,6 +2089,7 @@ export default function ExperimentItemsTable({
orderByState={orderByState}
rowHeight={rowHeight}
setRowHeight={setRowHeight}
+ customRowHeight={customRowHeightMenu(adjustableRowHeight)}
toolbarSettings={toolbarSettings}
multiSelect={{
selectAll,
@@ -2161,6 +2196,11 @@ export default function ExperimentItemsTable({
isLoading={items.status === "loading" || isViewLoading}
ioLoading={ioLoading}
rowHeight={rowHeight}
+ customRowHeightPx={activeHeightPx}
+ onCustomRowHeightChange={
+ hideControls ? undefined : setCustomPx
+ }
+ onSelectRowHeight={hideControls ? undefined : setRowHeight}
showExpectedOutput={showExpectedOutput}
pagination={pagination}
observationScoreOrder={observationScoreOrder}
@@ -2206,6 +2246,9 @@ export default function ExperimentItemsTable({
columnVisibility={columnVisibility}
onColumnVisibilityChange={handleColumnVisibilityChange}
rowHeight={rowHeight}
+ customRowHeightPx={activeHeightPx}
+ onCustomRowHeightChange={hideControls ? undefined : setCustomPx}
+ onSelectRowHeight={hideControls ? undefined : setRowHeight}
peekView={peekConfig}
noResultsMessage={
!hasSelectedRuns ? (
diff --git a/web/src/features/experiments/components/table/ExperimentsTable.tsx b/web/src/features/experiments/components/table/ExperimentsTable.tsx
index 1aed4983c1..2e60100992 100644
--- a/web/src/features/experiments/components/table/ExperimentsTable.tsx
+++ b/web/src/features/experiments/components/table/ExperimentsTable.tsx
@@ -37,7 +37,12 @@ import {
} from "@langfuse/shared";
import { numberFormatter } from "@/src/utils/numbers";
import { useOrderByState } from "@/src/features/orderBy";
-import { useRowHeightLocalStorage } from "@/src/components/table/data-table-row-height-switch";
+import {
+ customRowHeightMenu,
+ isCompactRowHeight,
+ useCompactRows,
+ useRowHeightLocalStorage,
+} from "@/src/components/table/data-table-row-height-switch";
import { useTableDateRange } from "@/src/hooks/useTableDateRange";
import { toAbsoluteTimeRange } from "@/src/utils/date-range-utils";
import { TableHeaderControls } from "@/src/components/table/table-header-controls";
@@ -285,6 +290,44 @@ function ExperimentsMultiSelectActionMenu({
);
}
+function ExperimentPromptBadges({
+ fallbackCompact,
+ projectId,
+ prompts,
+}: {
+ fallbackCompact: boolean;
+ projectId: string;
+ prompts: Array<[string, number | null]>;
+}) {
+ const compact = useCompactRows(fallbackCompact);
+ return (
+ <div
+ className={
+ compact
+ ? "flex max-w-full flex-nowrap gap-1 overflow-x-auto py-0.5 whitespace-nowrap"
+ : "flex flex-wrap gap-1"
+ }
+ >
+ {prompts.map(([name, version]) => (
+ <Link
+ key={`${name}-${version}`}
+ href={`/project/${projectId}/prompts/${encodeURIComponent(name)}?version=${version}`}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="shrink-0"
+ >
+ <Badge
+ variant="secondary"
+ className="hover:bg-secondary/80 cursor-pointer"
+ >
+ {name}
+ </Badge>
+ </Link>
+ ))}
+ </div>
+ );
+}
+
export default function ExperimentsTable({
projectId,
defaultFilter,
@@ -301,10 +344,15 @@ export default function ExperimentsTable({
const [paginationState, setPaginationState] = usePaginationState(1, 50);
- const [rowHeight, setRowHeight] = useRowHeightLocalStorage(
+ const [rowHeight, setRowHeight, rowHeights] = useRowHeightLocalStorage(
"experiments",
"s",
);
+ const compactRows = isCompactRowHeight(
+ rowHeight,
+ rowHeights.mode,
+ rowHeights.activeHeightPx,
+ );
const [inputFilterState] = useQueryFilterState([], "experiments", projectId);
@@ -594,7 +642,7 @@ export default function ExperimentsTable({
// Off by default: 300px of mostly boilerplate ahead of the score columns.
defaultHidden: true,
getCell: (value) => value || undefined,
- singleLine: rowHeight === "s",
+ singleLine: compactRows,
}),
createIOTableColumn<ExperimentsTableRow>({
// Placed here (right after the identifying name/description columns) rather
@@ -606,7 +654,7 @@ export default function ExperimentsTable({
size: 100,
enableHiding: true,
defaultHidden: true,
- singleLine: rowHeight === "s",
+ singleLine: compactRows,
}),
createNumberTableColumn<ExperimentsTableRow>({
accessorKey: "itemCount",
@@ -708,30 +756,11 @@ export default function ExperimentsTable({
cell: ({ row }) => {
const value: Array<[string, number | null]> = row.getValue("prompts");
return (
- <div
- className={
- rowHeight === "s"
- ? "flex max-w-full flex-nowrap gap-1 overflow-x-auto py-0.5 whitespace-nowrap"
- : "flex flex-wrap gap-1"
- }
- >
- {value.map(([name, version]) => (
- <Link
- key={`${name}-${version}`}
- href={`/project/${projectId}/prompts/${encodeURIComponent(name)}?version=${version}`}
- target="_blank"
- rel="noopener noreferrer"
- className="shrink-0"
- >
- <Badge
- variant="secondary"
- className="hover:bg-secondary/80 cursor-pointer"
- >
- {name}
- </Badge>
- </Link>
- ))}
- </div>
+ <ExperimentPromptBadges
+ fallbackCompact={compactRows}
+ projectId={projectId}
+ prompts={value}
+ />
);
},
},
@@ -1012,6 +1041,7 @@ export default function ExperimentsTable({
orderByState={orderByState}
rowHeight={rowHeight}
setRowHeight={setRowHeight}
+ customRowHeight={customRowHeightMenu(rowHeights)}
timeRange={showControlsInPageHeader ? undefined : timeRange}
setTimeRange={
showControlsInPageHeader ? undefined : setTimeRange
@@ -1136,6 +1166,9 @@ export default function ExperimentsTable({
columnVisibility={columnVisibility}
onColumnVisibilityChange={handleColumnVisibilityChange}
rowHeight={rowHeight}
+ customRowHeightPx={rowHeights.activeHeightPx}
+ onCustomRowHeightChange={rowHeights.setCustomPx}
+ onSelectRowHeight={setRowHeight}
onRowClick={(row, event) => {
// Handle Command/Ctrl+click to open experiment in new tab
if (event && (event.metaKey || event.ctrlKey)) {
diff --git a/web/src/features/experiments/hooks/useExperimentItemsTableData.ts b/web/src/features/experiments/hooks/useExperimentItemsTableData.ts
index 0b85eae0d3..4f7adf4c17 100644
--- a/web/src/features/experiments/hooks/useExperimentItemsTableData.ts
+++ b/web/src/features/experiments/hooks/useExperimentItemsTableData.ts
@@ -23,6 +23,8 @@ type UseExperimentItemsTableDataParams = {
order: "ASC" | "DESC";
} | null;
itemVisibility?: "baseline-only" | "all";
+ /** Chars of I/O to load from the full event text. Omitted keeps the preview. */
+ ioCharLimit?: number;
};
/**
@@ -40,6 +42,7 @@ export function useExperimentItemsTableData({
paginationState,
orderByState,
itemVisibility,
+ ioCharLimit,
}: UseExperimentItemsTableDataParams) {
const hasSelectedRuns =
Boolean(baseExperimentId) || compExperimentIds.length > 0;
@@ -113,8 +116,15 @@ export function useExperimentItemsTableData({
itemIds: data.map((item) => item.itemId),
baseExperimentId,
compExperimentIds,
+ ...(ioCharLimit !== undefined ? { ioCharLimit } : {}),
};
- }, [itemsQuery.data?.data, projectId, baseExperimentId, compExperimentIds]);
+ }, [
+ itemsQuery.data?.data,
+ projectId,
+ baseExperimentId,
+ compExperimentIds,
+ ioCharLimit,
+ ]);
// Fetch IO data for visible items
const batchIOQuery = api.experiments.batchIO.useQuery(batchIOPayload!, {
diff --git a/web/src/features/experiments/server/router.ts b/web/src/features/experiments/server/router.ts
index 87847d289c..ebde77a08c 100644
--- a/web/src/features/experiments/server/router.ts
+++ b/web/src/features/experiments/server/router.ts
@@ -863,6 +863,7 @@ export const experimentsRouter = createTRPCRouter({
itemIds: z.array(z.string()),
baseExperimentId: z.string().nullish(),
compExperimentIds: z.array(z.string()),
+ ioCharLimit: z.number().int().positive().max(10_000).optional(),
}),
)
.query(async ({ input, ctx }) => {
@@ -881,6 +882,7 @@ export const experimentsRouter = createTRPCRouter({
itemIds: input.itemIds,
baseExperimentId: input.baseExperimentId ?? undefined,
compExperimentIds: input.compExperimentIds,
+ ioCharLimit: input.ioCharLimit,
});
return batchIO;
diff --git a/web/src/features/models/ModelDefinitionsTable/ModelDefinitionsTable.tsx b/web/src/features/models/ModelDefinitionsTable/ModelDefinitionsTable.tsx
index 359a8b1bb6..b2780efee7 100644
--- a/web/src/features/models/ModelDefinitionsTable/ModelDefinitionsTable.tsx
+++ b/web/src/features/models/ModelDefinitionsTable/ModelDefinitionsTable.tsx
@@ -8,7 +8,10 @@ import {
SettingsTable,
type SettingsTableProps,
} from "@/src/components/SettingsTable/SettingsTable";
-import { type RowHeight } from "@/src/components/table/data-table-row-height-switch";
+import {
+ resolveRowHeightRendering,
+ type RowHeight,
+} from "@/src/components/table/data-table-row-height-switch";
import { createIOTableColumn } from "@/src/components/design-system/table/columns/createIOTableColumn";
import { createBadgeTableColumn } from "@/src/components/design-system/table/columns/createBadgeTableColumn";
import { createDateTableColumn } from "@/src/components/design-system/table/columns/createDateTableColumn";
@@ -157,7 +160,7 @@ export function ModelDefinitionsTable({
enableHiding: true,
size: 120,
getCell: (value) => value || undefined,
- singleLine: rowHeight === "s",
+ singleLine: resolveRowHeightRendering({ preset: rowHeight }).compact,
}),
createDateTableColumn<ModelTableRow>({
accessorFn: () => undefined,
diff --git a/web/src/features/prompts/PromptMetricsPage.tsx b/web/src/features/prompts/PromptMetricsPage.tsx
index 31a33161e3..459a94d985 100644
--- a/web/src/features/prompts/PromptMetricsPage.tsx
+++ b/web/src/features/prompts/PromptMetricsPage.tsx
@@ -1,6 +1,9 @@
/* eslint-disable no-nested-ternary */
import { DataTable } from "@/src/components/table/data-table";
-import { useRowHeightLocalStorage } from "@/src/components/table/data-table-row-height-switch";
+import {
+ customRowHeightMenu,
+ useRowHeightLocalStorage,
+} from "@/src/components/table/data-table-row-height-switch";
import { DataTableToolbar } from "@/src/components/table/data-table-toolbar";
import { type LangfuseColumnDef } from "@/src/components/table/types";
import { useOrderByState } from "@/src/features/orderBy";
@@ -111,7 +114,7 @@ export default function PromptMetricsPage({
column: "startTime",
order: "DESC",
});
- const [rowHeight, setRowHeight] = useRowHeightLocalStorage(
+ const [rowHeight, setRowHeight, rowHeights] = useRowHeightLocalStorage(
"promptVersion",
"s",
);
@@ -415,6 +418,7 @@ export default function PromptMetricsPage({
setTimeRange={showControlsInPageHeader ? undefined : setTimeRange}
rowHeight={rowHeight}
setRowHeight={setRowHeight}
+ customRowHeight={customRowHeightMenu(rowHeights)}
columnVisibility={columnVisibility}
setColumnVisibility={setColumnVisibilityState}
columnOrder={columnOrder}
@@ -451,6 +455,9 @@ export default function PromptMetricsPage({
columnOrder={columnOrder}
onColumnOrderChange={setColumnOrder}
rowHeight={rowHeight}
+ customRowHeightPx={rowHeights.activeHeightPx}
+ onCustomRowHeightChange={rowHeights.setCustomPx}
+ onSelectRowHeight={setRowHeight}
/>
</Page>
);
diff --git a/web/src/features/scores/ScoresTable.tsx b/web/src/features/scores/ScoresTable.tsx
index 4b3f608338..2611293661 100644
--- a/web/src/features/scores/ScoresTable.tsx
+++ b/web/src/features/scores/ScoresTable.tsx
@@ -1,7 +1,12 @@
/* eslint-disable no-nested-ternary */
import { type ViewVersion } from "@langfuse/shared/query";
import { DataTable } from "@/src/components/table/data-table";
-import { useRowHeightLocalStorage } from "@/src/components/table/data-table-row-height-switch";
+import {
+ customRowHeightMenu,
+ isCompactRowHeight,
+ useCompactRows,
+ useRowHeightLocalStorage,
+} from "@/src/components/table/data-table-row-height-switch";
import {
DataTableMobileFilterControls,
DataTableToolbar,
@@ -175,6 +180,21 @@ function createFilterState(
}, userFilterState);
}
+function ScoreTraceTags({
+ tags,
+ fallbackCompact,
+}: {
+ tags: string[];
+ fallbackCompact: boolean;
+}) {
+ const compact = useCompactRows(fallbackCompact);
+ return (
+ <div className={cn("flex gap-x-2 gap-y-1", !compact && "flex-wrap")}>
+ <TagList selectedTags={tags} isLoading={false} viewOnly />
+ </div>
+ );
+}
+
export default function ScoresTable({
projectId,
userId,
@@ -219,7 +239,15 @@ export default function ScoresTable({
});
const { selectAll, setSelectAll } = useSelectAll(projectId, "scores");
- const [rowHeight, setRowHeight] = useRowHeightLocalStorage("scores", "s");
+ const [rowHeight, setRowHeight, rowHeights] = useRowHeightLocalStorage(
+ "scores",
+ "s",
+ );
+ const compactRows = isCompactRowHeight(
+ rowHeight,
+ rowHeights.mode,
+ rowHeights.activeHeightPx,
+ );
const { timeRange, setTimeRange } = useTableDateRange(projectId);
// Convert timeRange to absolute date range for compatibility
@@ -696,7 +724,7 @@ export default function ScoresTable({
enableHiding: true,
size: 400,
getCell: (value) => value || undefined,
- singleLine: rowHeight === "s",
+ singleLine: compactRows,
}),
createBadgeTableColumn<ScoresTableRow>({
accessorKey: "environment",
@@ -721,14 +749,7 @@ export default function ScoresTable({
return (
traceTags &&
traceTags.length > 0 && (
- <div
- className={cn(
- "flex gap-x-2 gap-y-1",
- rowHeight !== "s" && "flex-wrap",
- )}
- >
- <TagList selectedTags={traceTags} isLoading={false} viewOnly />
- </div>
+ <ScoreTraceTags tags={traceTags} fallbackCompact={compactRows} />
)
);
},
@@ -739,7 +760,7 @@ export default function ScoresTable({
id: "metadata",
size: 400,
loadingCell: () => (
- <ConnectedIOTableCell isLoading singleLine={rowHeight === "s"} />
+ <ConnectedIOTableCell isLoading singleLine={compactRows} />
),
headerTooltip: {
description: "Add metadata to scores to track additional information.",
@@ -752,7 +773,7 @@ export default function ScoresTable({
<ScoresMetadataCell
scoreId={scoreId}
projectId={projectId}
- singleLine={rowHeight === "s"}
+ singleLine={compactRows}
/>
);
},
@@ -1240,6 +1261,7 @@ export default function ScoresTable({
]}
rowHeight={rowHeight}
setRowHeight={setRowHeight}
+ customRowHeight={customRowHeightMenu(rowHeights)}
timeRange={
showControlsInPageHeader || isTraceScoped
? undefined
@@ -1365,6 +1387,9 @@ export default function ScoresTable({
columnOrder={columnOrder}
onColumnOrderChange={handleColumnOrderChange}
rowHeight={rowHeight}
+ customRowHeightPx={rowHeights.activeHeightPx}
+ onCustomRowHeightChange={rowHeights.setCustomPx}
+ onSelectRowHeight={setRowHeight}
/>
)}
</div>
diff --git a/web/src/features/sessions/SessionsTable.tsx b/web/src/features/sessions/SessionsTable.tsx
index bf42f15dd7..0d9ae649cf 100644
--- a/web/src/features/sessions/SessionsTable.tsx
+++ b/web/src/features/sessions/SessionsTable.tsx
@@ -58,7 +58,12 @@ import { tablePlaceholderOptions } from "@/src/components/table/utils/tablePlace
import { toAbsoluteTimeRange } from "@/src/utils/date-range-utils";
import { joinSessionCoreAndMetrics } from "@/src/features/sessions/session-row-data";
import { TagList } from "@/src/features/tag";
-import { useRowHeightLocalStorage } from "@/src/components/table/data-table-row-height-switch";
+import {
+ customRowHeightMenu,
+ isCompactRowHeight,
+ useCompactRows,
+ useRowHeightLocalStorage,
+} from "@/src/components/table/data-table-row-height-switch";
import { TableHeaderControls } from "@/src/components/table/table-header-controls";
import { cn } from "@/src/utils/tailwind";
import { useTableViewManager } from "@/src/components/table/table-view-presets/hooks/useTableViewManager";
@@ -110,6 +115,21 @@ export type SessionTableProps = {
showControlsInPageHeader?: boolean;
};
+function SessionTraceTags({
+ tags,
+ fallbackCompact,
+}: {
+ tags: string[];
+ fallbackCompact: boolean;
+}) {
+ const compact = useCompactRows(fallbackCompact);
+ return (
+ <div className={cn("flex gap-x-2 gap-y-1", !compact && "flex-wrap")}>
+ <TagList selectedTags={tags} isLoading={false} viewOnly />
+ </div>
+ );
+}
+
export default function SessionsTable({
projectId,
userId,
@@ -196,7 +216,15 @@ export default function SessionsTable({
limit: "pageSize",
});
- const [rowHeight, setRowHeight] = useRowHeightLocalStorage("sessions", "s");
+ const [rowHeight, setRowHeight, rowHeights] = useRowHeightLocalStorage(
+ "sessions",
+ "s",
+ );
+ const compactRows = isCompactRowHeight(
+ rowHeight,
+ rowHeights.mode,
+ rowHeights.activeHeightPx,
+ );
const [orderByState, setOrderByState] = useOrderByState({
column: "createdAt",
@@ -757,14 +785,7 @@ export default function SessionsTable({
return (
value &&
value.length > 0 && (
- <div
- className={cn(
- "flex gap-x-2 gap-y-1",
- rowHeight !== "s" && "flex-wrap",
- )}
- >
- <TagList selectedTags={value} isLoading={false} viewOnly />
- </div>
+ <SessionTraceTags tags={value} fallbackCompact={compactRows} />
)
);
},
@@ -905,6 +926,7 @@ export default function SessionsTable({
columnsWithCustomSelect={["userIds"]}
rowHeight={rowHeight}
setRowHeight={setRowHeight}
+ customRowHeight={customRowHeightMenu(rowHeights)}
multiSelect={{
selectAll,
setSelectAll,
@@ -981,6 +1003,9 @@ export default function SessionsTable({
href: "https://langfuse.com/docs/observability/features/sessions",
}}
rowHeight={rowHeight}
+ customRowHeightPx={rowHeights.activeHeightPx}
+ onCustomRowHeightChange={rowHeights.setCustomPx}
+ onSelectRowHeight={setRowHeight}
/>
</div>
</StickySearchableTableFilterLayout>
diff --git a/web/src/features/traces/TracesTable.tsx b/web/src/features/traces/TracesTable.tsx
index b1a29f00fc..2ec5a2568b 100644
--- a/web/src/features/traces/TracesTable.tsx
+++ b/web/src/features/traces/TracesTable.tsx
@@ -57,7 +57,11 @@ import {
type TracingSearchType,
DEFAULT_SIDEBAR_IMPLICIT_ENVIRONMENT_CONFIG,
} from "@langfuse/shared";
-import { useRowHeightLocalStorage } from "@/src/components/table/data-table-row-height-switch";
+import {
+ customRowHeightMenu,
+ isCompactRowHeight,
+ useRowHeightLocalStorage,
+} from "@/src/components/table/data-table-row-height-switch";
import { EmptyValue } from "@/src/components/design-system/table/components/EmptyValue/EmptyValue";
import { ConnectedIOTableCell } from "@/src/components/table/ConnectedIOTableCell";
import { useTableDateRange } from "@/src/hooks/useTableDateRange";
@@ -576,11 +580,18 @@ function TracesTableInternal({
// traces.all should load first together with everything else.
// This here happens in the background.
- const [storedRowHeight, setRowHeight] = useRowHeightLocalStorage(
+ const [storedRowHeight, setRowHeight, rowHeights] = useRowHeightLocalStorage(
"traces",
"s",
);
const rowHeight = hideControls ? "s" : storedRowHeight;
+ const compactRows =
+ hideControls ||
+ isCompactRowHeight(
+ storedRowHeight,
+ rowHeights.mode,
+ rowHeights.activeHeightPx,
+ );
// Trace rows render trace-scoped aggregates: direct trace scores plus
// observation scores that belong to the same trace.
@@ -759,7 +770,7 @@ function TracesTableInternal({
size: 400,
cellBackground: "gray",
loadingCell: () => (
- <ConnectedIOTableCell isLoading singleLine={rowHeight === "s"} />
+ <ConnectedIOTableCell isLoading singleLine={compactRows} />
),
cell: ({ row }) => {
const traceId: TracesTableRow["id"] = row.getValue("id");
@@ -771,7 +782,7 @@ function TracesTableInternal({
projectId={projectId}
timestamp={new Date(traceTimestamp)}
col="input"
- singleLine={rowHeight === "s"}
+ singleLine={compactRows}
/>
);
},
@@ -784,7 +795,7 @@ function TracesTableInternal({
size: 400,
cellBackground: "green",
loadingCell: () => (
- <ConnectedIOTableCell isLoading singleLine={rowHeight === "s"} />
+ <ConnectedIOTableCell isLoading singleLine={compactRows} />
),
cell: ({ row }) => {
const traceId: TracesTableRow["id"] = row.getValue("id");
@@ -796,7 +807,7 @@ function TracesTableInternal({
projectId={projectId}
timestamp={new Date(traceTimestamp)}
col="output"
- singleLine={rowHeight === "s"}
+ singleLine={compactRows}
/>
);
},
@@ -923,7 +934,7 @@ function TracesTableInternal({
),
href: "https://langfuse.com/docs/observability/features/tags",
},
- shouldWrap: rowHeight !== "s",
+ shouldWrap: !compactRows,
enableHiding: true,
}),
{
@@ -931,7 +942,7 @@ function TracesTableInternal({
header: "Metadata",
size: 400,
loadingCell: () => (
- <ConnectedIOTableCell isLoading singleLine={rowHeight === "s"} />
+ <ConnectedIOTableCell isLoading singleLine={compactRows} />
),
headerTooltip: {
description: (
@@ -962,7 +973,7 @@ function TracesTableInternal({
projectId={projectId}
timestamp={new Date(traceTimestamp)}
col="metadata"
- singleLine={rowHeight === "s"}
+ singleLine={compactRows}
/>
);
},
@@ -1532,6 +1543,7 @@ function TracesTableInternal({
setColumnOrder={handleColumnOrderChange}
rowHeight={rowHeight}
setRowHeight={setRowHeight}
+ customRowHeight={customRowHeightMenu(rowHeights)}
timeRange={showControlsInPageHeader ? undefined : timeRange}
setTimeRange={
showControlsInPageHeader ? undefined : setTimeRange
@@ -1614,6 +1626,13 @@ function TracesTableInternal({
columnOrder={columnOrder}
onColumnOrderChange={handleColumnOrderChange}
rowHeight={rowHeight}
+ customRowHeightPx={
+ hideControls ? undefined : rowHeights.activeHeightPx
+ }
+ onCustomRowHeightChange={
+ hideControls ? undefined : rowHeights.setCustomPx
+ }
+ onSelectRowHeight={hideControls ? undefined : setRowHeight}
peekView={peekConfig}
tableName="traces"
/>
@@ -1660,14 +1679,20 @@ const TracesDynamicCell = ({
})();
if (trace.isPending) {
- return <ConnectedIOTableCell isLoading singleLine={singleLine} />;
+ return (
+ <ConnectedIOTableCell
+ isLoading
+ singleLine={singleLine}
+ enableExpandOnHover
+ />
+ );
}
return (
<ConnectedIOTableCell
data={data}
singleLine={singleLine}
- enableExpandOnHover={singleLine}
+ enableExpandOnHover
/>
);
};
diff --git a/web/src/features/tracing-tables/observations/ObservationsTable.tsx b/web/src/features/tracing-tables/observations/ObservationsTable.tsx
index 6f803a249e..b625fc4972 100644
--- a/web/src/features/tracing-tables/observations/ObservationsTable.tsx
+++ b/web/src/features/tracing-tables/observations/ObservationsTable.tsx
@@ -64,7 +64,11 @@ import {
isObservationCostDisplayable,
} from "@/src/utils/observationCost";
import { useOrderByState } from "@/src/features/orderBy";
-import { useRowHeightLocalStorage } from "@/src/components/table/data-table-row-height-switch";
+import {
+ customRowHeightMenu,
+ isCompactRowHeight,
+ useRowHeightLocalStorage,
+} from "@/src/components/table/data-table-row-height-switch";
import { EmptyValue } from "@/src/components/design-system/table/components/EmptyValue/EmptyValue";
import { ConnectedIOTableCell } from "@/src/components/table/ConnectedIOTableCell";
import { useTableDateRange } from "@/src/hooks/useTableDateRange";
@@ -293,11 +297,18 @@ export default function ObservationsTable({
limit: "pageSize",
});
- const [storedRowHeight, setRowHeight] = useRowHeightLocalStorage(
+ const [storedRowHeight, setRowHeight, rowHeights] = useRowHeightLocalStorage(
"generations",
"s",
);
const rowHeight = hideControls ? "s" : storedRowHeight;
+ const compactRows =
+ hideControls ||
+ isCompactRowHeight(
+ storedRowHeight,
+ rowHeights.mode,
+ rowHeights.activeHeightPx,
+ );
const [inputFilterState] = useQueryFilterState(
// If the user loads saved table view presets, we should not apply the default type filter
@@ -804,7 +815,7 @@ export default function ObservationsTable({
size: 300,
cellBackground: "gray",
loadingCell: () => (
- <ConnectedIOTableCell isLoading singleLine={rowHeight === "s"} />
+ <ConnectedIOTableCell isLoading singleLine={compactRows} />
),
cell: ({ row }) => {
const observationId: string = row.getValue("id");
@@ -816,7 +827,7 @@ export default function ObservationsTable({
projectId={projectId}
startTime={row.getValue("startTime")}
col="input"
- singleLine={rowHeight === "s"}
+ singleLine={compactRows}
/>
);
},
@@ -829,7 +840,7 @@ export default function ObservationsTable({
size: 300,
cellBackground: "green",
loadingCell: () => (
- <ConnectedIOTableCell isLoading singleLine={rowHeight === "s"} />
+ <ConnectedIOTableCell isLoading singleLine={compactRows} />
),
cell: ({ row }) => {
const observationId: string = row.getValue("id");
@@ -841,7 +852,7 @@ export default function ObservationsTable({
projectId={projectId}
startTime={row.getValue("startTime")}
col="output"
- singleLine={rowHeight === "s"}
+ singleLine={compactRows}
/>
);
},
@@ -1022,14 +1033,14 @@ export default function ObservationsTable({
header: "Trace Tags",
size: 250,
enableHiding: true,
- shouldWrap: rowHeight !== "s",
+ shouldWrap: !compactRows,
}),
{
accessorKey: "metadata",
header: "Metadata",
size: 300,
loadingCell: () => (
- <ConnectedIOTableCell isLoading singleLine={rowHeight === "s"} />
+ <ConnectedIOTableCell isLoading singleLine={compactRows} />
),
headerTooltip: {
description: "Add metadata to traces to track additional information.",
@@ -1045,7 +1056,7 @@ export default function ObservationsTable({
projectId={projectId}
startTime={row.getValue("startTime")}
col="metadata"
- singleLine={rowHeight === "s"}
+ singleLine={compactRows}
/>
);
},
@@ -1436,6 +1447,7 @@ export default function ObservationsTable({
orderByState={orderBy}
rowHeight={rowHeight}
setRowHeight={setRowHeight}
+ customRowHeight={customRowHeightMenu(rowHeights)}
timeRange={showControlsInPageHeader ? undefined : timeRange}
setTimeRange={
showControlsInPageHeader ? undefined : setTimeRange
@@ -1499,6 +1511,13 @@ export default function ObservationsTable({
columnVisibility={columnVisibility}
onColumnVisibilityChange={handleColumnVisibilityChange}
rowHeight={rowHeight}
+ customRowHeightPx={
+ hideControls ? undefined : rowHeights.activeHeightPx
+ }
+ onCustomRowHeightChange={
+ hideControls ? undefined : rowHeights.setCustomPx
+ }
+ onSelectRowHeight={hideControls ? undefined : setRowHeight}
onRowClick={(row, event) => {
// Handle Command/Ctrl+click to open observation in new tab
if (event && (event.metaKey || event.ctrlKey)) {