mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-11-20 16:09:26 +00:00
keep raw app sidebar and split layout per session full screen mode (#12129)
* feat: keep raw app sidebar and split layout per session full screen mode Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: keep caller-owned raw app layout on a narrow open Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: return the raw app panel to preview when leaving full screen Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat: open session full screen raw app unsplit by default Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
efcffb5117
commit
b5d40c3e31
@@ -28,6 +28,7 @@
|
||||
type RawAppRunSummary,
|
||||
type RawAppRunsProvider,
|
||||
type RawAppScreenshotRequester,
|
||||
type LayoutFlag,
|
||||
RAW_APP_SANDBOX_FLAGS,
|
||||
RAW_APP_PREVIEW_RELAY,
|
||||
rawAppStorageKey,
|
||||
@@ -141,14 +142,14 @@
|
||||
headBy?: string
|
||||
headAt?: string
|
||||
}) => void
|
||||
/** Initial collapsed state for the file/runnable sidebar. The user's
|
||||
* toggled preference is persisted under `sidebarStorageKey`; this prop
|
||||
* only seeds the very first open. */
|
||||
defaultSidebarCollapsed?: boolean
|
||||
/** localStorage key for the persisted sidebar state. Pass a different
|
||||
* key when the editor is rendered in a context that wants its own
|
||||
* preference. */
|
||||
sidebarStorageKey?: string
|
||||
/** Collapsed state of the file/runnable sidebar, for a context that keeps its
|
||||
* own preference; the editor follows it live when the caller swaps it and
|
||||
* never collapses it on a narrow open. Defaults to the full-page editor's
|
||||
* persisted preference. */
|
||||
sidebarCollapsedState?: LayoutFlag
|
||||
/** "Split with Preview" state, likewise owned by the caller and followed live.
|
||||
* Takes precedence over `defaultSplitWithPreview` and `compact`. */
|
||||
splitWithPreviewState?: LayoutFlag
|
||||
liveEditorDraftStoragePath?: string
|
||||
/** Indicator-only overrides forwarded to RawAppEditorHeader so the
|
||||
* sessions preview's AutosaveIndicator watches the session's
|
||||
@@ -239,8 +240,8 @@
|
||||
diffDrawer = undefined,
|
||||
onNavigate,
|
||||
onDeploy = undefined,
|
||||
defaultSidebarCollapsed = false,
|
||||
sidebarStorageKey = 'raw-app-sidebar-collapsed',
|
||||
sidebarCollapsedState = undefined,
|
||||
splitWithPreviewState = undefined,
|
||||
liveEditorDraftStoragePath = undefined,
|
||||
autosaveWorkspace = undefined,
|
||||
autosavePath = undefined,
|
||||
@@ -592,7 +593,17 @@ addEventListener('message', function (e) {
|
||||
let tabs: TabItem[] = $state([previewTab])
|
||||
let activeTabId: string = $state(PREVIEW_TAB_ID)
|
||||
// Seed from the prop, then own the state locally so the user's toggle
|
||||
// after mount sticks even if the prop reference changes.
|
||||
// after mount sticks even if the prop reference changes.
|
||||
let ownSplitWithPreview: boolean = $state(untrack(() => defaultSplitWithPreview && !compact))
|
||||
const ownSplitState: LayoutFlag = {
|
||||
get val() {
|
||||
return ownSplitWithPreview
|
||||
},
|
||||
set val(v) {
|
||||
ownSplitWithPreview = v
|
||||
}
|
||||
}
|
||||
const splitState = $derived(splitWithPreviewState ?? ownSplitState)
|
||||
const splitWithPreview = $derived(splitState.val)
|
||||
const activeTabKind = $derived<'file' | 'runnable' | 'preview'>(
|
||||
activeTabId === PREVIEW_TAB_ID
|
||||
@@ -819,21 +830,38 @@ addEventListener('message', function (e) {
|
||||
tabs = [...next, ...rest].filter((t) => t.id !== PREVIEW_TAB_ID).concat(previewTab)
|
||||
}
|
||||
|
||||
function toggleSplit() {
|
||||
if (splitWithPreview) {
|
||||
function toggleSplit() {
|
||||
splitState.val = !splitWithPreview
|
||||
}
|
||||
|
||||
// Entering split, whether toggled or by the caller swapping `splitWithPreviewState`:
|
||||
// Preview leaves the left bar, so give the left pane the last file/runnable tab,
|
||||
// or the default file when none is open (this also boots the UI Builder iframe).
|
||||
// A swap to an unsplit state lands on Preview, the single-pane view's default; a
|
||||
// manual unsplit keeps the tab the user is on.
|
||||
let lastSplitState = untrack(() => splitState)
|
||||
$effect(() => {
|
||||
const state = splitState
|
||||
const split = splitWithPreview
|
||||
const swapped = state !== lastSplitState
|
||||
lastSplitState = state
|
||||
if (!split) {
|
||||
if (swapped) untrack(() => select({ kind: 'preview' }, { force: true }))
|
||||
return
|
||||
}
|
||||
// single → split: if Preview is active, move focus to the last
|
||||
// file/runnable tab (it's leaving the left bar).
|
||||
}
|
||||
untrack(() => {
|
||||
if (activeTabId !== PREVIEW_TAB_ID) return
|
||||
const lastUserTab = tabs
|
||||
.slice()
|
||||
.reverse()
|
||||
.find((t) => t.id !== PREVIEW_TAB_ID)
|
||||
if (lastUserTab) activateTab(lastUserTab.id)
|
||||
}
|
||||
splitWithPreview = true
|
||||
.find((t) => t.id !== PREVIEW_TAB_ID)
|
||||
if (lastUserTab) {
|
||||
activateTab(lastUserTab.id)
|
||||
return
|
||||
}
|
||||
const def = pickDefaultFile(files)
|
||||
if (def) select({ kind: 'file', path: def })
|
||||
})
|
||||
})
|
||||
let yamlEditorDrawer: Drawer | undefined = $state(undefined)
|
||||
|
||||
@@ -844,21 +872,15 @@ addEventListener('message', function (e) {
|
||||
const SIDEBAR_PX_MIN = 160
|
||||
const sidebarMinPercent = $derived(paneMinPercent(splitContainerWidth, SIDEBAR_PX_MIN))
|
||||
const sidebarPanelSize = $derived(Math.max(rawSidebarSize, sidebarMinPercent))
|
||||
|
||||
// Persisted across opens. Seeded with `defaultSidebarCollapsed` only when
|
||||
// localStorage has no entry yet — callers (like the session preview pane)
|
||||
// can default the initial state without overriding a user who has already
|
||||
// expressed a preference.
|
||||
const sidebarCollapsed = useLocalStorageValue(
|
||||
sidebarStorageKey,
|
||||
defaultSidebarCollapsed,
|
||||
'boolean'
|
||||
|
||||
const ownSidebarCollapsed = useLocalStorageValue('raw-app-sidebar-collapsed', false, 'boolean')
|
||||
const sidebarCollapsed = $derived(sidebarCollapsedState ?? ownSidebarCollapsed)
|
||||
|
||||
// Auto-compact when the editor opens in a narrow container (e.g. the session
|
||||
// preview pane): drop to the merged single-pane view and retract the file
|
||||
// sidebar. Applied once, on the first measured layout — later resizes are the
|
||||
// user's call. The sidebar is set without persisting so a transient narrow
|
||||
|
||||
// Auto-compact when the editor opens in a narrow container: drop to the merged
|
||||
// single-pane view and retract the file sidebar. Applied once, on the first
|
||||
// measured layout — later resizes are the user's call. The sidebar is set without
|
||||
// persisting so a transient narrow open never overrides the saved preference.
|
||||
// Caller-owned layout state is left alone: its owner already picks a default
|
||||
// for the context it renders in.
|
||||
let rootWidth = $state(0)
|
||||
const NARROW_PX = 900
|
||||
@@ -867,8 +889,8 @@ addEventListener('message', function (e) {
|
||||
const w = rootWidth
|
||||
if (appliedNarrowDefault || w <= 0) return
|
||||
appliedNarrowDefault = true
|
||||
if (compact || w < NARROW_PX) {
|
||||
splitWithPreview = false
|
||||
if (compact || w < NARROW_PX) {
|
||||
if (!splitWithPreviewState) ownSplitWithPreview = false
|
||||
if (!sidebarCollapsedState) ownSidebarCollapsed.setWithoutPersist(true)
|
||||
}
|
||||
})
|
||||
@@ -2468,20 +2490,6 @@ addEventListener('message', function (e) {
|
||||
prevSelectedDocument = selectedDocument
|
||||
}
|
||||
})
|
||||
|
||||
// Open a default file on mount (boots the iframe in split mode and gives
|
||||
// the user something to edit on the left). When the caller seeded
|
||||
// `defaultSplitWithPreview=false` we instead want the Preview tab as the
|
||||
// only-visible / active surface, so skip the file-tab activation — the
|
||||
// iframe still boots via `populateFiles`/`setFilesInIframe` even without
|
||||
// a selected document.
|
||||
onMount(() => {
|
||||
if (!splitWithPreview) return
|
||||
if (tabs.length === 1) {
|
||||
const def = pickDefaultFile(files)
|
||||
if (def) select({ kind: 'file', path: def })
|
||||
}
|
||||
})
|
||||
|
||||
// Drop tabs whose file/runnable no longer exists. Enumerate the keys: reading
|
||||
// only the `$state` proxy misses a `delete runnables[id]`, which is exactly
|
||||
|
||||
@@ -121,6 +121,10 @@ export function canonicalRawAppDiffValue(source: Record<string, any>) {
|
||||
return stripRawAppDiffNoise(appSourceToDraftValue(source))
|
||||
}
|
||||
|
||||
/** A boolean editor-layout preference (file sidebar, split with preview), owned and
|
||||
* typically persisted by whoever passes it. */
|
||||
export type LayoutFlag = { val: boolean }
|
||||
|
||||
export type RawAppRuntimeLogLevel = 'log' | 'info' | 'warn' | 'error' | 'debug'
|
||||
export type RawAppRuntimeLogEntry = {
|
||||
level: RawAppRuntimeLogLevel
|
||||
|
||||
@@ -379,6 +379,7 @@
|
||||
{isActiveSession}
|
||||
{active}
|
||||
{newRawApp}
|
||||
{fullscreen}
|
||||
/>
|
||||
{/await}
|
||||
{/if}
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
} from '$lib/components/raw_apps/utils'
|
||||
import type { RawAppDomRequester } from '$lib/components/raw_apps/rawAppDom'
|
||||
import type { InspectorElementInfo } from '$lib/components/copilot/chat/app/core'
|
||||
import { useLocalStorageValue } from '$lib/svelte5Utils.svelte'
|
||||
|
||||
let {
|
||||
runtime,
|
||||
@@ -39,7 +40,8 @@
|
||||
onNavigate,
|
||||
isActiveSession = true,
|
||||
active = true,
|
||||
newRawApp = false
|
||||
newRawApp = false,
|
||||
fullscreen = false
|
||||
}: {
|
||||
runtime: SessionRuntime
|
||||
path: string
|
||||
@@ -52,8 +54,34 @@
|
||||
active?: boolean
|
||||
/** The tab was opened on an app the new-app builder just started. */
|
||||
newRawApp?: boolean
|
||||
/** Preview panel is in full screen. */
|
||||
fullscreen?: boolean
|
||||
} = $props()
|
||||
|
||||
// The side panel leaves little room for the file sidebar, full screen leaves plenty:
|
||||
// each keeps its own sidebar and split preferences, the sidebar open by default only
|
||||
// in full screen.
|
||||
const panelSidebarCollapsed = useLocalStorageValue(
|
||||
'raw-app-sidebar-collapsed-preview',
|
||||
true,
|
||||
'boolean'
|
||||
)
|
||||
const fullscreenSidebarCollapsed = useLocalStorageValue(
|
||||
'raw-app-sidebar-collapsed-preview-fullscreen',
|
||||
false,
|
||||
'boolean'
|
||||
)
|
||||
const panelSplitWithPreview = useLocalStorageValue(
|
||||
'raw-app-split-with-preview-preview',
|
||||
false,
|
||||
'boolean'
|
||||
)
|
||||
const fullscreenSplitWithPreview = useLocalStorageValue(
|
||||
'raw-app-split-with-preview-preview-fullscreen',
|
||||
false,
|
||||
'boolean'
|
||||
)
|
||||
|
||||
// This tab's own raw-app cell; each open app editor binds its own store.
|
||||
const cell = $derived(runtime.rawAppCell(path))
|
||||
|
||||
@@ -398,8 +426,8 @@
|
||||
condensedHeader={true}
|
||||
onResetToDeployed={reloadDeployed}
|
||||
onDeploy={(e) => runtime.itemDeployed(workspaceId, 'raw_app', path, e.path)}
|
||||
defaultSidebarCollapsed
|
||||
sidebarStorageKey="raw-app-sidebar-collapsed-preview"
|
||||
sidebarCollapsedState={fullscreen ? fullscreenSidebarCollapsed : panelSidebarCollapsed}
|
||||
splitWithPreviewState={fullscreen ? fullscreenSplitWithPreview : panelSplitWithPreview}
|
||||
defaultSplitWithPreview={false}
|
||||
onRuntimeLogRequester={registerRuntimeLogRequester}
|
||||
onRunsProvider={registerRunsProvider}
|
||||
|
||||
Reference in New Issue
Block a user