🪢 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(playground): preserve window state during viewport change (#10234)
Aman Thakurd084a815ee4d
diff --git a/web/src/features/playground/page/components/MultiWindowPlayground.tsx b/web/src/features/playground/page/components/MultiWindowPlayground.tsxindex 50e018d7ed..cf107e833b 100644--- a/web/src/features/playground/page/components/MultiWindowPlayground.tsx+++ b/web/src/features/playground/page/components/MultiWindowPlayground.tsx@@ -14,6 +14,7 @@ import {TooltipProvider,TooltipTrigger,} from "@/src/components/ui/tooltip";+import { useIsMobile } from "@/src/hooks/use-mobile";/*** MultiWindowPlayground Component@@ -49,6 +50,7 @@ export default function MultiWindowPlayground({}: MultiWindowPlaygroundProps) {const containerRef = useRef<HTMLDivElement>(null);const prevWindowCountRef = useRef(windowState.windowIds.length);+ const isMobile = useIsMobile();/*** Calculate responsive window width based on screen size and window count@@ -99,48 +101,38 @@ export default function MultiWindowPlayground({if (!firstWindowId) return null;return (- <>- {/* Mobile layout: single window only - visible below md breakpoint */}- <div className="block h-full p-4 md:hidden">- <PlaygroundProvider windowId={firstWindowId}>- <PlaygroundWindowContent- windowId={firstWindowId}- onRemove={onRemoveWindow}- onCopy={handleCopyWindow}- canRemove={false}- isMobile={true}- />- </PlaygroundProvider>- </div>-- {/* 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",- gridAutoFlow: "column",- gridAutoColumns: windowWidth,- gap: "1rem",- padding: "1rem",- scrollBehavior: "smooth",- }}- >- {windowState.windowIds.map((windowId) => (- <PlaygroundProvider key={windowId} windowId={windowId}>+ <div+ ref={containerRef}+ className="flex h-full flex-1 overflow-x-auto md:grid"+ style={{+ gridAutoFlow: "column",+ gridAutoColumns: windowWidth,+ gap: "1rem",+ padding: "1rem",+ scrollBehavior: "smooth",+ }}+ >+ {windowState.windowIds.map((windowId, index) => {+ const isFirstWindow = index === 0;++ return (+ <div+ key={windowId}+ className={isFirstWindow ? "flex-1" : "hidden md:block"}+ >+ <PlaygroundProvider windowId={windowId}><PlaygroundWindowContentwindowId={windowId}onRemove={onRemoveWindow}onCopy={handleCopyWindow}canRemove={windowState.windowIds.length > 1}- isMobile={false}+ isMobile={isMobile}/></PlaygroundProvider>- ))}- </div>- </div>- </>+ </div>+ );+ })}+ </div>);}@@ -158,7 +150,6 @@ function PlaygroundWindowContent({onRemove: (windowId: string) => void;onCopy: (windowId: string) => void;canRemove: boolean;- windowCount?: number;isMobile?: boolean;}) {const playgroundContext = usePlaygroundContext();diff --git a/web/src/features/playground/page/context/index.tsx b/web/src/features/playground/page/context/index.tsxindex 7c3218bffd..9b16643372 100644--- a/web/src/features/playground/page/context/index.tsx+++ b/web/src/features/playground/page/context/index.tsx@@ -519,7 +519,8 @@ export const PlaygroundProvider: React.FC<PlaygroundProviderProps> = ({if (!cacheLoaded) return;// Don't save empty initial state to avoid overwriting valid cache- if (messages.length > 0 && modelParams.provider.value) {+ // Save if we have messages - provider selection is optional+ if (messages.length > 0) {setPlaygroundCache({messages,modelParams,