🪢 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): filled badge variant, score and tag chips built on it (#18277)
Trang Nguyen9d7108e5f1af
diff --git a/web/src/components/GroupedScoreBadges.stories.tsx b/web/src/components/GroupedScoreBadges.stories.tsxindex 24d042c913..377bafb8c7 100644--- a/web/src/components/GroupedScoreBadges.stories.tsx+++ b/web/src/components/GroupedScoreBadges.stories.tsx@@ -49,10 +49,6 @@ export const Default = meta.story({args: { scores },});-export const Compact = meta.story({- args: { scores, compact: true },-});-export const WithOverflow = meta.story({name: "(Test) With Overflow",args: {diff --git a/web/src/components/ScoreBadge/ScoreBadge.tsx b/web/src/components/ScoreBadge/ScoreBadge.tsxindex 713f165045..282953fc2a 100644--- a/web/src/components/ScoreBadge/ScoreBadge.tsx+++ b/web/src/components/ScoreBadge/ScoreBadge.tsx@@ -11,14 +11,11 @@ export const ScoreBadge = <name,scores,showLevels,- compact,}: {name: string;scores: T[];/** Render this group's level tags when the selection mixes score levels. */showLevels?: boolean;- /** Tree rows use the small badge size. */- compact?: boolean;}) => {const levels = showLevels? Array.from(new Set(scores.map((score) => scoreLevelFromScore(score))))@@ -29,15 +26,14 @@ export const ScoreBadge = <{levels.map((level) => (<ScoreTag key={level} level={level} />))}- <BadgeShell size={compact ? "sm" : undefined}>- <span- aria-hidden- className="bg-dark-yellow size-1.25 shrink-0 rounded-[1px]"- />- <span className="min-w-0 flex-1 truncate" title={name}>- {name}+ <BadgeShell color="filled" size="md">+ <span className="text-muted-foreground flex min-w-0 flex-1 font-mono">+ <span className="truncate py-0.5" title={name}>+ {name}+ </span>+ <span className="py-0.5">:</span></span>- <span className="flex min-w-0 items-center gap-1 text-nowrap">+ <span className="text-foreground flex min-w-0 items-center gap-1 font-mono text-nowrap">{scores.map((score, index) => {return (<spandiff --git a/web/src/components/ScoreValue.tsx b/web/src/components/ScoreValue.tsxindex 03df237330..f35493a89c 100644--- a/web/src/components/ScoreValue.tsx+++ b/web/src/components/ScoreValue.tsx@@ -42,7 +42,7 @@ export const ScoreValue = ({return (<span className="inline-flex min-w-0 items-center gap-1">- <span className="truncate" title={value}>+ <span className="text-foreground truncate py-0.5" title={value}>{value}</span>{score.comment && (diff --git a/web/src/components/design-system/Badge/Badge.stories.tsx b/web/src/components/design-system/Badge/Badge.stories.tsxindex d02b63c5ea..8678b781d6 100644--- a/web/src/components/design-system/Badge/Badge.stories.tsx+++ b/web/src/components/design-system/Badge/Badge.stories.tsx@@ -24,6 +24,7 @@ const allColors = Object.keys({teal: true,green: true,ghost: true,+ filled: true,} satisfies Record<Color, true>) as Color[];export const Default = meta.story({});diff --git a/web/src/components/design-system/Badge/Badge.tsx b/web/src/components/design-system/Badge/Badge.tsxindex 1ed6f09328..a8c5b2d0ec 100644--- a/web/src/components/design-system/Badge/Badge.tsx+++ b/web/src/components/design-system/Badge/Badge.tsx@@ -11,17 +11,20 @@ const badgeVariants = cva(variants: {size: {default: "h-5.5 gap-1.5 pr-1.5 pl-2",+ md: "h-5 gap-1 px-1.5",sm: "h-4.5 gap-1 px-1.5",},color: {primary: "border-border bg-transparent text-foreground-secondary",- red: "border-transparent bg-light-red/60 text-dark-red/90 dark:bg-light-red/40 dark:text-dark-red/90",- yellow: "border-transparent bg-light-yellow/80 text-dark-yellow",+ red: "border-red-100 bg-red-50 text-red-800 dark:border-transparent dark:bg-light-red/40 dark:text-dark-red/90",+ yellow:+ "border-yellow-100 bg-yellow-50 text-yellow-800 dark:border-transparent dark:bg-light-yellow/80 dark:text-dark-yellow",blue: "border-transparent bg-light-blue text-dark-blue",violet: "border-transparent bg-light-violet text-dark-violet",teal: "border-transparent bg-light-teal text-dark-teal",green: "border-transparent bg-light-green text-dark-green",ghost: "border-0 bg-transparent px-0 text-foreground-secondary",+ filled: "border-transparent bg-muted text-foreground-secondary",},interactive: {true: "decoration-border-contrast underline decoration-dashed decoration-1 underline-offset-[3px]",@@ -85,7 +88,7 @@ export function Badge({}: BadgeProps) {return (<BadgeShell color={color} {...props}>- {label && <span className="shrink-0 py-0.5">{label}</span>}+ {label && <span className="shrink-0 py-0.5">{label}:</span>}<spanclassName={cn("overflow-x-clip overflow-y-visible py-0.5 text-ellipsis whitespace-nowrap",diff --git a/web/src/components/grouped-score-badge.tsx b/web/src/components/grouped-score-badge.tsxindex 057b272d09..8d89ca1a9a 100644--- a/web/src/components/grouped-score-badge.tsx+++ b/web/src/components/grouped-score-badge.tsx@@ -4,7 +4,6 @@ import {PopoverContent,PopoverTrigger,} from "@/src/components/ui/popover";-import { cn } from "@/src/utils/tailwind";import { type LastUserScore, type ScoreDomain } from "@langfuse/shared";import { type WithStringifiedMetadata } from "@/src/utils/clientSideDomainTypes";import { scoreLevelFromScore } from "@/src/components/score-tag";@@ -51,7 +50,7 @@ const ScoreTable = <T extends ChipScore>({ scores }: { scores: T[] }) => {return (<div className="p-2 text-xs"><div className="text-foreground mb-1 font-bold">Scores</div>- <ul className="grid grid-cols-[auto_auto] gap-x-4 gap-y-1">+ <ul className="grid grid-cols-[auto_auto] gap-x-4 gap-y-1 font-mono">{groups.map(([name, groupScores]) => (<li key={name} className="contents"><span className="text-muted-foreground whitespace-nowrap">@@ -78,11 +77,9 @@ const ScoreTable = <T extends ChipScore>({ scores }: { scores: T[] }) => {export const GroupedScoreBadges = <T extends ChipScore>({scores,maxVisible = MAX_VISIBLE_SCORE_GROUPS,- compact,}: {scores: T[];maxVisible?: number;- compact?: boolean;}) => {const groupedScores = groupScoresByName(scores);@@ -97,44 +94,42 @@ export const GroupedScoreBadges = <T extends ChipScore>({maxVisible,);+ const overflow = (+ <Popover>+ <PopoverTrigger asChild>+ <BadgeShell asChild color="filled" size="md">+ <button+ type="button"+ className="text-muted-foreground cursor-pointer self-center font-mono"+ aria-label={`Show all ${Object.keys(groupedScores).length} scores`}+ // Chips render inside clickable rows; opening must not select the row.+ onClick={(event) => event.stopPropagation()}+ >+ +{hiddenScores.length}+ </button>+ </BadgeShell>+ </PopoverTrigger>+ <PopoverContent+ align="start"+ className="max-h-[320px] w-max max-w-[min(560px,90vw)] overflow-y-auto p-0"+ onClick={(event) => event.stopPropagation()}+ >+ <ScoreTable scores={scores} />+ </PopoverContent>+ </Popover>+ );+return (<>{visibleScores.map(([name, scores]) => (<ScoreBadgekey={name}- compact={compact}name={name}scores={scores}showLevels={showLevels}/>))}- {Boolean(hiddenScores.length) && (- <Popover>- <PopoverTrigger asChild>- <BadgeShell asChild size={compact ? "sm" : undefined}>- <button- type="button"- className={cn(- "cursor-pointer self-center text-xs font-bold",- compact ? "px-0.5 py-0 leading-tight" : "px-1",- )}- aria-label={`Show all ${Object.keys(groupedScores).length} scores`}- // Chips render inside clickable rows; opening must not select the row.- onClick={(event) => event.stopPropagation()}- >- +{hiddenScores.length}- </button>- </BadgeShell>- </PopoverTrigger>- <PopoverContent- align="start"- className="max-h-[320px] w-max max-w-[min(560px,90vw)] overflow-y-auto p-0"- onClick={(event) => event.stopPropagation()}- >- <ScoreTable scores={scores} />- </PopoverContent>- </Popover>- )}+ {Boolean(hiddenScores.length) && overflow}</>);};diff --git a/web/src/features/sessions/ModernSessionHeader.stories.tsx b/web/src/features/sessions/ModernSessionHeader.stories.tsxindex ef641949bd..4adf5b0b91 100644--- a/web/src/features/sessions/ModernSessionHeader.stories.tsx+++ b/web/src/features/sessions/ModernSessionHeader.stories.tsx@@ -231,7 +231,7 @@ export const TestBoundsManyUsers = meta.story({await userEvent.type(searchInput, "[email protected]");await expect(within(results).getByRole("link", {- name: "user [email protected]",+ name: "user: [email protected]",}),).toBeInTheDocument();},diff --git a/web/src/features/tag/components/TagButton.tsx b/web/src/features/tag/components/TagButton.tsxindex 7e9241b1e3..8d56e0f68d 100644--- a/web/src/features/tag/components/TagButton.tsx+++ b/web/src/features/tag/components/TagButton.tsx@@ -14,7 +14,7 @@ export const TagButton: React.FC<{<TagIcon className="text-foreground-tertiary size-3 shrink-0" /><spanclassName={cn(- "overflow-hidden text-ellipsis whitespace-nowrap",+ "overflow-hidden py-0.5 text-ellipsis whitespace-nowrap",!isTableCell && "text-xs",)}title={tag}@@ -26,8 +26,10 @@ export const TagButton: React.FC<{if (viewOnly) {return (- <span className="inline-flex max-w-40 min-w-0">- <BadgeShell>{label}</BadgeShell>+ <span className="inline-flex max-w-40 min-w-0 font-mono">+ <BadgeShell color="filled" size="md">+ {label}+ </BadgeShell></span>);}diff --git a/web/src/features/traces/components/SpanContent.tsx b/web/src/features/traces/components/SpanContent.tsxindex dee7fedd98..407915b784 100644--- a/web/src/features/traces/components/SpanContent.tsx+++ b/web/src/features/traces/components/SpanContent.tsx@@ -179,7 +179,7 @@ export function SpanContent({pill that opens a table of all scores. */}{showScores && nodeScores.length > 0 && (<div className="flex flex-wrap gap-1">- <GroupedScoreBadges compact scores={nodeScores} />+ <GroupedScoreBadges scores={nodeScores} /></div>)}</div>