Skip to content

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

feat(dataset-runs): improve UI/UX of runs and compare page (#6296)

marliessophie849428abee93
diff --git a/web/src/components/layouts/peek-view.tsx b/web/src/components/layouts/peek-view.tsx
deleted file mode 100644
index 8bd2124ba6..0000000000
--- a/web/src/components/layouts/peek-view.tsx
+++ /dev/null
@@ -1,58 +0,0 @@
-import { Button } from "@/src/components/ui/button";
-import {
- Drawer,
- DrawerClose,
- DrawerContent,
- DrawerHeader,
- DrawerTitle,
-} from "@/src/components/ui/drawer";
-import { X } from "lucide-react";
-import Link from "next/link";
-import { type ReactNode } from "react";
-
-export default function PeekView(props: {
- item: {
- name: string;
- type: string;
- link: string;
- };
- open: boolean;
- onClose: () => void;
- children: ReactNode;
- actionButtons?: ReactNode;
-}) {
- return (
- <Drawer open={props.open} modal={false} onClose={props.onClose}>
- <DrawerContent size="lg" className="mx-auto" data-vaul-no-drag>
- <DrawerHeader className="sticky top-0 z-10 mb-2 flex flex-row items-center justify-between rounded-tl-xl border-b bg-background p-3">
- <DrawerTitle className="flex flex-row items-center gap-2">
- <div className="mb-2 mt-2 flex flex-wrap items-center justify-between gap-2">
- {props.actionButtons ?? null}
- <h3 className="text-xl font-bold leading-7 sm:tracking-tight">
- {`${props.item.type}:`}
- </h3>
- <Link
- className="inline-block h-5 max-w-full overflow-hidden text-ellipsis text-nowrap rounded bg-primary-accent/20 px-2 py-0.5 text-base font-semibold text-accent-dark-blue shadow-sm hover:bg-accent-light-blue/45"
- href={props.item.link}
- title={props.item.name}
- >
- {props.item.name}
- </Link>
- </div>
- </DrawerTitle>
- <DrawerClose asChild onClick={props.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 select-text gap-4 overflow-hidden px-4"
- >
- {props.children}
- </div>
- </DrawerContent>
- </Drawer>
- );
-}
diff --git a/web/src/components/scores-table-cell.tsx b/web/src/components/scores-table-cell.tsx
index e88e422154..ba8f0220d8 100644
--- a/web/src/components/scores-table-cell.tsx
+++ b/web/src/components/scores-table-cell.tsx
@@ -20,13 +20,18 @@ const COLLAPSE_CATEGORICAL_SCORES_AFTER = 2;
const ScoreValueCounts = ({
valueCounts,
+ wrap,
}: {
valueCounts: CategoricalAggregate["valueCounts"];
+ wrap: boolean;
}) => {
- return valueCounts.map(({ value, count }) => (
+ return valueCounts.map(({ value, count }, index) => (
<div key={value} className="flex flex-row">
<span className="truncate">{value}</span>
<span>{`: ${numberFormatter(count, 0)}`}</span>
+ {!wrap && index < valueCounts.length - 1 && (
+ <span className="mr-1">{";"}</span>
+ )}
</div>
));
};
@@ -34,9 +39,11 @@ const ScoreValueCounts = ({
export const ScoresTableCell = ({
aggregate,
showSingleValue = false,
+ wrap = true,
}: {
aggregate: CategoricalAggregate | NumericAggregate;
showSingleValue?: boolean;
+ wrap?: boolean;
}) => {
if (showSingleValue && aggregate.values.length === 1) {
const value =
@@ -80,16 +87,17 @@ export const ScoresTableCell = ({
0,
COLLAPSE_CATEGORICAL_SCORES_AFTER,
)}
+ wrap={wrap}
/>
</div>
</HoverCardTrigger>
<HoverCardContent className="z-20 flex max-h-[40vh] max-w-64 flex-col overflow-y-auto whitespace-normal break-normal">
- <ScoreValueCounts valueCounts={aggregate.valueCounts} />
+ <ScoreValueCounts valueCounts={aggregate.valueCounts} wrap={wrap} />
</HoverCardContent>
</HoverCard>
) : (
- <div className="flex flex-col">
- <ScoreValueCounts valueCounts={aggregate.valueCounts} />
+ <div className={cn("flex", wrap ? "flex-col" : "flex-row")}>
+ <ScoreValueCounts valueCounts={aggregate.valueCounts} wrap={wrap} />
</div>
)}
</div>
diff --git a/web/src/components/table/data-table.tsx b/web/src/components/table/data-table.tsx
index 02d3a1c890..da43d6f55d 100644
--- a/web/src/components/table/data-table.tsx
+++ b/web/src/components/table/data-table.tsx
@@ -1,6 +1,6 @@
"use client";
import { type OrderByState } from "@langfuse/shared";
-import React, { useState, useMemo } from "react";
+import React, { useState, useMemo, useCallback } from "react";
import DocPopup from "@/src/components/layouts/doc-popup";
import { DataTablePagination } from "@/src/components/table/data-table-pagination";
import {
@@ -31,16 +31,9 @@ import {
type RowSelectionState,
type VisibilityState,
} from "@tanstack/react-table";
-import { useRouter } from "next/router";
-import {
- TablePeekView,
- type DataTablePeekViewProps,
-} from "@/src/components/table/peek";
-
-type PeekViewProps<TData> = Omit<
- DataTablePeekViewProps<TData>,
- "selectedRowId"
->;
+import { TablePeekView } from "@/src/components/table/peek";
+import { type PeekViewProps } from "@/src/components/table/peek/hooks/usePeekView";
+import { usePeekView } from "@/src/components/table/peek/hooks/usePeekView";
interface DataTableProps<TData, TValue> {
columns: LangfuseColumnDef<TData, TValue>[];
@@ -123,9 +116,6 @@ export function DataTable<TData extends object, TValue>({
const [columnFilters, setColumnFilters] = useState<ColumnFiltersState>([]);
const rowheighttw = getRowHeightTailwindClass(rowHeight);
const capture = usePostHogClientCapture();
- const router = useRouter();
- const peekViewId = router.query.peek as string | undefined;
-
const flattedColumnsByGroup = useMemo(() => {
const flatColumnsByGroup = new Map<string, string[]>();
@@ -138,24 +128,6 @@ export function DataTable<TData extends object, TValue>({
return flatColumnsByGroup;
}, [columns]);
- const handleOnRowClick = (row: TData) => {
- if (peekView) {
- const rowId =
- "id" in row && typeof row.id === "string" ? row.id : undefined;
-
- // If clicking the same row that's already open, close it
- if (rowId === peekViewId) {
- peekView.onOpenChange(false);
- }
- // If clicking a different row, update without closing first
- else {
- peekView.onOpenChange(true, row);
- }
- }
- onRowClick?.(row);
- };
- const hasRowClickAction = !!onRowClick || !!peekView;
-
const table = useReactTable({
data: data.data ?? [],
columns,
@@ -199,6 +171,25 @@ export function DataTable<TData extends object, TValue>({
columnResizeMode: "onChange",
});
+ const getRowMemoized = useCallback(
+ (id: string) => table.getRow(id)?.original,
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ [],
+ );
+
+ const { inflatedPeekView, peekViewId, handleOnRowClickPeek } = usePeekView({
+ getRow: getRowMemoized,
+ peekView,
+ });
+
+ const handleOnRowClick = (row: TData) => {
+ if (inflatedPeekView) {
+ handleOnRowClickPeek?.(row);
+ }
+ onRowClick?.(row);
+ };
+ const hasRowClickAction = !!onRowClick || !!inflatedPeekView;
+
// memo column sizes for performance
// https://tanstack.com/table/v8/docs/guide/column-sizing#advanced-column-resizing-performance
const columnSizeVars = useMemo(() => {
@@ -370,9 +361,7 @@ export function DataTable<TData extends object, TValue>({
</div>
<div className="grow"></div>
</div>
- {peekView && peekViewId && (
- <TablePeekView selectedRowId={peekViewId} {...peekView} />
- )}
+ {inflatedPeekView && <TablePeekView {...inflatedPeekView} />}
{pagination !== undefined ? (
<div
className={cn(
diff --git a/web/src/components/table/peek.tsx b/web/src/components/table/peek.tsx
index 217d5e652d..100262618e 100644
--- a/web/src/components/table/peek.tsx
+++ b/web/src/components/table/peek.tsx
@@ -9,48 +9,103 @@ import { Expand, ExternalLink } from "lucide-react";
import { Separator } from "@/src/components/ui/separator";
import { ItemBadge, type LangfuseItemType } from "@/src/components/ItemBadge";
import { DetailPageNav } from "@/src/features/navigate-detail-pages/DetailPageNav";
+import { type ListEntry } from "@/src/features/navigate-detail-pages/context";
+import { cn } from "@/src/utils/tailwind";
-type PeekViewItemType = Extract<LangfuseItemType, "TRACE">;
+type PeekViewItemType = Extract<LangfuseItemType, "TRACE" | "DATASET_ITEM">;
+/**
+ * Options to control peek event behavior.
+ * Ignore close events from certain clickable elements to ensure integrity of table row actions.
+ */
+export type PeekEventControlOptions = {
+ ignoredSelectors?: string[];
+ customCheck?: (event?: Event) => boolean;
+};
+
+/**
+ * Configuration for a data table peek view.
+ */
export type DataTablePeekViewProps<TData> = {
+ // Core identification
+ /** The type of item being peeked at */
itemType: PeekViewItemType;
- selectedRowId: string | null;
- onOpenChange: (open: boolean, row?: TData) => void;
- onExpand: (openInNewTab: boolean) => void;
- render: () => React.ReactNode;
+ /** Key used for detail page navigation */
+ listKey?: string;
+
+ // Data
+ /** The currently selected row ID */
+ selectedRowId?: string | null;
+ /** The row data for the selected item */
+ row?: TData;
+
+ // Navigation and URL handling
+ /** The base pathname for constructing URLs */
urlPathname: string;
+ /** Function to get navigation path for a list entry */
+ getNavigationPath?: (entry: ListEntry) => string;
+
+ // Event handlers
+ /** Called when the peek view is opened or closed */
+ onOpenChange: (open: boolean, id?: string, timestamp?: string) => void;
+ /** Called when the peek view is expanded to full view */
+ onExpand?: (openInNewTab: boolean) => void;
+ /** Additional peek event options */
+ peekEventOptions?: PeekEventControlOptions;
+
+ // Content
+ /**
+ * The content to display in the peek view.
+ * Can be either a React node or a function that receives the row data and returns a React node.
+ */
+ children: React.ReactNode | ((row?: TData) => React.ReactNode);
};
-const mapItemTypeToPageUrl: Record<PeekViewItemType, string> = {
- TRACE: "traces",
-} as const;
+export const createPeekEventHandler = (options?: PeekEventControlOptions) => {
+ if (!options) return () => false;
+ const { ignoredSelectors = [], customCheck } = options;
+
+ return (): boolean => {
+ if (customCheck?.()) {
+ return true;
+ }
+
+ for (const selector of ignoredSelectors) {
+ if (document.activeElement?.closest(selector)) {
+ return true;
+ }
+ }
+
+ return false;
+ };
+};
export function TablePeekView<TData>({
itemType,
selectedRowId,
onOpenChange,
onExpand,
- render,
- urlPathname,
+ getNavigationPath,
+ children,
+ listKey,
+ peekEventOptions,
+ row,
}: DataTablePeekViewProps<TData>) {
- const pageUrl = mapItemTypeToPageUrl[itemType];
+ const eventHandler = createPeekEventHandler(peekEventOptions);
+
+ if (!selectedRowId) return null;
+
+ const handleOpenChange = (open: boolean) => {
+ if (!open && eventHandler()) {
+ return;
+ }
+ onOpenChange(open, selectedRowId);
+ };
+
+ const canExpand = typeof onExpand === "function";
return (
- <Sheet
- open={!!selectedRowId}
- onOpenChange={(open) => {
- // Ignore close events from checkbox or bookmark star toggle clicks to ensure integrity of table row actions
- if (
- !open &&
- (document.activeElement?.closest('[role="checkbox"]') ||
- document.activeElement?.closest('[aria-label="bookmark"]'))
- ) {
- return;
- }
- onOpenChange(open);
- }}
- modal={false}
- >
+ <Sheet open={!!selectedRowId} onOpenChange={handleOpenChange} modal={false}>
<SheetContent
onPointerDownOutside={(e) => {
// Prevent the default behavior of closing when clicking outside when we set modal={false}
@@ -69,62 +124,47 @@ export function TablePeekView<TData>({
{selectedRowId}
</span>
</SheetTitle>
- <div className="!mt-0 flex flex-row items-center gap-2">
- {selectedRowId && (
+ <div
+ className={cn(
+ "!mt-0 flex flex-row items-center gap-2",
+ !canExpand && "mr-8",
+ )}
+ >
+ {selectedRowId && listKey && getNavigationPath && (
<DetailPageNav
currentId={selectedRowId}
- path={(entry) => {
- const url = new URL(window.location.href);
-
- // Update the path part
- url.pathname = urlPathname;
-
- // Keep all existing query params
- const params = new URLSearchParams(url.search);
-
- // Update timestamp if it exists in entry.params
- if (entry.params) {
- if (entry.params.timestamp)
- params.set(
- "timestamp",
- encodeURIComponent(entry.params.timestamp),
- );
- params.delete("observation");
- }
-
- // Update peek param to the new id
- params.set("peek", entry.id);
-
- // Set the search part of the URL
- return `${url.pathname}?${params.toString()}`;
- }}
- listKey={pageUrl}
+ path={getNavigationPath}
+ listKey={listKey}
/>
)}
- <div className="!mt-0 mr-8 flex h-full flex-row items-center gap-1 border-l">
- <Button
- variant="ghost"
- size="icon-xs"
- title="Open in current tab"
- className="ml-2"
- onClick={() => onExpand(false)}
- >
- <Expand className="h-4 w-4" />
- </Button>
- <Button
- variant="ghost"
- size="icon-xs"
- title="Open in new tab"
- onClick={() => onExpand(true)}
- >
- <ExternalLink className="h-4 w-4" />
- </Button>
- </div>
+ {canExpand && (
+ <div className="!mt-0 mr-8 flex h-full flex-row items-center gap-1 border-l">
+ <Button
+ variant="ghost"
+ size="icon-xs"
+ title="Open in current tab"
+ className="ml-2"
+ onClick={() => onExpand(false)}
+ >
+ <Expand className="h-4 w-4" />
+ </Button>
+ <Button
+ variant="ghost"
+ size="icon-xs"
+ title="Open in new tab"
+ onClick={() => onExpand(true)}
+ >
+ <ExternalLink className="h-4 w-4" />
+ </Button>
+ </div>
+ )}
</div>
</SheetHeader>
<Separator />
<div className="flex max-h-full min-h-0 flex-1 flex-col">
- <div className="flex-1 overflow-auto">{render()}</div>
+ <div className="flex-1 overflow-auto">
+ {typeof children === "function" ? children(row) : children}
+ </div>
</div>
</SheetContent>
</Sheet>
diff --git a/web/src/components/table/peek/hooks/useDatasetComparePeekState.ts b/web/src/components/table/peek/hooks/useDatasetComparePeekState.ts
new file mode 100644
index 0000000000..3c2ff9809b
--- /dev/null
+++ b/web/src/components/table/peek/hooks/useDatasetComparePeekState.ts
@@ -0,0 +1,47 @@
+import { useRouter } from "next/router";
+import { useCallback, useState } from "react";
+
+export const useDatasetComparePeekState = (pathname: string) => {
+ const router = useRouter();
+ const { peek: datasetItem } = router.query;
+
+ const [selectedRunItemProps, setSelectedRunItemProps] = useState<{
+ runId: string;
+ traceId: string;
+ observationId?: string;
+ } | null>(null);
+
+ const setPeekView = useCallback(
+ (open: boolean, itemId?: string) => {
+ const url = new URL(window.location.href);
+ const params = new URLSearchParams(url.search);
+
+ if (!open || !itemId) {
+ // close peek view
+ params.delete("peek");
+ } else if (open && itemId !== datasetItem) {
+ // open peek view or update peek view
+ params.set("peek", itemId);
+ } else {
+ return;
+ }
+
+ router.replace(
+ {
+ pathname,
+ query: params.toString(),
+ },
+ undefined,
+ { shallow: true },
+ );
+ },
+ [router, datasetItem, pathname],
+ );
+
+ return {
+ datasetItemId: datasetItem as string | undefined,
+ selectedRunItemProps,
+ setSelectedRunItemProps,
+ setPeekView,
+ };
+};
diff --git a/web/src/components/table/peek/hooks/usePeekData.ts b/web/src/components/table/peek/hooks/usePeekData.ts
new file mode 100644
index 0000000000..7c6336c007
--- /dev/null
+++ b/web/src/components/table/peek/hooks/usePeekData.ts
@@ -0,0 +1,28 @@
+import { api } from "@/src/utils/api";
+
+type UsePeekDataProps = {
+ projectId: string;
+ traceId?: string;
+ timestamp?: Date;
+};
+
+export const usePeekData = ({
+ projectId,
+ traceId,
+ timestamp,
+}: UsePeekDataProps) => {
+ return api.traces.byIdWithObservationsAndScores.useQuery(
+ {
+ traceId: traceId as string,
+ projectId,
+ timestamp,
+ },
+ {
+ enabled: !!traceId,
+ retry(failureCount, error) {
+ if (error.data?.code === "UNAUTHORIZED") return false;
+ return failureCount < 3;
+ },
+ },
+ );
+};
diff --git a/web/src/components/table/peek/hooks/usePeekView.ts b/web/src/components/table/peek/hooks/usePeekView.ts
new file mode 100644
index 0000000000..203c55f833
--- /dev/null
+++ b/web/src/components/table/peek/hooks/usePeekView.ts
@@ -0,0 +1,128 @@
+import { type DataTablePeekViewProps } from "@/src/components/table/peek";
+import { useRouter } from "next/router";
+import { useEffect, useRef, useState } from "react";
+
+export type PeekViewProps<TData> = Omit<
+ DataTablePeekViewProps<TData>,
+ "selectedRowId" | "row"
+>;
+
+function getInitialRow<TData>(
+ peekViewId: string | undefined,
+ getRow: (id: string) => TData | undefined,
+): TData | undefined {
+ if (!peekViewId) return undefined;
+ try {
+ const row = getRow(peekViewId);
+ return row ? row : undefined;
+ } catch (error) {
+ return undefined;
+ }
+}
+
+type UsePeekViewProps<TData> = {
+ getRow: (id: string) => TData | undefined;
+ peekView?: PeekViewProps<TData>;
+ shouldUpdateRowOnDetailPageNavigation?: boolean;
+};
+
+/**
+ * A hook that manages the peek view state for a data table.
+ *
+ * @param getRow - The React Table's getRow function
+ * @param peekView - Optional configuration for the peek view
+ * @param shouldUpdateRowOnDetailPageNavigation - Whether to update the row when the peekViewId changes on detail page navigation. If you do not require the row data to be updated, set this to false. Be mindful of this setting as it adds one extra re-render to the table when the detail page is navigated to.
+ *
+ * @returns An object containing:
+ * - handleOnRowClickPeek: Function to handle row clicks for peek view
+ * - inflatedPeekView: The peek view props with the selected row data
+ * - peekViewId: The ID of the currently selected row for peek view
+ *
+ * The peek view allows users to preview details of a row without navigating away from the table.
+ * It manages the URL state via query parameters and handles row selection/deselection.
+ */
+
+export const usePeekView = <TData extends object>({
+ getRow,
+ peekView,
+ shouldUpdateRowOnDetailPageNavigation = false,
+}: UsePeekViewProps<TData>) => {
+ const router = useRouter();
+
+ const peekViewId = router.query.peek as string | undefined;
+ const [row, setRow] = useState<TData | undefined>(
+ getInitialRow(peekViewId, getRow),
+ );
+
+ // Populate the row after the table is mounted
+ const attemptRef = useRef(false);
+
+ // Try to find the row with delayed attempts
+ useEffect(() => {
+ if (peekView && peekViewId && !row && !attemptRef.current) {
+ attemptRef.current = true;
+ let foundOnce = false;
+ let intervalId = setInterval(() => {
+ const foundRow = getInitialRow(peekViewId, getRow);
+ if (foundRow) {
+ setRow(foundRow);
+ if (foundOnce) clearInterval(intervalId);
+ foundOnce = true;
+ }
+ }, 500);
+ }
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, []);
+
+ const inflatedPeekView = peekView
+ ? { ...peekView, selectedRowId: peekViewId, row }
+ : undefined;
+
+ // Update the row state when the user clicks on a row
+ const handleOnRowClickPeek = (row: TData) => {
+ if (inflatedPeekView) {
+ const rowId =
+ "id" in row && typeof row.id === "string" ? row.id : undefined;
+ // If clicking the same row that's already open, close it
+ if (rowId === inflatedPeekView.selectedRowId) {
+ inflatedPeekView.onOpenChange(false);
+ setRow(undefined);
+ }
+ // If clicking a different row update the row data and URL
+ else {
+ const timestamp =
+ "timestamp" in row ? (row.timestamp as Date) : undefined;
+ inflatedPeekView.onOpenChange(true, rowId, timestamp?.toISOString());
+ setRow(row);
+ }
+ }
+ };
+
+ // Update the row state when the peekViewId changes on detail page navigation
+ useEffect(() => {
+ if (!shouldUpdateRowOnDetailPageNavigation || !peekView) return;
+
+ const rowId =
+ row && "id" in row && typeof row.id === "string" ? row.id : undefined;
+
+ if (peekViewId !== rowId) {
+ if (peekViewId && inflatedPeekView) {
+ try {
+ const row = getRow(peekViewId);
+ if (row) {
+ setRow(row);
+ }
+ } catch (error) {
+ console.log("Row not found in table:", error);
+ }
+ }
+ }
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [peekViewId]);
+
+ return {
+ handleOnRowClickPeek: peekView ? handleOnRowClickPeek : undefined,
+ inflatedPeekView,
+ peekViewId,
+ };
+};
diff --git a/web/src/components/table/peek/hooks/useTracePeekNavigation.ts b/web/src/components/table/peek/hooks/useTracePeekNavigation.ts
new file mode 100644
index 0000000000..e0fcd928c0
--- /dev/null
+++ b/web/src/components/table/peek/hooks/useTracePeekNavigation.ts
@@ -0,0 +1,47 @@
+import { type ListEntry } from "@/src/features/navigate-detail-pages/context";
+import { useRouter } from "next/router";
+
+export const useTracePeekNavigation = (urlPathname: string) => {
+ const router = useRouter();
+ const { projectId, peek } = router.query;
+
+ const getNavigationPath = (entry: ListEntry) => {
+ const url = new URL(window.location.href);
+
+ // Update the path part
+ url.pathname = urlPathname;
+
+ // Keep all existing query params
+ const params = new URLSearchParams(url.search);
+
+ // Update timestamp if it exists in entry.params
+ if (entry.params) {
+ if (entry.params.timestamp)
+ params.set("timestamp", encodeURIComponent(entry.params.timestamp));
+ params.delete("observation");
+ }
+
+ // Update peek param to the new id
+ params.set("peek", entry.id);
+
+ // Set the search part of the URL
+ return `${url.pathname}?${params.toString()}`;
+ };
+
+ const expandPeek = (openInNewTab: boolean) => {
+ const url = new URL(window.location.href);
+ const params = new URLSearchParams(url.search);
+ const timestamp = params.get("timestamp");
+ const display = params.get("display") ?? "details";
+
+ const pathname = `/project/${projectId}/traces/${encodeURIComponent(peek as string)}?timestamp=${timestamp}&display=${display}`;
+
+ if (openInNewTab) {
+ window.open(pathname, "_blank");
+ } else {
+ router.push(pathname);
+ }
+ };
+
+ return { getNavigationPath, expandPeek };
+};
diff --git a/web/src/components/table/peek/hooks/useTracePeekState.ts b/web/src/components/table/peek/hooks/useTracePeekState.ts
new file mode 100644
index 0000000000..fea3ba32bf
--- /dev/null
+++ b/web/src/components/table/peek/hooks/useTracePeekState.ts
@@ -0,0 +1,46 @@
+import { useRouter } from "next/router";
+import { useCallback } from "react";
+
+export const useTracePeekState = (pathname: string) => {
+ const router = useRouter();
+ const { peek, timestamp } = router.query;
+
+ const setPeekView = useCallback(
+ (open: boolean, id?: string, time?: string) => {
+ const url = new URL(window.location.href);
+ const params = new URLSearchParams(url.search);
+
+ if (!open || !id) {
+ // close peek view
+ params.delete("peek");
+ params.delete("timestamp");
+ params.delete("observation");
+ params.delete("display");
+ } else if (open && id !== peek) {
+ // open peek view or update peek view
+ params.set("peek", id);
+ const relevantTimestamp = time ?? (timestamp as string);
+ if (relevantTimestamp) params.set("timestamp", relevantTimestamp);
+ params.delete("observation");
+ } else {
+ return;
+ }
+
+ router.replace(
+ {
+ pathname,
+ query: params.toString(),
+ },
+ undefined,
+ { shallow: true },
+ );
+ },
+ [router, pathname, peek, timestamp],
+ );
+
+ return {
+ peekId: peek as string | undefined,
+ timestamp: timestamp ? new Date(timestamp as string) : undefined,
+ setPeekView,
+ };
+};
diff --git a/web/src/components/table/peek/peek-dataset-compare-detail.tsx b/web/src/components/table/peek/peek-dataset-compare-detail.tsx
new file mode 100644
index 0000000000..47d201acb1
--- /dev/null
+++ b/web/src/components/table/peek/peek-dataset-compare-detail.tsx
@@ -0,0 +1,238 @@
+import { useDatasetComparePeekState } from "@/src/components/table/peek/hooks/useDatasetComparePeekState";
+import {
+ ResizablePanelGroup,
+ ResizablePanel,
+ ResizableHandle,
+} from "@/src/components/ui/resizable";
+import { IOPreview } from "@/src/components/trace/IOPreview";
+import { ObservationTree } from "@/src/components/trace/ObservationTree";
+import { Skeleton } from "@/src/components/ui/skeleton";
+import { type RouterOutputs } from "@/src/utils/api";
+import { DatasetAggregateTableCell } from "@/src/features/datasets/components/DatasetAggregateTableCell";
+import { Button } from "@/src/components/ui/button";
+import { PanelLeftOpen, PanelLeftClose, ListTree } from "lucide-react";
+import { cn } from "@/src/utils/tailwind";
+import { Command } from "@/src/components/ui/command";
+import DocPopup from "@/src/components/layouts/doc-popup";
+import type {
+ DatasetCompareRunRowData,
+ DatasetRunMetric,
+} from "@/src/features/datasets/components/DatasetCompareRunsTable";
+import { useRouter } from "next/router";
+import { usePeekData } from "@/src/components/table/peek/hooks/usePeekData";
+
+export type PeekDatasetCompareDetailProps = {
+ projectId: string;
+ datasetId: string;
+ runsData: RouterOutputs["datasets"]["baseRunDataByDatasetId"];
+ scoreKeyToDisplayName: Map<string, string>;
+ selectedMetrics?: DatasetRunMetric[];
+ row?: DatasetCompareRunRowData;
+};
+
+export const PeekDatasetCompareDetail = ({
+ projectId,
+ datasetId,
+ runsData,
+ scoreKeyToDisplayName,
+ selectedMetrics = ["scores", "resourceMetrics"],
+ row,
+}: PeekDatasetCompareDetailProps) => {
+ const router = useRouter();
+
+ const timestamp =
+ router.query.timestamp && typeof router.query.timestamp === "string"
+ ? new Date(decodeURIComponent(router.query.timestamp))
+ : undefined;
+
+ const { datasetItemId, selectedRunItemProps, setSelectedRunItemProps } =
+ useDatasetComparePeekState(
+ `/project/${projectId}/datasets/${datasetId}/compare`,
+ );
+ const { runId, traceId } = selectedRunItemProps ?? {};
+
+ const trace = usePeekData({
+ projectId,
+ traceId: traceId,
+ timestamp,
+ });
+
+ const handleToggleTrace = (
+ newTraceId?: string,
+ newRunId?: string,
+ newObservationId?: string,
+ ) => {
+ if (!newTraceId || !newRunId) return;
+
+ if (newTraceId === traceId) {
+ setSelectedRunItemProps(null);
+ } else {
+ setSelectedRunItemProps({
+ runId: newRunId,
+ traceId: newTraceId,
+ observationId: newObservationId,
+ });
+ }
+ };
+
+ const handleSetCurrentObservationId = (id?: string) => {
+ if (id && traceId)
+ window.open(
+ `/project/${projectId}/traces/${encodeURIComponent(traceId)}?observation=${encodeURIComponent(id)}`,
+ "_blank",
+ "noopener noreferrer",
+ );
+ };
+
+ if (!row) return <Skeleton className="min-h-full w-full" />;
+
+ return (
+ <div
+ className={cn(
+ "grid md:h-full",
+ traceId ? "grid-cols-[1fr,3fr]" : "grid-cols-1",
+ )}
+ >
+ {traceId && (
+ <div className="h-full overflow-y-auto border-r p-2">
+ {trace.data ? (
+ <Command>
+ <h3 className="mb-3 font-semibold">{`Run: ${
+ runsData?.find((r: any) => r.id === runId)?.name
+ }`}</h3>
+ <ObservationTree
+ observations={trace.data?.observations ?? []}
+ collapsedObservations={[]}
+ toggleCollapsedObservation={() => {}}
+ collapseAll={() => {}}
+ expandAll={() => {}}
+ trace={trace.data}
+ scores={trace.data.scores ?? []}
+ currentObservationId={undefined}
+ setCurrentObservationId={handleSetCurrentObservationId}
+ showComments={false}
+ showMetrics={false}
+ showScores={true}
+ colorCodeMetrics={false}
+ className="flex w-full flex-col overflow-y-auto"
+ showExpandControls={false}
+ />
+ </Command>
+ ) : (
+ <Skeleton className="min-h-full w-full" />
+ )}
+ </div>
+ )}
+ <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 p-2 pl-3"
+ >
+ <div className="grid h-full grid-cols-2 gap-4">
+ <div className="min-h-0 overflow-hidden">
+ <h3 className="mb-1 font-semibold">Input</h3>
+ <div className="h-[calc(100%-1.75rem)] space-y-2 overflow-y-auto">
+ <IOPreview
+ key={datasetItemId + "-input"}
+ input={row?.input ?? null}
+ hideOutput
+ />
+ </div>
+ </div>
+ <div className="min-h-0 overflow-hidden">
+ <h3 className="mb-1 font-semibold">Expected output</h3>
+ <div className="h-[calc(100%-1.75rem)] space-y-2 overflow-y-auto">
+ <IOPreview
+ key={datasetItemId + "-output"}
+ output={row?.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 p-2 pl-3"
+ >
+ <h3 className="mb-1 font-semibold">Run outputs</h3>
+ {row?.runs && (
+ <div className="flex h-[calc(100%-2rem)] w-full gap-4 overflow-x-auto">
+ {Object.entries(row.runs).map(([id, run]) => {
+ const runData = runsData?.find((r: any) => 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={selectedMetrics}
+ output={row.expectedOutput}
+ isHighlighted={id === runId}
+ 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={
+ traceId === run.traceId
+ ? "Hide trace tree"
+ : "View trace tree"
+ }
+ onClick={() =>
+ handleToggleTrace(
+ run.traceId,
+ id,
+ run.observationId,
+ )
+ }
+ >
+ {traceId === run.traceId ? (
+ <PanelLeftClose className="h-4 w-4" />
+ ) : (
+ <PanelLeftOpen className="h-4 w-4" />
+ )}
+ </Button>
+ </div>
+ }
+ />
+ </div>
+ );
+ })}
+ </div>
+ )}
+ </ResizablePanel>
+ </ResizablePanelGroup>
+ </div>
+ </div>
+ );
+};
diff --git a/web/src/components/table/peek/peek-trace-detail.tsx b/web/src/components/table/peek/peek-trace-detail.tsx
new file mode 100644
index 0000000000..07852763c1
--- /dev/null
+++ b/web/src/components/table/peek/peek-trace-detail.tsx
@@ -0,0 +1,25 @@
+import { usePeekData } from "@/src/components/table/peek/hooks/usePeekData";
+import { useTracePeekState } from "@/src/components/table/peek/hooks/useTracePeekState";
+import { Trace } from "@/src/components/trace";
+import { Skeleton } from "@/src/components/ui/skeleton";
+
+export const PeekViewTraceDetail = ({ projectId }: { projectId: string }) => {
+ const { peekId, timestamp } = useTracePeekState("traces");
+ const trace = usePeekData({
+ projectId,
+ traceId: peekId,
+ timestamp,
+ });
+
+ return !peekId || !trace.data ? (
+ <Skeleton className="h-full w-full" />
+ ) : (
+ <Trace
+ key={trace.data.id}
+ trace={trace.data}
+ scores={trace.data.scores}
+ projectId={trace.data.projectId}
+ observations={trace.data.observations}
+ />
+ );
+};
diff --git a/web/src/components/table/use-cases/traces.tsx b/web/src/components/table/use-cases/traces.tsx
index b29869be27..6ae7107b0e 100644
--- a/web/src/components/table/use-cases/traces.tsx
+++ b/web/src/components/table/use-cases/traces.tsx
@@ -74,13 +74,14 @@ import {
DropdownMenuTrigger,
} from "@/src/components/ui/dropdown-menu";
import { Button } from "@/src/components/ui/button";
-import { Trace } from "@/src/components/trace";
-import router from "next/router";
import TableId from "@/src/components/table/table-id";
import {
useEnvironmentFilter,
convertSelectedEnvironmentsToFilter,
} from "@/src/hooks/use-environment-filter";
+import { PeekViewTraceDetail } from "@/src/components/table/peek/peek-trace-detail";
+import { useTracePeekNavigation } from "@/src/components/table/peek/hooks/useTracePeekNavigation";
+import { useTracePeekState } from "@/src/components/table/peek/hooks/useTracePeekState";
export type TracesTableRow = {
bookmarked: boolean;
@@ -133,17 +134,12 @@ export default function TracesTable({
omittedFilter = [],
}: TracesTableProps) {
const utils = api.useUtils();
- const [peekViewId] = useQueryParam("peek", withDefault(StringParam, null));
const [selectedRows, setSelectedRows] = useState<RowSelectionState>({});
const { setDetailPageList } = useDetailPageLists();
const [searchQuery, setSearchQuery] = useQueryParam(
"search",
withDefault(StringParam, null),
);
- const [selectedTab, setSelectedTab] = useQueryParam(
- "display",
- withDefault(StringParam, "details"),
- );
const { selectedOption, dateRange, setDateRangeAndOption } =
useTableDateRange(projectId);
const [userFilterState, setUserFilterState] = useQueryFilterState(
@@ -916,6 +912,13 @@ export default function TracesTable({
columns,
);
+ const urlPathname = userId
+ ? `/project/${projectId}/users/${userId}`
+ : `/project/${projectId}/traces`;
+
+ const { getNavigationPath, expandPeek } = useTracePeekNavigation(urlPathname);
+ const { setPeekView } = useTracePeekState(urlPathname);
+
const rows = useMemo(() => {
return traces.isSuccess
? (traceRowData?.rows?.map((trace) => {
@@ -1047,97 +1050,15 @@ export default function TracesTable({
pinFirstColumn
peekView={{
itemType: "TRACE",
- urlPathname: userId
- ? `/project/${projectId}/users/${userId}`
- : `/project/${projectId}/traces`,
- onOpenChange: (open: boolean, row?: TracesTableRow) => {
- const url = new URL(window.location.href);
- const params = new URLSearchParams(url.search);
-
- if (!open || !row) {
- // Remove peek and timestamp params while keeping others
- params.delete("peek");
- params.delete("timestamp");
- params.delete("observation");
- params.delete("display");
- } else if (open && row.id && peekViewId !== row.id) {
- // Update or add peek and timestamp params
- params.set("peek", row.id);
- params.set("timestamp", row.timestamp.toISOString());
- params.delete("observation");
- } else {
- return;
- }
-
- router.replace(
- {
- pathname: userId
- ? `/project/${projectId}/users/${userId}`
- : `/project/${projectId}/traces`,
- query: params.toString(),
- },
- undefined,
- { shallow: true },
- );
- },
- onExpand: (openInNewTab: boolean) => {
- if (peekViewId) {
- const url = new URL(window.location.href);
- const params = new URLSearchParams(url.search);
- const timestamp = params.get("timestamp");
- const display = params.get("display") ?? "details";
-
- if (openInNewTab) {
- window.open(
- `/project/${projectId}/traces/${encodeURIComponent(peekViewId)}?timestamp=${timestamp}&display=${display}`,
- "_blank",
- );
- } else {
- router.replace(
- `/project/${projectId}/traces/${encodeURIComponent(peekViewId)}?timestamp=${timestamp}&display=${display}`,
- );
- }
- }
- },
- render: () => {
- const { peek, timestamp } = router.query;
-
- const trace = api.traces.byIdWithObservationsAndScores.useQuery(
- {
- traceId: peek as string,
- timestamp:
- typeof timestamp === "string"
- ? new Date(timestamp)
- : undefined,
- projectId,
- },
- {
- enabled: !!peek && !!timestamp,
- retry(failureCount, error) {
- if (
- error.data?.code === "UNAUTHORIZED" ||
- error.data?.code === "NOT_FOUND"
- )
- return false;
- return failureCount < 3;
- },
- },
- );
-
- return !trace.data ? (
- <Skeleton className="h-full w-full" />
- ) : (
- <Trace
- key={trace.data.id}
- trace={trace.data}
- scores={trace.data.scores}
- projectId={trace.data.projectId}
- observations={trace.data.observations}
- selectedTab={selectedTab}
- setSelectedTab={setSelectedTab}
- />
- );
+ listKey: "traces",
+ urlPathname,
+ peekEventOptions: {
+ ignoredSelectors: ['[role="checkbox"]', '[aria-label="bookmark"]'],
},
+ onOpenChange: setPeekView,
+ onExpand: expandPeek,
+ getNavigationPath,
+ children: <PeekViewTraceDetail projectId={projectId} />,
}}
/>
</>
diff --git a/web/src/components/ui/side-panel.tsx b/web/src/components/ui/side-panel.tsx
index c42910f78a..f8692ae27d 100644
--- a/web/src/components/ui/side-panel.tsx
+++ b/web/src/components/ui/side-panel.tsx
@@ -26,11 +26,13 @@ const SidePanel = ({
children,
className,
mobileTitle,
+ scrollable = true,
}: {
id: string;
children: ReactNode;
className?: string;
mobileTitle?: string;
+ scrollable?: boolean;
}) => {
const [showPanel, setShowPanel] = useSessionStorage<boolean>(
`${id}-showPanel`,
@@ -84,6 +86,7 @@ const SidePanel = ({
className={cn(
"flex h-full w-full flex-col gap-2",
showPanel ? "p-2" : "p-1 pr-2 pt-2",
+ scrollable ? "overflow-y-auto" : "overflow-hidden",
)}
>
{children}
diff --git a/web/src/features/dashboard/lib/score-analytics-utils.ts b/web/src/features/dashboard/lib/score-analytics-utils.ts
index 045e1e2762..2740f3088b 100644
--- a/web/src/features/dashboard/lib/score-analytics-utils.ts
+++ b/web/src/features/dashboard/lib/score-analytics-utils.ts
@@ -13,12 +13,14 @@ export const RESOURCE_METRICS = [
value: "Latency",
objectKey: "avgLatency",
label: "Latency (s)",
+ maxFractionDigits: 2,
},
{
key: "cost",
value: "Cost",
objectKey: "avgTotalCost",
label: "Average Total Cost ($)",
+ maxFractionDigits: 5,
},
];
diff --git a/web/src/features/datasets/components/DatasetAggregateTableCell.tsx b/web/src/features/datasets/components/DatasetAggregateTableCell.tsx
index abba856651..66846816d3 100644
--- a/web/src/features/datasets/components/DatasetAggregateTableCell.tsx
+++ b/web/src/features/datasets/components/DatasetAggregateTableCell.tsx
@@ -1,7 +1,16 @@
+import DiffViewer from "@/src/components/DiffViewer";
import { ScoresTableCell } from "@/src/components/scores-table-cell";
-import TableLink from "@/src/components/table/table-link";
import { Badge } from "@/src/components/ui/badge";
+import { Button } from "@/src/components/ui/button";
import { IOTableCell } from "@/src/components/ui/CodeJsonViewer";
+import {
+ Dialog,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+} from "@/src/components/ui/dialog";
+import { DialogTrigger } from "@/src/components/ui/dialog";
+import { DialogContent } from "@/src/components/ui/dialog";
import {
type DatasetRunMetric,
type RunMetrics,
@@ -9,8 +18,15 @@ import {
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";
+import { type Prisma } from "@langfuse/shared";
+import {
+ ChartNoAxesCombined,
+ ClockIcon,
+ FileDiffIcon,
+ GaugeCircle,
+ ListCheck,
+} from "lucide-react";
+import { useState, type ReactNode } from "react";
const DatasetAggregateCell = ({
scores,
@@ -20,19 +36,18 @@ const DatasetAggregateCell = ({
observationId,
scoreKeyToDisplayName,
selectedMetrics,
- singleLine = true,
- className,
- variant = "table",
actionButtons,
+ output,
+ isHighlighted = false,
}: RunMetrics & {
projectId: string;
scoreKeyToDisplayName: Map<string, string>;
selectedMetrics: DatasetRunMetric[];
- singleLine?: boolean;
- className?: string;
- variant?: "table" | "peek";
actionButtons?: ReactNode;
+ output?: Prisma.JsonValue;
+ isHighlighted?: boolean;
}) => {
+ const [isOpen, setIsOpen] = useState(false);
// conditionally fetch the trace or observation depending on the presence of observationId
const trace = api.traces.byId.useQuery(
{ traceId, projectId },
@@ -72,83 +87,148 @@ const DatasetAggregateCell = ({
);
const data = observationId === undefined ? trace.data : observation.data;
+ const scoresEntries = Object.entries(scores);
return (
<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,
+ "group relative flex h-full w-full flex-col overflow-y-auto overflow-x-hidden rounded-md",
+ isHighlighted ? "border-4" : "border",
)}
>
- {variant === "peek" && actionButtons}
- <div className="flex flex-row items-center justify-center gap-1">
- <IOTableCell
- isLoading={
- (!!!observationId ? trace.isLoading : observation.isLoading) ||
- !data
- }
- data={data?.output ?? "null"}
- className={"bg-accent-light-green"}
- singleLine={singleLine}
- />
- </div>
-
+ {actionButtons}
{selectedMetrics.includes("scores") && (
- <div className="flex w-full flex-wrap gap-1">
- {Object.entries(scores).map(([key, score]) => (
- <Badge
- variant="outline"
- className="flex-wrap p-0.5 px-1 font-normal"
- key={key}
- >
- <span className="whitespace-nowrap capitalize">
- {scoreKeyToDisplayName.get(key)}:
- </span>
- <span className="ml-[2px]">
- <ScoresTableCell aggregate={score} />
- </span>
- </Badge>
- ))}
+ <div className="flex flex-shrink-0">
+ <div className="w-fit min-w-0 border-r px-1">
+ <ChartNoAxesCombined className="mt-2 h-4 w-4 text-muted-foreground" />
+ </div>
+ <div className="mt-1 w-full min-w-0 p-1">
+ <div className="flex w-full flex-wrap gap-1 overflow-hidden">
+ {scoresEntries.length > 0 ? (
+ scoresEntries.map(([key, score]) => (
+ <Badge
+ variant="tertiary"
+ className="flex-wrap p-0.5 px-1 font-normal"
+ key={key}
+ >
+ <span className="whitespace-nowrap capitalize">
+ {scoreKeyToDisplayName.get(key)}:
+ </span>
+ <span className="ml-[2px]">
+ <ScoresTableCell
+ aggregate={score}
+ showSingleValue
+ wrap={false}
+ />
+ </span>
+ </Badge>
+ ))
+ ) : (
+ <span className="text-xs text-muted-foreground">No scores</span>
+ )}
+ </div>
+ </div>
</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>
- )}
+ {selectedMetrics.includes("resourceMetrics") && (
+ <div className="flex flex-shrink-0">
+ <div className="w-fit min-w-0 border-r px-1">
+ <GaugeCircle className="mt-1 h-4 w-4 text-muted-foreground" />
</div>
- )}
+ <div className="w-full min-w-0 p-1">
+ <div className="flex w-full flex-row flex-wrap gap-1">
+ {!!resourceMetrics.latency && (
+ <Badge variant="tertiary" 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="tertiary" className="p-0.5 px-1 font-normal">
+ <span className="mr-0.5">{resourceMetrics.totalCost}</span>
+ </Badge>
+ )}
+ </div>
+ </div>
+ </div>
+ )}
+ <div className="flex min-h-0 flex-grow">
+ <div className="w-fit min-w-0 border-r px-1">
+ <ListCheck className="mt-1 h-4 w-4 text-muted-foreground" />
+ </div>
+ <div className="relative w-full min-w-0 overflow-auto p-1">
+ <IOTableCell
+ isLoading={
+ (!!!observationId ? trace.isLoading : observation.isLoading) ||
+ !data
+ }
+ data={data?.output ?? "null"}
+ className={"bg-accent-light-green"}
+ singleLine={false}
+ />
+ {output && data?.output && (
+ <Dialog
+ open={isOpen}
+ onOpenChange={(open) => {
+ setIsOpen(open);
+ }}
+ >
+ <DialogTrigger asChild>
+ <Button
+ variant="ghost"
+ size="icon-xs"
+ title="Compare expected output with actual output"
+ className="absolute right-2 top-2 rounded bg-background p-1 opacity-0 transition-opacity hover:bg-secondary group-hover:opacity-100"
+ aria-label="Action button"
+ >
+ <FileDiffIcon className="h-4 w-4" />
+ </Button>
+ </DialogTrigger>
- <div className="flex-grow" />
+ <DialogContent
+ className="max-w-screen-xl"
+ onClick={(event) => event.stopPropagation()}
+ >
+ <DialogHeader>
+ <DialogTitle>Expected Output → Actual Output</DialogTitle>
+ </DialogHeader>
- {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 className="max-h-[80vh] max-w-screen-xl space-y-6 overflow-y-auto">
+ <div className="space-y-6">
+ <div className="space-y-4">
+ <div>
+ <DiffViewer
+ oldString={JSON.stringify(output, null, 2)}
+ newString={JSON.stringify(
+ data?.output ?? "null",
+ null,
+ 2,
+ )}
+ oldLabel="Expected Output"
+ newLabel="Actual Output"
+ />
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <DialogFooter className="flex flex-row">
+ <Button
+ onClick={() => {
+ setIsOpen(false);
+ }}
+ className="w-full"
+ >
+ Close
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ )}
+ </div>
+ </div>
</div>
);
};
@@ -158,19 +238,17 @@ export const DatasetAggregateTableCell = ({
projectId,
scoreKeyToDisplayName,
selectedMetrics,
- singleLine = true,
- className,
- variant = "table",
actionButtons,
+ output,
+ isHighlighted = false,
}: {
value: RunMetrics;
projectId: string;
scoreKeyToDisplayName: Map<string, string>;
selectedMetrics: DatasetRunMetric[];
- singleLine?: boolean;
- className?: string;
- variant?: "table" | "peek";
actionButtons?: ReactNode;
+ output?: Prisma.JsonValue;
+ isHighlighted?: boolean;
}) => {
return value ? (
<DatasetAggregateCell
@@ -178,10 +256,9 @@ export const DatasetAggregateTableCell = ({
{...value}
scoreKeyToDisplayName={scoreKeyToDisplayName}
selectedMetrics={selectedMetrics}
- singleLine={singleLine}
- className={className}
- variant={variant}
actionButtons={actionButtons}
+ output={output}
+ isHighlighted={isHighlighted}
/>
) : null;
};
diff --git a/web/src/features/datasets/components/DatasetAnalytics.tsx b/web/src/features/datasets/components/DatasetAnalytics.tsx
index 36c830deb7..baeddae07a 100644
--- a/web/src/features/datasets/components/DatasetAnalytics.tsx
+++ b/web/src/features/datasets/components/DatasetAnalytics.tsx
@@ -1,7 +1,8 @@
+import { DropdownMenuItem } from "@/src/components/ui/dropdown-menu";
import { RESOURCE_METRICS } from "@/src/features/dashboard/lib/score-analytics-utils";
import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";
import { MultiSelectKeyValues } from "@/src/features/scores/components/multi-select-key-values";
-import { ChartColumnBig } from "lucide-react";
+import { ChartLine } from "lucide-react";
export function DatasetAnalytics(props: {
projectId: string;
@@ -12,11 +13,11 @@ export function DatasetAnalytics(props: {
const capture = usePostHogClientCapture();
return (
<MultiSelectKeyValues
- className="max-w-fit"
+ className="max-w-full focus:!ring-0 focus:!ring-offset-0"
placeholder="Search..."
- title="Charts"
- variant="outline"
- iconLeft={<ChartColumnBig className="mr-1 h-4 w-4" />}
+ title="Selected"
+ variant="ghost"
+ iconLeft={<ChartLine className="mr-1 h-4 w-4" />}
hideClearButton
onValueChange={(values, changedValue, selectedKeys) => {
if (values.length === 0) props.setSelectedMetrics([]);
@@ -36,6 +37,15 @@ export function DatasetAnalytics(props: {
values={props.selectedMetrics}
options={RESOURCE_METRICS}
groupedOptions={[{ label: "Scores", options: props.scoreOptions }]}
+ controlButtons={
+ <DropdownMenuItem
+ onSelect={() => {
+ props.setSelectedMetrics([]);
+ }}
+ >
+ Hide all charts
+ </DropdownMenuItem>
+ }
/>
);
}
diff --git a/web/src/features/datasets/components/DatasetCompareRunPeekView.tsx b/web/src/features/datasets/components/DatasetCompareRunPeekView.tsx
deleted file mode 100644
index a1871a2631..0000000000
--- a/web/src/features/datasets/components/DatasetCompareRunPeekView.tsx
+++ /dev/null
@@ -1,246 +0,0 @@
-import DocPopup from "@/src/components/layouts/doc-popup";
-import PeekView from "@/src/components/layouts/peek-view";
-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 {
- 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, ListTree } from "lucide-react";
-import { useRouter } from "next/router";
-
-export function DatasetCompareRunPeekView({
- projectId,
- datasetId,
- scoreKeyToDisplayName,
- clickedRow,
- setClickedRow,
- traceAndObservationId,
- setTraceAndObservationId,
- runsData,
-}: {
- projectId: string;
- datasetId: 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,
- },
- {
- enabled: !!traceAndObservationId,
- retry(failureCount, error) {
- if (error.data?.code === "UNAUTHORIZED") return false;
- return failureCount < 3;
- },
- },
- );
-
- const onClose = () => {
- setClickedRow(null);
- setTraceAndObservationId(null);
- };
-
- return (
- <PeekView
- onClose={onClose}
- item={{
- name: clickedRow?.id ?? "item",
- type: "Dataset item",
- link: `/project/${projectId}/datasets/${datasetId}/items/${clickedRow?.id}`,
- }}
- open={!!clickedRow}
- actionButtons={
- <>
- {traceAndObservationId?.traceId && (
- <Button
- variant="outline"
- size="icon"
- onClick={() => setTraceAndObservationId(null)}
- >
- <PanelLeftClose className="h-4 w-4" />
- </Button>
- )}
- </>
- }
- >
- <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",
- );
- }}
- showComments={false}
- 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>
- </PeekView>
- );
-}
diff --git a/web/src/features/datasets/components/DatasetCompareRunsTable.tsx b/web/src/features/datasets/components/DatasetCompareRunsTable.tsx
index c5fb740378..a26a209b24 100644
--- a/web/src/features/datasets/components/DatasetCompareRunsTable.tsx
+++ b/web/src/features/datasets/components/DatasetCompareRunsTable.tsx
@@ -15,17 +15,19 @@ 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, Expand, Rows3 } from "lucide-react";
+import { Cog } from "lucide-react";
import {
DropdownMenu,
DropdownMenuCheckboxItem,
DropdownMenuContent,
DropdownMenuTrigger,
} from "@/src/components/ui/dropdown-menu";
-import { DatasetCompareRunPeekView } from "@/src/features/datasets/components/DatasetCompareRunPeekView";
import { getQueryKey } from "@trpc/react-query";
import { useQueryClient } from "@tanstack/react-query";
import _ from "lodash";
+import { useDatasetComparePeekState } from "@/src/components/table/peek/hooks/useDatasetComparePeekState";
+import { PeekDatasetCompareDetail } from "@/src/components/table/peek/peek-dataset-compare-detail";
+
export type RunMetrics = {
id: string;
scores: ScoreAggregate;
@@ -48,6 +50,41 @@ export type DatasetCompareRunRowData = {
runs?: RunAggregate;
};
+type QueryKeyType = ReturnType<typeof getQueryKey>;
+
+const formatQueryKey = (queryKey?: QueryKeyType): QueryKeyType => {
+ try {
+ return queryKey
+ ? [
+ queryKey[0],
+ {
+ input: queryKey[1]?.input,
+ type: queryKey[1]?.type ?? "query",
+ },
+ ]
+ : ([[]] as QueryKeyType);
+ } catch (error) {
+ return [[]] as QueryKeyType;
+ }
+};
+
+// Run items are added async for prompt experiment runs, so we must continue to refetch until all items are present
+// As evaluations are added async too, we must compare the scores for all run items to check if they're all complete
+const isDataComplete = (
+ prevData: RouterOutputs["datasets"]["runitemsByRunIdOrItemId"],
+ newData: RouterOutputs["datasets"]["runitemsByRunIdOrItemId"],
+) => {
+ if (prevData.totalRunItems !== newData.totalRunItems) return false;
+
+ // Compare scores for all run items to check if they're all complete
+ return prevData.runItems.every((prevItem, index) => {
+ const newItem = newData.runItems[index];
+ if (!newItem) return false;
+
+ return JSON.stringify(prevItem.scores) === JSON.stringify(newItem.scores);
+ });
+};
+
const getRefetchInterval = (
runId: string,
localExperiments: { key: string; value: string }[],
@@ -73,14 +110,6 @@ 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 [unchangedCounts, setUnchangedCounts] = useState<
Record<string, number>
>({});
@@ -126,10 +155,17 @@ export function DatasetCompareRunsTable(props: {
setUnchangedCounts((prev) => {
const prevCount = prev[runId] || 0;
const queryKey = runQueries.find((r) => r.runId === runId)?.queryKey;
- const prevData = queryClient.getQueryData(queryKey || []);
+ const formattedQueryKey = formatQueryKey(queryKey);
+ const prevData = queryClient.getQueryData(formattedQueryKey);
- // Only increment if we have previous data and it matches the new data
- if (prevData && JSON.stringify(prevData) === JSON.stringify(newData)) {
+ // Only increment if we there are no more items included in the new data that are not in the previous data
+ if (
+ prevData &&
+ isDataComplete(
+ prevData as RouterOutputs["datasets"]["runitemsByRunIdOrItemId"],
+ newData as RouterOutputs["datasets"]["runitemsByRunIdOrItemId"],
+ )
+ ) {
const newCount = prevCount + 1;
return { ...prev, [runId]: newCount };
}
@@ -273,18 +309,7 @@ export function DatasetCompareRunsTable(props: {
"input",
) as DatasetCompareRunRowData["input"];
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>
+ <div className="h-full w-full">
<IOTableCell data={input} />
</div>
) : null;
@@ -301,18 +326,7 @@ export function DatasetCompareRunsTable(props: {
"expectedOutput",
) as DatasetCompareRunRowData["expectedOutput"];
return expectedOutput !== 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>
+ <div className="h-full w-full">
<IOTableCell
data={expectedOutput}
className="bg-accent-light-green"
@@ -347,6 +361,10 @@ export function DatasetCompareRunsTable(props: {
columns,
);
+ const urlPathname = `/project/${props.projectId}/datasets/${props.datasetId}/compare`;
+
+ const { setPeekView } = useDatasetComparePeekState(urlPathname);
+
return (
<>
<DataTableToolbar
@@ -359,11 +377,10 @@ export function DatasetCompareRunsTable(props: {
<DropdownMenuTrigger asChild>
<Button
variant="outline"
+ size="icon"
onClick={() => setIsMetricsDropdownOpen(!isMetricsDropdownOpen)}
>
- <Rows3 className="mr-2 h-4 w-4" />
- <span className="text-xs text-muted-foreground">Metrics</span>
- <ChevronDown className="ml-2 h-4 w-4" />
+ <Cog className="h-4 w-4" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent
@@ -422,19 +439,22 @@ export function DatasetCompareRunsTable(props: {
state: paginationState,
}}
rowHeight={rowHeight}
+ peekView={{
+ itemType: "DATASET_ITEM",
+ urlPathname,
+ onOpenChange: setPeekView,
+ children: (row?: DatasetCompareRunRowData) => (
+ <PeekDatasetCompareDetail
+ projectId={props.projectId}
+ datasetId={props.datasetId}
+ scoreKeyToDisplayName={scoreKeyToDisplayName}
+ runsData={props.runsData ?? []}
+ selectedMetrics={selectedMetrics}
+ row={row}
+ />
+ ),
+ }}
/>
- {scoreKeysAndProps.isSuccess && (
- <DatasetCompareRunPeekView
- projectId={props.projectId}
- datasetId={props.datasetId}
- scoreKeyToDisplayName={scoreKeyToDisplayName}
- clickedRow={clickedRow}
- setClickedRow={setClickedRow}
- traceAndObservationId={traceAndObservationId}
- setTraceAndObservationId={setTraceAndObservationId}
- runsData={props.runsData ?? []}
- />
- )}
</>
);
}
diff --git a/web/src/features/datasets/components/DatasetRunAggregateColumnHelpers.tsx b/web/src/features/datasets/components/DatasetRunAggregateColumnHelpers.tsx
index 3318052e5f..de4b3ea91d 100644
--- a/web/src/features/datasets/components/DatasetRunAggregateColumnHelpers.tsx
+++ b/web/src/features/datasets/components/DatasetRunAggregateColumnHelpers.tsx
@@ -35,7 +35,7 @@ export const constructDatasetRunAggregateColumns = ({
id,
accessorKey: id,
header: name,
- size: 150,
+ size: 250,
...(description && {
headerTooltip: {
description,
diff --git a/web/src/features/datasets/components/DatasetRunsTable.tsx b/web/src/features/datasets/components/DatasetRunsTable.tsx
index 45b143ba66..7a951e5bdc 100644
--- a/web/src/features/datasets/components/DatasetRunsTable.tsx
+++ b/web/src/features/datasets/components/DatasetRunsTable.tsx
@@ -41,7 +41,6 @@ import {
transformAggregatedRunMetricsToChartData,
} from "@/src/features/dashboard/lib/score-analytics-utils";
import { TimeseriesChart } from "@/src/features/scores/components/TimeseriesChart";
-import { Card, CardContent } from "@/src/components/ui/card";
import { CompareViewAdapter } from "@/src/features/scores/adapters";
import { isNumericDataType } from "@/src/features/scores/lib/helpers";
import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";
@@ -53,6 +52,12 @@ import {
DialogHeader,
DialogTitle,
} from "@/src/components/ui/dialog";
+import {
+ ResizablePanelGroup,
+ ResizablePanel,
+ ResizableHandle,
+} from "@/src/components/ui/resizable";
+import useSessionStorage from "@/src/components/useSessionStorage";
export type DatasetRunRowData = {
id: string;
@@ -100,8 +105,9 @@ const DatasetRunTableMultiSelectAction = ({
<ChevronDown className="h-5 w-5" />
</Button>
</DropdownMenuTrigger>
- <DropdownMenuContent>
+ <DropdownMenuContent key="dropdown-menu-content">
<Link
+ key="compare"
href={
selectedRunIds.length < 2
? "#"
@@ -116,7 +122,10 @@ const DatasetRunTableMultiSelectAction = ({
<span>Compare</span>
</DropdownMenuItem>
</Link>
- <DropdownMenuItem onClick={() => setIsDeleteDialogOpen(true)}>
+ <DropdownMenuItem
+ key="delete"
+ onClick={() => setIsDeleteDialogOpen(true)}
+ >
<Trash className="mr-2 h-4 w-4" />
<span>Delete</span>
</DropdownMenuItem>
@@ -124,6 +133,7 @@ const DatasetRunTableMultiSelectAction = ({
</DropdownMenu>
<Dialog
+ key="delete-dialog"
open={isDeleteDialogOpen}
onOpenChange={(isOpen) => {
if (!mutDelete.isLoading) {
@@ -178,6 +188,13 @@ export function DatasetRunsTable(props: {
"datasetRuns",
"s",
);
+
+ // Add panel size state with default size of 30%
+ const [chartsPanelSize, setChartsPanelSize] = useSessionStorage<number>(
+ "dataset-runs-charts-panel-size",
+ 30,
+ );
+
const { setScoreOptions } = props;
const runs = api.datasets.runsByDatasetId.useQuery({
@@ -453,13 +470,28 @@ export function DatasetRunsTable(props: {
columns,
);
+ // Check if we have charts to display
+ const hasCharts =
+ Boolean(props.selectedMetrics.length) &&
+ Boolean(runAggregatedMetrics?.size);
+
return (
<>
- {Boolean(props.selectedMetrics.length) &&
- Boolean(runAggregatedMetrics?.size) && (
- <Card className="my-4 max-h-64">
- <CardContent className="mt-2 h-full">
- <div className="flex h-full w-full gap-4 overflow-x-auto">
+ {hasCharts ? (
+ <ResizablePanelGroup
+ direction="vertical"
+ className="h-full"
+ onLayout={(sizes) => {
+ setChartsPanelSize(sizes[0]);
+ }}
+ >
+ <ResizablePanel
+ defaultSize={chartsPanelSize}
+ minSize={20}
+ className="overflow-hidden"
+ >
+ <div className="h-full w-full overflow-x-auto overflow-y-auto p-3">
+ <div className="flex h-full w-full gap-4">
{props.selectedMetrics.map((key) => {
const adapter = new CompareViewAdapter(
runAggregatedMetrics,
@@ -470,92 +502,166 @@ export function DatasetRunsTable(props: {
const scoreData = scoreKeyToData.get(key);
if (!scoreData)
return (
+ <div key={key} className="h-full min-w-80 max-w-full">
+ <TimeseriesChart
+ chartData={chartData}
+ chartLabels={chartLabels}
+ title={
+ RESOURCE_METRICS.find(
+ (metric) => metric.key === key,
+ )?.label ?? key
+ }
+ type="numeric"
+ maxFractionDigits={
+ RESOURCE_METRICS.find(
+ (metric) => metric.key === key,
+ )?.maxFractionDigits
+ }
+ />
+ </div>
+ );
+
+ return (
+ <div key={key} className="h-full min-w-80 max-w-full">
<TimeseriesChart
- key={key}
chartData={chartData}
chartLabels={chartLabels}
- title={
- RESOURCE_METRICS.find((metric) => metric.key === key)
- ?.label ?? key
+ title={`${getScoreDataTypeIcon(scoreData.dataType)} ${scoreData.name} (${scoreData.source.toLowerCase()})`}
+ type={
+ isNumericDataType(scoreData.dataType)
+ ? "numeric"
+ : "categorical"
}
- type="numeric"
/>
- );
-
- return (
- <TimeseriesChart
- key={key}
- chartData={chartData}
- chartLabels={chartLabels}
- title={`${getScoreDataTypeIcon(scoreData.dataType)} ${scoreData.name} (${scoreData.source.toLowerCase()})`}
- type={
- isNumericDataType(scoreData.dataType)
- ? "numeric"
- : "categorical"
- }
- />
+ </div>
);
})}
</div>
- </CardContent>
- </Card>
- )}
- <DataTableToolbar
- columns={columns}
- columnVisibility={columnVisibility}
- setColumnVisibility={setColumnVisibility}
- columnOrder={columnOrder}
- setColumnOrder={setColumnOrder}
- rowHeight={rowHeight}
- setRowHeight={setRowHeight}
- actionButtons={[
- Object.keys(selectedRows).filter((runId) =>
- runs.data?.runs.map((run) => run.id).includes(runId),
- ).length > 0 ? (
- <DatasetRunTableMultiSelectAction
- // Exclude items that are not in the current page
- selectedRunIds={Object.keys(selectedRows).filter((runId) =>
- runs.data?.runs.map((run) => run.id).includes(runId),
- )}
- projectId={props.projectId}
- datasetId={props.datasetId}
+ </div>
+ </ResizablePanel>
+ <ResizableHandle withHandle className="bg-border" />
+ <ResizablePanel
+ minSize={40}
+ className="flex h-full flex-1 flex-col overflow-hidden"
+ >
+ <DataTableToolbar
+ columns={columns}
+ columnVisibility={columnVisibility}
+ setColumnVisibility={setColumnVisibility}
+ columnOrder={columnOrder}
+ setColumnOrder={setColumnOrder}
+ rowHeight={rowHeight}
+ setRowHeight={setRowHeight}
+ actionButtons={[
+ Object.keys(selectedRows).filter((runId) =>
+ runs.data?.runs.map((run) => run.id).includes(runId),
+ ).length > 0 ? (
+ <DatasetRunTableMultiSelectAction
+ // Exclude items that are not in the current page
+ selectedRunIds={Object.keys(selectedRows).filter((runId) =>
+ runs.data?.runs.map((run) => run.id).includes(runId),
+ )}
+ projectId={props.projectId}
+ datasetId={props.datasetId}
+ setRowSelection={setSelectedRows}
+ />
+ ) : null,
+ ]}
+ />
+ <DataTable
+ columns={columns}
+ data={
+ runs.isLoading
+ ? { isLoading: true, isError: false }
+ : runs.isError
+ ? {
+ isLoading: false,
+ isError: true,
+ error: runs.error.message,
+ }
+ : {
+ isLoading: false,
+ isError: false,
+ data: (runsWithMetrics.rows ?? []).map((t) =>
+ convertToTableRow(t),
+ ),
+ }
+ }
+ pagination={{
+ totalCount: runs.data?.totalRuns ?? null,
+ onChange: setPaginationState,
+ state: paginationState,
+ }}
+ columnVisibility={columnVisibility}
+ onColumnVisibilityChange={setColumnVisibility}
+ columnOrder={columnOrder}
+ onColumnOrderChange={setColumnOrder}
+ rowHeight={rowHeight}
+ rowSelection={selectedRows}
setRowSelection={setSelectedRows}
/>
- ) : null,
- ]}
- />
- <DataTable
- columns={columns}
- data={
- runs.isLoading
- ? { isLoading: true, isError: false }
- : runs.isError
- ? {
- isLoading: false,
- isError: true,
- error: runs.error.message,
- }
- : {
- isLoading: false,
- isError: false,
- data: (runsWithMetrics.rows ?? []).map((t) =>
- convertToTableRow(t),
- ),
- }
- }
- pagination={{
- totalCount: runs.data?.totalRuns ?? null,
- onChange: setPaginationState,
- state: paginationState,
- }}
- columnVisibility={columnVisibility}
- onColumnVisibilityChange={setColumnVisibility}
- columnOrder={columnOrder}
- onColumnOrderChange={setColumnOrder}
- rowHeight={rowHeight}
- rowSelection={selectedRows}
- setRowSelection={setSelectedRows}
- />
+ </ResizablePanel>
+ </ResizablePanelGroup>
+ ) : (
+ <>
+ <DataTableToolbar
+ columns={columns}
+ columnVisibility={columnVisibility}
+ setColumnVisibility={setColumnVisibility}
+ columnOrder={columnOrder}
+ setColumnOrder={setColumnOrder}
+ rowHeight={rowHeight}
+ setRowHeight={setRowHeight}
+ actionButtons={[
+ Object.keys(selectedRows).filter((runId) =>
+ runs.data?.runs.map((run) => run.id).includes(runId),
+ ).length > 0 ? (
+ <DatasetRunTableMultiSelectAction
+ // Exclude items that are not in the current page
+ selectedRunIds={Object.keys(selectedRows).filter((runId) =>
+ runs.data?.runs.map((run) => run.id).includes(runId),
+ )}
+ projectId={props.projectId}
+ datasetId={props.datasetId}
+ setRowSelection={setSelectedRows}
+ />
+ ) : null,
+ ]}
+ />
+ <DataTable
+ columns={columns}
+ data={
+ runs.isLoading
+ ? { isLoading: true, isError: false }
+ : runs.isError
+ ? {
+ isLoading: false,
+ isError: true,
+ error: runs.error.message,
+ }
+ : {
+ isLoading: false,
+ isError: false,
+ data: (runsWithMetrics.rows ?? []).map((t) =>
+ convertToTableRow(t),
+ ),
+ }
+ }
+ pagination={{
+ totalCount: runs.data?.totalRuns ?? null,
+ onChange: setPaginationState,
+ state: paginationState,
+ }}
+ columnVisibility={columnVisibility}
+ onColumnVisibilityChange={setColumnVisibility}
+ columnOrder={columnOrder}
+ onColumnOrderChange={setColumnOrder}
+ rowHeight={rowHeight}
+ rowSelection={selectedRows}
+ setRowSelection={setSelectedRows}
+ />
+ </>
+ )}
</>
);
}
diff --git a/web/src/features/scores/components/ScoreChart.tsx b/web/src/features/scores/components/ScoreChart.tsx
index 89f7cc5442..de63d7524a 100644
--- a/web/src/features/scores/components/ScoreChart.tsx
+++ b/web/src/features/scores/components/ScoreChart.tsx
@@ -31,10 +31,13 @@ export function CategoricalChart(props: {
/>
) : (
<Card
- className={cn("w-full rounded-tremor-default border", props.className)}
+ className={cn(
+ "max-h-full min-h-0 rounded-tremor-default border",
+ props.className,
+ )}
>
<BarChart
- className={cn("mt-4", props.chartClass)}
+ className={cn("mt-4 max-h-full min-h-0", props.chartClass)}
data={props.chartData}
index="binLabel"
categories={props.chartLabels}
@@ -55,20 +58,23 @@ export function NumericChart(props: {
chartData: ChartBin[];
chartLabels: string[];
index: string;
+ maxFractionDigits?: number;
}) {
const colors = getColorsForCategories(props.chartLabels);
return isEmptyChart({ data: props.chartData }) ? (
<NoDataOrLoading isLoading={false} />
) : (
- <Card className="h-full w-full rounded-tremor-default border">
+ <Card className="max-h-full min-h-0 min-w-0 max-w-full flex-1 rounded-tremor-default border">
<LineChart
- className="h-full"
+ className="max-h-full min-h-0 min-w-0 max-w-full"
data={props.chartData}
index={props.index}
categories={props.chartLabels}
colors={colors}
- valueFormatter={compactNumberFormatter}
+ valueFormatter={(value) => {
+ return compactNumberFormatter(value, props.maxFractionDigits);
+ }}
noDataText="No data"
showAnimation={true}
onValueChange={() => {}}
diff --git a/web/src/features/scores/components/TimeseriesChart.tsx b/web/src/features/scores/components/TimeseriesChart.tsx
index e9902d3f2f..e1c1a6f1ee 100644
--- a/web/src/features/scores/components/TimeseriesChart.tsx
+++ b/web/src/features/scores/components/TimeseriesChart.tsx
@@ -6,7 +6,7 @@ import { type TimeseriesChartProps } from "@/src/features/scores/types";
function ChartWrapper(props: { title: string; children: React.ReactNode }) {
return (
- <div className="mb-2 flex w-[400px] flex-none flex-col overflow-hidden">
+ <div className="mb-2 flex max-h-full min-h-0 min-w-0 max-w-full flex-none flex-col overflow-hidden">
<div className="shrink-0 text-sm font-medium">{props.title}</div>
{props.children}
</div>
@@ -19,12 +19,13 @@ export function TimeseriesChart({
title,
type,
index,
+ maxFractionDigits,
}: TimeseriesChartProps) {
const chartIndex = index ?? "binLabel";
return (
<ChartWrapper title={title}>
- <div className="mt-2 min-h-0 flex-1">
+ <div className="mt-2 flex max-h-full min-h-0 min-w-0 max-w-full">
{type === "categorical" ? (
<CategoricalChart
chartLabels={chartLabels}
@@ -38,6 +39,7 @@ export function TimeseriesChart({
chartLabels={chartLabels}
chartData={chartData}
index={chartIndex}
+ maxFractionDigits={maxFractionDigits}
/>
)}
</div>
diff --git a/web/src/features/scores/components/multi-select-key-values.tsx b/web/src/features/scores/components/multi-select-key-values.tsx
index ea351562f8..357c42c028 100644
--- a/web/src/features/scores/components/multi-select-key-values.tsx
+++ b/web/src/features/scores/components/multi-select-key-values.tsx
@@ -52,7 +52,7 @@ type MultiSelectKeyValuesProps<
hideClearButton?: boolean;
iconLeft?: React.ReactNode;
iconRight?: React.ReactNode;
- variant?: "outline" | "secondary";
+ variant?: "outline" | "secondary" | "ghost";
};
export function MultiSelectKeyValues<
diff --git a/web/src/features/scores/types.ts b/web/src/features/scores/types.ts
index 54601c578b..90395fc747 100644
--- a/web/src/features/scores/types.ts
+++ b/web/src/features/scores/types.ts
@@ -10,6 +10,7 @@ export type TimeseriesChartProps = {
title: string;
type: "numeric" | "categorical";
index?: string;
+ maxFractionDigits?: number;
};
export type ChartData = {
diff --git a/web/src/pages/project/[projectId]/datasets/[datasetId]/compare.tsx b/web/src/pages/project/[projectId]/datasets/[datasetId]/compare.tsx
index 1144eb3829..46c40054f2 100644
--- a/web/src/pages/project/[projectId]/datasets/[datasetId]/compare.tsx
+++ b/web/src/pages/project/[projectId]/datasets/[datasetId]/compare.tsx
@@ -2,15 +2,10 @@ import { Button } from "@/src/components/ui/button";
import { DatasetCompareRunsTable } from "@/src/features/datasets/components/DatasetCompareRunsTable";
import { MultiSelectKeyValues } from "@/src/features/scores/components/multi-select-key-values";
import { api } from "@/src/utils/api";
-import { FlaskConical, FolderKanban } from "lucide-react";
+import { ChartLine, Cog, FlaskConical, List } from "lucide-react";
import { useRouter } from "next/router";
import { useMemo, useState } from "react";
import { useQueryParams, withDefault, ArrayParam } from "use-query-params";
-import {
- Popover,
- PopoverTrigger,
- PopoverContent,
-} from "@/src/components/ui/popover";
import { MarkdownJsonView } from "@/src/components/ui/MarkdownJsonView";
import {
Dialog,
@@ -20,7 +15,6 @@ import {
import { CreateExperimentsForm } from "@/src/ee/features/experiments/components/CreateExperimentsForm";
import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";
import { DatasetAnalytics } from "@/src/features/datasets/components/DatasetAnalytics";
-import { Card, CardContent } from "@/src/components/ui/card";
import { getScoreDataTypeIcon } from "@/src/features/scores/components/ScoreDetailColumnHelpers";
import { TimeseriesChart } from "@/src/features/scores/components/TimeseriesChart";
import {
@@ -34,6 +28,19 @@ import {
} from "@/src/features/dashboard/lib/score-analytics-utils";
import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";
import Page from "@/src/components/layouts/page";
+import { SubHeader, SubHeaderLabel } from "@/src/components/layouts/header";
+import {
+ SidePanel,
+ SidePanelContent,
+ SidePanelHeader,
+ SidePanelTitle,
+} from "@/src/components/ui/side-panel";
+import {
+ Popover,
+ PopoverContent,
+ PopoverTrigger,
+} from "@/src/components/ui/popover";
+import { Separator } from "@/src/components/ui/separator";
export default function DatasetCompare() {
const router = useRouter();
@@ -206,46 +213,14 @@ export default function DatasetCompare() {
/>
</DialogContent>
</Dialog>
- <Popover key="show-dataset-details">
- <PopoverTrigger asChild>
- <Button variant="outline">
- <FolderKanban className="mr-2 h-4 w-4" />
- <span className="hidden md:block">Dataset details</span>
- </Button>
- </PopoverTrigger>
- <PopoverContent className="mx-2 max-h-[50vh] w-[50vw] overflow-y-auto md:w-[25vw]">
- <div className="space-y-4">
- <div>
- <h4 className="mb-1 font-medium">Description</h4>
- <span className="text-sm text-muted-foreground">
- {dataset.data?.description ?? "No description"}
- </span>
- </div>
- <div>
- <h4 className="mb-1 font-medium">Metadata</h4>
- <MarkdownJsonView
- content={dataset.data?.metadata ?? null}
- />
- </div>
- </div>
- </PopoverContent>
- </Popover>
- {runIds && runIds.length > 1 ? (
- <DatasetAnalytics
- key="dataset-analytics"
- projectId={projectId}
- scoreOptions={scoreAnalyticsOptions}
- selectedMetrics={selectedMetrics}
- setSelectedMetrics={setSelectedMetrics}
- />
- ) : null}
<MultiSelectKeyValues
key="select-runs"
- title="Select runs"
+ title="Runs"
placeholder="Select runs to compare"
className="w-fit"
variant="outline"
hideClearButton
+ iconLeft={<List className="mr-2 h-4 w-4" />}
options={runs.map((run) => ({
key: run.key,
value: run.value,
@@ -275,60 +250,138 @@ export default function DatasetCompare() {
),
}}
>
- {Boolean(selectedMetrics.length) &&
- Boolean(runAggregatedMetrics?.size) && (
- <Card className="my-4 max-h-64">
- <CardContent className="mt-2 h-full">
- <div className="flex h-full w-full gap-4 overflow-x-auto">
- {selectedMetrics.map((key) => {
- const adapter = new CompareViewAdapter(
- runAggregatedMetrics,
- key,
- );
- const { chartData, chartLabels } = adapter.toChartData();
+ <div className="grid flex-1 grid-cols-[1fr,auto] overflow-hidden">
+ <div className="flex h-full flex-col overflow-hidden">
+ <DatasetCompareRunsTable
+ key={runIds?.join(",") ?? "empty"}
+ projectId={projectId}
+ datasetId={datasetId}
+ runsData={runsData.data}
+ runIds={runIds ?? []}
+ localExperiments={localRuns}
+ />
+ </div>
+ <SidePanel
+ mobileTitle="Compare Experiments"
+ id="compare-experiments"
+ scrollable={false}
+ >
+ <SidePanelHeader>
+ <SidePanelTitle>Compare Experiments</SidePanelTitle>
+ </SidePanelHeader>
+ <SidePanelContent className="overflow-y-auto p-1">
+ <div className="w-full space-y-4">
+ <div>
+ <SubHeaderLabel title="Description" />
+ <span className="text-sm text-muted-foreground">
+ {dataset.data?.description ?? "No description"}
+ </span>
+ </div>
+ {dataset.data?.metadata && (
+ <div>
+ <SubHeaderLabel title="Metadata" />
+ <MarkdownJsonView content={dataset.data?.metadata} />
+ </div>
+ )}
+ </div>
- const scoreData = scoreKeyToData.get(key);
- if (!scoreData)
- return (
- <TimeseriesChart
- key={key}
- chartData={chartData}
- chartLabels={chartLabels}
- title={
- RESOURCE_METRICS.find((metric) => metric.key === key)
- ?.label ?? key
- }
- type="numeric"
+ <>
+ <div className="flex w-full flex-row items-center justify-between gap-2">
+ <SubHeader title="Charts" />
+ <Popover>
+ <PopoverTrigger asChild>
+ <Button
+ variant="outline"
+ size="icon"
+ className="focus-visible:ring-0 focus-visible:ring-offset-0"
+ >
+ <div className="relative" title="Chart settings">
+ <ChartLine className="h-4 w-4" />
+ <Cog className="absolute -bottom-1.5 -right-1 h-3.5 w-3.5 rounded-full bg-background p-0.5" />
+ </div>
+ </Button>
+ </PopoverTrigger>
+ <PopoverContent align="end" className="w-[250px] p-0">
+ <div className="px-3 py-2 font-medium">Chart settings</div>
+ <Separator />
+ <div onClick={(e) => e.stopPropagation()} className="p-1">
+ <DatasetAnalytics
+ key="dataset-analytics"
+ projectId={projectId}
+ scoreOptions={scoreAnalyticsOptions}
+ selectedMetrics={selectedMetrics}
+ setSelectedMetrics={setSelectedMetrics}
/>
+ </div>
+ </PopoverContent>
+ </Popover>
+ </div>
+
+ {Boolean(selectedMetrics.length) &&
+ Boolean(runAggregatedMetrics?.size) ? (
+ <div className="grid w-full grid-cols-1 gap-4">
+ {selectedMetrics.map((key) => {
+ const adapter = new CompareViewAdapter(
+ runAggregatedMetrics,
+ key,
);
+ const { chartData, chartLabels } = adapter.toChartData();
- return (
- <TimeseriesChart
- key={key}
- chartData={chartData}
- chartLabels={chartLabels}
- title={`${getScoreDataTypeIcon(scoreData.dataType)} ${scoreData.name} (${scoreData.source.toLowerCase()})`}
- type={
- isNumericDataType(scoreData.dataType)
- ? "numeric"
- : "categorical"
- }
- />
- );
- })}
- </div>
- </CardContent>
- </Card>
- )}
+ const scoreData = scoreKeyToData.get(key);
+ if (!scoreData)
+ return (
+ <div
+ key={key}
+ className="max-h-52 min-h-0 min-w-0 max-w-full"
+ >
+ <TimeseriesChart
+ key={key}
+ chartData={chartData}
+ chartLabels={chartLabels}
+ title={
+ RESOURCE_METRICS.find(
+ (metric) => metric.key === key,
+ )?.label ?? key
+ }
+ type="numeric"
+ maxFractionDigits={
+ RESOURCE_METRICS.find(
+ (metric) => metric.key === key,
+ )?.maxFractionDigits
+ }
+ />
+ </div>
+ );
- <DatasetCompareRunsTable
- key={runIds?.join(",") ?? "empty"}
- projectId={projectId}
- datasetId={datasetId}
- runsData={runsData.data}
- runIds={runIds ?? []}
- localExperiments={localRuns}
- />
+ return (
+ <div
+ key={key}
+ className="max-h-52 min-h-0 min-w-0 max-w-full"
+ >
+ <TimeseriesChart
+ key={key}
+ chartData={chartData}
+ chartLabels={chartLabels}
+ title={`${getScoreDataTypeIcon(scoreData.dataType)} ${scoreData.name} (${scoreData.source.toLowerCase()})`}
+ type={
+ isNumericDataType(scoreData.dataType)
+ ? "numeric"
+ : "categorical"
+ }
+ />
+ </div>
+ );
+ })}
+ </div>
+ ) : (
+ <span className="-mt-2 text-sm text-muted-foreground">
+ All charts hidden. Enable them in settings.
+ </span>
+ )}
+ </>
+ </SidePanelContent>
+ </SidePanel>
+ </div>
</Page>
);
}
diff --git a/web/src/pages/project/[projectId]/datasets/[datasetId]/index.tsx b/web/src/pages/project/[projectId]/datasets/[datasetId]/index.tsx
index bb5bf81856..16c8046e4a 100644
--- a/web/src/pages/project/[projectId]/datasets/[datasetId]/index.tsx
+++ b/web/src/pages/project/[projectId]/datasets/[datasetId]/index.tsx
@@ -14,9 +14,10 @@ import { DuplicateDatasetButton } from "@/src/features/datasets/components/Dupli
import { useState } from "react";
import { MultiSelectKeyValues } from "@/src/features/scores/components/multi-select-key-values";
import {
+ ChartLine,
+ Cog,
ExternalLink,
FlaskConical,
- FolderKanban,
MoreVertical,
} from "lucide-react";
import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";
@@ -39,13 +40,13 @@ import {
PopoverTrigger,
} from "@/src/components/ui/popover";
import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";
-import { MarkdownJsonView } from "@/src/components/ui/MarkdownJsonView";
import Page from "@/src/components/layouts/page";
import {
TabsBarList,
TabsBarTrigger,
TabsBar,
} from "@/src/components/ui/tabs-bar";
+import { Separator } from "@/src/components/ui/separator";
export default function Dataset() {
const router = useRouter();
@@ -176,14 +177,6 @@ export default function Dataset() {
</DialogContent>
</Dialog>
- <DatasetAnalytics
- key="dataset-analytics"
- projectId={projectId}
- scoreOptions={scoreOptions}
- selectedMetrics={selectedMetrics}
- setSelectedMetrics={setSelectedMetrics}
- />
-
{hasReadAccess && hasEntitlement && evaluators.isSuccess && (
<MultiSelectKeyValues
variant="outline"
@@ -212,30 +205,35 @@ export default function Dataset() {
}
/>
)}
- <Popover key="show-dataset-details">
+
+ <Popover>
<PopoverTrigger asChild>
- <Button variant="outline">
- <FolderKanban className="mr-2 h-4 w-4" />
- <span className="hidden md:block">Dataset details</span>
+ <Button
+ variant="outline"
+ size="icon"
+ className="focus-visible:ring-0 focus-visible:ring-offset-0"
+ >
+ <div className="relative" title="Chart settings">
+ <ChartLine className="h-4 w-4" />
+ <Cog className="absolute -bottom-1.5 -right-1 h-3.5 w-3.5 rounded-full bg-background p-0.5" />
+ </div>
</Button>
</PopoverTrigger>
- <PopoverContent className="mx-2 max-h-[50vh] w-[50vw] overflow-y-auto md:w-[25vw]">
- <div className="space-y-4">
- <div>
- <h4 className="mb-1 font-medium">Description</h4>
- <span className="text-sm text-muted-foreground">
- {dataset.data?.description ?? "No description"}
- </span>
- </div>
- <div>
- <h4 className="mb-1 font-medium">Metadata</h4>
- <MarkdownJsonView
- content={dataset.data?.metadata ?? null}
- />
- </div>
+ <PopoverContent align="end" className="w-[250px] p-0">
+ <div className="px-3 py-2 font-medium">Chart settings</div>
+ <Separator />
+ <div onClick={(e) => e.stopPropagation()} className="p-1">
+ <DatasetAnalytics
+ key="dataset-analytics"
+ projectId={projectId}
+ scoreOptions={scoreOptions}
+ selectedMetrics={selectedMetrics}
+ setSelectedMetrics={setSelectedMetrics}
+ />
</div>
</PopoverContent>
</Popover>
+
<DetailPageNav
currentId={datasetId}
path={(entry) => `/project/${projectId}/datasets/${entry.id}`}
diff --git a/web/src/pages/project/[projectId]/datasets/[datasetId]/items.tsx b/web/src/pages/project/[projectId]/datasets/[datasetId]/items.tsx
index 3e6f61fe8d..df2ac0dce8 100644
--- a/web/src/pages/project/[projectId]/datasets/[datasetId]/items.tsx
+++ b/web/src/pages/project/[projectId]/datasets/[datasetId]/items.tsx
@@ -13,14 +13,8 @@ import { DeleteDatasetButton } from "@/src/components/deleteButton";
import { NewDatasetItemButton } from "@/src/features/datasets/components/NewDatasetItemButton";
import { DuplicateDatasetButton } from "@/src/features/datasets/components/DuplicateDatasetButton";
import { UploadDatasetCsvButton } from "@/src/features/datasets/components/UploadDatasetCsvButton";
-import { MarkdownJsonView } from "@/src/components/ui/MarkdownJsonView";
import { Button } from "@/src/components/ui/button";
-import {
- Popover,
- PopoverContent,
- PopoverTrigger,
-} from "@/src/components/ui/popover";
-import { FolderKanban, MoreVertical } from "lucide-react";
+import { MoreVertical } from "lucide-react";
import Page from "@/src/components/layouts/page";
import {
DropdownMenu,
@@ -71,30 +65,6 @@ export default function DatasetItems() {
projectId={projectId}
datasetId={datasetId}
/>
- <Popover key="show-dataset-details">
- <PopoverTrigger asChild>
- <Button variant="outline">
- <FolderKanban className="mr-2 h-4 w-4" />
- <span className="hidden md:block">Dataset details</span>
- </Button>
- </PopoverTrigger>
- <PopoverContent className="mx-2 max-h-[50vh] w-[50vw] overflow-y-auto md:w-[25vw]">
- <div className="space-y-4">
- <div>
- <h4 className="mb-1 font-medium">Description</h4>
- <span className="text-sm text-muted-foreground">
- {dataset.data?.description ?? "No description"}
- </span>
- </div>
- <div>
- <h4 className="mb-1 font-medium">Metadata</h4>
- <MarkdownJsonView
- content={dataset.data?.metadata ?? null}
- />
- </div>
- </div>
- </PopoverContent>
- </Popover>
<DetailPageNav
currentId={datasetId}
path={(entry) =>
diff --git a/web/src/utils/numbers.ts b/web/src/utils/numbers.ts
index aad3cf3b36..d2a5763cdc 100644
--- a/web/src/utils/numbers.ts
+++ b/web/src/utils/numbers.ts
@@ -1,10 +1,13 @@
import Decimal from "decimal.js";
-export const compactNumberFormatter = (number?: number | bigint) => {
+export const compactNumberFormatter = (
+ number?: number | bigint,
+ maxFractionDigits?: number,
+) => {
return Intl.NumberFormat("en-US", {
notation: "compact",
compactDisplay: "short",
- maximumFractionDigits: 2,
+ maximumFractionDigits: maxFractionDigits ?? 2,
}).format(number ?? 0);
};