From 589b982db97ce9dce9c44e8993a36de30d82cece Mon Sep 17 00:00:00 2001 From: Guilhem Lemouel Date: Mon, 26 Oct 2026 12:13:05 -0700 Subject: [PATCH] feat: keep home's layout on both sides of the sidebar switch Co-Authored-By: Claude Opus 5.5 (1M context) --- frontend/src/lib/assets/app.css | 62 +++++ .../lib/components/copilot/chat/AIChat.svelte | 4 + .../copilot/chat/AIChatDisplay.svelte | 8 + .../copilot/chat/starter/composerCollapse.ts | 5 +- .../src/lib/components/home/HomeAIChat.svelte | 28 +-- .../home/HomeComposerSkeleton.svelte | 26 +- .../components/home/HomePreviewPanel.svelte | 179 ------------- .../components/home/HomeQuickAccess.svelte | 132 +++++----- .../src/lib/components/home/ItemsList.svelte | 4 +- .../sessions/HomeSessionStarter.svelte | 12 +- .../sessions/homeComposerContext.svelte.ts | 11 +- .../sessions/homeSessionsTransition.svelte.ts | 30 +++ .../sessions/sessionState.svelte.ts | 5 +- .../sessions/sessionSwitch.svelte.ts | 15 +- .../components/sessions/sidebarList.svelte.ts | 10 +- .../src/routes/(root)/(logged)/+layout.svelte | 7 +- .../src/routes/(root)/(logged)/+page.svelte | 237 +++++++----------- 17 files changed, 315 insertions(+), 460 deletions(-) delete mode 100644 frontend/src/lib/components/home/HomePreviewPanel.svelte diff --git a/frontend/src/lib/assets/app.css b/frontend/src/lib/assets/app.css index e562e9027f..b833582069 100644 --- a/frontend/src/lib/assets/app.css +++ b/frontend/src/lib/assets/app.css @@ -443,3 +443,65 @@ input[type='time']::-webkit-calendar-picker-indicator { :root[data-home-sessions-transition='fade'] * { view-transition-name: none !important; } + +/* Home's Workspace ⇄ AI Sessions switch (swapHomeSide in homeSessionsTransition.svelte.ts). + Home is the same page beside either list, so only the sidebar's list moves. The page shows + its new state at once, live, which lets the composer's own opening or folding play; named, + the composer would be held to the size it had when the switch began. The list's name exists + only while the switch runs: carried at all times, a send's move to the session page would + animate it too. */ +:root[data-home-side-transition] .wm-vt-sidebar-list { + view-transition-name: home-sidebar-list; +} +:root[data-home-side-transition] [data-session-composer] { + view-transition-name: none !important; +} +:root[data-home-side-transition]::view-transition-old(root) { + display: none; +} +:root[data-home-side-transition]::view-transition-new(root) { + animation: none; +} +/* The list comes in from the side of the button pressed: AI Sessions is the right one. */ +:root[data-home-side-transition]::view-transition-old(home-sidebar-list), +:root[data-home-side-transition]::view-transition-new(home-sidebar-list) { + animation-duration: 260ms; + animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1); + animation-fill-mode: both; +} +:root[data-home-side-transition='sessions']::view-transition-old(home-sidebar-list) { + animation-name: wm-side-out-left; +} +:root[data-home-side-transition='sessions']::view-transition-new(home-sidebar-list) { + animation-name: wm-side-in-right; +} +:root[data-home-side-transition='workspace']::view-transition-old(home-sidebar-list) { + animation-name: wm-side-out-right; +} +:root[data-home-side-transition='workspace']::view-transition-new(home-sidebar-list) { + animation-name: wm-side-in-left; +} +@keyframes wm-side-out-left { + to { + opacity: 0; + transform: translateX(-28px); + } +} +@keyframes wm-side-in-right { + from { + opacity: 0; + transform: translateX(28px); + } +} +@keyframes wm-side-out-right { + to { + opacity: 0; + transform: translateX(28px); + } +} +@keyframes wm-side-in-left { + from { + opacity: 0; + transform: translateX(-28px); + } +} diff --git a/frontend/src/lib/components/copilot/chat/AIChat.svelte b/frontend/src/lib/components/copilot/chat/AIChat.svelte index 8d9f24df63..4852efa179 100644 --- a/frontend/src/lib/components/copilot/chat/AIChat.svelte +++ b/frontend/src/lib/components/copilot/chat/AIChat.svelte @@ -130,6 +130,10 @@ await aiChatDisplay?.attachContext(element) } + export function foldComposer() { + aiChatDisplay?.foldComposer() + } + const historyManager = aiChatManager.historyManager let aiChatDisplay: AIChatDisplay | undefined = $state(undefined) diff --git a/frontend/src/lib/components/copilot/chat/AIChatDisplay.svelte b/frontend/src/lib/components/copilot/chat/AIChatDisplay.svelte index cb17cc4388..7a5e1ac0b4 100644 --- a/frontend/src/lib/components/copilot/chat/AIChatDisplay.svelte +++ b/frontend/src/lib/components/copilot/chat/AIChatDisplay.svelte @@ -314,6 +314,14 @@ aiChatInput?.focusInput(selection) } + /** A starter composer back on one line, as a press outside it does: not while it holds a + * draft, which is never hidden. Takes the caret out, or the next keypress reopens it. */ + export function foldComposer() { + closeComposer() + if (!composerOpened && composerEl?.contains(document.activeElement)) + (document.activeElement as HTMLElement).blur() + } + /** Mention a workspace item in the draft, as "+" → Mention file does, and hand the user * the caret after it. Focusing is what opens Home's one-line composer. */ export async function attachContext(element: ContextElement) { diff --git a/frontend/src/lib/components/copilot/chat/starter/composerCollapse.ts b/frontend/src/lib/components/copilot/chat/starter/composerCollapse.ts index d21f04f1ba..5c082154fc 100644 --- a/frontend/src/lib/components/copilot/chat/starter/composerCollapse.ts +++ b/frontend/src/lib/components/copilot/chat/starter/composerCollapse.ts @@ -1,7 +1,10 @@ // The layers the composer's controls open render in portals under , outside the // composer's own element: DropdownV2 menus, melt popovers, and the settings modals. Not // `[data-menu]`: DropdownV2 puts it on its trigger too, and Home has triggers everywhere. -const OVERLAY = '[data-melt-dropdown-menu], [data-melt-popover-content], [role="dialog"]' +// `.wm-modal-form-popup` is Modal2's box, which carries no dialog role: without it a press +// inside Assistant settings folds the composer, and the modal goes with it. +const OVERLAY = + '[data-melt-dropdown-menu], [data-melt-popover-content], [role="dialog"], .wm-modal-form-popup' /** Whether a pointer-down outside the composer still leaves it open: it landed in a menu or * dialog, or one is open, and the press is closing it rather than leaving the composer. */ diff --git a/frontend/src/lib/components/home/HomeAIChat.svelte b/frontend/src/lib/components/home/HomeAIChat.svelte index bafbad135c..d0fe016745 100644 --- a/frontend/src/lib/components/home/HomeAIChat.svelte +++ b/frontend/src/lib/components/home/HomeAIChat.svelte @@ -17,7 +17,6 @@ import { logFeatureUsage } from '$lib/utils/featureUsage' import { hubBaseUrlStore, roleCapabilities, workspaceStore } from '$lib/stores' import { homeDraft, sessionState } from '../sessions/sessionState.svelte' - import { homeListsSessions, homeSidebarList } from '../sessions/sidebarList.svelte' import { currentWorkspaceRootId } from '../sessions/sessionScope.svelte' import { HOME_SHOW_HUB } from '$lib/consts' import { homeComposerPin, setHomeComposerRemoved } from './homeComposerPin.svelte' @@ -93,10 +92,6 @@ ) let hero = $derived(showComposer && !removed) - - // Beside the session list Home is the AI side's page: the composer rests open there. Beside - // the workspace nav it rests on one line. - const sessionsListed = $derived(homeListsSessions())
@@ -118,19 +113,14 @@ fork shares its parent's, and remounting for it only flashes the block. Also keyed on the asks for another draft (New session, a draft picked in the session list). --> {#if HomeSessionStarter && sessionState.hydrated} - -
(homeSidebarList.val = 'sessions')}> - {#key `${$currentWorkspaceRootId}:${homeDraft.requests}`} - - rememberComposerHeight($workspaceStore ?? undefined, sessionsListed, height)} - restsOpen={sessionsListed} - /> - {/key} -
+ + {#key `${$currentWorkspaceRootId}:${homeDraft.requests}`} + rememberComposerHeight($workspaceStore ?? undefined, height)} + /> + {/key} {:else} {@render placeholder()} {/if} @@ -139,7 +129,7 @@
{#snippet placeholder()} - + {/snippet} diff --git a/frontend/src/lib/components/home/HomeComposerSkeleton.svelte b/frontend/src/lib/components/home/HomeComposerSkeleton.svelte index ade4d6d76d..cd81077342 100644 --- a/frontend/src/lib/components/home/HomeComposerSkeleton.svelte +++ b/frontend/src/lib/components/home/HomeComposerSkeleton.svelte @@ -12,30 +12,14 @@ // the shortest open block: anything below it is one line, whatever the browser. const OPEN_MIN_HEIGHT = OPEN_BOX_MIN + BLOCK_MARGINS - // The composer rests open beside the session list and on one line beside the workspace nav, - // so each side of the sidebar switch keeps its own height. - function heightSetting(workspace: string, sessionsListed: boolean): string { - return HEIGHT_SETTING + workspace + (sessionsListed ? ':sessions' : '') - } - - /** The height Home's composer took when it last appeared in this workspace, beside this list. */ - export function composerHeight( - workspace: string | undefined, - sessionsListed: boolean - ): number | undefined { - const stored = workspace - ? Number(getLocalSetting(heightSetting(workspace, sessionsListed))) - : NaN + /** The height Home's composer took when it last appeared in this workspace. */ + export function composerHeight(workspace: string | undefined): number | undefined { + const stored = workspace ? Number(getLocalSetting(HEIGHT_SETTING + workspace)) : NaN return Number.isFinite(stored) && stored > 0 ? stored : undefined } - export function rememberComposerHeight( - workspace: string | undefined, - sessionsListed: boolean, - height: number - ) { - if (workspace && height > 0) - storeLocalSetting(heightSetting(workspace, sessionsListed), String(height)) + export function rememberComposerHeight(workspace: string | undefined, height: number) { + if (workspace && height > 0) storeLocalSetting(HEIGHT_SETTING + workspace, String(height)) } diff --git a/frontend/src/lib/components/home/HomePreviewPanel.svelte b/frontend/src/lib/components/home/HomePreviewPanel.svelte deleted file mode 100644 index bf8c1e63f4..0000000000 --- a/frontend/src/lib/components/home/HomePreviewPanel.svelte +++ /dev/null @@ -1,179 +0,0 @@ - - - - - shown && onPreviewFrameMessage(e, owner)} /> - -{#if owner && !shown} - -{/if} - -{#snippet openButton()} - -{/snippet} - -{#if owner && shown} -
-
-
-
- owner?.reorder(next.map((t) => t.id))} - size="sm" - class="session-preview-tab-strip h-8 border-b border-light bg-surface-secondary/50 pl-9 pr-2" - /> -
- {#if previewTabHostComponent.current} - {@const TabHost = previewTabHostComponent.current} - {#each owner.tabs as tab (tab.id)} - {@const active = tab.id === owner.activeId} - owner?.open({ type: 'item', item, mode: 'view' })} - onLoad={(frame) => observeLocation(tab, frame)} - /> - {/each} - {/if} - {#if owner.tabs.length === 0} -
- - No preview open - - Click a script, flow or app on Home to preview it here. - -
- {/if} -
-
-
-{/if} diff --git a/frontend/src/lib/components/home/HomeQuickAccess.svelte b/frontend/src/lib/components/home/HomeQuickAccess.svelte index 2971d8e42b..493b6a0e8f 100644 --- a/frontend/src/lib/components/home/HomeQuickAccess.svelte +++ b/frontend/src/lib/components/home/HomeQuickAccess.svelte @@ -40,7 +40,7 @@ import HomeSectionLabel from './HomeSectionLabel.svelte' import HomeSectionCount from './HomeSectionCount.svelte' import { QUICK_ACCESS_ROWS, homeQuickAccessSettings } from './homeQuickAccessSettings.svelte' - import { homeListsSessions } from '$lib/components/sessions/sidebarList.svelte' + import { sessionsSwitchShown } from '$lib/components/sessions/sidebarList.svelte' import { getEffectiveWorkspaceId, homeDraft, @@ -78,6 +78,24 @@ const RECENT_COUNT = 6 + // The workspace's last sessions, one row of them: sent ones and drafts with text, not Home's + // own draft, which is the composer above. The session list holds the rest. + const CONTINUE_COUNT = 3 + let continueSessions = $derived( + sessionsSwitchShown() + ? sessionState.sessions + .filter( + (s) => + !s.archived && + s.id !== homeDraft.id && + (!!s.workspace_id || !!s.draftPrompt?.trim()) && + getEffectiveWorkspaceId(s) === workspace + ) + .sort((a, b) => sessionLastActivityAt(b) - sessionLastActivityAt(a)) + .slice(0, CONTINUE_COUNT) + : [] + ) + // The way back from Hide from Home is in the header menu HomeAIChat adds, which Home mounts // only with the AI sessions beta on. Without it the section can't be hidden, and one hidden // earlier shows again. @@ -198,25 +216,6 @@ ] } - // Beside the session list the workspace's last sessions take the favorites' place: sent ones - // and drafts with text, not Home's own draft, which is the composer above. - const sessionsSide = $derived(homeListsSessions()) - const showFavorites = $derived(homeQuickAccessSettings.showFavorites && !sessionsSide) - let recentSessions = $derived( - sessionsSide - ? sessionState.sessions - .filter( - (s) => - !s.archived && - s.id !== homeDraft.id && - (!!s.workspace_id || !!s.draftPrompt?.trim()) && - getEffectiveWorkspaceId(s) === workspace - ) - .sort((a, b) => sessionLastActivityAt(b) - sessionLastActivityAt(a)) - .slice(0, RECENT_COUNT) - : [] - ) - // Assets are favorites too, but they open in the database manager rather than at a page, // so they stay in the sidebar's menu. let favorites: Entry[] = $derived( @@ -227,7 +226,7 @@ // Favorites first, then what was opened lately; a starred item is listed once, as a favorite. // With the favorites turned off, a starred item opened lately shows among the recent ones. let recentAll: Entry[] = $derived.by(() => { - const { showRecent } = homeQuickAccessSettings + const { showFavorites, showRecent } = homeQuickAccessSettings const starred = new Set( showFavorites ? favorites.map((f) => `${asStarKind(f.kind)}/${f.path}`) : [] ) @@ -246,7 +245,7 @@ let recentLimit = $state(RECENT_COUNT) let recentMore = $derived(Math.max(0, recentAll.length - recentLimit)) let entries: { item: Entry; favorite: boolean }[] = $derived([ - ...(showFavorites ? favorites : []).map((item) => ({ + ...(homeQuickAccessSettings.showFavorites ? favorites : []).map((item) => ({ item, favorite: true })), @@ -257,10 +256,12 @@ // (the only way to turn the list back on) would leave with it. let emptiedBySettings = $derived( entries.length === 0 && - recentSessions.length === 0 && - ((!showFavorites && favorites.length > 0) || + ((!homeQuickAccessSettings.showFavorites && favorites.length > 0) || (!homeQuickAccessSettings.showRecent && recentItems.list(workspace).length > 0)) ) + let favoritesShown = $derived( + favoriteManager.loadedFor === workspace && (entries.length > 0 || emptiedBySettings) && !hidden + ) // Read when the pointer reaches the time, so the tooltip is current however long the // page has been open. @@ -281,7 +282,7 @@ } // Everything the lists hold, the recent ones not loaded yet included. - let favoriteCount = $derived(showFavorites ? favorites.length : 0) + let favoriteCount = $derived(homeQuickAccessSettings.showFavorites ? favorites.length : 0) let recentCount = $derived(recentAll.length) // The cards fill one screen at a time, row by row, and the next screen scrolls in from the @@ -289,7 +290,7 @@ // whole columns. The column counts follow the `auto-cols` breakpoints below. let innerWidth = $state(1280) let cols = $derived(innerWidth >= 1024 ? 3 : innerWidth >= 640 ? 2 : 1) - let cellCount = $derived(recentSessions.length + entries.length + (recentMore > 0 ? 1 : 0)) + let cellCount = $derived(entries.length + (recentMore > 0 ? 1 : 0)) // Fewer rows when there aren't enough cards to fill a screen. let rows = $derived(Math.min(homeQuickAccessSettings.rows, Math.ceil(cellCount / cols))) @@ -431,19 +432,46 @@ {/snippet} +{#if continueSessions.length > 0} +
+ Continue last session + +
+{/if} + -{#if favoriteManager.loadedFor === workspace && (entries.length > 0 || recentSessions.length > 0 || emptiedBySettings) && !hidden} +{#if favoritesShown}
- {#if recentSessions.length > 0} - Sessions - {/if} - {#if recentSessions.length > 0 && (favoriteCount > 0 || recentCount > 0)} - · - {/if} {#if favoriteCount > 0} Favorites {/if} @@ -458,9 +486,9 @@
- {#if entries.length === 0 && recentSessions.length === 0} + {#if entries.length === 0}

- {showFavorites + {homeQuickAccessSettings.showFavorites ? 'No favorites yet. Star a script, flow or app to keep it here.' : 'Nothing opened lately in this browser.'}

@@ -477,43 +505,15 @@ class="grid gap-2 overflow-x-auto no-scrollbar px-px -mx-px auto-cols-[85%] sm:auto-cols-[calc((100%_-_0.5rem)/2)] lg:auto-cols-[calc((100%_-_1rem)/3)]" style:grid-template-rows="repeat({rows}, auto)" > - {#each recentSessions as session, i (session.id)} - {@const at = cellPosition(i)} - - {/each} {#each entries as { item, favorite }, i (item.kind + '/' + item.path)} - {@const at = cellPosition(recentSessions.length + i)} + {@const at = cellPosition(i)}
{@render card(item, favorite)}
{/each} {#if recentMore > 0} {@const next = Math.min(recentMore, RECENT_COUNT)} - {@const at = cellPosition(recentSessions.length + entries.length)} + {@const at = cellPosition(entries.length)}
+{/if} +{#if favoritesShown || continueSessions.length > 0} Workspace items {#if itemCount != undefined} diff --git a/frontend/src/lib/components/home/ItemsList.svelte b/frontend/src/lib/components/home/ItemsList.svelte index 4c7380d7f7..9832215405 100644 --- a/frontend/src/lib/components/home/ItemsList.svelte +++ b/frontend/src/lib/components/home/ItemsList.svelte @@ -68,7 +68,6 @@ import BulkActionsBar from './BulkActionsBar.svelte' import { HomeSelection, setHomeSelection, toBulkItem } from './homeSelection.svelte' import HomeQuickAccess from './HomeQuickAccess.svelte' - import { homeListsSessions } from '../sessions/sidebarList.svelte' const editRights = useEditRights() @@ -2014,8 +2013,7 @@ - - {#if canCreateHere && !homeListsSessions()} + {#if canCreateHere} diff --git a/frontend/src/lib/components/sessions/HomeSessionStarter.svelte b/frontend/src/lib/components/sessions/HomeSessionStarter.svelte index 8f8fb4bbcf..adfc37a850 100644 --- a/frontend/src/lib/components/sessions/HomeSessionStarter.svelte +++ b/frontend/src/lib/components/sessions/HomeSessionStarter.svelte @@ -29,17 +29,14 @@ // Picked once; the parent remounts this on a workspace family switch and whenever // another draft is asked for (New session, a draft picked in the session list). // `placeholder` stands in while the chat waits on its config; `onSettled` reports the height - // the chat first took, for the next placeholder to take. `restsOpen` keeps the composer open - // at rest whatever the workspace holds; a workspace small enough that the composer is the - // page's main way in keeps it open anyway. + // the chat first took, for the next placeholder to take. A workspace small enough that the + // composer is the page's main way in keeps it open at rest. let { placeholder, - onSettled, - restsOpen = false + onSettled }: { placeholder?: Snippet onSettled?: (height: number) => void - restsOpen?: boolean } = $props() const initialSession = homeStarterSession() @@ -92,6 +89,7 @@ await aiChat?.attachContext(element) }, focus: () => aiChat?.focusInput(), + fold: () => aiChat?.foldComposer(), runtime }) }) @@ -114,7 +112,7 @@ onAttachmentsChange={(a) => setSessionDraftAttachments(sessionId, a)} starter={{ suggestions: starterPrompts.suggestions, - restsOpen: restsOpen || starterPrompts.fewItems + restsOpen: starterPrompts.fewItems }} viewTransitionNames {onSent} diff --git a/frontend/src/lib/components/sessions/homeComposerContext.svelte.ts b/frontend/src/lib/components/sessions/homeComposerContext.svelte.ts index 5fc84724be..411b7e5ec0 100644 --- a/frontend/src/lib/components/sessions/homeComposerContext.svelte.ts +++ b/frontend/src/lib/components/sessions/homeComposerContext.svelte.ts @@ -26,7 +26,13 @@ export function itemContextElement(item: { return { type, path: item.path, title: item.path, summary: item.summary, deletable: true } } -type Registration = { attach: Attach; focus: () => void; runtime: SessionRuntime } +type Registration = { + attach: Attach + focus: () => void + /** Back to one line, unless it holds a draft, and out of the caret's way. */ + fold: () => void + runtime: SessionRuntime +} // Raw: the runtime is shared with the session page and must stay the same object there. let registered = $state.raw(undefined) @@ -51,6 +57,9 @@ export const homeComposerContext = { focus(): void { registered?.focus() }, + fold(): void { + registered?.fold() + }, /** Returns the unregister, which only clears its own registration: a remount registers * the new composer before the old one is destroyed. */ register(registration: Registration): () => void { diff --git a/frontend/src/lib/components/sessions/homeSessionsTransition.svelte.ts b/frontend/src/lib/components/sessions/homeSessionsTransition.svelte.ts index 2e7b62808c..a72e9ebde7 100644 --- a/frontend/src/lib/components/sessions/homeSessionsTransition.svelte.ts +++ b/frontend/src/lib/components/sessions/homeSessionsTransition.svelte.ts @@ -1,4 +1,5 @@ import type { OnNavigate } from '@sveltejs/kit' +import { tick } from 'svelte' // A send from Home keeps the composer in sight: the browser snapshots the page before and // after the navigation to the session the send started, and glides the element that carries @@ -50,3 +51,32 @@ export function homeSessionsTransition(navigation: OnNavigate): Promise | void transition.finished.then(done, done) }) } + +/** For the Workspace ⇄ AI Sessions switch on Home, which stays on the page: runs `swap` as a + * view transition in which the sidebar's list comes in from the side of the button pressed. + * The name and timing live in app.css, keyed on `data-home-side-transition`: set only for the + * switch, so a move to a session page does not pick the name up. + * + * Resolves once the swap is on the page and the click that asked for it has played out. */ +export function swapHomeSide(to: 'workspace' | 'sessions', swap: () => void): Promise { + if ( + typeof document === 'undefined' || + !document.startViewTransition || + window.matchMedia('(prefers-reduced-motion: reduce)').matches + ) { + swap() + return new Promise((resolve) => setTimeout(resolve, 0)) + } + const root = document.documentElement + root.dataset.homeSideTransition = to + const transition = document.startViewTransition(async () => { + swap() + await tick() + }) + const done = () => delete root.dataset.homeSideTransition + void transition.finished.then(done, done) + return transition.updateCallbackDone.then( + () => undefined, + () => undefined + ) +} diff --git a/frontend/src/lib/components/sessions/sessionState.svelte.ts b/frontend/src/lib/components/sessions/sessionState.svelte.ts index 1f643d0cc6..6df6946a64 100644 --- a/frontend/src/lib/components/sessions/sessionState.svelte.ts +++ b/frontend/src/lib/components/sessions/sessionState.svelte.ts @@ -1171,13 +1171,12 @@ function newTransientSession(): Session { /** Whether a session opens in Home's composer rather than on a page of its own: unsent, not * archived (its page holds the way back), and neither about an item (it carries preview tabs, - * which need the session page's panel), armed to send itself on arrival, nor already sending. - * Tabs opened from Home's own panel keep its draft there. */ + * which need the session page's panel), armed to send itself on arrival, nor already sending. */ export function opensOnHome(s: Session): boolean { return ( !s.workspace_id && !s.archived && - (!s.previewTabs?.length || s.id === homeDraft.id) && + !s.previewTabs?.length && !autoSendIsFresh(s) && !sendUnderWay(s.id) ) diff --git a/frontend/src/lib/components/sessions/sessionSwitch.svelte.ts b/frontend/src/lib/components/sessions/sessionSwitch.svelte.ts index fb44b4f932..4878f4e168 100644 --- a/frontend/src/lib/components/sessions/sessionSwitch.svelte.ts +++ b/frontend/src/lib/components/sessions/sessionSwitch.svelte.ts @@ -27,6 +27,7 @@ import { } from '../sidebar/workspaceSwitchUrl' import { pinHomeComposer } from '../home/homeComposerPin.svelte' import { homeComposerContext } from './homeComposerContext.svelte' +import { swapHomeSide } from './homeSessionsTransition.svelte' // Type-only: erased at compile time, so the component graph stays out of this // navigation seam (see the dynamic import in openEditorInSession). import type { OpenInSessionSource } from './OpenInSessionButton.svelte' @@ -64,13 +65,15 @@ export function noteArrival(url: URL): void { if (homeSidebarList.val === 'workspace') rememberWorkspacePage(url.pathname + url.search) } -/** The switch on Home, which belongs to both lists: it swaps the list and stays. */ +/** The switch on Home, which belongs to both lists: it swaps the list and stays. Home is the + * same page beside either; the switch only opens its composer, for AI Sessions, or folds it. + * Both after the click has played out, or the switch button it landed on takes focus back. */ export function swapHomeList(list: SidebarList, homeHref: string): void { - homeSidebarList.val = list - if (list === 'workspace') rememberWorkspacePage(homeHref) - // The AI side of Home is its composer: going there puts the caret in it. After the click - // has played out, or the switch button it landed on takes focus back. - else setTimeout(() => homeComposerContext.focus(), 0) + const swapped = swapHomeSide(list, () => (homeSidebarList.val = list)) + if (list === 'workspace') { + rememberWorkspacePage(homeHref) + void swapped.then(() => homeComposerContext.fold()) + } else void swapped.then(() => homeComposerContext.focus()) } // The session last opened, else the family's most recently used one. Scoped to the diff --git a/frontend/src/lib/components/sessions/sidebarList.svelte.ts b/frontend/src/lib/components/sessions/sidebarList.svelte.ts index 583775f5ea..2bb908b048 100644 --- a/frontend/src/lib/components/sessions/sidebarList.svelte.ts +++ b/frontend/src/lib/components/sessions/sidebarList.svelte.ts @@ -31,8 +31,7 @@ export function sessionsSwitchShown(): boolean { /** The list the sidebar shows while Home is open. Every other page decides its own (a * session's page lists sessions, any other page the workspace nav) and, on arrival, sets * this to it: Home sits above the switch and belongs to both, so it keeps the list you - * came from, until you go into its composer (HomeAIChat). Per browser, so a reload of Home - * keeps it too. */ + * came from until the switch changes it. Per browser, so a reload of Home keeps it too. */ export const homeSidebarList = useLocalStorageValue( 'windmill_sidebar_list', 'workspace', @@ -45,13 +44,6 @@ export function sidebarListFor(pathname: string): SidebarList { return pathname === '/' ? homeSidebarList.val : 'workspace' } -/** Whether Home is laid out for sessions: the session list is beside it. Where the sidebar - * offers none, Home is the workspace's whatever list it kept, or its creation menu and - * favorites would be gone with no switch to bring them back. */ -export function homeListsSessions(): boolean { - return homeSidebarList.val === 'sessions' && sessionsSwitchShown() -} - /** Turning AI Sessions back on asks to see them: Home, with the session list beside it. */ export function activateAiSessions(): void { homeSidebarList.val = 'sessions' diff --git a/frontend/src/routes/(root)/(logged)/+layout.svelte b/frontend/src/routes/(root)/(logged)/+layout.svelte index e272a21de9..3f983a8398 100644 --- a/frontend/src/routes/(root)/(logged)/+layout.svelte +++ b/frontend/src/routes/(root)/(logged)/+layout.svelte @@ -324,8 +324,7 @@ // The /sessions page has its own gate for direct navigation. const globalAiEnabled = isGlobalAiEnabled() // A workspace that hid the assistant (`ai_config.copilot_disabled`) loses both entry - // points: the Workspace ⇄ AI Sessions switch and the legacy Ask-AI button. Home lays - // itself out by the same gate (`homeListsSessions`). + // points: the Workspace ⇄ AI Sessions switch and the legacy Ask-AI button. const switchRowShown = $derived(sessionsSwitchShown()) // The page picks the list: a session's page lists sessions and a workspace page shows // the workspace nav. Home keeps the list you came from. Where the switch is hidden, so @@ -1280,7 +1279,7 @@ outside this layout, and their shortcut must reopen the URL that is their creden {#if sidebarListsSessions} -
+
{@render settingsMenu(collapsed)} @@ -1289,7 +1288,7 @@ outside this layout, and their shortcut must reopen the URL that is their creden overflow fade hint. The three sections (Runs + Favorites + Search / workspace items / instance settings) are spaced by the scroll area's gap rather than each scrolling on its own. --> - +
{@render quickLinks(collapsed)} diff --git a/frontend/src/routes/(root)/(logged)/+page.svelte b/frontend/src/routes/(root)/(logged)/+page.svelte index d0c750736d..d23f92de96 100644 --- a/frontend/src/routes/(root)/(logged)/+page.svelte +++ b/frontend/src/routes/(root)/(logged)/+page.svelte @@ -1,5 +1,5 @@ @@ -329,119 +290,111 @@ (showCreateButtons = v)} /> {/snippet} -
-
- - + - - -
- - {#if isGlobalAiEnabled()} - - {/if} + {#if isGlobalAiEnabled()} + + {/if} - {#if $workspaceStore == 'admins'} - - The Admins workspace is for admins only and contains scripts whose purpose is to manage - your Windmill instance, such as keeping resource types up to date. - -
- {/if} + {#if $workspaceStore == 'admins'} + + The Admins workspace is for admins only and contains scripts whose purpose is to manage your + Windmill instance, such as keeping resource types up to date. + +
+ {/if} - {#if tab == 'hub'} -
-
- {#snippet toggleKinds()} - { - setQuery('kind', v, window.location.hash) - }} - noWFull - > - {#snippet children({ item })} - - - - {/snippet} - - - {/snippet} + {#if tab == 'hub'} +
+
+ {#snippet toggleKinds()} + { + setQuery('kind', v, window.location.hash) + }} + noWFull + > + {#snippet children({ item })} + + + + {/snippet} + + + {/snippet} - {#if subtab == 'script'} - viewCode(e.detail)} - > - {#snippet children()} - {@render toggleKinds?.()} - {/snippet} - - {:else if subtab == 'flow'} - viewFlow(e.detail)} - > - {#snippet children()} - {@render toggleKinds?.()} - {/snippet} - - {:else if subtab == 'app'} - viewApp(e.detail)} - > - {#snippet children()} - {@render toggleKinds?.()} - {/snippet} - - {/if} -
+ {#if subtab == 'script'} + viewCode(e.detail)} + > + {#snippet children()} + {@render toggleKinds?.()} + {/snippet} + + {:else if subtab == 'flow'} + viewFlow(e.detail)} + > + {#snippet children()} + {@render toggleKinds?.()} + {/snippet} + + {:else if subtab == 'app'} + viewApp(e.detail)} + > + {#snippet children()} + {@render toggleKinds?.()} + {/snippet} + + {/if}
- {/if} -
- - {#if tab == 'workspace'} - +
{/if}
- {#if homeListsSessions()} - + + {#if tab == 'workspace'} + {/if}