feat: list ai sessions inline in the sidebar and regroup its pages (#12103)

* fix: stop the breadcrumb sliding when switching sessions

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat: make the sidebar switch a button row that only swaps the list

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat: list ai sessions inline in the workspace sidebar

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat: keep home's composer open while switching workspace

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat: data stores in the data menu and a customizable sidebar

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat: move folders and groups to settings and add a data section to the sidebar

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat: space the sidebar's sections apart and give its rows a little more height

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore: remove the session mode switch the sidebar no longer renders

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: follow same-page chat links, restore new session on the rail and list ai chats once

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: follow a chat link whenever the panel shows another conversation

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat: let the sidebar's session list fill the space above its pinned rows

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor: drop the group data pages option and keep data as a sidebar section

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: keep home's composer open only in an empty workspace

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat: tell admins without ai credentials they can also hide ai sessions

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: fold home's composer on an outside click while the sidebar is hidden

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat: scroll the sidebar as one list and pin the session edit actions

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:
Guilhem
2026-10-30 12:34:55 +01:00
committed by GitHub
co-authored by Claude Opus 5.5
parent 75b2b214a1
commit f917d7bdd2
49 changed files with 910 additions and 682 deletions
+19 -62
View File
@@ -423,6 +423,25 @@ input[type='time']::-webkit-calendar-picker-indicator {
outline: 2px solid rgb(var(--color-border-accent, 59 130 246));
}
/* Home's composer, pointed at by New session (AIChatDisplay's flashComposer): its box's outline
lights up in the accent color and fades, as a setting does when the settings search lands on
it. Scoped to the flash, so the box carries no outline otherwise. */
[data-composer-flash] [data-composer-box] {
outline: 2px solid transparent;
outline-offset: 1px;
animation: wm-composer-flash 0.8s ease-in;
}
@keyframes wm-composer-flash {
from {
outline-color: rgb(var(--color-border-accent, 59 130 246));
}
}
@media (prefers-reduced-motion: reduce) {
[data-composer-flash] [data-composer-box] {
animation: none;
}
}
.svelte-flow__edges {
z-index: -10;
}
@@ -443,65 +462,3 @@ 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);
}
}
@@ -35,6 +35,7 @@
import Badge from './common/badge/Badge.svelte'
import InputError from './InputError.svelte'
import Popover from './meltComponents/Popover.svelte'
import GroupsPageLink from './GroupsPageLink.svelte'
import { deepEqual } from 'fast-equals'
import {
folderPermissionDiff,
@@ -652,6 +653,9 @@
<div class="flex flex-col w-72 p-4 gap-4">
<span class="text-sm leading-6 font-semibold">Add a member</span>
<Label label="User or group">
{#snippet action()}
<GroupsPageLink />
{/snippet}
<div class="flex items-center gap-1">
<!-- The toggle group is `w-full`; unwrapped it takes half the row. -->
<div>
@@ -0,0 +1,13 @@
<script lang="ts">
import { ExternalLink } from 'lucide-svelte'
// A new tab: every group picker sits in a drawer or modal whose unsaved form a navigation would drop.
</script>
<a
href="/groups"
target="_blank"
class="inline-flex items-center gap-1 text-2xs font-normal whitespace-nowrap"
>
Manage groups <ExternalLink size={12} />
</a>
@@ -284,35 +284,39 @@ not this component) — so the lead can run the whole line.
<ChevronDown size={ICON} class="flex-shrink-0" />
</span>
{:else}
<Menubar>
{#snippet children({ createMenu })}
<Menu
bind:this={workspaceMenu}
{createMenu}
usePointerDownOutside
placement="bottom-start"
class="h-auto"
contentStyle="margin-left: {-nameWidth}px"
>
{#snippet triggr({ trigger })}
<MeltButton
meltElement={trigger}
class="flex items-center h-9 px-1.5 rounded text-tertiary hover:bg-surface-hover hover:text-primary transition-colors"
title="Switch workspace"
>
<ChevronDown size={ICON} class="flex-shrink-0" />
</MeltButton>
{/snippet}
{#snippet children({ item: menuItem })}
<WorkspacePickerBody
item={menuItem}
collapseFamilies={actingWorkspaceId != undefined}
closeMenu={() => workspaceMenu?.close()}
/>
{/snippet}
</Menu>
{/snippet}
</Menubar>
<!-- `data-works-with-composer`: switching workspace leaves Home's composer open; the menu is
portaled away from here, so WorkspacePickerBody carries the marker too. -->
<span data-works-with-composer class="contents">
<Menubar>
{#snippet children({ createMenu })}
<Menu
bind:this={workspaceMenu}
{createMenu}
usePointerDownOutside
placement="bottom-start"
class="h-auto"
contentStyle="margin-left: {-nameWidth}px"
>
{#snippet triggr({ trigger })}
<MeltButton
meltElement={trigger}
class="flex items-center h-9 px-1.5 rounded text-tertiary hover:bg-surface-hover hover:text-primary transition-colors"
title="Switch workspace"
>
<ChevronDown size={ICON} class="flex-shrink-0" />
</MeltButton>
{/snippet}
{#snippet children({ item: menuItem })}
<WorkspacePickerBody
item={menuItem}
collapseFamilies={actingWorkspaceId != undefined}
closeMenu={() => workspaceMenu?.close()}
/>
{/snippet}
</Menu>
{/snippet}
</Menubar>
</span>
{/if}
{/snippet}
@@ -22,6 +22,7 @@
import Toggle from './Toggle.svelte'
import { Trash } from 'lucide-svelte'
import { DEMO_RESTRICTION_HINT, isDemoWorkspaceRestricted } from '$lib/cloud'
import GroupsPageLink from './GroupsPageLink.svelte'
import { useScheduleLock, useTriggerLock } from '$lib/operatorWriteRights'
import {
useOperatingWorkspace,
@@ -337,6 +338,9 @@
on:click={() => addAcl(newOwner, write)}>Add member</Button
>
</div>
<div class="flex justify-end pt-1">
<GroupsPageLink />
</div>
{/if}
{#if acls?.length > 0}
<TableCustom>
@@ -89,7 +89,7 @@
: $aiUserDisabled
? 'Windmill AI is disabled in your account settings'
: isAdmin
? 'Enable Windmill AI in your [workspace settings](/workspace_settings?tab=ai) to use this chat'
? 'Enable Windmill AI in your [workspace settings](/workspace_settings?tab=ai) to use this chat, or hide AI sessions there'
: 'Ask an admin to enable Windmill AI in this workspace to use this chat'
: aiChatManager.mode === AIMode.SCRIPT &&
aiChatManager.scriptEditorOptions?.lang &&
@@ -126,12 +126,12 @@
aiChatDisplay?.focusInput(selection)
}
export async function attachContext(element: import('./context').ContextElement) {
await aiChatDisplay?.attachContext(element)
export function flashComposer() {
aiChatDisplay?.flashComposer()
}
export function foldComposer() {
aiChatDisplay?.foldComposer()
export async function attachContext(element: import('./context').ContextElement) {
await aiChatDisplay?.attachContext(element)
}
const historyManager = aiChatManager.historyManager
@@ -78,7 +78,7 @@
import ComposerSuggestions from './starter/ComposerSuggestions.svelte'
import type { DraftAttachments } from './messageDraft.svelte'
import type { ChatStarter } from './starter/starterPrompts.svelte'
import { isComposerOverlay } from './starter/composerCollapse'
import { asksForComposer, isComposerOverlay } from './starter/composerCollapse'
import { smoothHeight } from './starter/smoothHeight'
const MAX_YOLO_TOOLTIP_TOOLS = 8
@@ -316,14 +316,6 @@
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) {
@@ -634,7 +626,18 @@
}
function onComposerPointerDown(e: PointerEvent) {
if (!starterLayout || !composerOpened || composerEl?.contains(e.target as Node)) return
if (!isComposerOverlay(e.target)) closeComposer()
if (!isComposerOverlay(e.target) && !asksForComposer(e.target)) closeComposer()
}
// While the box plays its accent outline (app.css, `data-composer-flash`).
let flashing = $state(false)
/** Points the eye at a composer the user was sent to without it moving: its box's outline
* lights up in the accent color and fades. */
export function flashComposer() {
// Off for a frame first, so a flash asked for while one plays starts over.
flashing = false
requestAnimationFrame(() => (flashing = true))
}
// Home's composer is one block of the page and takes the page's column as it is.
@@ -1017,13 +1020,20 @@ the panel, or the Escape-to-stop focus check would wrongly reject them. -->
<!-- The focus and key handlers take events bubbling from the field inside, which is the
interactive element; the group itself is never focused. -->
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
<!-- `data-composer-open`: while the reader is in Home's composer, Home keeps it at the top
and quiets its cards. -->
<div
data-session-composer
data-composer-open={starterLayout && composerOpened ? '' : undefined}
data-composer-flash={flashing ? '' : undefined}
role="group"
aria-label="Message composer"
bind:this={composerEl}
class="relative {columnClass} pb-2"
style:view-transition-name={viewTransitionNames ? 'composer' : undefined}
onanimationend={(e) => {
if (e.animationName === 'wm-composer-flash') flashing = false
}}
onfocusin={(e) => {
if (starterLayout && e.target instanceof HTMLTextAreaElement) composerOpened = true
}}
@@ -813,6 +813,7 @@
<!-- The box that opens a session grows and shrinks between its one-line and full shapes. -->
<div
data-composer-box
class={twMerge(composerBoxClass(disabled), hero && HERO_BOX_CLASS)}
use:smoothHeight={{ enabled: hero, key: oneLine }}
>
@@ -857,7 +858,7 @@
bind:this={textarea}
onkeydown={handleKeyDown}
bind:value
use:autosize={hero && !oneLine ? { maxHeight: 160, minHeight: 56 } : { maxHeight: '40vh' }}
use:autosize={hero && !oneLine ? { maxHeight: 160, minHeight: 80 } : { maxHeight: '40vh' }}
rows={1}
oninput={handleInput}
onpaste={handlePaste}
@@ -23,8 +23,11 @@ export function composerBoxClass(disabled: boolean = false): string {
}
/** Added to a usable box that opens a session (Home, an empty session). Focus shows as the
* base box's border colour alone: the brand has no focus ring. */
export const HERO_BOX_CLASS = 'rounded-[10px]'
* base box's border colour alone: the brand has no focus ring. On Home, an open composer
* floats over the lists scrolling under it, so it takes the brand's elevation for moving
* elements. */
export const HERO_BOX_CLASS =
'rounded-[10px] transition-[border-color,box-shadow] group-has-[[data-composer-open]]/home:shadow-md'
/** Applied to the field inside the box; without it the field draws a second border. */
export const COMPOSER_FIELD_RESET =
@@ -10,5 +10,17 @@ const OVERLAY =
* dialog, or one is open, and the press is closing it rather than leaving the composer. */
export function isComposerOverlay(target: EventTarget | null): boolean {
if (target instanceof Element && target.closest(OVERLAY)) return true
return document.querySelector(OVERLAY) !== null
// An inert one is closed but kept mounted: the hidden sidebar's floating card is a dialog.
return [...document.querySelectorAll(OVERLAY)].some((el) => !el.closest('[inert]'))
}
/** Whether a pointer-down outside the composer leaves it open: it is on a control that brings
* the user to it (`data-asks-for-composer`, New session), where folding it on the way in would
* collapse it and open it again under the user's eyes, or on what the user works in alongside
* it (`data-works-with-composer`, Home's lists), where a click adds an item to it. */
export function asksForComposer(target: EventTarget | null): boolean {
return (
target instanceof Element &&
target.closest('[data-asks-for-composer], [data-works-with-composer]') !== null
)
}
@@ -99,11 +99,11 @@ export class StarterPrompts {
return composerSuggestions(signals, builds ? role : { ...role, operator: true })
})
/** Whether the workspace holds fewer than `FEW_ITEMS`, below which Home's composer rests
* open as the page's main way in; undefined until known. */
get fewItems(): boolean | undefined {
/** Whether the workspace holds no item the reader can list, where Home's composer rests
* open as the page's only way in; undefined until known. */
get empty(): boolean | undefined {
const count = this.#currentSignals?.itemCount
return count === undefined ? undefined : count < FEW_ITEMS
return count === undefined ? undefined : count === 0
}
}
@@ -83,6 +83,7 @@
useOperatingWorkspaceHref
} from '$lib/components/operatingWorkspace.svelte'
import FlowChat from '$lib/components/flows/conversations/FlowChat.svelte'
import { page } from '$app/state'
import { slide } from 'svelte/transition'
import { twMerge } from 'tailwind-merge'
import CiTestResults from '$lib/components/CiTestResults.svelte'
@@ -857,6 +858,7 @@
flowModules={flow?.value?.modules}
wideLayout
frame="none"
openConversation={page.url.searchParams.get('conversation') ?? undefined}
/>
{:else}
{@const hasSchema =
@@ -71,6 +71,8 @@
view?: boolean
/** Opens the agent's configuration, offered beside the model it runs with. */
onOpenConfig?: () => void
/** A chat conversation to show once the chat is up, as a link to it names one. */
openConversation?: string
/** A view's form mode: the run form, drawn by the page. Kept out of this component because
* the flow editor reaches it, and the run form reads the navigation workspace. */
viewForm?: import('svelte').Snippet<
@@ -95,6 +97,7 @@
isNew = false,
view = false,
onOpenConfig = undefined,
openConversation = undefined,
viewForm = undefined
}: Props = $props()
@@ -726,6 +729,7 @@
inputSchema={AGENT_CHAT_SCHEMA}
flowModules={chatModules}
composerSettings={onOpenConfig ? configButton : undefined}
{openConversation}
/>
</div>
</div>
@@ -12,6 +12,7 @@
import FlowConversationsSidebar from './FlowConversationsSidebar.svelte'
import FlowChatInterface from './FlowChatInterface.svelte'
import { getContext, untrack } from 'svelte'
import { afterNavigate } from '$app/navigation'
import type { FlowEditorContext } from '../types'
import { ApiError, type FlowModule } from '$lib/gen'
import { FlowChatPool, type FlowChatPoolState } from './flowChatPool'
@@ -63,6 +64,8 @@
subject?: 'flow' | 'agent'
/** The host's own controls, after the model's in the composer's footer. */
composerSettings?: import('svelte').Snippet
/** A conversation to show once the chat is up, as a link to it names one. */
openConversation?: string
}
let {
@@ -78,7 +81,8 @@
frame = 'top',
conversationKind = 'deployed',
subject = 'flow',
composerSettings = undefined
composerSettings = undefined,
openConversation = undefined
}: Props = $props()
const flowEditorContext = getContext<FlowEditorContext>('FlowEditorContext')
@@ -164,6 +168,10 @@
}
})
const unsubscribePool = createdPool.subscribe((s) => (poolState = s))
// Untracked: a later change of the prop must not rebuild every chat of the flow; the
// navigation below follows it instead.
const linked = untrack(() => openConversation)
if (linked) createdPool.select(linked)
listChat = createdList
pool = createdPool
return () => {
@@ -174,6 +182,16 @@
}
})
// A link to another chat of this flow changes only the query, so the page is not remounted
// and the pool stays: it is shown here. Compared with what the panel shows, not with the
// link last followed: picking a chat in the panel's own sidebar leaves the query as it was,
// and the reader can still link back to it.
afterNavigate(() => {
const linked = openConversation
if (!linked || !pool || linked === poolState?.selectedId) return
pool.select(linked)
})
// The panel on screen. Every other panel the pool holds stays mounted behind it.
const shownKey = $derived(poolState?.shownKey)
@@ -13,6 +13,11 @@ export function agentChatPath(agentPath: string): string {
return `${agentPath}.chat`
}
/** The agent a conversation's path files it under, or undefined for a flow's own chat. */
export function agentOfChatPath(chatPath: string): string | undefined {
return chatPath.endsWith('.chat') ? chatPath.slice(0, -'.chat'.length) : undefined
}
/** The id of the one step a saved agent's run is made of, as the server names it too: job-read
* scoping and the run's agent detection match on it, so it is only ever relabeled for display. */
export const AGENT_STEP_ID = '__wm_agent_root'
@@ -113,6 +113,11 @@
// kept static so tailwind doesn't purge the badge tones
const badgeAdvanced = 'bg-gray-100 text-gray-600 dark:bg-gray-700 dark:text-gray-300'
// While Home's composer is open (`data-composer-open`) the button looks like the default
// variant: that state lives in the DOM, not in a prop. The border is an inset ring so the
// button keeps its width.
const QUIET_AS_DEFAULT =
'group-has-[[data-composer-open]]/home:bg-transparent group-has-[[data-composer-open]]/home:hover:bg-surface-hover group-has-[[data-composer-open]]/home:text-primary group-has-[[data-composer-open]]/home:ring-1 group-has-[[data-composer-open]]/home:ring-inset group-has-[[data-composer-open]]/home:ring-border-light'
const badgeLegacy = 'bg-amber-100 text-amber-700 dark:bg-amber-900/40 dark:text-amber-300'
const badgeAlpha = 'bg-emerald-100 text-emerald-700 dark:bg-emerald-900/40 dark:text-emerald-300'
const badgeRecommended = 'bg-blue-100 text-blue-700 dark:bg-blue-900/40 dark:text-blue-300'
@@ -535,6 +540,7 @@
aiDescription="Create a new script, flow or app"
unifiedSize="md"
variant="accent"
btnClasses={QUIET_AS_DEFAULT}
startIcon={{ icon: Plus }}
endIcon={{ icon: ChevronDown }}
bind:element={triggerEl}
@@ -113,8 +113,6 @@
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}
<!-- Home is the same page beside either sidebar list. The switch only opens the
composer (AI Sessions) or folds it (Workspace); a focus moves nothing. -->
{#key `${$currentWorkspaceRootId}:${homeDraft.requests}`}
<HomeSessionStarter
{placeholder}
@@ -335,7 +335,7 @@
{#snippet card(item: Entry, favorite: boolean)}
<div
class="group flex items-center gap-1 rounded-md border border-light bg-surface-tertiary hover:bg-surface-hover transition-colors min-w-0"
class="group flex items-center gap-1 rounded-md border border-light bg-surface-tertiary hover:bg-surface-hover transition-colors min-w-0 group-has-[[data-composer-open]]/home:border-transparent group-has-[[data-composer-open]]/home:bg-transparent group-has-[[data-composer-open]]/home:hover:bg-surface-hover"
>
<a
href={getFavoriteHref(item.path, item.kind)}
@@ -405,7 +405,7 @@
landing in front of them would push every card over. -->
{#if favoriteManager.loadedFor === workspace && (entries.length > 0 || emptiedBySettings) && !hidden}
<!-- 30px under the cards: the gap from the composer down to this section's heading text. -->
<section class="flex flex-col gap-2 px-4 sm:px-0 pb-[30px]">
<section data-works-with-composer class="flex flex-col gap-2 px-4 sm:px-0 pb-[30px]">
<div class="flex items-center gap-1 -my-1">
<HomeSectionLabel>
{#if favoriteCount > 0}
@@ -1549,7 +1549,10 @@
// button asynchronously after the menu closes. Without overriding it, pressing
// an arrow key would re-open / re-highlight the workspace picker instead of
// moving the flat list's selection. Run several times to win the focus race.
// Never over Home's composer: New session in another workspace switches it too, and asks
// for the caret there.
const focusSearch = () => {
if (document.activeElement?.closest('[data-session-composer]')) return
const el = document.getElementById('home-search-input') as HTMLInputElement | null
el?.focus()
}
@@ -1932,10 +1935,19 @@
{/if}
<!-- The items section, one card: its controls, its filters and its rows. No `overflow-hidden`
on it: the page scrolls, and that would stop the controls sticking. -->
<div class="flex flex-col bg-surface-tertiary border border-border-light rounded-lg">
<!-- While Home's composer is open the card loses its border and background, and so do the
Favorites and Recent cards (HomeQuickAccess), the search field loses its background and New
looks like a default button (CreateActionsMenu), so the lists sit quietly under the
composer. The border turns transparent rather than going, so nothing moves. -->
<!-- `data-works-with-composer`: a press in the card leaves Home's composer open
(composerCollapse), since its menus add items to it. -->
<div
data-works-with-composer
class="flex flex-col bg-surface-tertiary border border-border-light rounded-lg transition-colors duration-300 group-has-[[data-composer-open]]/home:bg-transparent group-has-[[data-composer-open]]/home:border-transparent"
>
<div
bind:clientHeight={toolbarHeight}
class="sticky top-0 z-10 bg-surface-tertiary rounded-t-lg flex flex-wrap gap-2 items-center justify-between px-5 py-3 shrink-0"
class="sticky top-0 group-has-[[data-composer-open]]/home:top-[var(--home-pinned)] z-10 bg-surface-tertiary transition-colors duration-300 group-has-[[data-composer-open]]/home:bg-surface rounded-t-lg flex flex-wrap gap-2 items-center justify-between px-5 py-3 shrink-0"
use:triggerableByAI={{
id: 'home-items-list',
description: 'Lists of scripts, flows, and apps'
@@ -1957,6 +1969,7 @@
autofocus
hideDropdownOnFreeText
inputId="home-search-input"
class="group-has-[[data-composer-open]]/home:bg-transparent group-has-[[data-composer-open]]/home:[&>*]:!bg-transparent"
onDropdownVisibleChange={(v) => (searchbarDropdownOpen = v)}
/>
</div>
@@ -42,6 +42,12 @@
// the trigger to the content.
debounceDelay?: number
classNames?: string
/** Element to focus when the menu closes; defaults to the trigger, `null` leaves focus alone. */
closeFocus?:
| string
| HTMLElement
| ((trigger?: HTMLElement | null) => HTMLElement | null)
| null
triggr?: import('svelte').Snippet<[any]>
children?: import('svelte').Snippet<[any]>
class?: string
@@ -64,6 +70,7 @@
openOnHover = false,
debounceDelay = 150,
class: classNames = '',
closeFocus = undefined,
triggr,
children
}: Props = $props()
@@ -80,6 +87,7 @@
strategy: 'fixed'
},
loop: true,
closeFocus: untrack(() => closeFocus),
// Hover tooltips (e.g. NameIdTooltip on menu rows) portal to body, so a
// click inside one — like its copy button — registers as an outside click.
// Veto the close so interacting with a tooltip doesn't tear the menu down.
@@ -21,6 +21,7 @@
Code2Icon,
Database,
DollarSignIcon,
FolderOpenIcon,
HomeIcon,
LayoutDashboardIcon,
MailIcon,
@@ -29,6 +30,7 @@
Search,
SearchCode,
Unplug,
UsersIcon,
WandSparkles
} from 'lucide-svelte'
import Portal from '$lib/components/Portal.svelte'
@@ -216,6 +218,20 @@
icon: CalendarIcon,
disabled: false
},
{
search_id: 'nav:folders',
label: 'Go to Folders',
action: (newtab: boolean = false) => gotoPage('/folders', newtab),
icon: FolderOpenIcon,
disabled: !$roleCapabilities.visibility.folders
},
{
search_id: 'nav:groups',
label: 'Go to Groups',
action: (newtab: boolean = false) => gotoPage('/groups', newtab),
icon: UsersIcon,
disabled: !$roleCapabilities.visibility.groups
},
...switchModeItems,
{
search_id: 'nav:service_logs',
@@ -17,6 +17,7 @@
sessionPageHref,
sessionState,
setSessionDraftPrompt,
takeHomeDraftFlash,
takeHomeDraftFocus
} from './sessionState.svelte'
import { useWorkModeLock } from './workModeLock.svelte'
@@ -67,6 +68,7 @@
function bindChat(chat: AIChat | undefined) {
aiChat = chat
if (chat && takeHomeDraftFocus()) setTimeout(() => chat.focusInput(), 0)
if (chat && takeHomeDraftFlash()) setTimeout(() => chat.flashComposer(), 0)
}
let chatWrapper: HTMLDivElement | undefined = $state(undefined)
// A seeded draft holds the composer open, which is not the shape it rests in once the
@@ -85,11 +87,12 @@
// The rows' "Ask AI" lands here. Before the chat has mounted (its config still
// loading) there is nowhere to put the item, and the attach does nothing.
return homeComposerContext.register({
sessionId,
attach: async (element) => {
await aiChat?.attachContext(element)
},
focus: () => aiChat?.focusInput(),
fold: () => aiChat?.foldComposer(),
flash: () => aiChat?.flashComposer(),
runtime
})
})
@@ -109,7 +112,7 @@
state. Any loaded config will do, so a fork switch does not hide it while the fork's loads.
The item count decides whether the composer rests collapsed, so it waits for that too
rather than open and fold up a moment later. -->
{#if session && $copilotWorkspace !== undefined && starterPrompts.fewItems !== undefined}
{#if session && $copilotWorkspace !== undefined && starterPrompts.empty !== undefined}
<div bind:this={chatWrapper}>
<AIChat
bind:this={() => aiChat, bindChat}
@@ -122,7 +125,7 @@
onAttachmentsChange={(a) => setSessionDraftAttachments(sessionId, a)}
starter={{
suggestions: starterPrompts.suggestions,
restsOpen: starterPrompts.fewItems
restsOpen: starterPrompts.empty
}}
viewTransitionNames
{onSent}
@@ -1,65 +0,0 @@
<script lang="ts">
import { Building, MessagesSquare } from 'lucide-svelte'
import { page } from '$app/state'
import ToggleButtonGroup from '$lib/components/common/toggleButton-v2/ToggleButtonGroup.svelte'
import ToggleButton from '$lib/components/common/toggleButton-v2/ToggleButton.svelte'
import { resumeAiSessions, returnToWorkspace, swapHomeList } from './sessionSwitch.svelte'
import type { SidebarList } from './sidebarList.svelte'
let {
list,
isCollapsed = false,
// Fired right before the switch navigates. Lets a host (the mobile menu drawer)
// stay open across it, to show the list it switched to.
onToggle
}: { list: SidebarList; isCollapsed?: boolean; onToggle?: () => void } = $props()
// The group's highlighted side. Melt moves it on click, before the navigation that
// changes `list`, so it is pushed back to `list` once the click has played out: a
// navigation that did not happen (an editor refusing to be left) must not leave the
// other side lit.
let selected: string | string[] | null | undefined = $derived(list)
async function onSelected(next: SidebarList) {
if (next === list) return
if (page.url.pathname === '/') {
swapHomeList(next, page.url.pathname + page.url.search)
} else {
onToggle?.()
await (next === 'sessions' ? resumeAiSessions() : returnToWorkspace())
}
selected = list
}
</script>
<!-- Each ToggleButton renders inside a Tooltip wrapper, which is the actual flex
child of the group's track — so the buttons fill the rail width only if those
wrappers grow. `[&>*]:flex-1` makes every direct child split the track evenly. -->
<ToggleButtonGroup
bind:selected
{onSelected}
tabListClass={isCollapsed ? 'flex-col w-full [&>*]:w-full' : 'w-full [&>*]:flex-1'}
>
{#snippet children({ item })}
<ToggleButton
{item}
value="workspace"
icon={isCollapsed ? Building : undefined}
label="Workspace"
iconOnly={isCollapsed}
tooltip={isCollapsed ? 'Workspace' : undefined}
size="sm"
class="w-full justify-center whitespace-nowrap"
/>
<ToggleButton
{item}
value="sessions"
icon={isCollapsed ? MessagesSquare : undefined}
label="AI Sessions"
iconOnly={isCollapsed}
tooltip={isCollapsed ? 'AI Sessions (beta)' : undefined}
size="sm"
class="w-full justify-center whitespace-nowrap"
/>
{/snippet}
</ToggleButtonGroup>
@@ -2,6 +2,7 @@
import ConfirmationModal from '$lib/components/common/confirmationModal/ConfirmationModal.svelte'
import Checkbox from '$lib/components/common/checkbox/Checkbox.svelte'
import { Button } from '$lib/components/common'
import SidebarSectionHeader from '$lib/components/sidebar/SidebarSectionHeader.svelte'
import {
Archive,
ArchiveRestore,
@@ -23,6 +24,7 @@
import TextInput from '$lib/components/text_input/TextInput.svelte'
import { goto } from '$lib/navigation'
import { leaveForHome, openDraftOnHome, openNewSession } from './sessionSwitch.svelte'
import { homeComposerContext } from './homeComposerContext.svelte'
import { useLocalStorageValue } from '$lib/svelte5Utils.svelte'
import { slide } from 'svelte/transition'
import {
@@ -424,10 +426,14 @@
}
}
// Whatever page is on screen, a new session starts on Home: a session about an item
// is started from that item, by its Open in AI session button.
async function createAndOpen() {
await openNewSession()
// The rail menu hands focus back to its trigger once it has closed, after New session has
// focused Home's composer: the composer takes it back instead.
let newSessionFromRail = false
function railMenuCloseFocus(trigger?: HTMLElement | null): HTMLElement | null {
if (!newSessionFromRail) return trigger ?? null
newSessionFromRail = false
homeComposerContext.focus()
return null
}
// The `+` on a workspace group header: a new session in that group's workspace,
@@ -669,17 +675,9 @@
explanatory message, mirroring the sidebar AI chat. -->
{:else if isCollapsed}
<div class={embedded ? '' : 'px-2 pt-3 pb-2 border-b border-light'}>
<MenuButton
stopPropagationOnClick={true}
on:click={createAndOpen}
{isCollapsed}
icon={Plus}
label="New session"
class="!text-xs"
/>
<Menubar>
{#snippet children({ createMenu })}
<Menu {createMenu} usePointerDownOutside submenuSafe>
<Menu {createMenu} usePointerDownOutside submenuSafe closeFocus={railMenuCloseFocus}>
{#snippet triggr({ trigger })}
<div class="relative">
<MenuButton
@@ -701,8 +699,15 @@
{/snippet}
{#snippet children({ item, builders })}
<div class="divide-y min-w-48" role="none">
<div class="py-1" role="none">
<MenuItem class={menuItemBase} onClick={createAndOpen} {item}>
<div class="py-1" role="none" data-asks-for-composer>
<MenuItem
class={menuItemBase}
onClick={() => {
newSessionFromRail = true
void openNewSession()
}}
{item}
>
<Plus size={14} />
New session
</MenuItem>
@@ -782,8 +787,8 @@
? 'border-b border-light'
: ''}"
>
<!-- Selection mode reuses the New session row (same h-8 slot, same px-2) so
the list below it never moves. -->
<!-- Selection mode reuses the options row (same h-8 slot) so the list below it
never moves. -->
{#if selectionMode}
<div class="flex flex-row items-center gap-1.5 h-8 px-2">
<Checkbox
@@ -826,17 +831,7 @@
{GROUP_BY_OPTIONS.find((o) => o.value === groupBy.val)?.hint ?? ''}
</span>
{/snippet}
<div class="flex flex-row items-center gap-0.5 pr-0.5">
<div class="flex-1 min-w-0">
<MenuButton
stopPropagationOnClick={true}
on:click={createAndOpen}
isCollapsed={false}
icon={Plus}
label="New session"
class="!text-xs"
/>
</div>
{#snippet listOptions(size: 'sm' | 'md')}
<DropdownV2
fixedHeight={false}
placement="bottom-end"
@@ -884,7 +879,7 @@
{#snippet buttonReplacement()}
<Button
nonCaptureEvent
unifiedSize="md"
unifiedSize={size}
variant="subtle"
iconOnly
startIcon={{ icon: EllipsisVertical }}
@@ -894,41 +889,44 @@
/>
{/snippet}
</DropdownV2>
</div>
{/if}
{#if collapsible}
<!-- Only the collapsible sidebar section needs a title: it doubles as the
fold toggle. In the rail the list owns the pane, so the label is noise. -->
<div class="flex flex-row items-center pl-1 pr-0.5">
<button
type="button"
onclick={() => (sectionCollapsed.val = !sectionCollapsed.val)}
class="text-secondary text-[0.5rem] uppercase flex flex-row items-center gap-1 rounded px-1 -mx-1 py-0.5 hover:bg-surface-hover focus:outline-none"
aria-expanded={!sectionCollapsed.val}
{/snippet}
{#if collapsible}
<SidebarSectionHeader
title="AI sessions"
collapsed={sectionCollapsed.val}
onToggle={() => (sectionCollapsed.val = !sectionCollapsed.val)}
disabled={visibleSessions.length === 0}
>
AI sessions
{#if visibleSessions.length > 0}
{#if sectionCollapsed.val}
<ChevronRight size={10} />
{:else}
<ChevronDown size={10} />
{/if}
{/if}
</button>
</div>
{#snippet actions()}
{@render listOptions('sm')}
<Button
unifiedSize="sm"
variant="subtle"
iconOnly
startIcon={{ icon: Plus }}
title="New session"
aria-label="New session"
data-asks-for-composer
btnClasses="text-secondary"
onClick={() => openNewSession()}
/>
{/snippet}
</SidebarSectionHeader>
{:else}
<!-- Where the list owns the pane, a title would only repeat what the pane is. -->
<div class="flex flex-row items-center gap-0.5 h-8 pr-0.5 justify-end">
{@render listOptions('md')}
</div>
{/if}
{/if}
{#if !collapsible || !sectionCollapsed.val}
<div
bind:this={listRoot}
transition:slide={{ duration: 180 }}
class={twMerge(
'flex flex-col gap-0.5 overflow-y-auto',
'flex flex-col gap-0.5',
// Shift-clicking rows would otherwise paint a text selection across them.
selectionMode ? 'select-none' : '',
// In the rail the picker is the whole list and the rail scrolls;
// only cap height when it's one section among others (normal sidebar).
collapsible ? 'max-h-[40vh]' : ''
selectionMode ? 'select-none' : ''
)}
onkeydown={handleListKeydown}
role="listbox"
@@ -1172,7 +1170,7 @@
plain text, no workspace icon or chip. -->
<div
class={twMerge(
'group flex flex-row items-center gap-1 pl-1 pr-0.5 pt-2 pb-1 min-w-0',
'group flex flex-row items-center gap-1 pl-2 pr-0.5 pt-2 pb-1 min-w-0',
// Space groups apart so their boundaries read clearly.
groupIdx > 0 ? 'mt-4' : ''
)}
@@ -1198,6 +1196,7 @@
on:click={() => createAndOpenIn(groupWsId)}
title="New session in {group.label}"
aria-label="New session in {group.label}"
data-asks-for-composer
wrapperClasses="ml-auto shrink-0"
btnClasses="text-tertiary opacity-0 group-hover:opacity-100 focus-visible:opacity-100 transition-opacity"
/>
@@ -1211,7 +1210,11 @@
{/if}
</div>
{#if selectionMode}
<div class="flex flex-col gap-1 px-1 pt-1.5">
<!-- Pinned to the sidebar's bottom edge while the rows scroll under it; z-10 keeps it
above the sidebar's bottom fade. -->
<div
class="sticky bottom-0 z-10 flex flex-col gap-1 px-1 pt-1.5 pb-2 bg-[var(--sidebar-bg-light)] dark:bg-[var(--sidebar-bg-dark)]"
>
<Button
unifiedSize="xs"
variant="default"
@@ -27,10 +27,12 @@ export function itemContextElement(item: {
}
type Registration = {
/** The draft the composer shows. */
sessionId: string
attach: Attach
focus: () => void
/** Back to one line, unless it holds a draft, and out of the caret's way. */
fold: () => void
/** The box's accent outline, for a composer the user is sent to without it moving. */
flash: () => void
runtime: SessionRuntime
}
@@ -54,11 +56,15 @@ export const homeComposerContext = {
async attach(element: ContextElement): Promise<void> {
await registered?.attach(element)
},
/** Whether Home's composer is on screen with this draft. */
holds(sessionId: string): boolean {
return registered?.sessionId === sessionId
},
focus(): void {
registered?.focus()
},
fold(): void {
registered?.fold()
flash(): void {
registered?.flash()
},
/** Returns the unregister, which only clears its own registration: a remount registers
* the new composer before the old one is destroyed. */
@@ -1,5 +1,4 @@
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
@@ -51,32 +50,3 @@ export function homeSessionsTransition(navigation: OnNavigate): Promise<void> |
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<void> {
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
)
}
@@ -1040,10 +1040,16 @@ onUserChange(async (email, prevEmail) => {
// session open on the sessions page: which draft Home shows says nothing about which
// session the user last opened. `requests` counts asks to show another one, which
// remount Home's composer when Home is already on screen.
export const homeDraft = $state<{ id: string | undefined; requests: number; focus: boolean }>({
export const homeDraft = $state<{
id: string | undefined
requests: number
focus: boolean
flash: boolean
}>({
id: undefined,
requests: 0,
focus: false
focus: false,
flash: false
})
// Workspace switches do not reload or clear the active session. The sidebar
@@ -1086,10 +1092,12 @@ export function holdHomeDraft(id: string): void {
followHomeDraft()
}
/** Ask Home to show `id`, and whether its composer takes focus as it mounts. */
export function showOnHome(id: string, opts?: { focus?: boolean }): void {
/** Ask Home to show `id`, whether its composer takes focus as it mounts, and whether it then
* plays its accent outline. */
export function showOnHome(id: string, opts?: { focus?: boolean; flash?: boolean }): void {
homeDraft.id = id
homeDraft.focus = opts?.focus ?? false
homeDraft.flash = opts?.flash ?? false
homeDraft.requests++
}
@@ -1100,6 +1108,13 @@ export function takeHomeDraftFocus(): boolean {
return focus
}
/** Whether Home's composer should play its accent outline now that it is on screen. Read once. */
export function takeHomeDraftFlash(): boolean {
const flash = homeDraft.flash
homeDraft.flash = false
return flash
}
export function sessionPageHref(id: string): string {
return `/sessions?session=${encodeURIComponent(id)}`
}
@@ -21,14 +21,9 @@ import {
type SessionTarget
} from './sessionState.svelte'
import { sessionTargetHref, withPreviewParams } from './sessionMode.svelte'
import { homeSidebarList, type SidebarList } from './sidebarList.svelte'
import {
fixupUrlAfterWorkspaceSwitch,
hrefAfterWorkspaceSwitch
} from '../sidebar/workspaceSwitchUrl'
import { fixupUrlAfterWorkspaceSwitch } 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'
@@ -38,44 +33,16 @@ import { presetScopeFor } from '../copilot/chat/workingScope'
// `seedDomElement` rides only with `autoSend`: it is the chip of the prompt being sent.
type SeedOpts = { seedPrompt?: string; autoSend?: boolean; seedDomElement?: AppDomSelectorElement }
// The Workspace ⇄ AI Sessions switch moves between two places worked in side by side,
// and comes back to each where it was left. Plain module state: read only in click
// handlers, never rendered. A reload forgets both, and the switch then falls back to
// Home and to the family's most recently used session.
// The last page shown with the workspace nav beside it, Home included, as a pathname
// with its search, and the workspace it was shown in.
let workspacePage: { href: string; workspace: string | undefined } | undefined
// The session last opened, on its page or in Home's composer.
// The session last opened, on its page or in Home's composer. Plain module state: a
// reload forgets it, and the family's most recently used session stands in.
let lastSessionId: string | undefined
/** The page Workspace returns to. Called on every arrival with the workspace nav shown,
* and by an in-place URL rewrite the router doesn't report as a navigation. */
export function rememberWorkspacePage(href: string): void {
workspacePage = { href, workspace: get(workspaceStore) ?? undefined }
}
/** Where a navigation landed, for the switch to come back to. Landing anywhere but Home
* also sets the list Home will show. */
/** Where a navigation landed: a session's page records the session, for the sessions
* page to resume when it is opened without one. */
export function noteArrival(url: URL): void {
if (url.pathname.startsWith('/sessions')) {
homeSidebarList.val = 'sessions'
lastSessionId = url.searchParams.get('session') ?? lastSessionId
return
}
if (url.pathname !== '/') homeSidebarList.val = 'workspace'
if (homeSidebarList.val === 'workspace') rememberWorkspacePage(url.pathname + url.search)
}
/** 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 {
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
@@ -89,9 +56,10 @@ function resumableSession(): Session | undefined {
.sort((a, b) => sessionLastActivityAt(b) - sessionLastActivityAt(a))[0]
}
/** AI Sessions, from anywhere but Home: the session to resume on its page, or in Home's
* composer for an unsent draft, else a blank draft there. `replace` for the sessions
* page's own redirects, where Back must not return to the URL that bounced here. */
/** The sessions page opened on no session of this family: the session to resume on its
* page, or in Home's composer for an unsent draft, else a blank draft there. `replace` for
* the sessions page's own redirects, where Back must not return to the URL that bounced
* here. */
export async function resumeAiSessions(opts?: { replace?: boolean }): Promise<void> {
const session = resumableSession()
if (!session || opensOnHome(session)) {
@@ -102,44 +70,40 @@ export async function resumeAiSessions(opts?: { replace?: boolean }): Promise<vo
await goto(sessionPageHref(session.id), { replaceState: opts?.replace ?? false })
}
/** Workspace, from a session's page: the page it was left on, else Home. One left in
* another workspace than the header's is moved by the workspace picker's rule: restored
* as it was, its item could be missing here or its params switch the workspace back. */
export async function returnToWorkspace(): Promise<void> {
homeSidebarList.val = 'workspace'
const left = workspacePage
const ws = get(workspaceStore) ?? undefined
let href = left?.href ?? '/'
if (left && ws && left.workspace !== ws) href = hrefAfterWorkspaceSwitch(left.href, ws)
await goto(href)
}
// A plain session starts on Home, and an unsent draft is shown there rather than on a
// page of its own, with the session list beside it. Asking for one puts the composer
// back on Home if the reader had unpinned it: there is nowhere else to type it.
async function toHome(id: string, opts?: { replace?: boolean }): Promise<void> {
homeSidebarList.val = 'sessions'
// page of its own. Asking for one puts the composer back on Home if the reader had
// unpinned it: there is nowhere else to type it.
async function toHome(id: string, opts?: { replace?: boolean; flash?: boolean }): Promise<void> {
lastSessionId = id
showOnHome(id, { focus: true })
pinHomeComposer()
const onHome = typeof window !== 'undefined' && window.location.pathname === '/'
// The draft already on screen is focused where it is: rebuilding the composer would fold it
// to one line and open it again under the user's eyes.
if (onHome && homeComposerContext.holds(id)) {
homeComposerContext.focus()
if (opts?.flash) homeComposerContext.flash()
return
}
showOnHome(id, { focus: true, flash: opts?.flash })
// `goto` has no same-URL short-circuit, so navigating from Home would push a
// duplicate history entry; showOnHome already remounts the composer there.
if (typeof window !== 'undefined' && window.location.pathname === '/') return
if (onHome) return
await goto('/', { replaceState: opts?.replace ?? false })
}
/** New session: Home's composer, blank and focused. It acts on the header's workspace,
* switched to `workspaceId` first when given. A draft already typed stays in the list. */
/** New session: Home's composer, blank, focused and outlined for a moment. It acts on the
* header's workspace, switched to `workspaceId` first when given. A draft already typed stays
* in the list. */
export async function openNewSession(workspaceId?: string): Promise<void> {
// Home's current draft stays where it is: the switch below must not take it along.
homeDraft.id = undefined
if (workspaceId && workspaceId !== get(workspaceStore)) {
// Home's current draft stays where it is: the switch must not take it along.
homeDraft.id = undefined
syncWorkspaceTo(workspaceId)
// Home may be open already, under a URL naming the workspace just left: a reload would
// switch back to it and take the new draft along.
await fixupUrlAfterWorkspaceSwitch(workspaceId)
}
await toHome(blankHomeDraft().id)
await toHome(blankHomeDraft().id, { flash: true })
}
/** An unsent draft, opened in Home's composer. `replace` for a redirect off the sessions
@@ -4,7 +4,6 @@ import {
noteArrival,
openSourceInSession,
resumeAiSessions,
returnToWorkspace,
startSessionWithPrompt
} from './sessionSwitch.svelte'
import {
@@ -52,7 +51,7 @@ function withTwoFamilies(activeWorkspace: string): () => void {
}
}
describe('the sidebar switch comes back where each side was left', () => {
describe('the sessions page resumes the last session opened', () => {
beforeEach(() => {
vi.mocked(goto).mockClear()
})
@@ -87,7 +86,7 @@ describe('the sidebar switch comes back where each side was left', () => {
sessionState.sessions.push(
session({ id: 'sw-draft', pending_workspace_id: 'rootA', draftPrompt: 'half typed' })
)
// Switched from a workspace page, so Home is not already open.
// Not on Home already, so the resume navigates there.
vi.stubGlobal('window', { location: { pathname: '/runs' } })
try {
noteArrival(new URL('http://localhost/sessions?session=sw-draft'))
@@ -100,29 +99,6 @@ describe('the sidebar switch comes back where each side was left', () => {
restore()
}
})
it('returns to the workspace page left, moved by the picker’s rule after a switch', async () => {
const restore = withTwoFamilies('rootA')
try {
noteArrival(new URL('http://localhost/runs?workspace=rootA'))
// Home with the session list beside it is not a workspace page to come back to.
noteArrival(new URL('http://localhost/sessions?session=sw-any'))
noteArrival(new URL('http://localhost/'))
await returnToWorkspace()
expect(goto).toHaveBeenLastCalledWith('/runs?workspace=rootA')
workspaceStore.set('rootB')
await returnToWorkspace()
expect(goto).toHaveBeenLastCalledWith('/runs?workspace=rootB')
noteArrival(new URL('http://localhost/flows/edit/f/foo'))
workspaceStore.set('rootA')
await returnToWorkspace()
expect(goto).toHaveBeenLastCalledWith('/')
} finally {
restore()
}
})
})
describe('openSourceInSession', () => {
@@ -1,6 +1,5 @@
import { BROWSER } from 'esm-env'
import { fromStore } from 'svelte/store'
import { useLocalStorageValue } from '$lib/svelte5Utils.svelte'
import { roleCapabilities } from '$lib/stores'
import { copilotInfo } from '$lib/aiStore'
import {
@@ -9,17 +8,14 @@ import {
sessionsAllowedFor
} from '$lib/components/copilot/chat/global/gate'
export type SidebarList = 'workspace' | 'sessions'
const capabilities = fromStore(roleCapabilities)
const copilot = fromStore(copilotInfo)
// Listing sessions from within a session's preview frame would nest the whole experience.
const embedded = BROWSER && window.self !== window.top
/** Whether the sidebar offers AI sessions: the Workspace ⇄ AI Sessions switch and the session
* list. Not in a browser that opted out of them, for a role /sessions refuses, in a workspace
* that hid the assistant, nor inside a preview frame. */
export function sessionsSwitchShown(): boolean {
/** Whether the sidebar lists AI sessions. Not in a browser that opted out of them, for a role
* /sessions refuses, in a workspace that hid the assistant, nor inside a preview frame. */
export function sidebarSessionsShown(): boolean {
return (
!embedded &&
isGlobalAiEnabled() &&
@@ -28,24 +24,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 the switch changes it. Per browser, so a reload of Home keeps it too. */
export const homeSidebarList = useLocalStorageValue<SidebarList>(
'windmill_sidebar_list',
'workspace',
'string'
)
/** The list the sidebar shows beside `pathname`, where it offers sessions. */
export function sidebarListFor(pathname: string): SidebarList {
if (pathname.startsWith('/sessions')) return 'sessions'
return pathname === '/' ? homeSidebarList.val : 'workspace'
}
/** Turning AI Sessions back on asks to see them: Home, with the session list beside it. */
/** Turning AI Sessions back on: Home, with the sessions listed in the sidebar. */
export function activateAiSessions(): void {
homeSidebarList.val = 'sessions'
clearSessionsBetaOptOut('/')
}
@@ -44,7 +44,7 @@
import { truncate } from '$lib/utils'
import { onDestroy, untrack } from 'svelte'
import { goto } from '$lib/navigation'
import { ArrowRightLeft } from 'lucide-svelte'
import { ArrowRightLeft, ExternalLink } from 'lucide-svelte'
let offboardingUser: string | undefined = $state(undefined)
let offboardingReassignOnly = $state(false)
@@ -495,6 +495,14 @@
description="Add members to your workspace and manage their roles. You can also auto-add users to join your workspace."
link="https://www.windmill.dev/docs/core_concepts/roles_and_permissions"
/>
<!-- Someone looking for a way to share with several people at once lands here, on members, rather
than on the Groups page that does it. -->
<p class="-mt-4 mb-6 text-xs text-secondary">
Sharing items with several members at once? Gather them in a group on the
<a href="/groups" target="_blank" class="whitespace-nowrap"
>Groups page <ExternalLink size={12} class="inline-block" /></a
>, then share with the group.
</p>
{#if isAdminsWorkspaceWithoutEE}
<Alert type="info" title="Admins workspace">
@@ -0,0 +1,98 @@
<script lang="ts">
import { resource } from 'runed'
import { slide } from 'svelte/transition'
import { twMerge } from 'tailwind-merge'
import { Bot } from 'lucide-svelte'
import SidebarSectionHeader from './SidebarSectionHeader.svelte'
import { page } from '$app/state'
import { afterNavigate } from '$app/navigation'
import BarsStaggered from '$lib/components/icons/BarsStaggered.svelte'
import { FlowConversationsService, type FlowConversation } from '$lib/gen'
import { workspaceStore } from '$lib/stores'
import { useLocalStorageValue } from '$lib/svelte5Utils.svelte'
import { agentOfChatPath } from '$lib/components/flows/conversations/agentEditorChat'
import { sidebarClasses } from './MenuButton.svelte'
// The workspace's flow and agent chats, the ones a flow's or an agent's own page shows: the
// editors' test chats stay with the editors.
let { isCollapsed = false }: { isCollapsed?: boolean } = $props()
const sectionCollapsed = useLocalStorageValue(
'windmill_ai_chats_section_collapsed',
false,
'boolean'
)
// Tagged with its workspace: responses are not ordered, and a late one from the workspace
// just left must not show here. Not read on the collapsed rail, which shows no chats.
const listing = resource(
() => [$workspaceStore, isCollapsed] as const,
async ([ws, collapsed]) => {
if (!ws || collapsed) return undefined
const rows = await FlowConversationsService.listFlowConversations({
workspace: ws,
perPage: 30,
kind: 'deployed'
})
return { ws, rows }
}
)
// A chat is started on its flow's or agent's page, so it lists once the reader leaves one.
afterNavigate(({ from, to }) => {
const left = from?.url.pathname
if (!left || left === to?.url.pathname) return
if (left.startsWith('/flows/get/') || left.startsWith('/agents/get/')) listing.refetch()
})
const rows = $derived(
listing.current && listing.current.ws === $workspaceStore ? listing.current.rows : []
)
function target(c: FlowConversation) {
const agent = agentOfChatPath(c.flow_path)
return {
agent: agent !== undefined,
path: agent ?? c.flow_path,
href: `/${agent !== undefined ? 'agents' : 'flows'}/get/${agent ?? c.flow_path}?conversation=${c.id}`
}
}
const openId = $derived(page.url.searchParams.get('conversation'))
</script>
{#if !isCollapsed && rows.length > 0}
<div class="flex flex-col gap-1">
<SidebarSectionHeader
title="AI chats"
collapsed={sectionCollapsed.val}
onToggle={() => (sectionCollapsed.val = !sectionCollapsed.val)}
/>
{#if !sectionCollapsed.val}
<div
transition:slide={{ duration: 180 }}
class="flex flex-col gap-0.5 max-h-[40vh] overflow-y-auto"
>
{#each rows as c (c.id)}
{@const t = target(c)}
{@const selected = openId === c.id}
<a
href={t.href}
title="{t.agent ? 'Agent' : 'Flow'} {t.path}"
class={twMerge(
'flex flex-row items-center gap-2 px-2 py-1 rounded text-xs font-normal min-w-0',
selected
? twMerge(sidebarClasses.selectedBg, sidebarClasses.selectedText)
: 'text-secondary hover:bg-surface-hover'
)}
>
{#if t.agent}
<Bot size={14} class="shrink-0 text-violet-500" />
{:else}
<BarsStaggered size={14} class="shrink-0 text-teal-500" />
{/if}
<span class="truncate">{c.title || 'Untitled chat'}</span>
</a>
{/each}
</div>
{/if}
</div>
{/if}
@@ -0,0 +1,97 @@
<!--
@component
The starred items as a sidebar section, turned on from "Customize sidebar" in the settings menu.
Hidden in the collapsed rail, like the AI chats.
-->
<script lang="ts">
import { slide } from 'svelte/transition'
import { twMerge } from 'tailwind-merge'
import { Bot, CodeXml, LayoutDashboard, Table2, Trash2 } from 'lucide-svelte'
import { page } from '$app/state'
import BarsStaggered from '$lib/components/icons/BarsStaggered.svelte'
import DropdownV2 from '$lib/components/DropdownV2.svelte'
import { globalDbManagerDrawer, workspaceStore } from '$lib/stores'
import { parseDbInputFromAssetSyntax } from '$lib/utils'
import { useLocalStorageValue } from '$lib/svelte5Utils.svelte'
import SidebarSectionHeader from './SidebarSectionHeader.svelte'
import { favoriteManager } from './FavoriteMenu.svelte'
import { sidebarClasses } from './MenuButton.svelte'
import { sidebarPrefs } from './sidebarPrefs.svelte'
let { isCollapsed = false }: { isCollapsed?: boolean } = $props()
const sectionCollapsed = useLocalStorageValue(
'windmill_favorites_section_collapsed',
false,
'boolean'
)
const loaded = $derived(favoriteManager.loadedFor === $workspaceStore)
</script>
{#if sidebarPrefs.favorites.val && !isCollapsed && loaded}
<div class="flex flex-col gap-1">
<SidebarSectionHeader
title="Favorites"
collapsed={sectionCollapsed.val}
onToggle={() => (sectionCollapsed.val = !sectionCollapsed.val)}
/>
{#if !sectionCollapsed.val}
<div transition:slide={{ duration: 180 }} class="flex flex-col gap-0.5">
{#each favoriteManager.current as favorite (`${favorite.kind}:${favorite.path}`)}
{@const selected = favorite.href !== '#' && page.url.pathname === favorite.href}
<div class="relative group/fav">
<!-- An asset's href is `#`: it opens in the database manager instead. -->
<a
href={favorite.href}
title={favorite.path}
onclick={(e) => {
if (favorite.kind !== 'asset') return
e.preventDefault()
const dbInput = parseDbInputFromAssetSyntax(favorite.path)
if (dbInput) globalDbManagerDrawer.val?.openDrawer(dbInput)
}}
class={twMerge(
'flex flex-row items-center gap-2 px-2 py-1 pr-7 rounded text-xs font-normal min-w-0',
selected
? twMerge(sidebarClasses.selectedBg, sidebarClasses.selectedText)
: 'text-secondary hover:bg-surface-hover'
)}
>
<!-- Kind colors mirror the home-page row icons (RowIcon.svelte). -->
{#if favorite.kind == 'script'}
<CodeXml size={14} class="shrink-0 text-blue-500" />
{:else if favorite.kind == 'flow'}
<BarsStaggered size={14} class="shrink-0 text-teal-500" />
{:else if favorite.kind == 'app' || favorite.kind == 'raw_app'}
<LayoutDashboard size={14} class="shrink-0 text-orange-500" />
{:else if favorite.kind == 'agent'}
<Bot size={14} class="shrink-0 text-violet-500" />
{:else}
<Table2 size={14} class="shrink-0 text-primary" />
{/if}
<span class="truncate">{favorite.label}</span>
</a>
<div
class="absolute right-0.5 top-0 h-full flex items-center opacity-0 group-hover/fav:opacity-100 has-[[aria-expanded=true]]:opacity-100 transition-opacity"
>
<DropdownV2
items={[
{
displayName: 'Remove from favorites',
icon: Trash2,
action: () => favoriteManager.unstar(favorite.path, favorite.kind)
}
]}
size="xs"
fixedHeight={false}
/>
</div>
</div>
{:else}
<p class="px-2 py-1 text-2xs text-hint">Star an item to list it here.</p>
{/each}
</div>
{/if}
</div>
{/if}
@@ -122,11 +122,13 @@
{href}
data-light-mode={lightMode}
class={twMerge(
'group flex items-center px-2 py-2 font-light rounded-md gap-2',
'group flex items-center px-2 py-1 font-light rounded-md gap-2',
compact ? 'w-auto' : 'w-full',
sidebarClasses.hoverBg,
'transition-all relative',
sublabel ? 'h-10' : 'h-8',
// Compact rows sit in the page header and keep its height; the nav's are 30px, and
// square on the collapsed rail.
sublabel ? 'h-10' : compact || isCollapsed ? 'h-8' : 'h-[30px]',
classNames,
buttonClass
)}
@@ -60,7 +60,9 @@
}}
{onclick}
class={twMerge(
'group flex items-center px-2 py-2 text-sm font-light rounded-md h-8 gap-2',
'group flex items-center px-2 py-1 text-sm font-light rounded-md gap-2',
// Collapsed, the rail's rows are squares, as its footer buttons are.
isCollapsed ? 'h-8' : 'h-[30px]',
isSelected
? sidebarClasses.selectedBg
: item
@@ -19,8 +19,13 @@
Gauge,
Trash2,
KeyRound,
GraduationCap
GraduationCap,
PanelLeft,
Star,
FolderOpen,
Users
} from 'lucide-svelte'
import { sidebarPrefs } from './sidebarPrefs.svelte'
import { goto } from '$lib/navigation'
import { type Item } from '$lib/utils'
import { logout } from '$lib/logoutKit'
@@ -161,6 +166,12 @@
// Workspace- and instance-scoped entries anchor the bottom of the menu,
// instance settings last.
const workspaceInstanceItems = $derived<Item[]>([
...($roleCapabilities.visibility.folders
? [{ displayName: 'Folders', icon: FolderOpen, href: '/folders' }]
: []),
...($roleCapabilities.visibility.groups
? [{ displayName: 'Groups', icon: Users, href: '/groups' }]
: []),
...(!canManageWorkspace && !workspaceSettingsTarget
? [
{
@@ -227,6 +238,18 @@
icon: darkMode ? Sun : Moon,
action: () => toggleDarkMode()
},
{
displayName: 'Customize sidebar',
icon: PanelLeft,
submenuItems: [
{
displayName: 'Favorites section',
icon: Star,
toggle: sidebarPrefs.favorites.val,
action: () => (sidebarPrefs.favorites.val = !sidebarPrefs.favorites.val)
}
]
},
{
// The email is the label itself; the crown icon carries the admin role.
displayName: $userStore?.non_member
@@ -277,9 +300,7 @@
const logsItems = $derived<Item[]>([
{ displayName: 'Audit logs', icon: Eye, href: '/audit_logs' },
...($devopsRole
? [{ displayName: 'Service logs', icon: Logs, href: '/service_logs' }]
: []),
...($devopsRole ? [{ displayName: 'Service logs', icon: Logs, href: '/service_logs' }] : []),
...($enterpriseLicense
? [
{
@@ -312,7 +333,7 @@
<!-- Workers and Logs are full pages (not account/instance actions), so they sit
as plain links above the Settings dropdown rather than inside it. -->
<div class="flex flex-col gap-1 pb-1">
<div class="flex flex-col gap-0.5 mb-0.5">
<MenuLink
class="!text-xs"
label="Workers"
@@ -328,15 +349,16 @@
items={logsItems}
placement="top-start"
class="w-full"
fixedHeight={false}
enableFlyTransition
aiId="sidebar-menu-link-logs"
aiDescription="Button to open the logs menu (audit logs, service logs, critical alerts)"
>
{#snippet buttonReplacement()}
<span
class="relative flex items-center gap-2 w-full px-2 py-1.5 rounded-md text-secondary text-xs hover:bg-surface-hover cursor-pointer {isCollapsed
? 'justify-center'
: ''}"
class="relative flex items-center gap-2 w-full px-2 rounded-md text-secondary text-xs hover:bg-surface-hover cursor-pointer {isCollapsed
? 'h-8 justify-center'
: 'h-[30px]'}"
>
<Logs size={16} />
{#if !isCollapsed}
@@ -378,14 +400,15 @@
{items}
placement="top-start"
class="w-full"
fixedHeight={false}
enableFlyTransition
on:close={onChangelogsOpened}
>
{#snippet buttonReplacement()}
<span
class="relative flex items-center gap-2 w-full px-2 py-1.5 rounded-md text-secondary text-xs hover:bg-surface-hover cursor-pointer {isCollapsed
? 'justify-center'
: ''}"
class="relative flex items-center gap-2 w-full px-2 rounded-md text-secondary text-xs hover:bg-surface-hover cursor-pointer {isCollapsed
? 'h-8 justify-center'
: 'h-[30px]'}"
>
<Settings size={16} />
{#if !isCollapsed}
@@ -32,9 +32,7 @@
Unplug,
AlertCircle,
Database,
MailIcon,
ChevronDown,
ChevronRight
MailIcon
} from 'lucide-svelte'
import { useLocalStorageValue } from '$lib/svelte5Utils.svelte'
import { slide } from 'svelte/transition'
@@ -63,6 +61,7 @@
MeltButton
} from '$lib/components/meltComponents'
import MenuButton from './MenuButton.svelte'
import SidebarSectionHeader from './SidebarSectionHeader.svelte'
import GoogleCloudIcon from '../icons/triggers/GoogleCloudIcon.svelte'
import AzureIcon from '../icons/triggers/AzureIcon.svelte'
import { leaveCurrentWorkspace } from './leaveWorkspace'
@@ -219,9 +218,7 @@
aiId: 'sidebar-menu-link-resources',
aiDescription: 'Button to navigate to resources'
},
Assets: { aiId: 'sidebar-menu-link-assets', aiDescription: 'Button to navigate to assets' },
Folders: { aiId: 'sidebar-menu-link-folders', aiDescription: 'Button to navigate to folders' },
Groups: { aiId: 'sidebar-menu-link-groups', aiDescription: 'Button to navigate to groups' }
Assets: { aiId: 'sidebar-menu-link-assets', aiDescription: 'Button to navigate to assets' }
}
let mainMenuLinks = $derived(
NAV_PAGES.filter((p) => p.label in MAIN_MENU_EXTRAS)
@@ -234,6 +231,19 @@
}))
.filter((l) => !excludeMainLabels.includes(l.label))
)
// Main-menu pages listed in a collapsible Data section of their own, as Triggers.
const DATA_LABELS = ['Variables', 'Resources', 'Assets']
let ungroupedMainLinks = $derived(mainMenuLinks.filter((l) => !DATA_LABELS.includes(l.label)))
// A disabled MenuLink renders nothing, so its page leaves the section, and a section with no
// page left leaves the nav.
let dataLinks = $derived(
mainMenuLinks.filter((l) => DATA_LABELS.includes(l.label) && !l.disabled)
)
const dataSectionCollapsed = useLocalStorageValue(
'windmill_data_section_collapsed',
false,
'boolean'
)
let defaultExtraTriggerLinks = $derived([
{
label: 'HTTP',
@@ -499,81 +509,112 @@
])
</script>
<nav class={twMerge('flex flex-col overflow-x-hidden scrollbar-hidden px-2 md:pb-2 gap-2')}>
<!-- Expanded, each section opens 10px under the one before, the gap the layout's scroll area puts
between this nav and the sections after it; the collapsed rail keeps one pitch instead. -->
<nav
class={twMerge(
'flex flex-col overflow-x-hidden scrollbar-hidden px-2 gap-2',
isCollapsed ? 'md:pb-2' : ''
)}
>
<div class={twMerge('flex flex-col')}>
{#if showMain}
<div class="space-y-1">
{#each mainMenuLinks as menuLink (menuLink.href ?? menuLink.label)}
<div class="space-y-0.5">
{#each ungroupedMainLinks as menuLink (menuLink.href ?? menuLink.label)}
<MenuLink class="!text-xs" {...menuLink} {isCollapsed} />
{/each}
</div>
{/if}
{#if showMain}
{#if dataLinks.length > 0}
<!-- 8px: the layout's 2px gap above this nav makes it 10 under Runs. -->
<div class={isCollapsed ? '' : 'mt-2'}>
<!-- Collapsed, no title row: the rail's icons keep one pitch across sections. -->
{#if !isCollapsed}
<SidebarSectionHeader
title="Data"
collapsed={dataSectionCollapsed.val}
onToggle={() => (dataSectionCollapsed.val = !dataSectionCollapsed.val)}
/>
{/if}
{#if isCollapsed || !dataSectionCollapsed.val}
<div transition:slide={{ duration: 180 }} class="flex flex-col gap-0.5">
{#each dataLinks as menuLink (menuLink.href)}
<MenuLink class="!text-xs" {...menuLink} {isCollapsed} />
{/each}
</div>
{/if}
</div>
{/if}
{/if}
{#if showMain && showTriggersGroup}
<div class="pt-4">
{#if isCollapsed}
<div class="text-secondary text-[0.5rem] uppercase transition-opacity opacity-0">
Triggers
</div>
{:else}
<button
type="button"
onclick={() => (triggersCollapsed.val = !triggersCollapsed.val)}
class="text-secondary text-[0.5rem] uppercase flex flex-row items-center gap-1 rounded px-1 -mx-1 py-0.5 hover:bg-surface-hover focus:outline-none"
aria-expanded={!triggersCollapsed.val}
>
Triggers
{#if triggersCollapsed.val}
<ChevronRight size={10} />
{:else}
<ChevronDown size={10} />
{/if}
</button>
<!-- Expanded, the + sits at the right of the section's title row, as the AI sessions
section's options do; the collapsed rail has no title row, so it ends the list. -->
{#snippet addTriggerMenu(createMenu: any, inHeader: boolean)}
<Menu {createMenu} usePointerDownOutside placement={inHeader ? 'bottom-end' : undefined}>
{#snippet triggr({ trigger })}
<MeltButton
aiId="sidebar-menu-link-add-trigger"
aiDescription="Button to add a new trigger. Can be HTTP, WebSocket, Postgres, Kafka, NATS, SQS, GCP Pub/Sub, or MQTT"
class={twMerge(
inHeader
? 'h-7 w-7 shrink-0 flex items-center justify-center rounded-md text-secondary hover:bg-surface-hover'
: 'w-full text-secondary text-2xs flex flex-row gap-1 py-1 items-center px-2 hover:bg-surface-hover rounded',
'data-[highlighted]:bg-surface-hover'
)}
title="Add trigger"
meltElement={trigger}
>
<Plus size={14} />
</MeltButton>
{/snippet}
{#snippet children({ item })}
{#each extraTriggerLinks as subItem (subItem.href ?? subItem.label)}
<MenuItem
aiId={subItem.aiId}
aiDescription={subItem.aiDescription}
href={subItem.disabled ? '' : subItem.href}
class={twMerge(itemClass, subItem.disabled ? 'pointer-events-none opacity-50' : '')}
{item}
disabled={subItem.disabled}
>
<div class="flex flex-row items-center gap-2">
{#if subItem.icon}
<subItem.icon size={16} />
{/if}
{subItem.label}
</div>
</MenuItem>
{/each}
{/snippet}
</Menu>
{/snippet}
<div class={isCollapsed ? 'mt-0.5' : 'mt-2.5'}>
<!-- Collapsed, no title row: the rail's icons keep one pitch across sections. -->
{#if !isCollapsed}
<SidebarSectionHeader
title="Triggers"
collapsed={triggersCollapsed.val}
onToggle={() => (triggersCollapsed.val = !triggersCollapsed.val)}
actions={showAddTriggerMenu ? triggerHeaderActions : undefined}
/>
{#snippet triggerHeaderActions()}
<Menubar>
{#snippet children({ createMenu })}
{@render addTriggerMenu(createMenu, true)}
{/snippet}
</Menubar>
{/snippet}
{/if}
{#if isCollapsed || !triggersCollapsed.val}
<div transition:slide={{ duration: 180 }}>
<Menubar class="flex flex-col gap-1">
<Menubar class="flex flex-col gap-0.5">
{#snippet children({ createMenu })}
{#each triggerMenuLinks as menuLink (menuLink.href ?? menuLink.label)}
<MenuLink class="!text-xs" {...menuLink} {isCollapsed} />
{/each}
{#if showAddTriggerMenu}
<Menu {createMenu} usePointerDownOutside>
{#snippet triggr({ trigger })}
<MeltButton
aiId="sidebar-menu-link-add-trigger"
aiDescription="Button to add a new trigger. Can be HTTP, WebSocket, Postgres, Kafka, NATS, SQS, GCP Pub/Sub, or MQTT"
class={twMerge(
'w-full text-secondary text-2xs flex flex-row gap-1 py-1 items-center px-2 hover:bg-surface-hover rounded',
'data-[highlighted]:bg-surface-hover'
)}
meltElement={trigger}
>
<Plus size={14} />
</MeltButton>
{/snippet}
{#snippet children({ item })}
{#each extraTriggerLinks as subItem (subItem.href ?? subItem.label)}
<MenuItem
aiId={subItem.aiId}
aiDescription={subItem.aiDescription}
href={subItem.disabled ? '' : subItem.href}
class={twMerge(
itemClass,
subItem.disabled ? 'pointer-events-none opacity-50' : ''
)}
{item}
disabled={subItem.disabled}
>
<div class="flex flex-row items-center gap-2">
{#if subItem.icon}
<subItem.icon size={16} />
{/if}
{subItem.label}
</div>
</MenuItem>
{/each}
{/snippet}
</Menu>
{#if showAddTriggerMenu && isCollapsed}
{@render addTriggerMenu(createMenu, false)}
{/if}
{/snippet}
</Menubar>
@@ -41,7 +41,7 @@
<div
bind:this={viewport}
onscroll={measure}
class="sidebar-scroll h-full overflow-y-auto overflow-x-hidden scrollbar-hidden flex flex-col gap-3"
class="sidebar-scroll h-full overflow-y-auto overflow-x-hidden scrollbar-subtle flex flex-col gap-2.5"
>
{@render children()}
</div>
@@ -0,0 +1,41 @@
<!--
@component
A sidebar section's title row. The title folds the section and fills the row up to its actions;
its padding lines the text up with the nav rows' icons and its height matches theirs, so actions
are `sm` (h-7) buttons.
-->
<script lang="ts">
import type { Snippet } from 'svelte'
import { ChevronDown, ChevronRight } from 'lucide-svelte'
interface Props {
title: string
collapsed: boolean
onToggle: () => void
/** A section with nothing to fold: the title stays, without its chevron. */
disabled?: boolean
actions?: Snippet
}
let { title, collapsed, onToggle, disabled = false, actions }: Props = $props()
</script>
<div class="flex flex-row items-center h-7 gap-0.5">
<button
type="button"
onclick={onToggle}
{disabled}
aria-expanded={!collapsed}
class="flex-1 min-w-0 h-7 px-2 rounded-md text-secondary text-[0.5rem] font-normal uppercase flex flex-row items-center gap-1 transition-colors hover:bg-surface-hover disabled:hover:bg-transparent focus:outline-none"
>
{title}
{#if !disabled}
{#if collapsed}
<ChevronRight size={10} />
{:else}
<ChevronDown size={10} />
{/if}
{/if}
</button>
{@render actions?.()}
</div>
@@ -161,7 +161,9 @@
// modal carries its own base-workspace picker). Hidden on non-premium cloud,
// in the admins workspace, or when forking is disabled.
const canForkHere = $derived(
(!isCloudHosted() || $maybePremium) && $workspaceStore !== 'admins' && canCreateFork($userStore, $roleCapabilities)
(!isCloudHosted() || $maybePremium) &&
$workspaceStore !== 'admins' &&
canCreateFork($userStore, $roleCapabilities)
)
// The row mechanics below — which family to expand, which collapsed row carries the tick — key on
// a depth-0 row of the list, which `buildWorkspaceHierarchy` puts at the highest workspace the
@@ -386,6 +388,7 @@
<div
bind:this={rootEl}
data-works-with-composer
role="none"
onpointermovecapture={keepSearchFocus}
onpointerleavecapture={keepSearchFocus}
@@ -0,0 +1,8 @@
import { useLocalStorageValue } from '$lib/svelte5Utils.svelte'
/** What "Customize sidebar" in the settings menu changes, per browser. Module-level so the
* menu that flips a choice and the sidebar that reads it share one value. */
export const sidebarPrefs = {
/** The starred items as a section of their own. */
favorites: useLocalStorageValue('windmill_sidebar_show_favorites', false, 'boolean')
}
@@ -1,13 +1,11 @@
import { page } from '$app/state'
import { goto } from '$lib/navigation'
// Post-workspace-switch URL fixup shared by the sidebar workspace pickers, and by the
// Workspace side of the sidebar switch for a page it left before a switch.
// Post-workspace-switch URL fixup shared by the sidebar workspace pickers.
// Item-scoped pages would show a wrong-workspace (or missing) item after a
// switch — go home instead. Otherwise, really rewrite the params in the address
// bar that name a workspace (mutating page.url is a no-op there): left stale,
// they get re-applied on reload or when the switch restores the page, silently
// switching the workspace back.
// they get re-applied on reload, silently switching the workspace back.
//
// `workspace_id` names the workspace a page acts on (the compare page's pair) and
// `workspace` the one the app is pointed at; a switch moves both. `target`, the
@@ -27,13 +25,21 @@ const EDIT_PAGES = [
'/apps_raw/get/'
]
/** Matches a route id or a pathname alike. */
function isItemPage(route: string): boolean {
return EDIT_PAGES.some((p) => route.includes(p))
}
/** Points the params naming a workspace at `id`; whether anything changed. */
function moveWorkspaceParams(url: URL, id: string): boolean {
export async function fixupUrlAfterWorkspaceSwitch(
id: string,
// Decided by the caller so the rule stays with the picker that has the context
// for it — a picker rendered outside the sidebar drives its own page and must
// not be navigated away from.
opts?: { landOnHome?: boolean }
): Promise<void> {
if (EDIT_PAGES.some((p) => page.route.id?.includes(p) ?? false) || opts?.landOnHome) {
await goto('/')
return
}
// `window.location`, never `page.url`: a param written by a previous shallow update
// is in the address bar but not in `page.url`, so rebuilding from it would undo that
// write (see the note on `setQuery` in $lib/navigation).
const url = new URL(window.location.href)
let changed = false
for (const key of WORKSPACE_PARAMS) {
if (url.searchParams.get(key) === id) continue
@@ -46,33 +52,7 @@ function moveWorkspaceParams(url: URL, id: string): boolean {
url.searchParams.delete(key)
changed = true
}
return changed
}
/** Where `href` (a pathname with its search) leads once the app has switched to `id`. */
export function hrefAfterWorkspaceSwitch(href: string, id: string): string {
const url = new URL(href, 'http://localhost')
if (isItemPage(url.pathname)) return '/'
moveWorkspaceParams(url, id)
return `${url.pathname}${url.search}${url.hash}`
}
export async function fixupUrlAfterWorkspaceSwitch(
id: string,
// Decided by the caller so the rule stays with the picker that has the context
// for it — a picker rendered outside the sidebar drives its own page and must
// not be navigated away from.
opts?: { landOnHome?: boolean }
): Promise<void> {
if (isItemPage(page.route.id ?? '') || opts?.landOnHome) {
await goto('/')
return
}
// `window.location`, never `page.url`: a param written by a previous shallow update
// is in the address bar but not in `page.url`, so rebuilding from it would undo that
// write (see the note on `setQuery` in $lib/navigation).
const url = new URL(window.location.href)
if (!moveWorkspaceParams(url, id)) return
if (!changed) return
// `goto` rather than `replaceState`: a page reading these params through `page.url`
// (the compare page derives the workspace it compares from them) sees nothing when
// they are written shallowly, since SvelteKit refreshes `page.url` only on a
@@ -17,6 +17,7 @@
import { DEV_WORKSPACE_LOCK_RULE_NAME } from '$lib/workspaceProtectionRules.svelte'
import { untrack } from 'svelte'
import { Save } from 'lucide-svelte'
import GroupsPageLink from '$lib/components/GroupsPageLink.svelte'
import { safeSelectItems } from '$lib/components/select/utils.svelte'
interface Props {
@@ -271,6 +272,9 @@
class="flex flex-col gap-4"
>
<Label label="Groups">
{#snippet action()}
<GroupsPageLink />
{/snippet}
<MultiSelect
bind:value={selectedGroups}
items={safeSelectItems(availableGroups)}
+2 -9
View File
@@ -17,18 +17,14 @@ vi.mock('./localDraftHints.svelte', () => ({
setLocalDraftHint: vi.fn(),
getLocalDraftHint: () => hints.value
}))
// `stripNewDraftFlag` rewrites the URL through SvelteKit's `replaceState` and
// refreshes the page the sidebar switch returns to. Mock those so the strip is
// observable via `window.location.href` (mirroring jsdom) and the remembered
// page can be asserted.
const rememberWorkspacePage = vi.hoisted(() => vi.fn())
// `stripNewDraftFlag` rewrites the URL through SvelteKit's `replaceState`. Mock it
// so the strip is observable via `window.location.href` (mirroring jsdom).
vi.mock('$app/navigation', () => ({
replaceState: (url: URL | string, _state: unknown) => {
window.location.href = new URL(url, window.location.href).toString()
}
}))
vi.mock('$app/state', () => ({ page: { state: {} } }))
vi.mock('$lib/components/sessions/sessionSwitch.svelte', () => ({ rememberWorkspacePage }))
import { UserDraftDbSyncer } from './userDraftDbSyncer.svelte'
import { stripNewDraftFlagOnSave, shouldSeedNewDraft } from './newDraftFlag'
@@ -120,9 +116,6 @@ describe('stripNewDraftFlagOnSave', () => {
expect(window.location.href).not.toContain('new_draft')
// Sibling seeding params are preserved.
expect(window.location.href).toContain('template=foo')
// The switch's Workspace side returns to the stripped URL, so it does not
// come back with ?new_draft.
expect(rememberWorkspacePage).toHaveBeenCalledWith('/scripts/edit/u/me/draft_d?template=foo')
})
it('does not strip on a delete save', async () => {
+2 -7
View File
@@ -1,6 +1,5 @@
import { page } from '$app/state'
import { replaceState } from '$app/navigation'
import { rememberWorkspacePage } from '$lib/components/sessions/sessionSwitch.svelte'
import { UserDraftDbSyncer, type UserDraftLastSyncQuery } from '$lib/userDraftDbSyncer.svelte'
import { getLocalDraftHint } from '$lib/localDraftHints.svelte'
import type { UserDraftItemKind } from '$lib/gen'
@@ -11,17 +10,13 @@ import type { UserDraftItemKind } from '$lib/gen'
*
* Uses SvelteKit's `replaceState` (not raw `history.replaceState`, which the
* router warns conflicts with it) so the history entry keeps the router's
* bookkeeping and `page.state`. Also refreshes the page the sidebar switch's
* Workspace side returns to: `afterNavigate` never observes this in-place
* rewrite, so the switch would restore the pre-strip URL — still carrying
* `?new_draft=true` — and re-enter the seed-empty branch. */
* bookkeeping and `page.state`. */
export function stripNewDraftFlag(): void {
if (typeof window === 'undefined') return
const url = new URL(window.location.href)
if (url.searchParams.get('new_draft') !== 'true') return
url.searchParams.delete('new_draft')
replaceState(url, page.state)
rememberWorkspacePage(url.pathname + url.search)
}
/**
@@ -31,7 +26,7 @@ export function stripNewDraftFlag(): void {
* `u/<user>/draft_<uuid>?new_draft=true`; the seed branch bootstraps an empty
* (or template/hub/fork-seeded) editor instead of fetching a row that doesn't
* exist yet. But the flag can outlive the seed: a return to the editor's URL
* (Back, the sidebar switch's Workspace side, a link kept from before) still
* (Back, a link kept from before) still
* carries `?new_draft=true` after the
* draft was materialized — by the first autosave, or by "Open in AI session"'s
* `forcePersist`. Re-running the seed branch then blanks the saved draft.
+129 -134
View File
@@ -24,6 +24,8 @@
import SettingsMenu from '$lib/components/sidebar/SettingsMenu.svelte'
import SidebarUsage from '$lib/components/sidebar/SidebarUsage.svelte'
import SidebarScrollArea from '$lib/components/sidebar/SidebarScrollArea.svelte'
import AiChatsSection from '$lib/components/sidebar/AiChatsSection.svelte'
import FavoritesSection from '$lib/components/sidebar/FavoritesSection.svelte'
import AccountSetupBanner from '$lib/components/sidebar/AccountSetupBanner.svelte'
import FinishAccountSetup from '$lib/components/sidebar/FinishAccountSetup.svelte'
import { accountSetup } from '$lib/components/sidebar/accountSetup.svelte'
@@ -66,7 +68,7 @@
import type SuperadminSettings from '$lib/components/SuperadminSettings.svelte'
import WindmillIcon from '$lib/components/icons/WindmillIcon.svelte'
import { page } from '$app/state'
import FavoriteMenu, {
import {
favoriteManager,
getFavoriteHref,
getFavoriteLabel
@@ -108,11 +110,10 @@
import InstanceUiSync from '$lib/components/InstanceUiSync.svelte'
import { onDestroy, setContext, untrack } from 'svelte'
import { cubicOut } from 'svelte/easing'
import { Menubar, Tooltip } from '$lib/components/meltComponents'
import { Tooltip } from '$lib/components/meltComponents'
import { aiChatManager } from '$lib/components/copilot/chat/AIChatManager.svelte'
import AiChatLayout from '$lib/components/copilot/chat/AiChatLayout.svelte'
import SessionPicker from '$lib/components/sessions/SessionPicker.svelte'
import SessionModeSwitch from '$lib/components/sessions/SessionModeSwitch.svelte'
import { isGlobalAiEnabled, sessionsAllowedFor } from '$lib/components/copilot/chat/global/gate'
import { copilotInfo } from '$lib/aiStore'
import {
@@ -120,7 +121,7 @@
parsePreviewItemRoute,
barePath
} from '$lib/components/sessions/previewPaths'
import { sessionsSwitchShown, sidebarListFor } from '$lib/components/sessions/sidebarList.svelte'
import { sidebarSessionsShown } from '$lib/components/sessions/sidebarList.svelte'
import { noteArrival } from '$lib/components/sessions/sessionSwitch.svelte'
import { sessionState } from '$lib/components/sessions/sessionState.svelte'
import { restoreSessionBackups } from '$lib/components/sessions/sessionMirror.svelte'
@@ -154,10 +155,6 @@
})
)
let menuOpen = $state(false)
// Set by the Workspace ⇄ AI Sessions switch before it navigates, so the mobile menu
// drawer stays open across it to show the list it switched to (unlike a normal link
// navigation, which dismisses it). Consumed once in beforeNavigate.
let preserveMenuOnNextNav = false
let globalSearchModal: GlobalSearchModal | undefined = $state(undefined)
// Persisted nav-rail collapse preference. A deliberate collapse writes to it —
// the manual toggle and a drag past the collapse threshold. The contextual
@@ -215,9 +212,7 @@
// which tracks the pointer. Easing that one leaves the band lying over the panel it is
// meant to stop beside — an empty strip across that panel's own header until it catches up.
let bandTransitionClass = $derived(
resizingSidebar && !sidebarSnapping
? ''
: 'transition-[left,padding-left] duration-200 ease-in-out'
resizingSidebar && !sidebarSnapping ? '' : 'transition-[padding-left] duration-200 ease-in-out'
)
// Set while a drag is live so it can be torn down if the layout unmounts
// mid-drag (otherwise the window listeners would leak).
@@ -303,8 +298,8 @@
let isDarkMode = useIsDarkMode()
let darkMode = $derived(isDarkMode.val)
// An operator without the opt-in (`gate.ts`) is refused by /sessions, so their sidebar is not
// handed over to a session list the page behind it declines, and they keep the docked chat.
// An operator without the opt-in (`gate.ts`) is refused by /sessions, so their sidebar lists
// no sessions the page behind it declines, and they keep the docked chat.
const sessionsAllowed = $derived(sessionsAllowedFor(!$roleCapabilities.code))
let onSessionsPage = $derived(page.url.pathname.startsWith('/sessions') && sessionsAllowed)
// A session's page points the bottom settings entry at the open session's own
@@ -319,18 +314,13 @@
const embedded = BROWSER && window.self !== window.top
// AI sessions (beta) are on unless this browser opted out earlier (see
// `global/gate.ts`). The Workspace ⇄ AI Sessions switch follows the gate;
// `global/gate.ts`). The sidebar's session section follows the gate;
// opted-out users get the legacy Ask-AI pane instead.
// 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.
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
// is the session list.
const sidebarList = $derived(sidebarListFor(page.url.pathname))
const sidebarListsSessions = $derived(switchRowShown && sidebarList === 'sessions')
// points: the session section and the legacy Ask-AI button.
const sessionsShown = $derived(sidebarSessionsShown())
const askAiShown = $derived(
(!globalAiEnabled || !sessionsAllowed) && !$copilotInfo.workspaceDisabled
)
@@ -450,11 +440,7 @@
onNavigate(homeSessionsTransition)
beforeNavigate((navigation) => {
if (preserveMenuOnNextNav) {
preserveMenuOnNextNav = false
} else {
menuOpen = false
}
menuOpen = false
// Inside a sessions-preview iframe, hand an editor-route navigation up to the
// parent so it mounts the in-process editor (sharing the session runtime)
@@ -791,9 +777,7 @@
$usedTriggerKinds = usedKinds
}
// Where each side of the Workspace ⇄ AI Sessions switch was left, so the switch comes
// back there. Not inside a preview iframe: it has no switch, and Home's list is stored
// per browser, so the frame's own navigation would set the list of the page around it.
// Not inside a preview iframe: it opens no session page of its own.
afterNavigate((n) => {
if (!embedded && n.to) noteArrival(n.to.url)
})
@@ -1136,9 +1120,8 @@ outside this layout, and their shortcut must reopen the URL that is their creden
<meta name="apple-mobile-web-app-title" content="Windmill" />
</svelte:head>
<!-- Runs lifted to the top of the workspace nav, sitting with Favorites and Search as the
primary quick-access cluster. Excluded from SidebarContent (via excludeMainLabels), as
Home is, so neither is rendered twice. -->
<!-- Runs lifted to the top of the workspace nav. Excluded from SidebarContent (via
excludeMainLabels), as Home is, so neither is rendered twice. -->
{#snippet quickLinks(collapsed: boolean)}
<MenuLink
class="!text-xs"
@@ -1157,7 +1140,7 @@ outside this layout, and their shortcut must reopen the URL that is their creden
/>
{/snippet}
<!-- In the rail's pinned footer, right above the plan usage, in both rails and both lists:
<!-- In the rail's pinned footer, right above the plan usage, in both rails:
an account with no credentials of its own needs to see this wherever it is on the
page and however far the nav has scrolled, and the footer is where the rail already
keeps what is about the account rather than the workspace. -->
@@ -1204,11 +1187,9 @@ outside this layout, and their shortcut must reopen the URL that is their creden
</div>
{/snippet}
<!-- Settings / instance section. Shared by both sidebar surfaces and both lists
(under the workspace nav it's the last section inside the unified scroll area;
under the session list it stays pinned below it). -->
<!-- Settings / instance section: the last section inside the nav's unified scroll area. -->
{#snippet settingsMenu(collapsed: boolean)}
<div class="px-2 pb-1">
<div class="px-2">
<SettingsMenu
isCollapsed={collapsed}
workspaceSettingsTarget={sessionSettingsWorkspace}
@@ -1250,101 +1231,110 @@ outside this layout, and their shortcut must reopen the URL that is their creden
></div>
{/if}
<!-- Top row: Home, level with the page header's own row so the two read as one band.
It sits above the switch because both lists start from it: Home is one page for
workspace and sessions alike. The workspace picker itself lives in that header,
Home is one page for workspace and sessions alike. The workspace picker itself lives in that header,
which is why nothing names the workspace here. -->
<div class="flex-shrink-0 px-2 h-12 flex flex-col justify-center">
<MenuLink
class="!text-xs"
label="Home"
href="/"
icon={Home}
isCollapsed={collapsed}
aiId="sidebar-menu-link-home"
aiDescription="Button to navigate to home which contains all the user's scripts, flows and apps"
/>
</div>
{#if switchRowShown}
<div class="flex-shrink-0 px-2 pb-1 flex {collapsed ? 'flex-col items-center' : ''}">
<div class="min-w-0 flex-1">
<SessionModeSwitch
list={sidebarList}
isCollapsed={collapsed}
onToggle={panel ? () => (preserveMenuOnNextNav = true) : undefined}
/>
</div>
</div>
{/if}
{#if sidebarListsSessions}
<!-- The session list owns the column. A session's page shows workspace pages in
its preview side panel (the iframe renders its own nav). -->
<div class="wm-vt-sidebar-list px-2 py-2 flex flex-col gap-1 flex-1 min-h-0 overflow-y-auto">
<SessionPicker isCollapsed={collapsed} embedded collapsible={false} />
</div>
{@render settingsMenu(collapsed)}
{:else}
<!-- The workspace nav: Runs → Settings scroll as ONE block with an
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. -->
<SidebarScrollArea class="wm-vt-sidebar-list" color={darkMode ? SIDEBAR_BG_DARK : SIDEBAR_BG}>
<!-- Section 1: Runs + Favorites + Search. -->
<div class="px-2 flex flex-col gap-1 pt-1">
{@render quickLinks(collapsed)}
<Menubar class="flex flex-col gap-1">
{#snippet children({ createMenu })}
<FavoriteMenu
{createMenu}
favoriteLinks={favoriteManager.current}
isCollapsed={collapsed}
/>
{/snippet}
</Menubar>
<MenuButton
stopPropagationOnClick={true}
on:click={() => openSearchModal()}
isCollapsed={collapsed}
icon={Search}
label="Search"
class="!text-xs"
shortcut={`${getModifierKey()}k`}
/>
{#if askAiShown}
<!-- Legacy Ask-AI pane, shown only when the user opted out of the
AI Sessions beta (otherwise SessionModeSwitch replaces it). -->
<MenuButton
stopPropagationOnClick={true}
on:click={() => aiChatManager.toggleOpen()}
isCollapsed={collapsed}
icon={WandSparkles}
iconProps={{ forceDarkMode: true }}
label="Ask AI"
class="!text-xs"
iconClasses="!text-ai"
shortcut={`${getModifierKey()}L`}
/>
{/if}
</div>
<!-- Section 2: workspace items -->
<SidebarContent
<div class="flex-shrink-0 px-2 h-12 flex flex-row items-center gap-0.5">
<div class="flex-1 min-w-0">
<MenuLink
class="!text-xs"
label="Home"
href="/"
icon={Home}
isCollapsed={collapsed}
showSecondary={false}
excludeMainLabels={['Home', 'Runs']}
numUnacknowledgedCriticalAlerts={isCriticalAlertsUiMuted
? 0
: numUnacknowledgedCriticalAlerts}
aiId="sidebar-menu-link-home"
aiDescription="Button to navigate to home which contains all the user's scripts, flows and apps"
/>
</div>
<!-- Expanded, Search shares Home's row; the collapsed rail keeps it in the nav below. -->
{#if !collapsed}
<Button
unifiedSize="sm"
variant="subtle"
startIcon={{ icon: Search }}
title="Search"
aria-label="Search"
btnClasses="text-secondary gap-1 px-1.5"
onClick={() => openSearchModal()}
>
<span class="text-2xs text-hint font-normal">{getModifierKey()}K</span>
</Button>
{/if}
</div>
<!-- Pulled up into the Home band's slack under its centred row (48px band; rows 30px, 32px
on the rail), so the next row sits 2px under Home, as the nav's rows sit apart. Kept
outside the scroll area: a negative margin inside it would clip that row. -->
<div class={twMerge('flex flex-col flex-1 min-h-0', collapsed ? '-mt-1.5' : '-mt-[7px]')}>
<!-- The workspace nav: Runs → Settings scroll as ONE block with an
overflow fade hint. The sections (Runs + workspace items / AI sessions /
instance settings) are spaced by the scroll area's
gap rather than each scrolling on its own. -->
<SidebarScrollArea color={darkMode ? SIDEBAR_BG_DARK : SIDEBAR_BG}>
<!-- Section 1: Search (collapsed) + Runs, then the workspace items, spaced as one list. -->
<div class="flex flex-col gap-0.5">
<div class="px-2 flex flex-col gap-0.5">
<!-- Collapsed, Search stays right under Home, where it sits beside it expanded. -->
{#if collapsed}
<MenuButton
stopPropagationOnClick={true}
on:click={() => openSearchModal()}
isCollapsed={collapsed}
icon={Search}
label="Search"
class="!text-xs"
shortcut={`${getModifierKey()}k`}
/>
{/if}
{@render quickLinks(collapsed)}
{#if askAiShown}
<!-- Legacy Ask-AI pane, shown only when the user opted out of the
AI Sessions beta (otherwise the AI sessions section replaces it). -->
<MenuButton
stopPropagationOnClick={true}
on:click={() => aiChatManager.toggleOpen()}
isCollapsed={collapsed}
icon={WandSparkles}
iconProps={{ forceDarkMode: true }}
label="Ask AI"
class="!text-xs"
iconClasses="!text-ai"
shortcut={`${getModifierKey()}L`}
/>
{/if}
</div>
<SidebarContent
isCollapsed={collapsed}
showSecondary={false}
excludeMainLabels={['Home', 'Runs']}
numUnacknowledgedCriticalAlerts={isCriticalAlertsUiMuted
? 0
: numUnacknowledgedCriticalAlerts}
/>
</div>
<!-- Section 3: instance settings — mt-auto drops it to the bottom
when the column has spare room, and collapses back to the normal
inter-section gap once the content overflows and scrolls. -->
<div class="mt-auto">
{@render settingsMenu(collapsed)}
<!-- The starred items, when "Customize sidebar" turns them on; hidden in the rail. -->
<div class="px-2 empty:hidden">
<FavoritesSection isCollapsed={collapsed} />
</div>
<!-- Section 2: AI sessions, one row each; collapsed, a menu of them. -->
{#if sessionsShown}
<div class="px-2">
<SessionPicker isCollapsed={collapsed} embedded />
</div>
{/if}
<!-- The flow and agent chats stored in the workspace; hidden in the collapsed rail. -->
<div class="px-2 empty:hidden">
<AiChatsSection isCollapsed={collapsed} />
</div>
</SidebarScrollArea>
{/if}
</div>
<!-- Section 3: instance settings, pinned under the scrolled lists: inside them, long
session and chat lists pushed it out of view under the bottom fade. -->
<div class="flex-shrink-0 pt-2">
{@render settingsMenu(collapsed)}
</div>
<div class="flex-shrink-0">
{@render accountSetupBanner(collapsed)}
@@ -1352,12 +1342,12 @@ outside this layout, and their shortcut must reopen the URL that is their creden
</div>
<div
class="flex-shrink-0 flex pt-3 pb-3.5 {collapsed
? 'flex-col items-center gap-3'
: 'items-center justify-between px-4'}"
class="flex-shrink-0 flex pb-3.5 {collapsed
? 'flex-col items-center gap-1 pt-4'
: 'items-center justify-between px-4 pt-1'}"
>
{@render brandMark(collapsed)}
<div class="flex {collapsed ? 'flex-col gap-3' : 'gap-3'}">
<div class="flex {collapsed ? 'flex-col gap-1' : 'gap-3'}">
{#if !panel || navDetached.val}
{@render sidebarToggle()}
{/if}
@@ -1518,12 +1508,17 @@ outside this layout, and their shortcut must reopen the URL that is their creden
up into the gap and the workspace menu losing the trigger it hangs from.
In flow, the band spans the content beside the rail. With an inset, a page owns
the right edge from the top (a session's side panel): the band floats, stopping
where that column starts, and the page pads its own content to clear it. -->
where that column starts, and the page pads its own content to clear it.
The rail offset must be padding in both placements, never `left` in the floating one:
a switch between placements (sessions with and without a side panel) would then ease
the padding to or from zero and slide the whole breadcrumb across. -->
<div
class={classNames(floatBand ? 'absolute top-0 z-30' : 'shrink-0', bandTransitionClass)}
style:left={floatBand ? `${leftInset}rem` : undefined}
class={classNames(
floatBand ? 'absolute top-0 left-0 z-30' : 'shrink-0',
bandTransitionClass
)}
style:right={floatBand ? `${rightInset ?? 0}px` : undefined}
style:padding-left={floatBand ? undefined : `${leftInset}rem`}
style:padding-left="{leftInset}rem"
>
<PageHeaderBar navHidden={menuHidden} panelled={useDrawer} />
</div>
@@ -98,6 +98,8 @@
// the mount animation below never covers. Replay it by hand instead of keying the page on the
// workspace: a remount would drop the list's own state and refetch what it is already loading.
let pageEl: HTMLDivElement | undefined = $state(undefined)
// Height of the composer's column, which stays at the top while the composer is open.
let pinnedHeight = $state(0)
// Back from AI Sessions the view transition (homeSessionsTransition.svelte.ts) carries the arrival, so
// the page skips its own fade-in. Decided once at mount: gating the class on the attribute
@@ -292,8 +294,11 @@
<div
bind:this={pageEl}
class="{fadeIn ? 'wm-page-in' : ''} flex flex-col w-full h-full overflow-y-auto items-center"
class="{fadeIn
? 'wm-page-in'
: ''} group/home flex flex-col w-full h-full overflow-y-auto items-center"
style="scrollbar-gutter: stable both-edges;"
style:--home-pinned="{pinnedHeight}px"
>
<!-- Where edits to this workspace are made is a fact about the workspace, so it sits in the
header with the workspace's own name rather than above the list. -->
@@ -301,7 +306,14 @@
<ForkWorkspaceBanner />
<WorkspaceDraftsBanner />
<div class="{HOME_COLUMN_WIDTH} px-4 sm:px-8 md:px-8 h-fit w-full mb-6 shrink-0">
<!-- While the composer is open this column stays at the top and the lists scroll under it. It
is the scroller's own child because a sticky element holds only inside its parent; its
background covers what passes under it, and the items' search bar sticks below it
(`--home-pinned`, ItemsList) rather than behind it. -->
<div
bind:clientHeight={pinnedHeight}
class="{HOME_COLUMN_WIDTH} px-4 sm:px-8 md:px-8 h-fit w-full pb-6 shrink-0 bg-surface group-has-[[data-composer-open]]/home:sticky group-has-[[data-composer-open]]/home:top-0 group-has-[[data-composer-open]]/home:z-20"
>
<!-- HomeAIChat carries both the AI composer and the AI-independent CLI/MCP connect row,
so it shows whenever the sessions beta is on; the composer itself is gated on the
workspace inside the component, which owns its own vertical spacing
@@ -281,6 +281,7 @@
enableAi={$copilotInfo.enabled}
view
onOpenConfig={() => configModal?.open()}
openConversation={page.url.searchParams.get('conversation') ?? undefined}
>
{#snippet viewForm({ schema, run, loading, actions })}
{#if config && !chatAvailable}
@@ -50,11 +50,7 @@
type SessionPreviewTab
} from '$lib/components/sessions/sessionState.svelte'
import { withWorkspaceParam } from '$lib/components/sessions/sessionMode.svelte'
import {
openDraftOnHome,
resumeAiSessions,
returnToWorkspace
} from '$lib/components/sessions/sessionSwitch.svelte'
import { openDraftOnHome, resumeAiSessions } from '$lib/components/sessions/sessionSwitch.svelte'
import { sendUserToast } from '$lib/toast'
import type { SessionPreviewTabs } from '$lib/components/sessions/sessionPreviewTabs.svelte'
import {
@@ -179,8 +175,8 @@
// Family reconcile: a workspace switch can land this page with no session
// selected or with another family's session in the URL (the workspace menu's
// link navigation keeps the route), and a chat must not bleed across
// families. Both resume as the switch's AI Sessions side does, within the
// active family. A `session` that resolves to nothing is left to the
// families. Both resume the last session opened, within the active family.
// A `session` that resolves to nothing is left to the
// recovery effect below.
$effect(() => {
if (embedded || !sessionState.hydrated) return
@@ -1230,7 +1226,7 @@
<Loader2 class="animate-spin" />
</div>
{:else if aiHiddenVerdict}
<!-- The workspace hid the assistant, and the sidebar switch with it, so only a
<!-- The workspace hid the assistant, and the sidebar's sessions with it, so only a
direct URL or a session acting on such a workspace lands here. -->
<!-- Centred like the loader above: the page header overlays this pane's top edge. -->
<div
@@ -1238,7 +1234,7 @@
>
<p class="text-primary font-medium">AI Sessions are hidden in this workspace</p>
<p>A workspace admin hid AI sessions in the workspace settings.</p>
<Button unifiedSize="sm" onclick={() => returnToWorkspace()}>Back to workspace</Button>
<Button unifiedSize="sm" onclick={() => goto('/')}>Back to workspace</Button>
</div>
{/if}
</div>