From 0119bd93b75b9bed6087b991fa5ce3f96b519df7 Mon Sep 17 00:00:00 2001 From: Guilhem Date: Tue, 3 Nov 2026 23:21:10 +0100 Subject: [PATCH] feat: let developers and operators pick the sidebar mode from one menu (#12124) * feat: let developers and operators pick the sidebar mode from one menu Co-Authored-By: Claude Opus 5.5 * chore: describe the footer's single mode button Co-Authored-By: Claude Opus 5.5 * fix: keep operators off the shared collapse preference and the narrow menu Co-Authored-By: Claude Opus 5.5 * feat: add expand-on-hover sidebar mode and a Cmd+\ rail toggle Co-Authored-By: Claude Opus 5.5 * feat: anchor sidebar rows across modes and open folded sections in popovers Co-Authored-By: Claude Opus 5.5 * feat: rework sidebar sections as foldable cards and keep hover mode on resize Co-Authored-By: Claude Opus 5.5 * feat: move sidebar mode menu to the hidden-mode handle and flash the mode button on change Co-Authored-By: Claude Opus 5.5 * fix: close section popovers on outside click, retract to icons only, and show section chevrons beside icons Co-Authored-By: Claude Opus 5.5 * refactor: build folded sidebar section flyouts on the melt menu with real submenus Co-Authored-By: Claude Opus 5.5 * fix: reveal the hidden sidebar from the keyboard, unclip nested submenus, close flyouts on any link Co-Authored-By: Claude Opus 5.5 * feat: put an unfolded section's chevron at the end of its row in the open sidebar Co-Authored-By: Claude Opus 5.5 * feat: start an unfolded section's title at the row's left edge Co-Authored-By: Claude Opus 5.5 * feat: show section rows as title and chevron only in the open sidebar Co-Authored-By: Claude Opus 5.5 * fix: keep a section title's line box the same folded and unfolded Co-Authored-By: Claude Opus 5.5 * feat: keep the folded AI sessions menu open for view options and edit sessions inside it Co-Authored-By: Claude Opus 5.5 * feat: show the hidden sidebar on keyboard focus of its handle instead of a menu item Co-Authored-By: Claude Opus 5.5 * feat: put session batch actions in one sticky row and hold the sidebar open while selecting Co-Authored-By: Claude Opus 5.5 * fix: leave session selection alone on an Esc that closes search, and end it when a menu batch delete is cancelled Co-Authored-By: Claude Opus 5.5 * fix: rename SidebarSection's children prop where the menu's own snippets shadow it Co-Authored-By: Claude Opus 5.5 * fix: render a section's title outside its fold control so folding cannot move it Co-Authored-By: Claude Opus 5.5 * feat: move the sidebar customization submenu from the settings menu to the sidebar mode menu Co-Authored-By: Claude Opus 5.5 * feat: let the sidebar's Customize menu hide the AI chats section Co-Authored-By: Claude Opus 5.5 * fix: show the sidebar's Customize menu in the narrow panel Co-Authored-By: Claude Opus 5.5 * feat: rename icons only to collapsed, add one-click collapse, label home row Co-Authored-By: Claude Opus 5.5 * fix: show the collapse button only in expanded and collapsed modes Co-Authored-By: Claude Opus 5.5 * fix: keep the home label until a click that leaves another page Co-Authored-By: Claude Opus 5.5 --------- Co-authored-by: Claude Opus 5.5 Co-authored-by: Ruben Fiszel --- .../lib/components/DropdownSubmenuItem.svelte | 40 +- .../src/lib/components/PageHeaderBar.svelte | 96 +- .../lib/components/meltComponents/Menu.svelte | 11 + .../components/meltComponents/MenuItem.svelte | 11 + .../sessions/SessionFilterMenu.svelte | 96 -- .../components/sessions/SessionPicker.svelte | 1128 ++++++++--------- .../sidebar/AccountSetupBanner.svelte | 4 +- .../components/sidebar/AiChatsSection.svelte | 44 +- .../sidebar/FavoritesSection.svelte | 52 +- .../lib/components/sidebar/MenuButton.svelte | 13 +- .../lib/components/sidebar/MenuLink.svelte | 19 +- .../components/sidebar/ModeButtonFlash.svelte | 14 + .../components/sidebar/SettingsMenu.svelte | 40 +- .../components/sidebar/SidebarContent.svelte | 169 +-- .../sidebar/SidebarScrollArea.svelte | 8 +- .../components/sidebar/SidebarSection.svelte | 262 ++++ .../sidebar/SidebarSectionHeader.svelte | 48 - .../components/sidebar/SidebarUsage.svelte | 6 +- .../sidebar/navHandlePlacement.svelte.ts | 26 + .../components/sidebar/sidebarPrefs.svelte.ts | 14 +- frontend/src/lib/utils.ts | 3 + .../src/routes/(root)/(logged)/+layout.svelte | 339 +++-- 22 files changed, 1420 insertions(+), 1023 deletions(-) delete mode 100644 frontend/src/lib/components/sessions/SessionFilterMenu.svelte create mode 100644 frontend/src/lib/components/sidebar/ModeButtonFlash.svelte create mode 100644 frontend/src/lib/components/sidebar/SidebarSection.svelte delete mode 100644 frontend/src/lib/components/sidebar/SidebarSectionHeader.svelte diff --git a/frontend/src/lib/components/DropdownSubmenuItem.svelte b/frontend/src/lib/components/DropdownSubmenuItem.svelte index a67411a039..87ef4ef048 100644 --- a/frontend/src/lib/components/DropdownSubmenuItem.svelte +++ b/frontend/src/lib/components/DropdownSubmenuItem.svelte @@ -8,15 +8,18 @@ import type { Item } from '$lib/utils' import type { MenubarMenuElements, createDropdownMenu } from '@melt-ui/svelte' import { Tooltip } from './meltComponents' + import DropdownSubmenuItem from './DropdownSubmenuItem.svelte' interface Props { item: Item builders: ReturnType['builders'] meltItem: MenubarMenuElements['item'] close?: (afterClose?: () => void) => void + /** Classes merged onto the row that opens the submenu. */ + class?: string } - let { item, builders, meltItem, close }: Props = $props() + let { item, builders, meltItem, close, class: className = '' }: Props = $props() const { elements: { subTrigger, subMenu }, @@ -33,11 +36,12 @@ class={twMerge( 'px-4 py-2 text-primary font-normal hover:bg-surface-hover cursor-pointer text-xs transition-colors w-full', 'data-[highlighted]:bg-surface-hover', - 'flex flex-row gap-2 items-center rounded-sm' + 'flex flex-row gap-2 items-center rounded-sm', + className )} > {#if item.icon} - + {/if}

{item.displayName} @@ -51,23 +55,29 @@ use:melt={$subMenu} class="z-[6000] bg-surface-tertiary dark:border {CustomSubmenu ? '' - : 'w-48 overflow-y-auto py-1'} origin-top-right rounded-lg shadow-lg focus:outline-none" + : 'w-48 py-1'} origin-top-right rounded-lg shadow-lg focus:outline-none" > {#if CustomSubmenu} {:else} - {#each subItems as subItem} - {#if subItem.separatorTop} -

