🪢 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
feat(playground): scroll horizontally as windows are added (#9613)
marliessophieb171db153ece
diff --git a/web/src/features/playground/page/components/MultiWindowPlayground.tsx b/web/src/features/playground/page/components/MultiWindowPlayground.tsxindex cb2cd155c6..a6d77198d9 100644--- a/web/src/features/playground/page/components/MultiWindowPlayground.tsx+++ b/web/src/features/playground/page/components/MultiWindowPlayground.tsx@@ -1,4 +1,4 @@-import React, { useMemo, useCallback } from "react";+import React, { useMemo, useCallback, useRef, useEffect } from "react";import { PlaygroundProvider } from "../context";import { SaveToPromptButton } from "./SaveToPromptButton";import { Button } from "@/src/components/ui/button";@@ -47,6 +47,9 @@ export default function MultiWindowPlayground({onRemoveWindow,onAddWindow,}: MultiWindowPlaygroundProps) {+ const containerRef = useRef<HTMLDivElement>(null);+ const prevWindowCountRef = useRef(windowState.windowIds.length);+/*** Calculate responsive window width based on screen size and window count* Ensures minimum width while distributing available space equally@@ -62,6 +65,23 @@ export default function MultiWindowPlayground({return `minmax(${minWidth}px, ${idealWidth})`;}, [windowState.windowIds.length]);+ /**+ * Auto-scroll to the right when a new window is added (not removed)+ */+ useEffect(() => {+ const currentCount = windowState.windowIds.length;+ const prevCount = prevWindowCountRef.current;++ if (currentCount > prevCount && containerRef.current) {+ containerRef.current.scrollTo({+ left: containerRef.current.scrollWidth,+ behavior: "smooth",+ });+ }++ prevWindowCountRef.current = currentCount;+ }, [windowState.windowIds.length]);+/*** Handle copying a specific window to create a new window* This is called when the individual window "Copy" button is clicked@@ -96,6 +116,7 @@ export default function MultiWindowPlayground({{/* Desktop layout: multi-window with horizontal grid - visible at md breakpoint and above */}<div className="hidden h-full md:block"><div+ ref={containerRef}className="h-full overflow-x-auto"style={{display: "grid",