🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
fix(web): Widget table colors & improve createBadgeTableColumn api (#17653)
Ben Bachem81549ad52d7c
diff --git a/web/src/components/design-system/table/columns/createBadgeTableColumn.stories.tsx b/web/src/components/design-system/table/columns/createBadgeTableColumn.stories.tsxindex e2588cb556..c71bf1d1a6 100644--- a/web/src/components/design-system/table/columns/createBadgeTableColumn.stories.tsx+++ b/web/src/components/design-system/table/columns/createBadgeTableColumn.stories.tsx@@ -8,6 +8,7 @@ import { createBadgeTableColumn } from "./createBadgeTableColumn";type Row = {environment: string | null;+ status: "success" | "error";};const columns = [@@ -16,6 +17,15 @@ const columns = [accessorFn: (row) => row.environment,header: "Badge",}),+ createBadgeTableColumn<Row>({+ range: "semantic",+ accessorKey: "status",+ header: "Semantic badge",+ getBadge: (status) => ({+ value: status,+ variant: status === "success" ? "success" : "error",+ }),+ }),];function BadgeTableColumnStory({ data }: { data: AsyncTableData<Row[]> }) {@@ -42,7 +52,7 @@ export const Default = meta.story({data: {isLoading: false,isError: false,- data: [{ environment: "production" }],+ data: [{ environment: "production", status: "success" }],},},});@@ -53,7 +63,7 @@ export const EmptyValue = meta.story({data: {isLoading: false,isError: false,- data: [{ environment: null }],+ data: [{ environment: null, status: "error" }],},},});diff --git a/web/src/components/design-system/table/columns/createBadgeTableColumn.tsx b/web/src/components/design-system/table/columns/createBadgeTableColumn.tsxindex f758e380b7..aeee5920a9 100644--- a/web/src/components/design-system/table/columns/createBadgeTableColumn.tsx+++ b/web/src/components/design-system/table/columns/createBadgeTableColumn.tsx@@ -9,37 +9,77 @@ import {type TableColumnOptions,} from "./utils/createTableColumn";+type BadgeVariant = NonNullable<BadgeProps["variant"]>;+type SemanticBadgeVariant = Extract<+ BadgeVariant,+ "destructive" | "error" | "success" | "warning"+>;+type DecorativeBadgeVariant = Extract<+ BadgeVariant,+ | "blue"+ | "violet"+ | "teal"+ | "emerald"+ | "purple"+ | "pink"+ | "orange"+ | "amber"+ | "green"+>;+type NeutralBadgeVariant = Extract<+ BadgeVariant,+ "default" | "secondary" | "tertiary"+>;++type GetBadge<TData extends RowData, TVariant extends BadgeVariant> = (+ value: string,+ context: CellContext<TData, string | null | undefined>,+) => {+ value: string;+ variant: TVariant;+ icon?: LucideIcon;+};++type BadgeTableColumnOptions<TData extends RowData> =+ | (TableColumnOptions<TData, string> & {+ range: "decorative";+ getBadge: GetBadge<TData, DecorativeBadgeVariant>;+ })+ | (TableColumnOptions<TData, string> & {+ range?: "neutral";+ getBadge?: GetBadge<TData, NeutralBadgeVariant>;+ })+ | (TableColumnOptions<TData, string> & {+ range: "semantic";+ getBadge: GetBadge<TData, SemanticBadgeVariant>;+ });+export function createBadgeTableColumn<TData extends RowData>({- getIcon,- getVariant,+ getBadge,+ range,...options-}: TableColumnOptions<TData, string> & {- getIcon?: (- value: string,- context: CellContext<TData, string | null | undefined>,- ) => LucideIcon | undefined;- getVariant?: (- value: string,- context: CellContext<TData, string | null | undefined>,- ) => BadgeProps["variant"];-}) {+}: BadgeTableColumnOptions<TData>) {return createTableColumn<TData, string>({...options,loadingCell: <Skeleton className="h-5 w-16 shrink-0 rounded-sm" />,renderCell: (value, context) => {if (!value) return null;- const Icon = getIcon?.(value, context);+ const badge =+ range === "semantic" || range === "decorative"+ ? getBadge(value, context)+ : (getBadge?.(value, context) ?? { value, variant: "secondary" });+ const Icon = badge.icon;return (<Badge- variant={getVariant?.(value, context) ?? "secondary"}+ variant={badge.variant ?? "secondary"}className="max-w-fit gap-1 truncate rounded-sm px-1 font-normal"- title={value}+ title={badge.value}>{Icon && <Icon className="size-3 shrink-0" aria-hidden />}- <span className="truncate" title={value}>- {value}+ <span className="truncate" title={badge.value}>+ {badge.value}</span></Badge>);diff --git a/web/src/components/ui/badge.tsx b/web/src/components/ui/badge.tsxindex e590eb005d..9e5fec1347 100644--- a/web/src/components/ui/badge.tsx+++ b/web/src/components/ui/badge.tsx@@ -23,6 +23,17 @@ const badgeVariants = cva(blue: "bg-light-blue text-dark-blue",violet: "bg-light-violet text-dark-violet",teal: "bg-light-teal text-dark-teal",+ emerald:+ "bg-emerald-100 text-emerald-800 dark:bg-emerald-950 dark:text-emerald-200",+ purple:+ "bg-purple-100 text-purple-800 dark:bg-purple-950 dark:text-purple-200",+ pink: "bg-pink-100 text-pink-800 dark:bg-pink-950 dark:text-pink-200",+ orange:+ "bg-orange-100 text-orange-800 dark:bg-orange-950 dark:text-orange-200",+ amber:+ "bg-amber-100 text-amber-800 dark:bg-amber-950 dark:text-amber-200",+ green:+ "bg-green-100 text-green-800 dark:bg-green-950 dark:text-green-200",},size: {default: "px-2.5 py-0.5 text-xs",diff --git a/web/src/features/dashboard/components/DashboardTable/DashboardTable.tsx b/web/src/features/dashboard/components/DashboardTable/DashboardTable.tsxindex eb59bfa7ad..7fb03d34e2 100644--- a/web/src/features/dashboard/components/DashboardTable/DashboardTable.tsx+++ b/web/src/features/dashboard/components/DashboardTable/DashboardTable.tsx@@ -67,12 +67,16 @@ export function DashboardTable({size: 300,}),createBadgeTableColumn<DashboardTableRow>({+ range: "decorative",id: "ownerTag",accessorFn: (row) =>row.owner === "LANGFUSE" ? "Langfuse" : "Project",header: "Owner",size: 80,- getVariant: (owner) => (owner === "Langfuse" ? "teal" : "blue"),+ getBadge: (owner) => ({+ value: owner,+ variant: owner === "Langfuse" ? "teal" : "blue",+ }),}),createDateTableColumn<DashboardTableRow>({accessorKey: "createdAt",diff --git a/web/src/features/widgets/components/WidgetTable/WidgetTable.stories.tsx b/web/src/features/widgets/components/WidgetTable/WidgetTable.stories.tsxindex bdcd5447bb..232d1075d4 100644--- a/web/src/features/widgets/components/WidgetTable/WidgetTable.stories.tsx+++ b/web/src/features/widgets/components/WidgetTable/WidgetTable.stories.tsx@@ -30,6 +30,86 @@ export const Default = meta.story({createdAt: new Date("2026-09-01"),updatedAt: new Date("2026-09-18"),},+ {+ id: "widget-2",+ name: "Observation volume",+ description: "Observation volume over time",+ view: "OBSERVATIONS",+ chartType: "AREA_TIME_SERIES",+ owner: "PROJECT",+ createdAt: new Date("2026-09-02"),+ updatedAt: new Date("2026-09-18"),+ },+ {+ id: "widget-3",+ name: "Numeric score trend",+ description: "Numeric scores over time",+ view: "SCORES_NUMERIC",+ chartType: "BAR_TIME_SERIES",+ owner: "PROJECT",+ createdAt: new Date("2026-09-03"),+ updatedAt: new Date("2026-09-18"),+ },+ {+ id: "widget-4",+ name: "Boolean score totals",+ description: "Boolean scores by value",+ view: "SCORES_BOOLEAN",+ chartType: "HORIZONTAL_BAR",+ owner: "PROJECT",+ createdAt: new Date("2026-09-04"),+ updatedAt: new Date("2026-09-18"),+ },+ {+ id: "widget-5",+ name: "Categorical score distribution",+ description: "Categorical scores by value",+ view: "SCORES_CATEGORICAL",+ chartType: "VERTICAL_BAR",+ owner: "PROJECT",+ createdAt: new Date("2026-09-05"),+ updatedAt: new Date("2026-09-18"),+ },+ {+ id: "widget-6",+ name: "Trace distribution",+ description: "Traces by category",+ view: "TRACES",+ chartType: "PIE",+ owner: "PROJECT",+ createdAt: new Date("2026-09-06"),+ updatedAt: new Date("2026-09-18"),+ },+ {+ id: "widget-7",+ name: "Observation count",+ description: "Total observations",+ view: "OBSERVATIONS",+ chartType: "NUMBER",+ owner: "PROJECT",+ createdAt: new Date("2026-09-07"),+ updatedAt: new Date("2026-09-18"),+ },+ {+ id: "widget-8",+ name: "Score histogram",+ description: "Numeric score distribution",+ view: "SCORES_NUMERIC",+ chartType: "HISTOGRAM",+ owner: "PROJECT",+ createdAt: new Date("2026-09-08"),+ updatedAt: new Date("2026-09-18"),+ },+ {+ id: "widget-9",+ name: "Boolean score matrix",+ description: "Boolean scores grouped by dimension",+ view: "SCORES_BOOLEAN",+ chartType: "PIVOT_TABLE",+ owner: "PROJECT",+ createdAt: new Date("2026-09-09"),+ updatedAt: new Date("2026-09-18"),+ },],},},diff --git a/web/src/features/widgets/components/WidgetTable/WidgetTable.tsx b/web/src/features/widgets/components/WidgetTable/WidgetTable.tsxindex 6f28c1ae04..2cc770c869 100644--- a/web/src/features/widgets/components/WidgetTable/WidgetTable.tsx+++ b/web/src/features/widgets/components/WidgetTable/WidgetTable.tsx@@ -42,22 +42,22 @@ const chartDisplayModes: Record<DashboardWidgetChartType, string> = {const viewBadgeVariants = {TRACES: "blue",- OBSERVATIONS: "success",- SCORES_NUMERIC: "warning",+ OBSERVATIONS: "teal",+ SCORES_NUMERIC: "green",SCORES_BOOLEAN: "violet",- SCORES_CATEGORICAL: "destructive",+ SCORES_CATEGORICAL: "pink",} as const;const chartTypeBadgeVariants = {LINE_TIME_SERIES: "blue",- AREA_TIME_SERIES: "blue",+ AREA_TIME_SERIES: "emerald",BAR_TIME_SERIES: "violet",HORIZONTAL_BAR: "teal",- VERTICAL_BAR: "destructive",- PIE: "warning",- NUMBER: "success",- HISTOGRAM: "violet",- PIVOT_TABLE: "teal",+ VERTICAL_BAR: "orange",+ PIE: "pink",+ NUMBER: "green",+ HISTOGRAM: "purple",+ PIVOT_TABLE: "amber",} as const;export type WidgetTableRow = {@@ -119,45 +119,48 @@ export function DashboardWidgetTable({size: 300,}),createBadgeTableColumn<WidgetTableRow>({- accessorFn: (row) => startCase(row.view.toLowerCase()),- id: "view",+ range: "decorative",+ accessorKey: "view",header: "View Type",enableSorting: true,size: TYPE_COLUMN_SIZE,- getVariant: (_view, { row }) =>- viewBadgeVariants[- row.original.view as keyof typeof viewBadgeVariants- ] ?? "blue",+ getBadge: (view) => ({+ value: startCase(view.toLowerCase()),+ variant:+ viewBadgeVariants[view as keyof typeof viewBadgeVariants] ?? "blue",+ }),}),createBadgeTableColumn<WidgetTableRow>({- accessorFn: (row) =>- chartTypeLabels[row.chartType as DashboardWidgetChartType],- id: "chartType",+ range: "decorative",+ accessorKey: "chartType",header: "Chart Type",enableSorting: true,size: TYPE_COLUMN_SIZE,- getVariant: (_chartType, { row }) =>- chartTypeBadgeVariants[- row.original.chartType as DashboardWidgetChartType- ],- getIcon: (_chartType, { row }) =>- dashboardWidgetChartTypeIcons[- row.original.chartType as DashboardWidgetChartType+ getBadge: (chartType) => ({+ value: chartTypeLabels[chartType as DashboardWidgetChartType],+ variant:+ chartTypeBadgeVariants[chartType as DashboardWidgetChartType],+ icon: dashboardWidgetChartTypeIcons[+ chartType as DashboardWidgetChartType],+ }),}),createBadgeTableColumn<WidgetTableRow>({+ range: "decorative",accessorFn: (row) =>chartDisplayModes[row.chartType as DashboardWidgetChartType],id: "displayMode",header: "Display Mode",enableSorting: true,size: TYPE_COLUMN_SIZE,- getVariant: (displayMode) =>- displayMode === "Time Series" ? "blue" : "teal",- getIcon: (displayMode) =>- displayMode === "Time Series"- ? dashboardWidgetChartTypeIcons.LINE_TIME_SERIES- : dashboardWidgetChartTypeIcons.NUMBER,+ getBadge: (displayMode) => ({+ value: displayMode,+ variant: displayMode === "Time Series" ? "blue" : "teal",+ icon:+ displayMode === "Time Series"+ ? dashboardWidgetChartTypeIcons.LINE_TIME_SERIES+ : dashboardWidgetChartTypeIcons.NUMBER,+ }),}),createDateTableColumn<WidgetTableRow>({accessorKey: "createdAt",