- {/if} - {@render subMenuItem(subItem)} - {/each} + +
+ {#each subItems as subItem} + {#if subItem.separatorTop} +
+ {/if} + {@render subMenuItem(subItem)} + {/each} +
{/if} {/if} {#snippet subMenuItem(subItem: Item)} - {#if subItem.disabled && subItem.tooltip} + {#if subItem.submenuItems || subItem.customSubmenu} + + {:else if subItem.disabled && subItem.tooltip}
@@ -84,6 +94,7 @@ href={subItem?.href} target={subItem?.hrefTarget} disabled={subItem?.disabled} + keepOpen={subItem.keepOpen} class={twMerge( 'px-4 py-2 text-primary font-normal hover:bg-surface-hover cursor-pointer text-xs transition-colors w-full', 'data-[highlighted]:bg-surface-hover', @@ -94,7 +105,12 @@ item={meltItem} > {#if subItem.icon} - + {/if}

import { ChevronDown, PanelLeft } from 'lucide-svelte' import { Button } from '$lib/components/common' + import DropdownV2 from '$lib/components/DropdownV2.svelte' + import { BROWSER } from 'esm-env' import { navDetached } from './sidebar/navDetached.svelte' import { navHandleSlot } from './sidebar/navHandlePlacement.svelte' + import ModeButtonFlash from './sidebar/ModeButtonFlash.svelte' import NavBreadcrumb from './NavBreadcrumb.svelte' import BreadcrumbNavPicker from './BreadcrumbNavPicker.svelte' import { BAR_HEIGHT, pageHeader, PHONE_BAR } from './pageHeaderRegistry.svelte' @@ -31,6 +34,39 @@ The row's height matches the sidebar's own header row, so the two read as one ba panelled?: boolean } = $props() + // Read once, as the layout does: whether the card slides in on hover or waits for a tap. + const hoverPointer = BROWSER && window.matchMedia('(hover: hover)').matches + // Below the layout's 768px breakpoint the sidebar is a drawer whatever the mode, so the handle + // has no mode to offer there. + let innerWidth = $state(BROWSER ? window.innerWidth : 0) + + // The keyboard's way to the hidden sidebar: focusing the handle shows the card as hovering it + // does, and Tab from the handle goes into the card, which comes later in no tab order. Focus + // coming back from the card (Esc) or from the handle's menu does not show it again. + function cameFromCardOrMenu(e: FocusEvent): boolean { + return !!(e.relatedTarget as Element | null)?.closest('[data-nav-card], [role="menu"]') + } + // A closing menu is gone before focus returns, so that return carries no related target. + let focusInHandleMenu = false + function revealOnKeyboardFocus(e: FocusEvent) { + const fromMenu = focusInHandleMenu + focusInHandleMenu = false + if (!(e.target as Element).matches(':focus-visible') || fromMenu || cameFromCardOrMenu(e)) + return + navHandleSlot.open() + } + function hideOnBlur(e: FocusEvent) { + if ((e.relatedTarget as Element | null)?.closest('[role="menu"]')) focusInHandleMenu = true + if (!cameFromCardOrMenu(e)) navHandleSlot.scheduleClose() + } + function tabIntoCard(e: KeyboardEvent) { + if (e.key !== 'Tab' || e.shiftKey) return + const link = document.querySelector('[data-nav-card] a[href]') + if (!link || link.closest('[inert]')) return + e.preventDefault() + if (!navHandleSlot.pinned) navHandleSlot.toggle() + link.focus() + } const content = $derived(pageHeader.content) const actions = $derived(pageHeader.actions) const hasActions = $derived(actions.length > 0) @@ -167,7 +203,7 @@ The row's height matches the sidebar's own header row, so the two read as one ba const showEdge = $derived(separator === 'always' || (separator === 'onScroll' && scrolledUnder)) - + +

navHandleSlot.open()} onmouseleave={() => navHandleSlot.scheduleClose()} + onfocusin={revealOnKeyboardFocus} + onfocusout={hideOnBlur} + onkeydown={tabIntoCard} > + -
{/if} diff --git a/frontend/src/lib/components/meltComponents/Menu.svelte b/frontend/src/lib/components/meltComponents/Menu.svelte index ce07341487..39b679765f 100644 --- a/frontend/src/lib/components/meltComponents/Menu.svelte +++ b/frontend/src/lib/components/meltComponents/Menu.svelte @@ -38,6 +38,10 @@ // Open on hover without pinning, so the menu closes again once the pointer leaves. // A click then pins it open until a click outside or on the trigger. openOnHover?: boolean + // A click inside the hover-opened content pins it too, for content that changes size + // under the pointer: a menu that grows near the window's edge moves, and the pointer + // it leaves behind would close it. + pinOnClick?: boolean // Grace period before a hover-opened menu closes, so the pointer can travel from // the trigger to the content. debounceDelay?: number @@ -68,6 +72,7 @@ renderContent = false, submenuSafe = false, openOnHover = false, + pinOnClick = false, debounceDelay = 150, class: classNames = '', closeFocus = undefined, @@ -233,6 +238,12 @@ data-menu onmouseenter={cancelPendingClose} onmouseleave={scheduleClose} + onclickcapture={() => { + if (openOnHover && pinOnClick && open) { + cancelPendingClose() + pinned = true + } + }} transition:placementFly={{ duration: 100, placement }} style={contentStyle} class={twMerge( diff --git a/frontend/src/lib/components/meltComponents/MenuItem.svelte b/frontend/src/lib/components/meltComponents/MenuItem.svelte index 282dc893da..2ab73e74ae 100644 --- a/frontend/src/lib/components/meltComponents/MenuItem.svelte +++ b/frontend/src/lib/components/meltComponents/MenuItem.svelte @@ -2,8 +2,11 @@ import { melt } from '@melt-ui/svelte' import type { MenubarMenuElements } from '@melt-ui/svelte' import { triggerableByAI } from '$lib/actions/triggerableByAI.svelte' + import { onCustomEvent } from '$lib/svelte5Utils.svelte' interface Props { + /** The menu stays open after a click on this item, for a setting whose effect shows in it. */ + keepOpen?: boolean aiId?: string | undefined aiDescription?: string | undefined href?: string | undefined @@ -19,6 +22,7 @@ } let { + keepOpen = false, aiId = undefined, aiDescription = undefined, href = undefined, @@ -66,6 +70,13 @@ bind:this={buttonRef} onclick={onClick} use:melt={$item} + use:onCustomEvent={{ + event: 'm-click', + // Cancelling melt's own click event skips its close; the click itself still runs. + handler: (e: Event) => { + if (keepOpen) e.preventDefault() + } + }} use:triggerableByAI={{ id: aiId, description: aiDescription, diff --git a/frontend/src/lib/components/sessions/SessionFilterMenu.svelte b/frontend/src/lib/components/sessions/SessionFilterMenu.svelte deleted file mode 100644 index d375c5f286..0000000000 --- a/frontend/src/lib/components/sessions/SessionFilterMenu.svelte +++ /dev/null @@ -1,96 +0,0 @@ - - - - -{#if $subOpen} -
- -
- - {#if archivedCount > 0} - - {archivedCount} archived session{archivedCount === 1 ? '' : 's'} - - {/if} -
-
-
Last activity
- {#each LAST_ACTIVITY_OPTIONS as option (option.days)} - - {/each} -
-
Group by
- {#each GROUP_BY_OPTIONS as option (option.value)} - - {/each} -
-{/if} diff --git a/frontend/src/lib/components/sessions/SessionPicker.svelte b/frontend/src/lib/components/sessions/SessionPicker.svelte index ac47a1fdbd..b194592809 100644 --- a/frontend/src/lib/components/sessions/SessionPicker.svelte +++ b/frontend/src/lib/components/sessions/SessionPicker.svelte @@ -2,7 +2,12 @@ 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 SidebarSection, { + flyoutRowClass, + type SectionActionsArgs + } from '$lib/components/sidebar/SidebarSection.svelte' + import DropdownSubmenuItem from '$lib/components/DropdownSubmenuItem.svelte' + import type { Item } from '$lib/utils' import { Archive, ArchiveRestore, @@ -11,6 +16,7 @@ ChevronRight, Clock, EllipsisVertical, + SlidersHorizontal, GitFork, ListChecks, MessageSquare, @@ -24,9 +30,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 { deleteSessionsForWorkspace, homeDraft, @@ -56,8 +60,6 @@ import SessionStatusDot from './SessionStatusDot.svelte' import UnreadCountBadge from '$lib/components/common/badge/UnreadCountBadge.svelte' import { buildWorkspaceHierarchy } from '$lib/utils/workspaceHierarchy' - import SessionFilterMenu from './SessionFilterMenu.svelte' - import { Menu, Menubar, MenuItem } from '$lib/components/meltComponents' import MenuButton, { sidebarClasses } from '$lib/components/sidebar/MenuButton.svelte' import DropdownV2 from '$lib/components/DropdownV2.svelte' import { userStore, userWorkspaces, workspaceStore } from '$lib/stores' @@ -66,6 +68,7 @@ import { sendUserToast } from '$lib/toast' import { currentWorkspaceRootId, workspaceRootId } from './sessionScope.svelte' import { page } from '$app/state' + import { overlayStack } from '$lib/components/common/overlayHost.svelte' import DevWorkspaceBadge from '$lib/components/DevWorkspaceBadge.svelte' import { dateBucket, @@ -377,9 +380,11 @@ // otherwise hide the user's first new session with no way to expand // it. Resetting here keeps the section expanded by default whenever // the first session arrives. Guarded on the current value so it writes - // once (true → false) rather than looping. + // once (true → false) rather than looping, and on hydration: before the + // sessions load, the list is empty for every reader, and the fold is a + // layout they chose to keep. $effect(() => { - if (visibleSessions.length === 0 && sectionCollapsed.val) { + if (sessionState.hydrated && visibleSessions.length === 0 && sectionCollapsed.val) { sectionCollapsed.val = false } }) @@ -423,16 +428,6 @@ } } - // 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, // which the header switches to, since Home's draft acts on the header's workspace. async function createAndOpenIn(workspaceId: string) { @@ -478,8 +473,11 @@ // Batch selection: "Edit sessions" in the header menu turns the rows into // checkboxes so several sessions can be deleted in one pass. let selectionMode = $state(false) + // Entered from the folded section's menu, whose own list then takes the checkboxes. + let selectionInFlyout = $state(false) let selectedIds = $state([]) let batchDeleteOpen = $state(false) + const viewportOverlays = overlayStack() const selectableIds = $derived(visibleSessions.map((s) => s.id)) const allSelected = $derived( @@ -505,15 +503,65 @@ if (pruned.length !== selectedIds.length) selectedIds = pruned }) - function enterSelectionMode() { + function enterSelectionMode(inFlyout: boolean) { selectionMode = true + selectionInFlyout = inFlyout selectedIds = [] // Checkboxes are unreachable while the section is folded away. - sectionCollapsed.val = false + if (!inFlyout) sectionCollapsed.val = false + } + + // The session list's options, for the ⋮ menu of the open list and the View submenu of the + // folded section's menu. That menu lists the sessions too, so it stays open to show the change. + function listOptionItems(inFlyout: boolean): Item[] { + return [ + { + displayName: archivedCount > 0 ? `Show archived (${archivedCount})` : 'Show archived', + icon: Archive, + toggle: showArchived.val, + keepOpen: inFlyout, + action: () => (showArchived.val = !showArchived.val) + }, + { + displayName: 'Last activity', + icon: Clock, + extra: lastActivityHint, + submenuItems: LAST_ACTIVITY_OPTIONS.map((o) => ({ + displayName: o.label, + selected: lastActivityDays.val === o.days, + keepOpen: inFlyout, + action: () => (lastActivityDays.val = o.days) + })) + }, + { + displayName: 'Group by', + icon: Rows3, + extra: groupByHint, + submenuItems: GROUP_BY_OPTIONS.map((o) => ({ + displayName: o.label, + selected: groupBy.val === o.value, + keepOpen: inFlyout, + action: () => (groupBy.val = o.value) + })) + }, + { + displayName: 'Edit sessions', + icon: ListChecks, + keepOpen: inFlyout, + action: () => enterSelectionMode(inFlyout), + separatorTop: true, + // Selection is built from `visibleSessions`, which the tree render + // path doesn't follow — it drops workspace-less sessions and hides + // rows under a collapsed workspace, so "Select all" there would + // reach rows that never showed a checkbox. + hide: visibleSessions.length === 0 || workspaceTree + } + ] } function exitSelectionMode() { selectionMode = false + selectionInFlyout = false selectedIds = [] rangeAnchorId = undefined } @@ -657,580 +705,491 @@ else if (e.key === 'Home') focusAt(0) else if (e.key === 'End') focusAt(buttons.length - 1) } - - const menuItemBase = twMerge( - 'text-secondary text-left font-normal text-xs', - 'flex flex-row items-center gap-2 px-3 py-1.5 w-full', - 'data-[highlighted]:bg-surface-hover data-[highlighted]:text-primary' - ) -{#if isCollapsed} -
- - {#snippet children({ createMenu })} - - {#snippet triggr({ trigger })} -
+
+ + {#snippet selectionBar()} +
+ 0 && !allSelected} + onChange={toggleSelectAll} + class="shrink-0 !w-4 !h-4 !p-0" + title="Select all sessions" + /> + + + {selectedIds.length} selected + +
+ {/snippet} + {#if selectionMode && !selectionInFlyout} + {@render selectionBar()} + {@render sessionList(false)} + {:else} + {#snippet listOptions(size: 'xs' | 'sm' | 'md')} + + {#snippet buttonReplacement()} + + +
+ startRename(session) + }, + ...(session.archived + ? // No Unarchive when the workspace is gone — it can't persist + // (putSession guard) and reconcile would re-archive it. + isUnavailableFork(session) + ? [] + : [ + { + displayName: 'Unarchive', + icon: ArchiveRestore, + action: () => setSessionArchived(session.id, false) + } + ] + : [ + { + displayName: 'Archive', + icon: Archive, + action: () => { + setSessionArchived(session.id, true) + leaveArchivedHomeDraft([session.id]) + } + } + ]), + { + displayName: 'Delete', + icon: Trash2, + type: 'delete', + action: () => (pendingDelete = session) + } + ]} + > + {#snippet buttonReplacement()} + + + + {/snippet} + +
+ {/if} +
+ {/snippet} + {#if workspaceTree} + {#each workspaceTreeItems as item, wi (item.workspace.id)} + {#if !hiddenWorkspaceIds.has(item.workspace.id)} + {@const wsSessions = sessionsByWorkspace.get(item.workspace.id) ?? []} + {@const collapsed = isWorkspaceCollapsed(item.workspace.id)} + {@const collapsible = item.hasChildren || wsSessions.length > 0} + +
0 && item.depth === 0 ? 'mt-3' : '', + browsedWorkspaceId === item.workspace.id + ? sidebarClasses.selectedBg + : 'hover:bg-surface-hover' + )} + > + {#each Array(item.depth) as _}{@render vline()}{/each} + + {#if collapsible} + {/if}
- {/snippet} - {#snippet children({ item, builders })} -
-
- { - newSessionFromRail = true - void openNewSession() - }} - {item} - > - - New session - -
-
- w.id === groupWsId) + : undefined} + +
0 ? 'mt-4' : '', + // The rail keeps the header's height, not its words. + rail ? 'invisible' : '' + )} + title={group.label} + > + + {group.label} + + {#if groupWs?.is_dev_workspace} + -
-
- {#each displayGroups as group (group.key)} - {#if group.showHeader} -
- {group.label} -
- {/if} - {#each group.sessions as session (session.id)} - {@const runtime = getRuntime(session.id)} - {@const status = runtime - ? getSessionChatStatus(runtime) - : (getSessionChatPeek(session.id)?.status ?? 'idle')} - {@const isSelected = session.id === activeRowId} - {@const unread = unreadFor(session)} - {@const draft = hasDraft(session)} - activate(session)} - {item} - > - - 0 ? 'font-semibold text-primary' : '' - )} - > - {session.summary ?? 'Untitled session'} - - {#if draft || unread > 0} - - {#if draft} - - {/if} - - - {/if} - - {/each} - {/each} -
+ {/if} + {#if groupWsId} +
- {/snippet} -
- {/snippet} -
-
-{:else} -
- - {#if selectionMode} -
- 0 && !allSelected} - onChange={toggleSelectAll} - class="shrink-0 !w-4 !h-4 !p-0" - title="Select all sessions" + {/if} + {#each group.sessions as session (session.id)} + {@render sessionRow(session, group.showHeader, undefined)} + {/each} + {/each} + {/if} +
+ {#if selecting} + +
+ - - {selectedIds.length} selected - + unifiedSize="sm" + variant="default" + destructive + iconOnly + disabled={selectedIds.length === 0} + startIcon={{ icon: Trash2 }} + title="Delete selected" + aria-label="Delete selected" + onClick={() => (batchDeleteOpen = true)} + />
- {:else} - - {#snippet lastActivityHint()} - - {LAST_ACTIVITY_OPTIONS.find((o) => o.days === lastActivityDays.val)?.hint ?? ''} - - {/snippet} - {#snippet groupByHint()} - - {GROUP_BY_OPTIONS.find((o) => o.value === groupBy.val)?.hint ?? ''} - - {/snippet} - {#snippet listOptions(size: 'sm' | 'md')} - 0 ? `Show archived (${archivedCount})` : 'Show archived', - icon: Archive, - toggle: showArchived.val, - action: () => (showArchived.val = !showArchived.val) - }, - { - displayName: 'Last activity', - icon: Clock, - extra: lastActivityHint, - submenuItems: LAST_ACTIVITY_OPTIONS.map((o) => ({ - displayName: o.label, - selected: lastActivityDays.val === o.days, - action: () => (lastActivityDays.val = o.days) - })) - }, - { - displayName: 'Group by', - icon: Rows3, - extra: groupByHint, - submenuItems: GROUP_BY_OPTIONS.map((o) => ({ - displayName: o.label, - selected: groupBy.val === o.value, - action: () => (groupBy.val = o.value) - })) - }, - { - displayName: 'Edit sessions', - icon: ListChecks, - action: enterSelectionMode, - separatorTop: true, - // Selection is built from `visibleSessions`, which the tree render - // path doesn't follow — it drops workspace-less sessions and hides - // rows under a collapsed workspace, so "Select all" there would - // reach rows that never showed a checkbox. - hide: visibleSessions.length === 0 || workspaceTree - } - ]} - > - {#snippet buttonReplacement()} - - -
- startRename(session) - }, - ...(session.archived - ? // No Unarchive when the workspace is gone — it can't persist - // (putSession guard) and reconcile would re-archive it. - isUnavailableFork(session) - ? [] - : [ - { - displayName: 'Unarchive', - icon: ArchiveRestore, - action: () => setSessionArchived(session.id, false) - } - ] - : [ - { - displayName: 'Archive', - icon: Archive, - action: () => { - setSessionArchived(session.id, true) - leaveArchivedHomeDraft([session.id]) - } - } - ]), - { - displayName: 'Delete', - icon: Trash2, - type: 'delete', - action: () => (pendingDelete = session) - } - ]} - > - {#snippet buttonReplacement()} - - - - {/snippet} - -
- {/if} -
- {/snippet} - {#if workspaceTree} - {#each workspaceTreeItems as item, wi (item.workspace.id)} - {#if !hiddenWorkspaceIds.has(item.workspace.id)} - {@const wsSessions = sessionsByWorkspace.get(item.workspace.id) ?? []} - {@const collapsed = isWorkspaceCollapsed(item.workspace.id)} - {@const collapsible = item.hasChildren || wsSessions.length > 0} - -
0 && item.depth === 0 ? 'mt-3' : '', - browsedWorkspaceId === item.workspace.id - ? sidebarClasses.selectedBg - : 'hover:bg-surface-hover' - )} - > - {#each Array(item.depth) as _}{@render vline()}{/each} - - {#if collapsible} - - {/if} -
- {#if !collapsed} - {#each wsSessions as session (session.id)} - {@render sessionRow(session, true, item.depth + 1)} - {/each} - {/if} - {/if} - {/each} - {:else} - {#each displayGroups as group, groupIdx (group.key)} - {#if group.showHeader} - {@const groupWsId = group.workspaceId} - {@const groupWs = groupWsId - ? $userWorkspaces.find((w) => w.id === groupWsId) - : undefined} - -
0 ? 'mt-4' : '' - )} - title={group.label} - > - - {group.label} - - {#if groupWs?.is_dev_workspace} - - {/if} - {#if groupWsId} -
- {/if} - {#each group.sessions as session (session.id)} - {@render sessionRow(session, group.showHeader, undefined)} - {/each} - {/each} - {/if} -
- {#if selectionMode} - -
- - -
- {/if} - {/if} - -{/if} + {/snippet} + + + + + { + if (e.key !== 'Escape' || !selectionMode || batchDeleteOpen) return + if (viewportOverlays.val.length > 0) return + setTimeout(() => { + if (e.defaultPrevented || document.querySelector('[role="menu"]:not([hidden])')) return + exitSelectionMode() + }) + }} +/> (batchDeleteOpen = false)} + onCanceled={() => { + batchDeleteOpen = false + // The confirmation closed the folded section's menu the selection was made in. + if (selectionInFlyout) exitSelectionMode() + }} >

@@ -1288,3 +1251,16 @@ {/if}

+ + +{#snippet lastActivityHint()} + + {LAST_ACTIVITY_OPTIONS.find((o) => o.days === lastActivityDays.val)?.hint ?? ''} + +{/snippet} +{#snippet groupByHint()} + + {GROUP_BY_OPTIONS.find((o) => o.value === groupBy.val)?.hint ?? ''} + +{/snippet} diff --git a/frontend/src/lib/components/sidebar/AccountSetupBanner.svelte b/frontend/src/lib/components/sidebar/AccountSetupBanner.svelte index 275a453a44..ad6b1f3b7d 100644 --- a/frontend/src/lib/components/sidebar/AccountSetupBanner.svelte +++ b/frontend/src/lib/components/sidebar/AccountSetupBanner.svelte @@ -30,7 +30,9 @@ icon={KeyRound} iconClasses="text-accent" labelClass="text-accent font-semibold" - buttonClass="border border-border-selected/50 bg-surface-accent-selected hover:bg-surface-accent-selected hover:border-border-selected" + buttonClass="border border-border-selected/50 bg-surface-accent-selected hover:bg-surface-accent-selected hover:border-border-selected {isCollapsed + ? 'h-10' + : ''}" {isCollapsed} stopPropagationOnClick on:click={() => (accountSetup.open = true)} diff --git a/frontend/src/lib/components/sidebar/AiChatsSection.svelte b/frontend/src/lib/components/sidebar/AiChatsSection.svelte index d29c1ffda7..662174f7ae 100644 --- a/frontend/src/lib/components/sidebar/AiChatsSection.svelte +++ b/frontend/src/lib/components/sidebar/AiChatsSection.svelte @@ -1,9 +1,8 @@ -{#if !isCollapsed && rows.length > 0} -
- (sectionCollapsed.val = !sectionCollapsed.val)} - /> - {#if !sectionCollapsed.val} +{#if rows.length > 0} + (sectionCollapsed.val = !sectionCollapsed.val)} + {isCollapsed} + > + {#snippet children(inPopover)} + {@const rail = isCollapsed && !inPopover}
{#each rows as c (c.id)} {@const t = target(c)} @@ -79,7 +79,9 @@ 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', + // shrink-0: in the capped list a row would otherwise shrink to its content, + // which is shorter in the rail, where it has no label. + 'flex flex-row items-center gap-2 px-2 h-6 shrink-0 rounded text-xs font-normal min-w-0', selected ? twMerge(sidebarClasses.selectedBg, sidebarClasses.selectedText) : 'text-secondary hover:bg-surface-hover' @@ -90,10 +92,10 @@ {:else} {/if} - {c.title || 'Untitled chat'} + {c.title || 'Untitled chat'} {/each}
- {/if} -
+ {/snippet} + {/if} diff --git a/frontend/src/lib/components/sidebar/FavoritesSection.svelte b/frontend/src/lib/components/sidebar/FavoritesSection.svelte index 47a75a2b43..93de979118 100644 --- a/frontend/src/lib/components/sidebar/FavoritesSection.svelte +++ b/frontend/src/lib/components/sidebar/FavoritesSection.svelte @@ -1,19 +1,17 @@ -{#if sidebarPrefs.favorites.val && !isCollapsed && loaded} -
- (sectionCollapsed.val = !sectionCollapsed.val)} - /> - {#if !sectionCollapsed.val} -
+{#if sidebarPrefs.favorites.val && loaded} + (sectionCollapsed.val = !sectionCollapsed.val)} + {isCollapsed} + > + {#snippet children(inPopover)} + {@const rail = isCollapsed && !inPopover} +
{#each favoriteManager.current as favorite (`${favorite.kind}:${favorite.path}`)} {@const selected = favorite.href !== '#' && page.url.pathname === favorite.href}
@@ -52,7 +52,8 @@ Hidden in the collapsed rail, like the AI chats. 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', + 'flex flex-row items-center gap-2 px-2 h-6 rounded text-xs font-normal min-w-0', + rail ? '' : 'pr-7', selected ? twMerge(sidebarClasses.selectedBg, sidebarClasses.selectedText) : 'text-secondary hover:bg-surface-hover' @@ -70,10 +71,13 @@ Hidden in the collapsed rail, like the AI chats. {:else} {/if} - {favorite.label} + {favorite.label}
{:else} -

Star an item to list it here.

+ +

+ Star an item to list it here. +

{/each}
- {/if} -
+ {/snippet} +
{/if} diff --git a/frontend/src/lib/components/sidebar/MenuButton.svelte b/frontend/src/lib/components/sidebar/MenuButton.svelte index 3f9d2ec7b9..17fa927501 100644 --- a/frontend/src/lib/components/sidebar/MenuButton.svelte +++ b/frontend/src/lib/components/sidebar/MenuButton.svelte @@ -35,6 +35,8 @@ notificationsCount?: number color?: string | null trigger?: MenubarMenuElements['trigger'] | undefined + /** Makes the button an item of an enclosing melt menu, in place of a trigger. */ + item?: MenubarMenuElements['item'] | undefined href?: string | undefined /** Applied to the button AND to the label, so text sizing reaches the label text. */ class?: string | undefined @@ -74,6 +76,7 @@ notificationsCount = 0, color = null, trigger = undefined, + item = undefined, href = undefined, class: classNames = undefined, buttonClass = undefined, @@ -86,6 +89,7 @@ }: Props = $props() let buttonRef: HTMLButtonElement | HTMLAnchorElement | undefined = $state(undefined) + const meltElement = $derived(trigger ?? item) let dispatch = createEventDispatcher() @@ -126,16 +130,15 @@ compact ? 'w-auto' : 'w-full', sidebarClasses.hoverBg, 'transition-all relative', - // 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]', + // One height in the rail and the open sidebar, so a row keeps its place in every mode. + sublabel ? 'h-10' : 'h-[30px]', classNames, buttonClass )} - use:conditionalMelt={trigger} + use:conditionalMelt={meltElement} aria-label={ariaLabel ?? label} title={isCollapsed || disableTitle ? undefined : label} - {...$trigger} + {...$meltElement} > {#if icon} {@const SvelteComponent = icon} diff --git a/frontend/src/lib/components/sidebar/MenuLink.svelte b/frontend/src/lib/components/sidebar/MenuLink.svelte index d0063e8677..46a7022b82 100644 --- a/frontend/src/lib/components/sidebar/MenuLink.svelte +++ b/frontend/src/lib/components/sidebar/MenuLink.svelte @@ -12,8 +12,11 @@ aiId?: string | undefined aiDescription?: string | undefined label: string + // Native tooltip in every mode, for a row whose label does not say where it goes. + hint?: string | undefined href: string icon?: any | undefined + iconProps?: Record isCollapsed: boolean disabled?: boolean lightMode?: boolean @@ -26,8 +29,10 @@ aiId = undefined, aiDescription = undefined, label, + hint = undefined, href, icon = undefined, + iconProps = {}, isCollapsed, disabled = false, lightMode = false, @@ -48,7 +53,12 @@ {#if !disabled} - + {#if icon} {@const SvelteComponent = icon} + import { navHandleSlot } from './navHandlePlacement.svelte' + + + +{#if navHandleSlot.modeFlash} + {#key navHandleSlot.modeFlash} + + {/key} +{/if} diff --git a/frontend/src/lib/components/sidebar/SettingsMenu.svelte b/frontend/src/lib/components/sidebar/SettingsMenu.svelte index a2b00c508b..6833e8089e 100644 --- a/frontend/src/lib/components/sidebar/SettingsMenu.svelte +++ b/frontend/src/lib/components/sidebar/SettingsMenu.svelte @@ -20,14 +20,11 @@ Trash2, KeyRound, GraduationCap, - PanelLeft, - Star, FolderOpen, Users, ShieldCheck } from 'lucide-svelte' import AccessDrawer from '../AccessDrawer.svelte' - import { sidebarPrefs } from './sidebarPrefs.svelte' import { goto } from '$lib/navigation' import { type Item } from '$lib/utils' import { logout } from '$lib/logoutKit' @@ -215,18 +212,6 @@ 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 @@ -320,7 +305,10 @@ {/snippet} + as plain links above the Settings dropdown rather than inside it. + The dropdown triggers below are anchored left and clip their row: DropdownV2 justifies its + button's content to the end, and Firefox repaints a button whose content overflows it, which + a label showing while the sidebar is still narrow would do on every frame of the expand. -->
{#snippet buttonReplacement()} - + {#if !isCollapsed} - Logs + Logs {#if numUnacknowledgedCriticalAlerts > 0} @@ -387,20 +373,18 @@ {#snippet buttonReplacement()} - + {#if !isCollapsed} - Settings + Settings {/if} {#if hasNewChangelogs} diff --git a/frontend/src/lib/components/sidebar/SidebarContent.svelte b/frontend/src/lib/components/sidebar/SidebarContent.svelte index 79c4f97fd5..ca1c4c6340 100644 --- a/frontend/src/lib/components/sidebar/SidebarContent.svelte +++ b/frontend/src/lib/components/sidebar/SidebarContent.svelte @@ -29,10 +29,10 @@ Unplug, AlertCircle, Database, - MailIcon + MailIcon, + Zap } from 'lucide-svelte' import { useLocalStorageValue } from '$lib/svelte5Utils.svelte' - import { slide } from 'svelte/transition' import UserMenu from './UserMenu.svelte' import DiscordIcon from '../icons/brands/Discord.svelte' import { twMerge } from 'tailwind-merge' @@ -49,15 +49,10 @@ getServiceIcon } from '../triggers/native/utils' import type { NativeServiceName } from '$lib/gen/types.gen' - import { - Menubar, - Menu, - MenuSingleItem, - MenuItem, - MeltButton - } from '$lib/components/meltComponents' + import { Menubar, Menu, MenuSingleItem, MenuItem } from '$lib/components/meltComponents' import MenuButton from './MenuButton.svelte' - import SidebarSectionHeader from './SidebarSectionHeader.svelte' + import SidebarSection, { flyoutRowClass } from './SidebarSection.svelte' + import DropdownSubmenuItem from '$lib/components/DropdownSubmenuItem.svelte' import GoogleCloudIcon from '../icons/triggers/GoogleCloudIcon.svelte' import AzureIcon from '../icons/triggers/AzureIcon.svelte' import type { VisibilityKey } from '$lib/roleCapabilities' @@ -479,14 +474,10 @@ ]) - -