🪢 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(trace): reopen peek nav panel on toggle at narrow widths (LFE-10547) (#14601)
Nikita Kabardin19c78de2f9ba
diff --git a/web/src/components/trace/components/_layout/TraceLayoutDesktop.tsx b/web/src/components/trace/components/_layout/TraceLayoutDesktop.tsxindex f4d3c1c648..2ddddcbe08 100644--- a/web/src/components/trace/components/_layout/TraceLayoutDesktop.tsx+++ b/web/src/components/trace/components/_layout/TraceLayoutDesktop.tsx@@ -27,6 +27,18 @@ const RESIZABLE_PANEL_HANDLE_ID = "trace-layout-handle";const RESIZABLE_PANEL_NAVIGATION_ID = "trace-layout-panel-navigation";const RESIZABLE_PANEL_PREVIEW_ID = "trace-layout-panel-preview";+// Min widths of the two collapsible panels (kept here so the Panel props and the+// toggle logic below can't drift apart). In a narrow peek the container can be+// too small to satisfy BOTH mins at once: react-resizable-panels' constraint+// solver then refuses to grow one panel past the other's min and the layout is+// left unchanged — which made expand() a silent no-op (LFE-10547). When that's+// the case we collapse the opposite panel first so the one being opened has room.+const NAVIGATION_PANEL_MIN_PX = 260;+const DETAIL_PANEL_MIN_PX = 360;+// Small slack so we don't fight the solver on layouts that only just fit.+const BOTH_PANELS_FIT_MIN_PX =+ NAVIGATION_PANEL_MIN_PX + DETAIL_PANEL_MIN_PX + 8;+// Context for sharing panel state with compound componentsinterface TraceLayoutDesktopContext {isNavigationPanelCollapsed: boolean;@@ -81,10 +93,35 @@ export function TraceLayoutDesktop({ children }: { children: ReactNode }) {// Detail (info/preview) panel collapse state + control.const detailPanelRef = usePanelRef();const [isDetailPanelCollapsed, setIsDetailPanelCollapsed] = useState(false);++ // Total width of the panel group, summed from both panels' current pixel+ // sizes (the imperative handle has no group-size getter). Either ref alone+ // covers the group: a collapsed panel still reports its 40px rail. 0 if the+ // refs aren't mounted yet — callers treat that as "can't tell, don't gate".+ const getGroupWidthPx = () => {+ const nav = panelRef.current?.getSize().inPixels ?? 0;+ const detail = detailPanelRef.current?.getSize().inPixels ?? 0;+ return nav + detail;+ };+ // True when the container is too narrow to hold both panels at their mins, so+ // opening one requires the other to yield (collapse) first.+ const bothPanelsFit = () => {+ const width = getGroupWidthPx();+ return width === 0 || width >= BOTH_PANELS_FIT_MIN_PX;+ };+// Guarded so it's a no-op (not a resize) when already open — safe to call on// every row click, which is how re-selecting the same node reopens it.const expandDetailPanel = () => {- if (detailPanelRef.current?.isCollapsed()) detailPanelRef.current.expand();+ if (!detailPanelRef.current?.isCollapsed()) return;+ // Narrow peek: both mins can't coexist, so the solver would refuse to grow+ // the detail panel and expand() would no-op. Collapse the nav panel first+ // so the detail panel has room (LFE-10547).+ if (!bothPanelsFit() && !panelRef.current?.isCollapsed()) {+ panelRef.current?.collapse();+ setIsNavigationPanelCollapsed(true);+ }+ detailPanelRef.current.expand();};// Selecting another node (timeline/tree) while the detail panel is collapsed@@ -117,6 +154,13 @@ export function TraceLayoutDesktop({ children }: { children: ReactNode }) {if (!panelRef.current) return;if (panelRef.current.isCollapsed()) {+ // Narrow peek: both mins can't coexist, so the solver would refuse to grow+ // the nav panel and expand() would silently no-op (the reported bug). Make+ // the detail panel yield first so the nav panel has room (LFE-10547).+ if (!bothPanelsFit() && !detailPanelRef.current?.isCollapsed()) {+ detailPanelRef.current?.collapse();+ setIsDetailPanelCollapsed(true);+ }panelRef.current.expand();} else {panelRef.current.collapse();@@ -189,7 +233,7 @@ TraceLayoutDesktop.NavigationPanel = function Navigation({panelRef={panelRef}collapsible={true}collapsedSize="40px"- minSize="260px"+ minSize={`${NAVIGATION_PANEL_MIN_PX}px`}defaultSize="60%"onResize={() => {setIsNavigationPanelCollapsed(panelRef.current?.isCollapsed() ?? false);@@ -238,7 +282,7 @@ TraceLayoutDesktop.DetailPanel = function Detail({defaultSize="40%"collapsible={true}collapsedSize="40px"- minSize="360px"+ minSize={`${DETAIL_PANEL_MIN_PX}px`}onResize={() => {setIsDetailPanelCollapsed(detailPanelRef.current?.isCollapsed() ?? false,