🪢 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(support-sidebar): prevent rerender of main content on-open of sidebar (#10351)
Marc Klingenc54ec81f2149
diff --git a/web/src/components/layouts/layout.tsx b/web/src/components/layouts/layout.tsxindex 17588179dd..fafaed8ff1 100644--- a/web/src/components/layouts/layout.tsx+++ b/web/src/components/layouts/layout.tsx@@ -1,5 +1,11 @@import { type Route } from "@/src/components/layouts/routes";-import { type PropsWithChildren, useEffect, useState } from "react";+import {+ type PropsWithChildren,+ useEffect,+ useLayoutEffect,+ useRef,+ useState,+} from "react";import { useRouter } from "next/router";import { getSession, signOut, useSession } from "next-auth/react";import Head from "next/head";@@ -22,6 +28,7 @@ import {ResizableHandle,ResizablePanel,ResizablePanelGroup,+ type ImperativePanelHandle,} from "@/src/components/ui/resizable";import {PaymentBanner,@@ -376,6 +383,25 @@ export function ResizableContent({ children }: PropsWithChildren) {const { open, setOpen } = useSupportDrawer();const isDesktop = useMediaQuery({ query: "(min-width: 768px)" });+ // 👉 DESKTOP: Always render ResizablePanelGroup to prevent remounting children+ // Use refs to programmatically control panel sizes when drawer opens/closes+ const drawerPanelRef = useRef<ImperativePanelHandle>(null);+ const mainPanelRef = useRef<ImperativePanelHandle>(null);++ useLayoutEffect(() => {+ if (!isDesktop) return;++ if (open) {+ // Open drawer: resize main to 70%, drawer to 30%+ drawerPanelRef.current?.resize(30);+ mainPanelRef.current?.resize(70);+ } else {+ // Close drawer: resize main to 100%, drawer to 0%+ drawerPanelRef.current?.resize(0);+ mainPanelRef.current?.resize(100);+ }+ }, [open, isDesktop]);+if (!isDesktop) {return (<>@@ -408,21 +434,10 @@ export function ResizableContent({ children }: PropsWithChildren) {);}- // 👉 DESKTOP: if drawer isn't open, render only the main content (like before)- if (isDesktop && !open) {- return (- <main className="h-full flex-1" style={{ overscrollBehaviorY: "none" }}>- {children}- </main>- );- }-- const mainDefault = 70;- const drawerDefault = 30;-+ // 👉 DESKTOP: Always render ResizablePanelGroup to prevent remounting childrenreturn (<ResizablePanelGroup direction="horizontal" className="flex h-full w-full">- <ResizablePanel defaultSize={mainDefault} minSize={30}>+ <ResizablePanel ref={mainPanelRef} defaultSize={100} minSize={30}><mainclassName="relative h-full w-full overflow-scroll"style={{ overscrollBehaviorY: "none" }}@@ -430,9 +445,16 @@ export function ResizableContent({ children }: PropsWithChildren) {{children}</main></ResizablePanel>- <ResizableHandle withHandle />- <ResizablePanel defaultSize={drawerDefault} minSize={20} maxSize={60}>- <SupportDrawer />+ {open && <ResizableHandle withHandle />}+ <ResizablePanel+ ref={drawerPanelRef}+ defaultSize={0}+ minSize={0}+ maxSize={60}+ collapsible={true}+ collapsedSize={0}+ >+ {open && <SupportDrawer />}</ResizablePanel></ResizablePanelGroup>);