From 77c7a1bb2b9823dcbf5a969df095bc46d5782162 Mon Sep 17 00:00:00 2001 From: Guilhem Lemouel Date: Mon, 25 May 2026 18:22:56 +0200 Subject: [PATCH] feat(script-editor): wire initialTestPanelCollapsed through ScriptBuilder MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `initialTestPanelCollapsed` prop was already declared on `ScriptBuilderProps` (used by the session preview to start the editor with the run/test pane closed) but never destructured in `ScriptBuilder.svelte`, so the value silently dropped on the floor and the test pane always opened. - `ScriptBuilder.svelte` — destructure the prop and forward it to ``. - `ScriptEditor.svelte` — accept the prop and seed `rawTestPanelSize` to 0 when true, while keeping `storedTestPanelSize` at the default 30 so the user's first toggle expands the pane to a sensible width rather than 0. Regular `/scripts/edit/...` doesn't pass the prop → default `false` → panel still opens by default. --- frontend/src/lib/components/ScriptBuilder.svelte | 4 +++- frontend/src/lib/components/ScriptEditor.svelte | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/frontend/src/lib/components/ScriptBuilder.svelte b/frontend/src/lib/components/ScriptBuilder.svelte index 710ce9bd5d..36a4987e72 100644 --- a/frontend/src/lib/components/ScriptBuilder.svelte +++ b/frontend/src/lib/components/ScriptBuilder.svelte @@ -134,7 +134,8 @@ onSaveDraftError, onSaveDraft, onNavigate, - disableAi + disableAi, + initialTestPanelCollapsed = false }: ScriptBuilderProps = $props() export function getInitialAndModifiedValues(): SavedAndModifiedValue { @@ -2091,6 +2092,7 @@ bind:assets={script.assets} bind:modules={script.modules} enablePreprocessorSnippet + {initialTestPanelCollapsed} /> {:else} diff --git a/frontend/src/lib/components/ScriptEditor.svelte b/frontend/src/lib/components/ScriptEditor.svelte index 7e8269913d..5d657a4cc5 100644 --- a/frontend/src/lib/components/ScriptEditor.svelte +++ b/frontend/src/lib/components/ScriptEditor.svelte @@ -159,6 +159,11 @@ modules?: { [key: string]: ScriptModule } | null editorBarRight?: import('svelte').Snippet enablePreprocessorSnippet?: boolean + // When true the right-hand test/run pane mounts collapsed. The user + // can still expand it via `toggleTestPanel`. Defaults to false so the + // regular /scripts/edit route keeps its current open-by-default UX; + // the session preview opts in to save vertical real estate. + initialTestPanelCollapsed?: boolean } let { @@ -192,7 +197,8 @@ assets = $bindable(), modules = $bindable(undefined), editorBarRight, - enablePreprocessorSnippet = false + enablePreprocessorSnippet = false, + initialTestPanelCollapsed = false }: Props = $props() let initialArgs = structuredClone($state.snapshot(args)) @@ -1359,8 +1365,11 @@ // dynamic minimum below — so when the editor shrinks, the displayed test // pane grows to honor the new minimum without needing an effect. The code // pane's size is purely derived from it (100 - test). - let rawTestPanelSize = $state(30) - let storedTestPanelSize = untrack(() => rawTestPanelSize) + // `initialTestPanelCollapsed` seeds the raw value at 0 (collapsed) while + // keeping the "remembered" size at 30, so the user's first toggle expands + // the pane to a sensible width rather than 0. + let rawTestPanelSize = $state(untrack(() => (initialTestPanelCollapsed ? 0 : 30))) + let storedTestPanelSize = 30 const testPanelSize = $derived( rawTestPanelSize === 0 ? 0 : Math.max(rawTestPanelSize, testPaneMinPercent) )