diff --git a/frontend/src/lib/components/copilot/chat/AIChatDisplay.svelte b/frontend/src/lib/components/copilot/chat/AIChatDisplay.svelte index e851bba857..0f2ad2f9f6 100644 --- a/frontend/src/lib/components/copilot/chat/AIChatDisplay.svelte +++ b/frontend/src/lib/components/copilot/chat/AIChatDisplay.svelte @@ -590,8 +590,7 @@ let composerEl: HTMLDivElement | undefined = $state() let composerOpened = $state(false) // Anything the user has started (text, an attachment) or is in the middle of (they opened it - // and have not left) keeps it open, and so does a workspace small enough that the composer is - // the page's main way in. + // and have not left) keeps it open, and so does a host that has it rest open. // Until the input is bound, the draft it starts with is the one it is seeded with: reading // it as empty collapses a remounted composer that holds text for a frame, and the box then // animates open as if the user had opened it. @@ -605,7 +604,7 @@ const composerCollapsed = $derived( starterLayout && !disabled && - !starter?.fewItems && + !starter?.restsOpen && !composerOpened && (aiChatInput ? aiChatInput.isDraftEmpty() : seededDraftEmpty) ) diff --git a/frontend/src/lib/components/copilot/chat/starter/starterPrompts.svelte.ts b/frontend/src/lib/components/copilot/chat/starter/starterPrompts.svelte.ts index a0d6120007..42d05c5efa 100644 --- a/frontend/src/lib/components/copilot/chat/starter/starterPrompts.svelte.ts +++ b/frontend/src/lib/components/copilot/chat/starter/starterPrompts.svelte.ts @@ -145,5 +145,5 @@ async function fetchItemCount(workspace: string): Promise { } /** What turns an empty chat into Home's block that starts a session, collapsed to one line at - * rest unless `fewItems`. */ -export type ChatStarter = { suggestions: ComposerSuggestion[]; fewItems: boolean } + * rest unless `restsOpen`. */ +export type ChatStarter = { suggestions: ComposerSuggestion[]; restsOpen: boolean } diff --git a/frontend/src/lib/components/home/HomeAIChat.svelte b/frontend/src/lib/components/home/HomeAIChat.svelte index 23cde9d1cf..df180bde55 100644 --- a/frontend/src/lib/components/home/HomeAIChat.svelte +++ b/frontend/src/lib/components/home/HomeAIChat.svelte @@ -112,6 +112,10 @@ ) 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(homeSidebarList.val === 'sessions')
@@ -141,7 +145,9 @@ (shownForRoot = $currentWorkspaceRootId)} {placeholder} - onSettled={(height) => rememberComposerHeight($workspaceStore ?? undefined, height)} + onSettled={(height) => + rememberComposerHeight($workspaceStore ?? undefined, sessionsListed, height)} + restsOpen={sessionsListed} /> {/key}
@@ -153,7 +159,7 @@ {#snippet placeholder()} - + {/snippet} diff --git a/frontend/src/lib/components/home/HomeComposerSkeleton.svelte b/frontend/src/lib/components/home/HomeComposerSkeleton.svelte index fee8991894..b75e1f654f 100644 --- a/frontend/src/lib/components/home/HomeComposerSkeleton.svelte +++ b/frontend/src/lib/components/home/HomeComposerSkeleton.svelte @@ -10,14 +10,30 @@ const SUGGESTIONS_ROW = 36 const OPEN_BOX_MIN = 78 - /** 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 + // 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 return Number.isFinite(stored) && stored > 0 ? stored : undefined } - export function rememberComposerHeight(workspace: string | undefined, height: number) { - if (workspace && height > 0) storeLocalSetting(HEIGHT_SETTING + workspace, String(height)) + export function rememberComposerHeight( + workspace: string | undefined, + sessionsListed: boolean, + height: number + ) { + if (workspace && height > 0) + storeLocalSetting(heightSetting(workspace, sessionsListed), String(height)) } diff --git a/frontend/src/lib/components/home/HomePreviewPanel.svelte b/frontend/src/lib/components/home/HomePreviewPanel.svelte new file mode 100644 index 0000000000..07609a7210 --- /dev/null +++ b/frontend/src/lib/components/home/HomePreviewPanel.svelte @@ -0,0 +1,177 @@ + + + + + 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 b81f848838..bc9bf65e09 100644 --- a/frontend/src/lib/components/home/HomeQuickAccess.svelte +++ b/frontend/src/lib/components/home/HomeQuickAccess.svelte @@ -10,6 +10,7 @@ GitFork, LayoutGrid, List, + MessagesSquare, Pen, Star as StarIcon, StarOff, @@ -39,6 +40,14 @@ import HomeSectionLabel from './HomeSectionLabel.svelte' import HomeSectionCount from './HomeSectionCount.svelte' import { QUICK_ACCESS_ROWS, homeQuickAccessSettings } from './homeQuickAccessSettings.svelte' + import { homeSidebarList } from '$lib/components/sessions/sidebarList.svelte' + import { + getEffectiveWorkspaceId, + homeDraft, + sessionLastActivityAt, + sessionState + } from '$lib/components/sessions/sessionState.svelte' + import { openSession } from '$lib/components/sessions/sessionSwitch.svelte' interface Props { workspace: string @@ -188,6 +197,25 @@ ] } + // 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(homeSidebarList.val === 'sessions') + 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( @@ -198,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 { showFavorites, showRecent } = homeQuickAccessSettings + const { showRecent } = homeQuickAccessSettings const starred = new Set( showFavorites ? favorites.map((f) => `${asStarKind(f.kind)}/${f.path}`) : [] ) @@ -217,7 +245,7 @@ let recentLimit = $state(RECENT_COUNT) let recentMore = $derived(Math.max(0, recentAll.length - recentLimit)) let entries: { item: Entry; favorite: boolean }[] = $derived([ - ...(homeQuickAccessSettings.showFavorites ? favorites : []).map((item) => ({ + ...(showFavorites ? favorites : []).map((item) => ({ item, favorite: true })), @@ -228,7 +256,8 @@ // (the only way to turn the list back on) would leave with it. let emptiedBySettings = $derived( entries.length === 0 && - ((!homeQuickAccessSettings.showFavorites && favorites.length > 0) || + recentSessions.length === 0 && + ((!showFavorites && favorites.length > 0) || (!homeQuickAccessSettings.showRecent && recentItems.list(workspace).length > 0)) ) @@ -251,7 +280,7 @@ } // Everything the lists hold, the recent ones not loaded yet included. - let favoriteCount = $derived(homeQuickAccessSettings.showFavorites ? favorites.length : 0) + let favoriteCount = $derived(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 @@ -259,7 +288,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(entries.length + (recentMore > 0 ? 1 : 0)) + let cellCount = $derived(recentSessions.length + 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))) @@ -403,11 +432,17 @@ -{#if favoriteManager.loadedFor === workspace && (entries.length > 0 || emptiedBySettings) && !hidden} +{#if favoriteManager.loadedFor === workspace && (entries.length > 0 || recentSessions.length > 0 || emptiedBySettings) && !hidden}
+ {#if recentSessions.length > 0} + Sessions + {/if} + {#if recentSessions.length > 0 && (favoriteCount > 0 || recentCount > 0)} + ยท + {/if} {#if favoriteCount > 0} Favorites {/if} @@ -422,9 +457,9 @@
- {#if entries.length === 0} + {#if entries.length === 0 && recentSessions.length === 0}

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

@@ -441,15 +476,37 @@ 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 entries as { item, favorite }, i (item.kind + '/' + item.path)} + {#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)}
{@render card(item, favorite)}
{/each} {#if recentMore > 0} {@const next = Math.min(recentMore, RECENT_COUNT)} - {@const at = cellPosition(entries.length)} + {@const at = cellPosition(recentSessions.length + entries.length)}