🪢 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): restore controls in the score overflow table (#18205)
Tobias Wochingerd423fe186245
diff --git a/web/src/components/GroupedScoreBadges.stories.tsx b/web/src/components/GroupedScoreBadges.stories.tsxindex 98cb1fed0d..24d042c913 100644--- a/web/src/components/GroupedScoreBadges.stories.tsx+++ b/web/src/components/GroupedScoreBadges.stories.tsx@@ -9,6 +9,13 @@ const meta = preview.meta({args: {scores: [],},+ parameters: {+ nextjs: {+ router: {+ query: { projectId: "storybook-project" },+ },+ },+ },});const scores = [@@ -50,7 +57,13 @@ export const WithOverflow = meta.story({name: "(Test) With Overflow",args: {scores: [- ...scores,+ {+ ...scores[0],+ comment: "Detailed quality feedback",+ executionTraceId: "execution-trace-id",+ metadata: { evaluator: "human" },+ },+ scores[1],{...scores[0],id: "accuracy",@@ -74,6 +87,23 @@ export const WithOverflow = meta.story({),).toHaveLength(3);});++ const popover = within(body.getByRole("dialog"));+ const commentButton = popover.getByLabelText(+ "View comment for quality: 0.92",+ );+ await expect(commentButton).toBeInTheDocument();+ await expect(+ popover.getByLabelText("View metadata for quality: 0.92"),+ ).toBeInTheDocument();++ await userEvent.hover(commentButton);+ await expect(+ await body.findByRole("link", { name: "View execution trace" }),+ ).toHaveAttribute(+ "href",+ "/project/storybook-project/traces/execution-trace-id",+ );},});diff --git a/web/src/components/ScoreBadge/ScoreBadge.tsx b/web/src/components/ScoreBadge/ScoreBadge.tsxindex 30c40a6b22..713f165045 100644--- a/web/src/components/ScoreBadge/ScoreBadge.tsx+++ b/web/src/components/ScoreBadge/ScoreBadge.tsx@@ -1,56 +1,10 @@import { type LastUserScore, type ScoreDomain } from "@langfuse/shared";-import {- BracesIcon,- ExternalLinkIcon,- MessageCircleMoreIcon,-} from "lucide-react";-import Link from "next/link";import { BadgeShell } from "@/src/components/design-system/Badge/Badge";-import { JSONView } from "@/src/components/ui/CodeJsonViewer";-import {- HoverCard,- HoverCardContent,- HoverCardTrigger,-} from "@/src/components/ui/hover-card";import { ScoreTag, scoreLevelFromScore } from "@/src/components/score-tag";-import useProjectIdFromURL from "@/src/hooks/useProjectIdFromURL";+import { ScoreValue } from "@/src/components/ScoreValue";import { type WithStringifiedMetadata } from "@/src/utils/clientSideDomainTypes";-const hasMetadata = (- score: WithStringifiedMetadata<ScoreDomain> | LastUserScore,-) => {- if (!score.metadata) return false;- try {- const metadata =- typeof score.metadata === "string"- ? JSON.parse(score.metadata)- : score.metadata;- return Object.keys(metadata).length > 0;- } catch {- return false;- }-};--const ExecutionTraceLink = ({- executionTraceId,- projectId,-}: {- executionTraceId: string;- projectId: string;-}) => {- return (- <Link- href={`/project/${projectId}/traces/${encodeURIComponent(executionTraceId)}`}- className="flex items-center gap-1 text-blue-600 hover:underline"- target="_blank"- >- <ExternalLinkIcon className="h-3 w-3" />- View execution trace- </Link>- );-};-export const ScoreBadge = <T extends WithStringifiedMetadata<ScoreDomain> | LastUserScore,>({@@ -66,8 +20,6 @@ export const ScoreBadge = </** Tree rows use the small badge size. */compact?: boolean;}) => {- const projectId = useProjectIdFromURL();-const levels = showLevels? Array.from(new Set(scores.map((score) => scoreLevelFromScore(score)))): [];@@ -87,55 +39,12 @@ export const ScoreBadge = <</span><span className="flex min-w-0 items-center gap-1 text-nowrap">{scores.map((score, index) => {- const value = score.stringValue ?? score.value?.toFixed(2) ?? "";-return (<spankey={index}className="inline-flex min-w-0 items-center gap-1">- <span className="truncate" title={value}>- {value}- </span>- {score.comment && (- <HoverCard>- <HoverCardTrigger- aria-label={`View comment for ${name}: ${value}`}- className="inline-block shrink-0"- >- <MessageCircleMoreIcon className="text-foreground-tertiary mb-0.25 size-3!" />- </HoverCardTrigger>- <HoverCardContent className="max-h-[50dvh] overflow-y-auto text-xs break-normal whitespace-normal">- <p className="whitespace-pre-wrap">{score.comment}</p>- {"executionTraceId" in score &&- score.executionTraceId &&- projectId && (- <div className="mt-2">- <ExecutionTraceLink- executionTraceId={score.executionTraceId}- projectId={projectId}- />- </div>- )}- </HoverCardContent>- </HoverCard>- )}- {hasMetadata(score) && (- <HoverCard>- <HoverCardTrigger- aria-label={`View metadata for ${name}: ${value}`}- className="inline-block shrink-0"- >- <BracesIcon className="text-foreground-tertiary mb-0.25 size-3!" />- </HoverCardTrigger>- <HoverCardContent className="max-h-[50dvh] overflow-y-auto rounded-md border-none p-0 text-xs break-normal whitespace-normal">- <JSONView- codeClassName="rounded-md!"- json={score.metadata}- />- </HoverCardContent>- </HoverCard>- )}+ <ScoreValue name={name} score={score} />{index < scores.length - 1 && <span>,</span>}</span>);diff --git a/web/src/components/ScoreValue.tsx b/web/src/components/ScoreValue.tsxnew file mode 100644index 0000000000..03df237330--- /dev/null+++ b/web/src/components/ScoreValue.tsx@@ -0,0 +1,90 @@+import { type LastUserScore, type ScoreDomain } from "@langfuse/shared";+import {+ BracesIcon,+ ExternalLinkIcon,+ MessageCircleMoreIcon,+} from "lucide-react";+import Link from "next/link";++import { JSONView } from "@/src/components/ui/CodeJsonViewer";+import {+ HoverCard,+ HoverCardContent,+ HoverCardTrigger,+} from "@/src/components/ui/hover-card";+import useProjectIdFromURL from "@/src/hooks/useProjectIdFromURL";+import { type WithStringifiedMetadata } from "@/src/utils/clientSideDomainTypes";++type ChipScore = WithStringifiedMetadata<ScoreDomain> | LastUserScore;++const hasMetadata = (score: ChipScore) => {+ if (!score.metadata) return false;+ try {+ const metadata =+ typeof score.metadata === "string"+ ? JSON.parse(score.metadata)+ : score.metadata;+ return Object.keys(metadata).length > 0;+ } catch {+ return false;+ }+};++export const ScoreValue = ({+ name,+ score,+}: {+ name: string;+ score: ChipScore;+}) => {+ const projectId = useProjectIdFromURL();+ const value = score.stringValue ?? score.value?.toFixed(2) ?? "";++ return (+ <span className="inline-flex min-w-0 items-center gap-1">+ <span className="truncate" title={value}>+ {value}+ </span>+ {score.comment && (+ <HoverCard>+ <HoverCardTrigger+ aria-label={`View comment for ${name}: ${value}`}+ className="inline-block shrink-0"+ >+ <MessageCircleMoreIcon className="text-foreground-tertiary mb-0.25 size-3!" />+ </HoverCardTrigger>+ <HoverCardContent className="max-h-[50dvh] overflow-y-auto text-xs break-normal whitespace-normal">+ <p className="whitespace-pre-wrap">{score.comment}</p>+ {"executionTraceId" in score &&+ score.executionTraceId &&+ projectId && (+ <div className="mt-2">+ <Link+ href={`/project/${projectId}/traces/${encodeURIComponent(score.executionTraceId)}`}+ className="flex items-center gap-1 text-blue-600 hover:underline"+ target="_blank"+ >+ <ExternalLinkIcon className="h-3 w-3" />+ View execution trace+ </Link>+ </div>+ )}+ </HoverCardContent>+ </HoverCard>+ )}+ {hasMetadata(score) && (+ <HoverCard>+ <HoverCardTrigger+ aria-label={`View metadata for ${name}: ${value}`}+ className="inline-block shrink-0"+ >+ <BracesIcon className="text-foreground-tertiary mb-0.25 size-3!" />+ </HoverCardTrigger>+ <HoverCardContent className="max-h-[50dvh] overflow-y-auto rounded-md border-none p-0 text-xs break-normal whitespace-normal">+ <JSONView codeClassName="rounded-md!" json={score.metadata} />+ </HoverCardContent>+ </HoverCard>+ )}+ </span>+ );+};diff --git a/web/src/components/grouped-score-badge.tsx b/web/src/components/grouped-score-badge.tsxindex a60672453e..057b272d09 100644--- a/web/src/components/grouped-score-badge.tsx+++ b/web/src/components/grouped-score-badge.tsx@@ -9,6 +9,7 @@ import { type LastUserScore, type ScoreDomain } from "@langfuse/shared";import { type WithStringifiedMetadata } from "@/src/utils/clientSideDomainTypes";import { scoreLevelFromScore } from "@/src/components/score-tag";import { ScoreBadge } from "@/src/components/ScoreBadge/ScoreBadge";+import { ScoreValue } from "@/src/components/ScoreValue";type ChipScore = WithStringifiedMetadata<ScoreDomain> | LastUserScore;@@ -42,9 +43,6 @@ const partitionScores = <T extends ChipScore>(};};-const formatScoreValue = (score: ChipScore) =>- score.stringValue ?? score.value?.toFixed(2) ?? "";-const ScoreTable = <T extends ChipScore>({ scores }: { scores: T[] }) => {const groups = Object.entries(groupScoresByName(scores)).sort(([a], [b]) =>a.localeCompare(b),@@ -59,8 +57,16 @@ const ScoreTable = <T extends ChipScore>({ scores }: { scores: T[] }) => {<span className="text-muted-foreground whitespace-nowrap">{name}</span>- <span className="text-foreground whitespace-nowrap">- {groupScores.map(formatScoreValue).join(", ")}+ <span className="text-foreground inline-flex items-center gap-1 whitespace-nowrap">+ {groupScores.map((score, index) => (+ <span+ key={index}+ className="inline-flex min-w-0 items-center gap-1"+ >+ <ScoreValue name={name} score={score} />+ {index < groupScores.length - 1 && <span>,</span>}+ </span>+ ))}</span></li>))}