Skip to content

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

feat(ui): peek view on dataset run compare table (#4131)

marliessophiea48817300bf7
diff --git a/web/src/components/trace/IOPreview.tsx b/web/src/components/trace/IOPreview.tsx
index a0374b724e..075522bbff 100644
--- a/web/src/components/trace/IOPreview.tsx
+++ b/web/src/components/trace/IOPreview.tsx
@@ -74,7 +74,15 @@ export const IOPreview: React.FC<{
output?: Prisma.JsonValue;
isLoading?: boolean;
hideIfNull?: boolean;
-}> = ({ isLoading = false, hideIfNull = false, ...props }) => {
+ hideOutput?: boolean;
+ hideInput?: boolean;
+}> = ({
+ isLoading = false,
+ hideIfNull = false,
+ hideOutput = false,
+ hideInput = false,
+ ...props
+}) => {
const [currentView, setCurrentView] = useState<"pretty" | "json">("pretty");
const capture = usePostHogClientCapture();
const input = deepParseJson(props.input);
@@ -169,10 +177,10 @@ export const IOPreview: React.FC<{
/>
) : (
<>
- {!(hideIfNull && !input) ? (
+ {!(hideIfNull && !input) && !hideInput ? (
<MarkdownOrJsonView title="Input" content={input} />
) : null}
- {!(hideIfNull && !output) ? (
+ {!(hideIfNull && !output) && !hideOutput ? (
<MarkdownOrJsonView
title="Output"
content={output}
@@ -186,7 +194,7 @@ export const IOPreview: React.FC<{
) : null}
{currentView === "json" || !isPrettyViewAvailable ? (
<>
- {!(hideIfNull && !input) ? (
+ {!(hideIfNull && !input) && !hideInput ? (
<JSONView
title="Input"
json={input ?? null}
@@ -194,7 +202,7 @@ export const IOPreview: React.FC<{
className="flex-1"
/>
) : null}
- {!(hideIfNull && !output) ? (
+ {!(hideIfNull && !output) && !hideOutput ? (
<JSONView
title="Output"
json={outputClean}
diff --git a/web/src/components/trace/ObservationTree.tsx b/web/src/components/trace/ObservationTree.tsx
index 5095fb96dc..2def1295db 100644
--- a/web/src/components/trace/ObservationTree.tsx
+++ b/web/src/components/trace/ObservationTree.tsx
@@ -19,7 +19,10 @@ import { CommentCountIcon } from "@/src/features/comments/CommentCountIcon";
import { usdFormatter } from "@/src/utils/numbers";
import Decimal from "decimal.js";
-export const ObservationTree = (props: {
+export const ObservationTree = ({
+ showExpandControls = true,
+ ...props
+}: {
observations: ObservationReturnType[];
collapsedObservations: string[];
toggleCollapsedObservation: (id: string) => void;
@@ -35,6 +38,7 @@ export const ObservationTree = (props: {
observationCommentCounts?: Map<string, number>;
traceCommentCounts?: Map<string, number>;
className?: string;
+ showExpandControls?: boolean;
}) => {
const nestedObservations = useMemo(
() => nestObservations(props.observations),
@@ -59,6 +63,7 @@ export const ObservationTree = (props: {
showMetrics={props.showMetrics}
showScores={props.showScores}
totalCost={totalCost}
+ showExpandControls={showExpandControls}
/>
<ObservationTreeNode
observations={nestedObservations}
@@ -92,6 +97,7 @@ const ObservationTreeTraceNode = (props: {
showMetrics?: boolean;
showScores?: boolean;
totalCost?: Decimal;
+ showExpandControls?: boolean;
}) => {
return (
<div
@@ -112,24 +118,26 @@ const ObservationTreeTraceNode = (props: {
{props.comments ? (
<CommentCountIcon count={props.comments.get(props.trace.id)} />
) : null}
- <div className="flex flex-1 justify-end">
- <Button
- onClick={(ev) => (ev.stopPropagation(), props.expandAll())}
- size="xs"
- variant="ghost"
- title="Expand all"
- >
- <PlusCircleIcon className="h-4 w-4" />
- </Button>
- <Button
- onClick={(ev) => (ev.stopPropagation(), props.collapseAll())}
- size="xs"
- variant="ghost"
- title="Collapse all"
- >
- <MinusCircle className="h-4 w-4" />
- </Button>
- </div>
+ {props.showExpandControls && (
+ <div className="flex flex-1 justify-end">
+ <Button
+ onClick={(ev) => (ev.stopPropagation(), props.expandAll())}
+ size="xs"
+ variant="ghost"
+ title="Expand all"
+ >
+ <PlusCircleIcon className="h-4 w-4" />
+ </Button>
+ <Button
+ onClick={(ev) => (ev.stopPropagation(), props.collapseAll())}
+ size="xs"
+ variant="ghost"
+ title="Collapse all"
+ >
+ <MinusCircle className="h-4 w-4" />
+ </Button>
+ </div>
+ )}
</div>
{props.showMetrics && (
diff --git a/web/src/components/trace/TraceTimelineView.tsx b/web/src/components/trace/TraceTimelineView.tsx
index 6909b8fc68..ebc41c78ab 100644
--- a/web/src/components/trace/TraceTimelineView.tsx
+++ b/web/src/components/trace/TraceTimelineView.tsx
@@ -138,7 +138,7 @@ function TreeItemInner({
<PanelRightOpen className="h-4 w-4"></PanelRightOpen>
</Button>
</DrawerTrigger>
- <DrawerContent className="h-1/2 w-full overflow-hidden md:w-3/5 lg:w-3/5 xl:w-3/5 2xl:w-3/5">
+ <DrawerContent className="w-full overflow-hidden" size="md">
{children}
</DrawerContent>
</Drawer>
diff --git a/web/src/components/ui/drawer.tsx b/web/src/components/ui/drawer.tsx
index 3fa6e6e723..5b3bd803a8 100644
--- a/web/src/components/ui/drawer.tsx
+++ b/web/src/components/ui/drawer.tsx
@@ -5,16 +5,45 @@ import { Drawer as DrawerPrimitive } from "vaul";
import { cn } from "@/src/utils/tailwind";
import { useMediaQuery } from "react-responsive";
+import { cva } from "class-variance-authority";
type DrawerContentProps = React.ComponentPropsWithoutRef<
typeof DrawerPrimitive.Content
> & {
overlayClassName?: string;
+ size?: "default" | "md" | "lg";
+ position?: "top";
+ height?: "default" | "md";
};
// https://tailwindcss.com/docs/responsive-design
const TAILWIND_MD_MEDIA_QUERY = 768;
+const drawerVariants = cva(
+ "fixed inset-x-0 z-50 flex h-auto flex-col rounded-t-lg border bg-background md:inset-x-auto md:right-0 md:mt-0 md:rounded-l-lg md:rounded-r-none",
+ {
+ variants: {
+ size: {
+ default: "md:w-1/2 lg:w-2/5 xl:w-1/3 2xl:w-1/4",
+ md: "w-3/5",
+ lg: "w-2/3",
+ },
+ position: {
+ top: "md:inset-y-0",
+ },
+ height: {
+ default: "h-1/3 md:h-full",
+ md: "md:h-1/2",
+ },
+ },
+ defaultVariants: {
+ size: "default",
+ position: "top",
+ height: "default",
+ },
+ },
+);
+
const Drawer = ({
shouldScaleBackground = true,
...props
@@ -55,24 +84,26 @@ DrawerOverlay.displayName = DrawerPrimitive.Overlay.displayName;
const DrawerContent = React.forwardRef<
React.ElementRef<typeof DrawerPrimitive.Content>,
DrawerContentProps
->(({ className, children, overlayClassName, ...props }, ref) => (
- <DrawerPortal>
- <DrawerOverlay className={overlayClassName} />
- <DrawerPrimitive.Content
- ref={ref}
- className={cn(
- "fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-lg border bg-background md:inset-x-auto md:inset-y-0 md:right-0 md:mt-0 md:h-full md:w-1/2 md:rounded-l-lg md:rounded-r-none lg:w-2/5 xl:w-1/3 2xl:w-1/4",
- className,
- )}
- {...props}
- >
- <DrawerDescription className="sr-only">
- {props.title ?? ""}
- </DrawerDescription>
- {children}
- </DrawerPrimitive.Content>
- </DrawerPortal>
-));
+>(
+ (
+ { className, children, overlayClassName, size, height, position, ...props },
+ ref,
+ ) => (
+ <DrawerPortal>
+ <DrawerOverlay className={overlayClassName} />
+ <DrawerPrimitive.Content
+ ref={ref}
+ className={cn(drawerVariants({ size, className, height, position }))}
+ {...props}
+ >
+ <DrawerDescription className="sr-only">
+ {props.title ?? ""}
+ </DrawerDescription>
+ {children}
+ </DrawerPrimitive.Content>
+ </DrawerPortal>
+ ),
+);
DrawerContent.displayName = "DrawerContent";
const DrawerHeader = ({
diff --git a/web/src/features/comments/CommentDrawerButton.tsx b/web/src/features/comments/CommentDrawerButton.tsx
index e8b4a8ed78..72defa952e 100644
--- a/web/src/features/comments/CommentDrawerButton.tsx
+++ b/web/src/features/comments/CommentDrawerButton.tsx
@@ -54,7 +54,7 @@ export function CommentDrawerButton({
)}
</Button>
</DrawerTrigger>
- <DrawerContent className="h-1/3" overlayClassName="bg-primary/10">
+ <DrawerContent overlayClassName="bg-primary/10">
<div className="mx-auto w-full overflow-y-auto md:max-h-full">
<DrawerHeader className="sticky top-0 z-10 rounded-sm bg-background">
<DrawerTitle>
diff --git a/web/src/features/datasets/components/DatasetAggregateTableCell.tsx b/web/src/features/datasets/components/DatasetAggregateTableCell.tsx
index bcbfbdbb91..fffed3cd85 100644
--- a/web/src/features/datasets/components/DatasetAggregateTableCell.tsx
+++ b/web/src/features/datasets/components/DatasetAggregateTableCell.tsx
@@ -8,7 +8,9 @@ import {
} from "@/src/features/datasets/components/DatasetCompareRunsTable";
import { api } from "@/src/utils/api";
import { formatIntervalSeconds } from "@/src/utils/dates";
+import { cn } from "@/src/utils/tailwind";
import { ClockIcon, ListTree } from "lucide-react";
+import { type ReactNode } from "react";
const DatasetAggregateCell = ({
scores,
@@ -18,10 +20,18 @@ const DatasetAggregateCell = ({
observationId,
scoreKeyToDisplayName,
selectedMetrics,
+ singleLine = true,
+ className,
+ variant = "table",
+ actionButtons,
}: RunMetrics & {
projectId: string;
scoreKeyToDisplayName: Map<string, string>;
selectedMetrics: DatasetRunMetric[];
+ singleLine?: boolean;
+ className?: string;
+ variant?: "table" | "peek";
+ actionButtons?: ReactNode;
}) => {
// conditionally fetch the trace or observation depending on the presence of observationId
const trace = api.traces.byId.useQuery(
@@ -62,13 +72,19 @@ const DatasetAggregateCell = ({
const data = observationId === undefined ? trace.data : observation.data;
return (
- <div className="group flex h-full w-full flex-col gap-1.5 overflow-hidden overflow-y-auto rounded-sm border p-1">
+ <div
+ className={cn(
+ "group flex h-full w-full flex-col gap-1.5 overflow-hidden overflow-y-auto rounded-sm border p-1",
+ className,
+ )}
+ >
+ {variant === "peek" && actionButtons}
<div className="flex flex-row items-center justify-center gap-1">
<IOTableCell
isLoading={!!!observationId ? trace.isLoading : observation.isLoading}
data={data?.output}
className={"bg-accent-light-green"}
- singleLine={true}
+ singleLine={singleLine}
/>
</div>
@@ -91,39 +107,43 @@ const DatasetAggregateCell = ({
</div>
)}
- {selectedMetrics.includes("resourceMetrics") && (
- <div className="flex w-full flex-row flex-wrap gap-1">
- <Badge variant="outline" className="p-0.5 px-1 font-normal">
- <ClockIcon className="mb-0.5 mr-1 h-3 w-3" />
- <span className="capitalize">
- {!!resourceMetrics.latency
- ? formatIntervalSeconds(resourceMetrics.latency)
- : null}
- </span>
- </Badge>
- <Badge variant="outline" className="p-0.5 px-1 font-normal">
- <span className="mr-0.5">{resourceMetrics.totalCost}</span>
- </Badge>
- </div>
- )}
+ {selectedMetrics.includes("resourceMetrics") &&
+ (resourceMetrics.latency || resourceMetrics.totalCost) && (
+ <div className="flex w-full flex-row flex-wrap gap-1">
+ {resourceMetrics.latency && (
+ <Badge variant="outline" className="p-0.5 px-1 font-normal">
+ <ClockIcon className="mb-0.5 mr-1 h-3 w-3" />
+ <span className="capitalize">
+ {formatIntervalSeconds(resourceMetrics.latency)}
+ </span>
+ </Badge>
+ )}
+ {resourceMetrics.totalCost && (
+ <Badge variant="outline" className="p-0.5 px-1 font-normal">
+ <span className="mr-0.5">{resourceMetrics.totalCost}</span>
+ </Badge>
+ )}
+ </div>
+ )}
<div className="flex-grow" />
- {observationId ? (
- <TableLink
- path={`/project/${projectId}/traces/${encodeURIComponent(traceId)}?observation=${encodeURIComponent(observationId)}`}
- value={`Trace: ${traceId}, Observation: ${observationId}`}
- icon={<ListTree className="h-4 w-4" />}
- className="hidden w-fit self-end group-hover:block"
- />
- ) : (
- <TableLink
- path={`/project/${projectId}/traces/${encodeURIComponent(traceId)}`}
- value={`Trace: ${traceId}`}
- icon={<ListTree className="h-4 w-4" />}
- className="hidden w-fit self-end group-hover:block"
- />
- )}
+ {variant === "table" &&
+ (observationId ? (
+ <TableLink
+ path={`/project/${projectId}/traces/${encodeURIComponent(traceId)}?observation=${encodeURIComponent(observationId)}`}
+ value={`Trace: ${traceId}, Observation: ${observationId}`}
+ icon={<ListTree className="h-4 w-4" />}
+ className="hidden w-fit self-end group-hover:block"
+ />
+ ) : (
+ <TableLink
+ path={`/project/${projectId}/traces/${encodeURIComponent(traceId)}`}
+ value={`Trace: ${traceId}`}
+ icon={<ListTree className="h-4 w-4" />}
+ className="hidden w-fit self-end group-hover:block"
+ />
+ ))}
</div>
);
};
@@ -133,11 +153,19 @@ export const DatasetAggregateTableCell = ({
projectId,
scoreKeyToDisplayName,
selectedMetrics,
+ singleLine = true,
+ className,
+ variant = "table",
+ actionButtons,
}: {
value: RunMetrics;
projectId: string;
scoreKeyToDisplayName: Map<string, string>;
selectedMetrics: DatasetRunMetric[];
+ singleLine?: boolean;
+ className?: string;
+ variant?: "table" | "peek";
+ actionButtons?: ReactNode;
}) => {
return value ? (
<DatasetAggregateCell
@@ -145,6 +173,10 @@ export const DatasetAggregateTableCell = ({
{...value}
scoreKeyToDisplayName={scoreKeyToDisplayName}
selectedMetrics={selectedMetrics}
+ singleLine={singleLine}
+ className={className}
+ variant={variant}
+ actionButtons={actionButtons}
/>
) : null;
};
diff --git a/web/src/features/datasets/components/DatasetCompareRunPeekView.tsx b/web/src/features/datasets/components/DatasetCompareRunPeekView.tsx
new file mode 100644
index 0000000000..4e4f370fe0
--- /dev/null
+++ b/web/src/features/datasets/components/DatasetCompareRunPeekView.tsx
@@ -0,0 +1,266 @@
+import { useClickhouse } from "@/src/components/layouts/ClickhouseAdminToggle";
+import DocPopup from "@/src/components/layouts/doc-popup";
+import Header from "@/src/components/layouts/header";
+import { IOPreview } from "@/src/components/trace/IOPreview";
+import { ObservationTree } from "@/src/components/trace/ObservationTree";
+import { Button } from "@/src/components/ui/button";
+import { Card } from "@/src/components/ui/card";
+import {
+ Drawer,
+ DrawerClose,
+ DrawerContent,
+ DrawerHeader,
+ DrawerTitle,
+} from "@/src/components/ui/drawer";
+import {
+ ResizablePanelGroup,
+ ResizablePanel,
+ ResizableHandle,
+} from "@/src/components/ui/resizable";
+import { Skeleton } from "@/src/components/ui/skeleton";
+import { DatasetAggregateTableCell } from "@/src/features/datasets/components/DatasetAggregateTableCell";
+import { type DatasetCompareRunRowData } from "@/src/features/datasets/components/DatasetCompareRunsTable";
+import { api, type RouterOutputs } from "@/src/utils/api";
+import { cn } from "@/src/utils/tailwind";
+import { PanelLeftOpen, PanelLeftClose, X, ListTree } from "lucide-react";
+import { useRouter } from "next/router";
+
+export function DatasetCompareRunPeekView({
+ projectId,
+ scoreKeyToDisplayName,
+ clickedRow,
+ setClickedRow,
+ traceAndObservationId,
+ setTraceAndObservationId,
+ runsData,
+}: {
+ projectId: string;
+ scoreKeyToDisplayName: Map<string, string>;
+ clickedRow: DatasetCompareRunRowData | null;
+ setClickedRow: (row: DatasetCompareRunRowData | null) => void;
+ traceAndObservationId: {
+ runId: string;
+ traceId: string;
+ observationId?: string;
+ } | null;
+ setTraceAndObservationId: (
+ id: { runId: string; traceId: string; observationId?: string } | null,
+ ) => void;
+ runsData: RouterOutputs["datasets"]["baseRunDataByDatasetId"];
+}) {
+ const router = useRouter();
+
+ const timestamp =
+ router.query.timestamp && typeof router.query.timestamp === "string"
+ ? new Date(decodeURIComponent(router.query.timestamp))
+ : undefined;
+
+ const trace = api.traces.byIdWithObservationsAndScores.useQuery(
+ {
+ traceId: traceAndObservationId?.traceId as string,
+ projectId,
+ timestamp,
+ queryClickhouse: useClickhouse(),
+ },
+ {
+ enabled: !!traceAndObservationId,
+ retry(failureCount, error) {
+ if (error.data?.code === "UNAUTHORIZED") return false;
+ return failureCount < 3;
+ },
+ },
+ );
+
+ const onClose = () => {
+ setClickedRow(null);
+ setTraceAndObservationId(null);
+ };
+
+ return (
+ <Drawer
+ key={clickedRow?.id ?? "closed"}
+ open={!!clickedRow}
+ modal={false}
+ onClose={onClose}
+ >
+ <DrawerContent size="lg" className="mx-auto">
+ <DrawerHeader className="sticky top-0 z-10 flex flex-row items-center justify-between rounded-sm bg-background">
+ <DrawerTitle className="flex flex-row items-center gap-2">
+ {traceAndObservationId?.traceId && (
+ <Button
+ variant="outline"
+ size="icon"
+ onClick={() => setTraceAndObservationId(null)}
+ >
+ <PanelLeftClose className="h-4 w-4" />
+ </Button>
+ )}
+ <Header title="Comparing traces" level="h3"></Header>
+ </DrawerTitle>
+ <DrawerClose asChild onClick={onClose}>
+ <Button variant="outline" size="icon">
+ <X className="h-4 w-4" />
+ </Button>
+ </DrawerClose>
+ </DrawerHeader>
+ <div
+ data-vaul-no-drag
+ className="mb-4 h-full flex-1 gap-4 overflow-hidden px-4"
+ >
+ <div
+ className={cn(
+ "grid gap-4 md:h-full",
+ traceAndObservationId?.traceId
+ ? "grid-cols-[1fr,3fr]"
+ : "grid-cols-1",
+ )}
+ >
+ {traceAndObservationId?.traceId && (
+ <Card className="h-full overflow-y-auto p-2">
+ {trace.data ? (
+ <ObservationTree
+ observations={trace.data?.observations ?? []}
+ collapsedObservations={[]}
+ toggleCollapsedObservation={() => {}}
+ collapseAll={() => {}}
+ expandAll={() => {}}
+ trace={trace.data}
+ scores={trace.data?.scores ?? []}
+ currentObservationId={undefined}
+ setCurrentObservationId={(id) => {
+ if (id)
+ window.open(
+ `/project/${projectId}/traces/${encodeURIComponent(traceAndObservationId?.traceId)}?observation=${encodeURIComponent(id)}`,
+ "_blank",
+ "noopener noreferrer",
+ );
+ }}
+ showMetrics={false}
+ showScores={true}
+ colorCodeMetrics={false}
+ className="flex w-full flex-col overflow-y-auto"
+ showExpandControls={false}
+ />
+ ) : (
+ <Skeleton className="min-h-full w-full" />
+ )}
+ </Card>
+ )}
+ <div className="grid h-full grid-rows-[minmax(0,1fr)] overflow-hidden">
+ <ResizablePanelGroup
+ direction="vertical"
+ className="overflow-hidden"
+ >
+ <ResizablePanel
+ minSize={30}
+ className="mb-2 min-h-0 overflow-hidden"
+ >
+ <div className="grid h-full grid-cols-2 gap-4">
+ <div className="min-h-0 overflow-hidden">
+ <h3 className="font-lg mb-1 font-semibold">Input</h3>
+ <div className="h-[calc(100%-1.75rem)] space-y-2 overflow-y-auto">
+ <IOPreview
+ key={clickedRow?.id + "-input"}
+ input={clickedRow?.input ?? null}
+ hideOutput
+ />
+ </div>
+ </div>
+ <div className="min-h-0 overflow-hidden">
+ <h3 className="font-lg mb-1 font-semibold">
+ Expected output
+ </h3>
+ <div className="h-[calc(100%-1.75rem)] space-y-2 overflow-y-auto">
+ <IOPreview
+ key={clickedRow?.id + "-output"}
+ output={clickedRow?.expectedOutput ?? null}
+ hideInput
+ />
+ </div>
+ </div>
+ </div>
+ </ResizablePanel>
+ <ResizableHandle withHandle className="bg-border" />
+ <ResizablePanel
+ minSize={30}
+ defaultSize={50}
+ className="mt-2 min-h-0 overflow-hidden"
+ >
+ <h3 className="font-lg mb-1 font-semibold">Run outputs</h3>
+ {clickedRow?.runs && (
+ <div className="flex h-[calc(100%-2rem)] w-full gap-4 overflow-x-auto">
+ {Object.entries(clickedRow.runs).map(([id, run]) => {
+ const runData = runsData?.find((r) => r.id === id);
+ return (
+ <div
+ key={id}
+ className="flex w-[45%] flex-none flex-col overflow-hidden"
+ >
+ <div className="mb-1 flex items-center text-sm font-medium">
+ {runData?.name ?? id}
+ {runData?.description && (
+ <DocPopup description={runData?.description} />
+ )}
+ </div>
+ <DatasetAggregateTableCell
+ value={run}
+ projectId={projectId}
+ scoreKeyToDisplayName={scoreKeyToDisplayName}
+ selectedMetrics={["scores", "resourceMetrics"]}
+ singleLine={false}
+ variant="peek"
+ className={cn(
+ "relative flex-1 overflow-y-auto",
+ traceAndObservationId?.runId === id &&
+ "border-4",
+ )}
+ actionButtons={
+ <div className="absolute right-1 top-1 z-10 hidden items-center justify-center gap-1 group-hover:flex">
+ <Button
+ variant="outline"
+ size="icon"
+ title="View full trace"
+ onClick={() =>
+ window.open(
+ run?.observationId
+ ? `/project/${projectId}/traces/${encodeURIComponent(run.traceId)}?observation=${encodeURIComponent(run.observationId)}`
+ : `/project/${projectId}/traces/${encodeURIComponent(run.traceId)}`,
+ "_blank",
+ "noopener noreferrer",
+ )
+ }
+ >
+ <ListTree className="h-4 w-4" />
+ </Button>
+
+ <Button
+ variant="outline"
+ size="icon"
+ title="View trace tree"
+ onClick={() =>
+ setTraceAndObservationId({
+ traceId: run.traceId,
+ observationId: run.observationId,
+ runId: id,
+ })
+ }
+ >
+ <PanelLeftOpen className="h-4 w-4" />
+ </Button>
+ </div>
+ }
+ />
+ </div>
+ );
+ })}
+ </div>
+ )}
+ </ResizablePanel>
+ </ResizablePanelGroup>
+ </div>
+ </div>
+ </div>
+ </DrawerContent>
+ </Drawer>
+ );
+}
diff --git a/web/src/features/datasets/components/DatasetCompareRunsTable.tsx b/web/src/features/datasets/components/DatasetCompareRunsTable.tsx
index 1d18de09d0..d39a2b6197 100644
--- a/web/src/features/datasets/components/DatasetCompareRunsTable.tsx
+++ b/web/src/features/datasets/components/DatasetCompareRunsTable.tsx
@@ -15,13 +15,14 @@ import { usdFormatter } from "@/src/utils/numbers";
import { getScoreDataTypeIcon } from "@/src/features/scores/components/ScoreDetailColumnHelpers";
import { api, type RouterOutputs } from "@/src/utils/api";
import { Button } from "@/src/components/ui/button";
-import { ChevronDown, Rows3 } from "lucide-react";
+import { ChevronDown, Expand, Rows3 } from "lucide-react";
import {
DropdownMenu,
DropdownMenuCheckboxItem,
DropdownMenuContent,
DropdownMenuTrigger,
} from "@/src/components/ui/dropdown-menu";
+import { DatasetCompareRunPeekView } from "@/src/features/datasets/components/DatasetCompareRunPeekView";
import { useClickhouse } from "@/src/components/layouts/ClickhouseAdminToggle";
export type RunMetrics = {
@@ -60,6 +61,15 @@ export function DatasetCompareRunsTable(props: {
"resourceMetrics",
]);
const [isMetricsDropdownOpen, setIsMetricsDropdownOpen] = useState(false);
+ const [clickedRow, setClickedRow] = useState<DatasetCompareRunRowData | null>(
+ null,
+ );
+ const [traceAndObservationId, setTraceAndObservationId] = useState<{
+ runId: string;
+ traceId: string;
+ observationId?: string;
+ } | null>(null);
+
const rowHeight = "l";
const [paginationState, setPaginationState] = useQueryParams({
@@ -201,7 +211,22 @@ export function DatasetCompareRunsTable(props: {
const input = row.getValue(
"input",
) as DatasetCompareRunRowData["input"];
- return input !== null ? <IOTableCell data={input} /> : null;
+ return input !== null ? (
+ <div className="group relative h-full w-full">
+ <Button
+ variant="outline"
+ size="icon"
+ className="absolute right-1 top-1 z-[5] hidden items-center justify-center group-hover:flex"
+ onClick={() => {
+ setTraceAndObservationId(null);
+ setClickedRow(row.original);
+ }}
+ >
+ <Expand className="h-4 w-4" />
+ </Button>
+ <IOTableCell data={input} />
+ </div>
+ ) : null;
},
},
{
@@ -215,10 +240,23 @@ export function DatasetCompareRunsTable(props: {
"expectedOutput",
) as DatasetCompareRunRowData["expectedOutput"];
return expectedOutput !== null ? (
- <IOTableCell
- data={expectedOutput}
- className="bg-accent-light-green"
- />
+ <div className="group relative h-full w-full">
+ <Button
+ variant="outline"
+ size="icon"
+ className="absolute right-1 top-1 z-[5] hidden items-center justify-center group-hover:flex"
+ onClick={() => {
+ setTraceAndObservationId(null);
+ setClickedRow(row.original);
+ }}
+ >
+ <Expand className="h-4 w-4" />
+ </Button>
+ <IOTableCell
+ data={expectedOutput}
+ className="bg-accent-light-green"
+ />
+ </div>
) : null;
},
},
@@ -324,6 +362,17 @@ export function DatasetCompareRunsTable(props: {
}}
rowHeight={rowHeight}
/>
+ {scoreKeysAndProps.isSuccess && (
+ <DatasetCompareRunPeekView
+ projectId={props.projectId}
+ scoreKeyToDisplayName={scoreKeyToDisplayName}
+ clickedRow={clickedRow}
+ setClickedRow={setClickedRow}
+ traceAndObservationId={traceAndObservationId}
+ setTraceAndObservationId={setTraceAndObservationId}
+ runsData={props.runsData ?? []}
+ />
+ )}
</>
);
}
diff --git a/web/src/features/scores/components/AnnotateDrawer.tsx b/web/src/features/scores/components/AnnotateDrawer.tsx
index 5256932a56..3f9e8d1075 100644
--- a/web/src/features/scores/components/AnnotateDrawer.tsx
+++ b/web/src/features/scores/components/AnnotateDrawer.tsx
@@ -107,7 +107,7 @@ export function AnnotateDrawer({
</Button>
)}
</DrawerTrigger>
- <DrawerContent className="h-1/3">
+ <DrawerContent>
{configsData.isLoading ? (
<DrawerHeader className="sticky top-0 z-10 rounded-sm bg-background">
<DrawerTitle>
diff --git a/web/src/pages/project/[projectId]/datasets/[datasetId]/compare.tsx b/web/src/pages/project/[projectId]/datasets/[datasetId]/compare.tsx
index 87b5eb1779..5b601f830e 100644
--- a/web/src/pages/project/[projectId]/datasets/[datasetId]/compare.tsx
+++ b/web/src/pages/project/[projectId]/datasets/[datasetId]/compare.tsx
@@ -108,10 +108,7 @@ export default function DatasetCompare() {
}))}
values={runs.filter((run) => runIds?.includes(run.key))}
onValueChange={(values, changedValueId, selectedValueKeys) => {
- if (values.length === 0)
- setRunState({
- runs: [],
- });
+ if (values.length === 0) return; // TODO: hide clear button
if (changedValueId) {
if (selectedValueKeys?.has(changedValueId)) {
setRunState({
diff --git a/web/src/pages/project/[projectId]/datasets/[datasetId]/runs/[runId].tsx b/web/src/pages/project/[projectId]/datasets/[datasetId]/runs/[runId].tsx
index 029bb0583f..334f18c9b7 100644
--- a/web/src/pages/project/[projectId]/datasets/[datasetId]/runs/[runId].tsx
+++ b/web/src/pages/project/[projectId]/datasets/[datasetId]/runs/[runId].tsx
@@ -1,11 +1,14 @@
import { FullScreenPage } from "@/src/components/layouts/full-screen-page";
import Header from "@/src/components/layouts/header";
import { TableWithMetadataWrapper } from "@/src/components/table/TableWithMetadataWrapper";
+import { Button } from "@/src/components/ui/button";
import { JSONView } from "@/src/components/ui/CodeJsonViewer";
import { DatasetRunItemsTable } from "@/src/features/datasets/components/DatasetRunItemsTable";
import { DeleteDatasetRunButton } from "@/src/features/datasets/components/DeleteDatasetRunButton";
import { DetailPageNav } from "@/src/features/navigate-detail-pages/DetailPageNav";
import { api } from "@/src/utils/api";
+import { Columns3 } from "lucide-react";
+import Link from "next/link";
import { useRouter } from "next/router";
export default function Dataset() {
@@ -51,6 +54,17 @@ export default function Dataset() {
}
listKey="datasetRuns"
/>
+ <Link
+ href={{
+ pathname: `/project/${projectId}/datasets/${datasetId}/compare`,
+ query: { runs: [runId] },
+ }}
+ >
+ <Button>
+ <Columns3 className="mr-2 h-4 w-4" />
+ <span>Compare</span>
+ </Button>
+ </Link>
</>
}
/>