🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
fix(ui): scroll behavior of large traces (#846)
Marc Klingen487e0a77d613
diff --git a/package-lock.json b/package-lock.jsonindex 2235f1e387..a5b151fc9d 100644--- a/package-lock.json+++ b/package-lock.json@@ -28,6 +28,7 @@"@radix-ui/react-icons": "^1.3.0","@radix-ui/react-label": "^2.0.2","@radix-ui/react-popover": "^1.0.7",+ "@radix-ui/react-scroll-area": "^1.0.5","@radix-ui/react-select": "^2.0.0","@radix-ui/react-separator": "^1.0.3","@radix-ui/react-slider": "^1.1.2",@@ -3749,6 +3750,37 @@}}},+ "node_modules/@radix-ui/react-scroll-area": {+ "version": "1.0.5",+ "resolved": "https://registry.npmjs.org/@radix-ui/react-scroll-area/-/react-scroll-area-1.0.5.tgz",+ "integrity": "sha512-b6PAgH4GQf9QEn8zbT2XUHpW5z8BzqEc7Kl11TwDrvuTrxlkcjTD5qa/bxgKr+nmuXKu4L/W5UZ4mlP/VG/5Gw==",+ "dependencies": {+ "@babel/runtime": "^7.13.10",+ "@radix-ui/number": "1.0.1",+ "@radix-ui/primitive": "1.0.1",+ "@radix-ui/react-compose-refs": "1.0.1",+ "@radix-ui/react-context": "1.0.1",+ "@radix-ui/react-direction": "1.0.1",+ "@radix-ui/react-presence": "1.0.1",+ "@radix-ui/react-primitive": "1.0.3",+ "@radix-ui/react-use-callback-ref": "1.0.1",+ "@radix-ui/react-use-layout-effect": "1.0.1"+ },+ "peerDependencies": {+ "@types/react": "*",+ "@types/react-dom": "*",+ "react": "^16.8 || ^17.0 || ^18.0",+ "react-dom": "^16.8 || ^17.0 || ^18.0"+ },+ "peerDependenciesMeta": {+ "@types/react": {+ "optional": true+ },+ "@types/react-dom": {+ "optional": true+ }+ }+ },"node_modules/@radix-ui/react-select": {"version": "2.0.0","resolved": "https://registry.npmjs.org/@radix-ui/react-select/-/react-select-2.0.0.tgz",diff --git a/package.json b/package.jsonindex d1d2ff80af..11bcf18c2e 100644--- a/package.json+++ b/package.json@@ -45,6 +45,7 @@"@radix-ui/react-icons": "^1.3.0","@radix-ui/react-label": "^2.0.2","@radix-ui/react-popover": "^1.0.7",+ "@radix-ui/react-scroll-area": "^1.0.5","@radix-ui/react-select": "^2.0.0","@radix-ui/react-separator": "^1.0.3","@radix-ui/react-slider": "^1.1.2",diff --git a/src/components/layouts/layout.tsx b/src/components/layouts/layout.tsxindex 1e8deae343..3d8b20a8d9 100644--- a/src/components/layouts/layout.tsx+++ b/src/components/layouts/layout.tsx@@ -569,9 +569,7 @@ export default function Layout(props: PropsWithChildren) {</Button></div>) : null}- <main className="py-4">- <div className="px-4">{props.children}</div>- </main>+ <main className="p-4">{props.children}</main></div></div></>diff --git a/src/components/trace/index.tsx b/src/components/trace/index.tsxindex f130710e14..6074c295b1 100644--- a/src/components/trace/index.tsx+++ b/src/components/trace/index.tsx@@ -20,6 +20,7 @@ import { NoAccessError } from "@/src/components/no-access";import useLocalStorage from "@/src/components/useLocalStorage";import { Toggle } from "@/src/components/ui/toggle";import { Award, ChevronsDownUp, ChevronsUpDown } from "lucide-react";+import { ScrollArea } from "@/src/components/ui/scroll-area";export function Trace(props: {observations: Array<ObservationReturnType>;@@ -39,8 +40,8 @@ export function Trace(props: {);return (- <div className="grid h-full gap-4 md:grid-cols-3">- <div className="md:col-span-2 md:h-full md:overflow-y-auto">+ <div className="grid gap-4 md:h-full md:grid-cols-3">+ <ScrollArea className="md:col-span-2 md:h-full">{currentObservationId === undefined ||currentObservationId === "" ||currentObservationId === null ? (@@ -58,9 +59,9 @@ export function Trace(props: {traceId={props.trace.id}/>)}- </div>- <div className="md:h-full md:overflow-hidden">- <div className="mb-2 flex flex-row justify-end gap-2">+ </ScrollArea>+ <div className="md:flex md:h-full md:flex-col md:overflow-hidden">+ <div className="mb-2 flex flex-shrink-0 flex-row justify-end gap-2"><Togglepressed={scoresOnObservationTree}onPressedChange={(e) => {@@ -86,16 +87,17 @@ export function Trace(props: {)}</Toggle></div>- <ObservationTree- observations={props.observations}- trace={props.trace}- scores={props.scores}- currentObservationId={currentObservationId ?? undefined}- setCurrentObservationId={setCurrentObservationId}- showMetrics={metricsOnObservationTree}- showScores={scoresOnObservationTree}- className="md:h-full md:overflow-y-auto"- />+ <ScrollArea className="flex flex-grow">+ <ObservationTree+ observations={props.observations}+ trace={props.trace}+ scores={props.scores}+ currentObservationId={currentObservationId ?? undefined}+ setCurrentObservationId={setCurrentObservationId}+ showMetrics={metricsOnObservationTree}+ showScores={scoresOnObservationTree}+ />+ </ScrollArea></div></div>);@@ -125,7 +127,7 @@ export function TracePage({ traceId }: { traceId: string }) {if (!trace.data) return <div>loading...</div>;return (- <div className="flex flex-col overflow-hidden xl:container md:h-[calc(100vh-100px)] xl:h-[calc(100vh-40px)]">+ <div className="flex flex-col overflow-hidden xl:container md:h-[calc(100vh-2rem)]"><Headertitle="Trace Detail"breadcrumb={[diff --git a/src/components/ui/scroll-area.tsx b/src/components/ui/scroll-area.tsxnew file mode 100644index 0000000000..d80e65d5e8--- /dev/null+++ b/src/components/ui/scroll-area.tsx@@ -0,0 +1,48 @@+"use client";++import * as React from "react";+import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area";++import { cn } from "@/src/utils/tailwind";++const ScrollArea = React.forwardRef<+ React.ElementRef<typeof ScrollAreaPrimitive.Root>,+ React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root>+>(({ className, children, ...props }, ref) => (+ <ScrollAreaPrimitive.Root+ ref={ref}+ className={cn("relative overflow-hidden", className)}+ {...props}+ >+ <ScrollAreaPrimitive.Viewport className="h-full w-full rounded-[inherit]">+ {children}+ </ScrollAreaPrimitive.Viewport>+ <ScrollBar />+ <ScrollAreaPrimitive.Corner />+ </ScrollAreaPrimitive.Root>+));+ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName;++const ScrollBar = React.forwardRef<+ React.ElementRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>,+ React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>+>(({ className, orientation = "vertical", ...props }, ref) => (+ <ScrollAreaPrimitive.ScrollAreaScrollbar+ ref={ref}+ orientation={orientation}+ className={cn(+ "flex touch-none select-none transition-colors",+ orientation === "vertical" &&+ "h-full w-2.5 border-l border-l-transparent p-[1px]",+ orientation === "horizontal" &&+ "h-2.5 flex-col border-t border-t-transparent p-[1px]",+ className,+ )}+ {...props}+ >+ <ScrollAreaPrimitive.ScrollAreaThumb className="relative flex-1 rounded-full bg-border" />+ </ScrollAreaPrimitive.ScrollAreaScrollbar>+));+ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName;++export { ScrollArea, ScrollBar };