From 1407a3b01b57acf742717aca414dea63bb5c9e14 Mon Sep 17 00:00:00 2001 From: Miguel Angel Simon Sierra Date: Thu, 6 Aug 2026 23:31:11 -0700 Subject: [PATCH 1/2] fix(studio): keep the preview alive when the window is tight Studio stored its three panel dimensions as absolute pixels with hard floors and reconciled them against the window only at mount. The preview is the only flexible region, so it absorbed every squeeze. Measured before: at a 760px window the preview was 192px wide; at 560px it was 2px wide on a fresh load; dragging a 1100px window from 760 to 520 tall left it 47px tall, showing only the transport bar. Add fitPanels, one pure owner of the 'who yields' decision for both axes, and route every caller through it: - the preview gets a 360x200 floor before any panel gets its preference - panel caps are relative to the window, replacing a flat 600px inspector cap that was no constraint at all on a small screen - a window resize re-reconciles both axes instead of only mount - below 860 the sidebar renders as its existing rail, below 700 the inspector collapses too; thresholds are derived from the minimums Auto-collapse is derived render state, never a write to user intent: leftCollapsed stays in localStorage and rightCollapsed stays in the shareable URL untouched, and an explicit reopen overrides the rail so the Inspector button still works on a narrow window. Measured after: 760 -> 433px, 560 -> 516px, 1100x520 -> 497x196. Windows at or above 1280px are unchanged. --- packages/studio/src/App.tsx | 4 +- .../src/components/StudioLeftSidebar.tsx | 4 +- .../studio/src/components/nle/NLEContext.tsx | 23 ++- .../components/nle/TimelineResizeDivider.tsx | 15 +- .../src/contexts/PanelLayoutContext.tsx | 6 + .../studio/src/hooks/usePanelLayout.test.ts | 73 +++++++++ packages/studio/src/hooks/usePanelLayout.ts | 136 +++++++++++---- packages/studio/src/utils/fitPanels.test.ts | 155 ++++++++++++++++++ packages/studio/src/utils/fitPanels.ts | 130 +++++++++++++++ 9 files changed, 488 insertions(+), 58 deletions(-) create mode 100644 packages/studio/src/utils/fitPanels.test.ts create mode 100644 packages/studio/src/utils/fitPanels.ts diff --git a/packages/studio/src/App.tsx b/packages/studio/src/App.tsx index ffafec9084..520b4e8554 100644 --- a/packages/studio/src/App.tsx +++ b/packages/studio/src/App.tsx @@ -399,7 +399,7 @@ export function StudioApp() { } = useInspectorState( panelLayout.rightPanelTab, panelLayout.rightInspectorPanes, - panelLayout.rightCollapsed, + panelLayout.effectiveRightCollapsed, isPlaying, domEditSession.domEditSelection, gestureState === "recording", @@ -512,7 +512,7 @@ export function StudioApp() { /> } right={ - panelLayout.rightCollapsed ? null : ( + panelLayout.effectiveRightCollapsed ? null : (