mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-11-17 16:20:25 +00:00
feat: list ai sessions inline in the workspace sidebar
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
b86a9d840f
commit
c20db2e56c
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<script lang="ts">
|
||||
import { Tab, Tabs } from '$lib/components/common'
|
||||
import { goto } from '$lib/navigation'
|
||||
import { roleCapabilities } from '$lib/stores'
|
||||
|
||||
// Folders and Groups read as one Sharing page: the sidebar links to it once and these tabs
|
||||
// move between the two routes, which stay separate so links to either keep working.
|
||||
let { selected }: { selected: 'folders' | 'groups' } = $props()
|
||||
|
||||
const bothShown = $derived(
|
||||
$roleCapabilities.visibility.folders && $roleCapabilities.visibility.groups
|
||||
)
|
||||
</script>
|
||||
|
||||
{#if bothShown}
|
||||
<Tabs {selected} on:selected={(e) => goto(`/${e.detail}`)} wrapperClass="pt-4">
|
||||
<Tab value="folders" label="Folders" />
|
||||
<Tab value="groups" label="Groups" />
|
||||
</Tabs>
|
||||
{/if}
|
||||
@@ -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 =
|
||||
|
||||
@@ -12,3 +12,14 @@ export function isComposerOverlay(target: EventTarget | null): boolean {
|
||||
if (target instanceof Element && target.closest(OVERLAY)) return true
|
||||
return document.querySelector(OVERLAY) !== null
|
||||
}
|
||||
|
||||
/** 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
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -63,6 +63,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 +80,8 @@
|
||||
frame = 'top',
|
||||
conversationKind = 'deployed',
|
||||
subject = 'flow',
|
||||
composerSettings = undefined
|
||||
composerSettings = undefined,
|
||||
openConversation = undefined
|
||||
}: Props = $props()
|
||||
|
||||
const flowEditorContext = getContext<FlowEditorContext>('FlowEditorContext')
|
||||
@@ -164,6 +167,10 @@
|
||||
}
|
||||
})
|
||||
const unsubscribePool = createdPool.subscribe((s) => (poolState = s))
|
||||
// Untracked: following the link once is the whole job; a later change of the prop must
|
||||
// not rebuild every chat of the flow.
|
||||
const linked = untrack(() => openConversation)
|
||||
if (linked) createdPool.select(linked)
|
||||
listChat = createdList
|
||||
pool = createdPool
|
||||
return () => {
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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
|
||||
})
|
||||
})
|
||||
|
||||
@@ -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,
|
||||
@@ -20,7 +21,6 @@
|
||||
Trash2
|
||||
} from 'lucide-svelte'
|
||||
import { twMerge } from 'tailwind-merge'
|
||||
import type { Snippet } from 'svelte'
|
||||
import TextInput from '$lib/components/text_input/TextInput.svelte'
|
||||
import { goto } from '$lib/navigation'
|
||||
import { leaveForHome, openDraftOnHome, openNewSession } from './sessionSwitch.svelte'
|
||||
@@ -142,13 +142,6 @@
|
||||
// Drop the section's own outer padding/border so it sits flush inside a
|
||||
// parent container (e.g. gathered with Favorites/Search in the sidebar).
|
||||
embedded?: boolean
|
||||
// Render only the collapsed rail's session menu, opened by hovering this trigger
|
||||
// (rendered with melt's `trigger` and the unread total). The trigger's own click is
|
||||
// the host's: it never reaches the menu.
|
||||
hoverTrigger?: Snippet<[{ trigger: any; unread: number }]>
|
||||
// Shares the options row, left of its menu. With it the picker fills its parent and
|
||||
// scrolls the list alone, so the row stays in place.
|
||||
leading?: Snippet
|
||||
}
|
||||
|
||||
let {
|
||||
@@ -158,9 +151,7 @@
|
||||
browsedWorkspaceId = undefined,
|
||||
onBrowseWorkspace = undefined,
|
||||
onSelectSession = undefined,
|
||||
embedded = false,
|
||||
hoverTrigger = undefined,
|
||||
leading = undefined
|
||||
embedded = false
|
||||
}: Props = $props()
|
||||
|
||||
const sectionCollapsed = useLocalStorageValue(
|
||||
@@ -671,33 +662,29 @@
|
||||
unavailable (no provider configured or disabled in the user's settings)
|
||||
the section still shows — the per-session chat input is disabled with an
|
||||
explanatory message, mirroring the sidebar AI chat. -->
|
||||
{:else if isCollapsed || hoverTrigger}
|
||||
<div class={embedded || hoverTrigger ? '' : 'px-2 pt-3 pb-2 border-b border-light'}>
|
||||
{:else if isCollapsed}
|
||||
<div class={embedded ? '' : 'px-2 pt-3 pb-2 border-b border-light'}>
|
||||
<Menubar>
|
||||
{#snippet children({ createMenu })}
|
||||
<Menu {createMenu} usePointerDownOutside submenuSafe openOnHover={!!hoverTrigger}>
|
||||
<Menu {createMenu} usePointerDownOutside submenuSafe>
|
||||
{#snippet triggr({ trigger })}
|
||||
{#if hoverTrigger}
|
||||
{@render hoverTrigger({ trigger, unread: totalUnread })}
|
||||
{:else}
|
||||
<div class="relative">
|
||||
<MenuButton
|
||||
class="!text-xs"
|
||||
icon={MessageSquare}
|
||||
label="AI sessions"
|
||||
{isCollapsed}
|
||||
{trigger}
|
||||
/>
|
||||
{#if totalUnread > 0}
|
||||
<span
|
||||
class="absolute top-1 right-1 pointer-events-none inline-block w-2 h-2 rounded-full bg-surface-accent-primary"
|
||||
aria-label="{totalUnread} unread message{totalUnread === 1
|
||||
? ''
|
||||
: 's'} across all sessions"
|
||||
></span>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
<div class="relative">
|
||||
<MenuButton
|
||||
class="!text-xs"
|
||||
icon={MessageSquare}
|
||||
label="AI sessions"
|
||||
{isCollapsed}
|
||||
{trigger}
|
||||
/>
|
||||
{#if totalUnread > 0}
|
||||
<span
|
||||
class="absolute top-1 right-1 pointer-events-none inline-block w-2 h-2 rounded-full bg-surface-accent-primary"
|
||||
aria-label="{totalUnread} unread message{totalUnread === 1
|
||||
? ''
|
||||
: 's'} across all sessions"
|
||||
></span>
|
||||
{/if}
|
||||
</div>
|
||||
{/snippet}
|
||||
{#snippet children({ item, builders })}
|
||||
<div class="divide-y min-w-48" role="none">
|
||||
@@ -774,7 +761,7 @@
|
||||
<div
|
||||
class="flex flex-col gap-1 {embedded ? '' : 'px-2 pt-3 pb-2'} {!embedded && collapsible
|
||||
? 'border-b border-light'
|
||||
: ''} {leading ? 'flex-1 min-h-0' : ''}"
|
||||
: ''}"
|
||||
>
|
||||
<!-- Selection mode reuses the options row (same h-8 slot) so the list below it
|
||||
never moves. -->
|
||||
@@ -820,10 +807,7 @@
|
||||
{GROUP_BY_OPTIONS.find((o) => o.value === groupBy.val)?.hint ?? ''}
|
||||
</span>
|
||||
{/snippet}
|
||||
<div class="flex flex-row items-center gap-0.5 h-8 pr-0.5 {leading ? '' : 'justify-end'}">
|
||||
{#if leading}
|
||||
<div class="flex-1 min-w-0">{@render leading()}</div>
|
||||
{/if}
|
||||
{#snippet listOptions(size: 'sm' | 'md')}
|
||||
<DropdownV2
|
||||
fixedHeight={false}
|
||||
placement="bottom-end"
|
||||
@@ -871,7 +855,7 @@
|
||||
{#snippet buttonReplacement()}
|
||||
<Button
|
||||
nonCaptureEvent
|
||||
unifiedSize="md"
|
||||
unifiedSize={size}
|
||||
variant="subtle"
|
||||
iconOnly
|
||||
startIcon={{ icon: EllipsisVertical }}
|
||||
@@ -881,29 +865,35 @@
|
||||
/>
|
||||
{/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()}
|
||||
<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()}
|
||||
/>
|
||||
{@render listOptions('sm')}
|
||||
{/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
|
||||
@@ -915,8 +905,7 @@
|
||||
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]' : '',
|
||||
leading ? 'flex-1 min-h-0' : ''
|
||||
collapsible ? 'max-h-[40vh]' : ''
|
||||
)}
|
||||
onkeydown={handleListKeydown}
|
||||
role="listbox"
|
||||
@@ -1160,7 +1149,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' : ''
|
||||
)}
|
||||
@@ -1186,6 +1175,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"
|
||||
/>
|
||||
|
||||
@@ -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, 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,11 +21,9 @@ import {
|
||||
type SessionTarget
|
||||
} from './sessionState.svelte'
|
||||
import { sessionTargetHref, withPreviewParams } from './sessionMode.svelte'
|
||||
import { chosenSidebarList, type SidebarList } from './sidebarList.svelte'
|
||||
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'
|
||||
@@ -47,16 +45,6 @@ export function noteArrival(url: URL): void {
|
||||
}
|
||||
}
|
||||
|
||||
/** The Workspace ⇄ AI Sessions switch: swaps the sidebar's list and leaves the page where it
|
||||
* is. On Home it also opens the composer, for AI Sessions, or folds it, after the click has
|
||||
* played out, or the switch button it landed on takes focus back. */
|
||||
export function swapSidebarList(list: SidebarList, onHome: boolean): void {
|
||||
const swapped = swapHomeSide(list, () => (chosenSidebarList.val = list))
|
||||
if (!onHome) return
|
||||
if (list === 'workspace') 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
|
||||
// family: reviving another family's session would pull its scope into this one.
|
||||
function resumableSession(): Session | undefined {
|
||||
@@ -85,28 +73,37 @@ export async function resumeAiSessions(opts?: { replace?: boolean }): Promise<vo
|
||||
// A plain session starts on Home, and an unsent draft is shown there rather than on a
|
||||
// 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 }): Promise<void> {
|
||||
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
|
||||
|
||||
@@ -6,7 +6,6 @@ import {
|
||||
resumeAiSessions,
|
||||
startSessionWithPrompt
|
||||
} from './sessionSwitch.svelte'
|
||||
import { chosenSidebarList } from './sidebarList.svelte'
|
||||
import {
|
||||
getSessionAutoSendDomElement,
|
||||
homeDraft,
|
||||
@@ -100,28 +99,6 @@ describe('the sessions page resumes the last session opened', () => {
|
||||
restore()
|
||||
}
|
||||
})
|
||||
|
||||
// The sidebar's list is the switch's alone: neither a navigation nor opening a
|
||||
// session in Home's composer may change it.
|
||||
it('leaves the sidebar list to the switch', async () => {
|
||||
const restore = withTwoFamilies('rootA')
|
||||
vi.stubGlobal('window', { location: { pathname: '/runs' } })
|
||||
const prev = chosenSidebarList.val
|
||||
try {
|
||||
chosenSidebarList.val = 'workspace'
|
||||
noteArrival(new URL('http://localhost/sessions?session=sw-any'))
|
||||
await resumeAiSessions()
|
||||
expect(chosenSidebarList.val).toBe('workspace')
|
||||
chosenSidebarList.val = 'sessions'
|
||||
noteArrival(new URL('http://localhost/runs'))
|
||||
expect(chosenSidebarList.val).toBe('sessions')
|
||||
} finally {
|
||||
chosenSidebarList.val = prev
|
||||
vi.unstubAllGlobals()
|
||||
homeDraft.id = undefined
|
||||
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,17 +24,7 @@ export function sessionsSwitchShown(): boolean {
|
||||
)
|
||||
}
|
||||
|
||||
/** The list the sidebar shows, on every page. Only the Workspace ⇄ AI Sessions switch
|
||||
* changes it: navigating never does, so a session's page can sit beside the workspace nav
|
||||
* and a workspace page beside the session list. Per browser, so a reload keeps it. */
|
||||
export const chosenSidebarList = useLocalStorageValue<SidebarList>(
|
||||
'windmill_sidebar_list',
|
||||
'workspace',
|
||||
'string'
|
||||
)
|
||||
|
||||
/** 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 {
|
||||
chosenSidebarList.val = 'sessions'
|
||||
clearSessionsBetaOptOut('/')
|
||||
}
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
<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 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'
|
||||
)
|
||||
|
||||
// Read again on each navigation, so a chat started on a page lists once the reader moves on.
|
||||
// Tagged with its workspace: responses are not ordered, and a late one from the workspace
|
||||
// just left must not show here.
|
||||
const listing = resource(
|
||||
() => [$workspaceStore, page.url.pathname] as const,
|
||||
async ([ws]) => {
|
||||
if (!ws) return undefined
|
||||
const rows = await FlowConversationsService.listFlowConversations({
|
||||
workspace: ws,
|
||||
perPage: 30,
|
||||
kind: 'deployed'
|
||||
})
|
||||
return { ws, rows }
|
||||
}
|
||||
)
|
||||
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}
|
||||
@@ -43,8 +43,6 @@
|
||||
buttonClass?: string | undefined
|
||||
// Show a trailing chevron to signal the button opens a dropdown.
|
||||
showChevron?: boolean
|
||||
// An icon at the row's end, hidden with the label when collapsed.
|
||||
trailingIcon?: any | undefined
|
||||
// Render the label with stronger weight/size (e.g. the workspace name).
|
||||
emphasizeLabel?: boolean
|
||||
// Drop the native `title` attributes — for callers that wrap the button
|
||||
@@ -80,7 +78,6 @@
|
||||
class: classNames = undefined,
|
||||
buttonClass = undefined,
|
||||
showChevron = false,
|
||||
trailingIcon = undefined,
|
||||
emphasizeLabel = false,
|
||||
disableTitle = false,
|
||||
ariaLabel = undefined,
|
||||
@@ -125,11 +122,12 @@
|
||||
{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 h-7.
|
||||
sublabel ? 'h-10' : compact ? 'h-8' : 'h-7',
|
||||
classNames,
|
||||
buttonClass
|
||||
)}
|
||||
@@ -216,14 +214,6 @@
|
||||
/>
|
||||
{/if}
|
||||
|
||||
{#if trailingIcon && !isCollapsed}
|
||||
{@const TrailingIcon = trailingIcon}
|
||||
<TrailingIcon
|
||||
size={14}
|
||||
class="flex-shrink-0 text-tertiary transition-colors group-hover:text-secondary"
|
||||
/>
|
||||
{/if}
|
||||
|
||||
{#if isCollapsed && notificationsCount > 0}
|
||||
<div class="absolute top-1 right-1 flex h-fit w-fit">
|
||||
<SideBarNotification notificationCount={notificationsCount} small={true} />
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
item?: MenubarMenuElements['item'] | undefined
|
||||
class?: string
|
||||
onclick?: (ev: MouseEvent) => any
|
||||
// Further paths the row is selected on, for a link standing for several pages.
|
||||
alsoSelectedOn?: string[]
|
||||
}
|
||||
|
||||
let {
|
||||
@@ -33,7 +35,8 @@
|
||||
lightMode = false,
|
||||
item = undefined,
|
||||
class: classNames = '',
|
||||
onclick = undefined
|
||||
onclick = undefined,
|
||||
alsoSelectedOn = []
|
||||
}: Props = $props()
|
||||
|
||||
let isSelected = $state(false)
|
||||
@@ -42,7 +45,7 @@
|
||||
if (href === '/') {
|
||||
isSelected = $page.url.pathname === href
|
||||
} else {
|
||||
isSelected = $page.url.pathname.startsWith(href)
|
||||
isSelected = [href, ...alsoSelectedOn].some((p) => $page.url.pathname.startsWith(p))
|
||||
}
|
||||
})
|
||||
</script>
|
||||
@@ -60,7 +63,7 @@
|
||||
}}
|
||||
{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 h-7 gap-2',
|
||||
isSelected
|
||||
? sidebarClasses.selectedBg
|
||||
: item
|
||||
|
||||
@@ -277,9 +277,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 +310,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 pb-1">
|
||||
<MenuLink
|
||||
class="!text-xs"
|
||||
label="Workers"
|
||||
|
||||
@@ -33,8 +33,7 @@
|
||||
AlertCircle,
|
||||
Database,
|
||||
MailIcon,
|
||||
ChevronDown,
|
||||
ChevronRight
|
||||
Users
|
||||
} from 'lucide-svelte'
|
||||
import { useLocalStorageValue } from '$lib/svelte5Utils.svelte'
|
||||
import { slide } from 'svelte/transition'
|
||||
@@ -62,7 +61,8 @@
|
||||
MenuItem,
|
||||
MeltButton
|
||||
} from '$lib/components/meltComponents'
|
||||
import MenuButton from './MenuButton.svelte'
|
||||
import MenuButton, { sidebarClasses } 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'
|
||||
@@ -234,6 +234,32 @@
|
||||
}))
|
||||
.filter((l) => !excludeMainLabels.includes(l.label))
|
||||
)
|
||||
// Main-menu pages folded under one menu each, to keep the nav short.
|
||||
const MAIN_MENU_GROUPS = [
|
||||
{
|
||||
label: 'Data',
|
||||
icon: Database,
|
||||
members: ['Variables', 'Resources', 'Assets'],
|
||||
aiId: 'sidebar-menu-data',
|
||||
aiDescription: 'Menu with the variables, resources and assets pages'
|
||||
}
|
||||
]
|
||||
// Folders and Groups are one Sharing page with a tab each (SharingTabs): one row, leading to
|
||||
// the first of the two the role can see.
|
||||
const SHARING_LABELS = ['Folders', 'Groups']
|
||||
let sharingLinks = $derived(
|
||||
mainMenuLinks.filter((l) => SHARING_LABELS.includes(l.label) && !l.disabled)
|
||||
)
|
||||
const groupedLabels = new Set([...MAIN_MENU_GROUPS.flatMap((g) => g.members), ...SHARING_LABELS])
|
||||
let ungroupedMainLinks = $derived(mainMenuLinks.filter((l) => !groupedLabels.has(l.label)))
|
||||
// A disabled MenuLink renders nothing, so its page leaves the menu, and a group with no
|
||||
// page left leaves the nav.
|
||||
let mainMenuGroups = $derived(
|
||||
MAIN_MENU_GROUPS.map((g) => ({
|
||||
...g,
|
||||
links: mainMenuLinks.filter((l) => g.members.includes(l.label) && !l.disabled)
|
||||
})).filter((g) => g.links.length > 0)
|
||||
)
|
||||
let defaultExtraTriggerLinks = $derived([
|
||||
{
|
||||
label: 'HTTP',
|
||||
@@ -502,78 +528,134 @@
|
||||
<nav class={twMerge('flex flex-col overflow-x-hidden scrollbar-hidden px-2 md:pb-2 gap-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}
|
||||
<Menubar class="flex flex-col gap-0.5">
|
||||
{#snippet children({ createMenu })}
|
||||
{#each mainMenuGroups as group (group.label)}
|
||||
{@const onGroupPage = group.links.some((l) => page.url.pathname.startsWith(l.href))}
|
||||
<Menu {createMenu} usePointerDownOutside placement="bottom-start">
|
||||
{#snippet triggr({ trigger })}
|
||||
<MenuButton
|
||||
class="!text-xs"
|
||||
icon={group.icon}
|
||||
label={group.label}
|
||||
{isCollapsed}
|
||||
showChevron
|
||||
buttonClass={onGroupPage ? sidebarClasses.selectedBg : undefined}
|
||||
labelClass={onGroupPage ? sidebarClasses.selectedText : undefined}
|
||||
aiId={group.aiId}
|
||||
aiDescription={group.aiDescription}
|
||||
{trigger}
|
||||
/>
|
||||
{/snippet}
|
||||
{#snippet children({ item })}
|
||||
{#each group.links as link (link.href)}
|
||||
<MenuItem
|
||||
class={itemClass}
|
||||
href={link.href}
|
||||
{item}
|
||||
aiId={link.aiId}
|
||||
aiDescription={link.aiDescription}
|
||||
>
|
||||
<div class="flex flex-row items-center gap-2">
|
||||
<link.icon size={16} />
|
||||
{link.label}
|
||||
</div>
|
||||
</MenuItem>
|
||||
{/each}
|
||||
{/snippet}
|
||||
</Menu>
|
||||
{/each}
|
||||
{/snippet}
|
||||
</Menubar>
|
||||
{#if sharingLinks.length > 0}
|
||||
<MenuLink
|
||||
class="!text-xs"
|
||||
label="Sharing"
|
||||
href={sharingLinks[0].href}
|
||||
alsoSelectedOn={sharingLinks.map((l) => l.href)}
|
||||
icon={Users}
|
||||
{isCollapsed}
|
||||
aiId="sidebar-menu-link-sharing"
|
||||
aiDescription="Button to navigate to sharing: the folders items are shared through, and the groups of users they are shared with"
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
{#if showMain && showTriggersGroup}
|
||||
<div class="pt-4">
|
||||
<!-- 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>
|
||||
{#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>
|
||||
<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>
|
||||
|
||||
@@ -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] 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>
|
||||
@@ -24,6 +24,7 @@
|
||||
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 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 +67,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 +109,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,10 +120,7 @@
|
||||
parsePreviewItemRoute,
|
||||
barePath
|
||||
} from '$lib/components/sessions/previewPaths'
|
||||
import {
|
||||
chosenSidebarList,
|
||||
sessionsSwitchShown
|
||||
} 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'
|
||||
@@ -300,8 +297,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
|
||||
@@ -316,16 +313,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())
|
||||
// Where the switch is hidden, so is the session list.
|
||||
const sidebarList = $derived(chosenSidebarList.val)
|
||||
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
|
||||
)
|
||||
@@ -1125,9 +1119,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"
|
||||
@@ -1146,7 +1139,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. -->
|
||||
@@ -1193,9 +1186,7 @@ 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">
|
||||
<SettingsMenu
|
||||
@@ -1239,79 +1230,62 @@ 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>
|
||||
<!-- One box for the switch row and either list: the switch's view transition slides
|
||||
it sideways, and a box that changed size between the two would also move it
|
||||
vertically. Expanded, the session list carries the way back in its own row. -->
|
||||
<div class="wm-vt-sidebar-list flex flex-col flex-1 min-h-0">
|
||||
{#if switchRowShown && !(sidebarListsSessions && !collapsed)}
|
||||
<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} />
|
||||
</div>
|
||||
</div>
|
||||
<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}
|
||||
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}
|
||||
|
||||
{#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). -->
|
||||
{#if collapsed}
|
||||
<div class="px-2 py-2 flex flex-col gap-1 flex-1 min-h-0 overflow-y-auto">
|
||||
<SessionPicker isCollapsed embedded collapsible={false} />
|
||||
</div>
|
||||
{:else}
|
||||
<div class="px-2 pb-2 flex flex-col flex-1 min-h-0">
|
||||
<SessionPicker embedded collapsible={false}>
|
||||
{#snippet leading()}
|
||||
<SessionModeSwitch list="sessions" />
|
||||
{/snippet}
|
||||
</SessionPicker>
|
||||
</div>
|
||||
{/if}
|
||||
{@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
|
||||
</div>
|
||||
<!-- Pulled up into the Home band's slack under its centred row (48px band, 28px row), so
|
||||
Runs sits as far below Home as the nav's rows sit apart. Kept outside the scroll
|
||||
area: a negative margin inside it would clip Runs. -->
|
||||
<div class="flex flex-col flex-1 min-h-0 -mt-2">
|
||||
<!-- 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: Runs + Favorites + Search. -->
|
||||
<div class="px-2 flex flex-col gap-1 pt-1">
|
||||
<SidebarScrollArea color={darkMode ? SIDEBAR_BG_DARK : SIDEBAR_BG}>
|
||||
<!-- Section 1: Runs + Search, 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">
|
||||
{@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 collapsed}
|
||||
<MenuButton
|
||||
stopPropagationOnClick={true}
|
||||
on:click={() => openSearchModal()}
|
||||
isCollapsed={collapsed}
|
||||
icon={Search}
|
||||
label="Search"
|
||||
class="!text-xs"
|
||||
shortcut={`${getModifierKey()}k`}
|
||||
/>
|
||||
{/if}
|
||||
{#if askAiShown}
|
||||
<!-- Legacy Ask-AI pane, shown only when the user opted out of the
|
||||
AI Sessions beta (otherwise SessionModeSwitch replaces it). -->
|
||||
AI Sessions beta (otherwise the AI sessions section replaces it). -->
|
||||
<MenuButton
|
||||
stopPropagationOnClick={true}
|
||||
on:click={() => aiChatManager.toggleOpen()}
|
||||
@@ -1325,8 +1299,6 @@ outside this layout, and their shortcut must reopen the URL that is their creden
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<!-- Section 2: workspace items -->
|
||||
<SidebarContent
|
||||
isCollapsed={collapsed}
|
||||
showSecondary={false}
|
||||
@@ -1335,15 +1307,27 @@ outside this layout, and their shortcut must reopen the URL that is their creden
|
||||
? 0
|
||||
: numUnacknowledgedCriticalAlerts}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- Section 3: instance settings — mt-auto drops it to the bottom
|
||||
<!-- 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>
|
||||
|
||||
<!-- 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)}
|
||||
</div>
|
||||
</SidebarScrollArea>
|
||||
{/if}
|
||||
<div class="mt-auto">
|
||||
{@render settingsMenu(collapsed)}
|
||||
</div>
|
||||
</SidebarScrollArea>
|
||||
</div>
|
||||
|
||||
<div class="flex-shrink-0">
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
import Dropdown from '$lib/components/DropdownV2.svelte'
|
||||
import FolderEditorDrawer from '$lib/components/FolderEditorDrawer.svelte'
|
||||
import PageHeader from '$lib/components/PageHeader.svelte'
|
||||
import SharingTabs from '$lib/components/SharingTabs.svelte'
|
||||
import { userStore, workspaceStore, roleCapabilities } from '$lib/stores'
|
||||
import { Button, Drawer, DrawerContent, EmptyState, Skeleton } from '$lib/components/common'
|
||||
import FolderInfo from '$lib/components/FolderInfo.svelte'
|
||||
@@ -105,6 +106,7 @@
|
||||
</div>
|
||||
{:else}
|
||||
<CenteredPage>
|
||||
<SharingTabs selected="folders" />
|
||||
<PageHeader
|
||||
title="Folders"
|
||||
tooltip="Folders allow to group items such as scripts/flows/resources/schedule together and to grant homogenous RBAC permissions to groups and individual users towards them."
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
import InstanceGroupEditor from '$lib/components/InstanceGroupEditor.svelte'
|
||||
import GroupInfo from '$lib/components/GroupInfo.svelte'
|
||||
import PageHeader from '$lib/components/PageHeader.svelte'
|
||||
import SharingTabs from '$lib/components/SharingTabs.svelte'
|
||||
import SharedBadge from '$lib/components/SharedBadge.svelte'
|
||||
import { userStore, workspaceStore, roleCapabilities } from '$lib/stores'
|
||||
import { useEditRights } from '$lib/operatorWriteRights'
|
||||
@@ -77,6 +78,7 @@
|
||||
</div>
|
||||
{:else}
|
||||
<CenteredPage>
|
||||
<SharingTabs selected="groups" />
|
||||
<PageHeader
|
||||
title="Groups"
|
||||
tooltip="Group users together to grant roles and homegenous permissions. Same users can be in many groups at the same time."
|
||||
|
||||
@@ -1226,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
|
||||
|
||||
Reference in New Issue
Block a user