From fac6f1f53a85173ff8e4c6f62c6e9e90bb24e011 Mon Sep 17 00:00:00 2001 From: Aleksander Grygier Date: Mon, 9 Nov 2026 10:48:13 +0100 Subject: [PATCH 01/24] ui: share the working directory row between chat and projects A project's folder shows the same row as a chat's working directory change. Master draws that row inline in ChatMessageCwdChange; move it into its own component so both use it. Assisted-by: Claude (Opus 5.5 Medium) --- .../ChatMessage/ChatMessageCwdChange.svelte | 21 +++++++------------ .../ChatMessageCwdChangeRow.svelte | 21 +++++++++++++++++++ .../chat/src/lib/components/app/chat/index.ts | 6 ++++++ 3 files changed, 35 insertions(+), 13 deletions(-) create mode 100644 ui/apps/chat/src/lib/components/app/chat/ChatMessages/ChatMessage/ChatMessageCwdChangeRow.svelte diff --git a/ui/apps/chat/src/lib/components/app/chat/ChatMessages/ChatMessage/ChatMessageCwdChange.svelte b/ui/apps/chat/src/lib/components/app/chat/ChatMessages/ChatMessage/ChatMessageCwdChange.svelte index b70fe2244cd5..dc5747b36775 100644 --- a/ui/apps/chat/src/lib/components/app/chat/ChatMessages/ChatMessage/ChatMessageCwdChange.svelte +++ b/ui/apps/chat/src/lib/components/app/chat/ChatMessages/ChatMessage/ChatMessageCwdChange.svelte @@ -1,5 +1,6 @@ {#if info} -
- {#if info.path === null} + {#if info.path === null} +
Working directory cleared - {:else} - - - Set working directory to  - - - {info.display} - - {/if} -
+
+ {:else} + + {/if} {/if} diff --git a/ui/apps/chat/src/lib/components/app/chat/ChatMessages/ChatMessage/ChatMessageCwdChangeRow.svelte b/ui/apps/chat/src/lib/components/app/chat/ChatMessages/ChatMessage/ChatMessageCwdChangeRow.svelte new file mode 100644 index 000000000000..999f000279e4 --- /dev/null +++ b/ui/apps/chat/src/lib/components/app/chat/ChatMessages/ChatMessage/ChatMessageCwdChangeRow.svelte @@ -0,0 +1,21 @@ + + +
+ + + Set working directory to  + + {display} +
diff --git a/ui/apps/chat/src/lib/components/app/chat/index.ts b/ui/apps/chat/src/lib/components/app/chat/index.ts index 728af4d183e4..7085eefd2c00 100644 --- a/ui/apps/chat/src/lib/components/app/chat/index.ts +++ b/ui/apps/chat/src/lib/components/app/chat/index.ts @@ -453,6 +453,12 @@ export { default as ChatMessageStatisticsBadge } from './ChatMessages/ChatMessag */ export { default as ChatMessageCwdChange } from './ChatMessages/ChatMessage/ChatMessageCwdChange.svelte'; +/** + * The `Set working directory to ` row itself, shared by the synthetic + * cwd message and by the project folder row. + */ +export { default as ChatMessageCwdChangeRow } from './ChatMessages/ChatMessage/ChatMessageCwdChangeRow.svelte'; + /** * Generic wrapper for UI-generated (synthetic) messages. Routes the * working-directory change to ChatMessageCwdChange and renders a muted From c41aa2a10daae50b333387081f2436e37bf10c40 Mon Sep 17 00:00:00 2001 From: Aleksander Grygier Date: Thu, 29 Oct 2026 19:32:56 +0100 Subject: [PATCH 02/24] ui : projects (parked) The projects work as it stood before groups split out of it, kept on top of groups until it is reworked into its own PR. Not for review. Projects live in their own IndexedDB table (schema version 3) with a name, a goal, instructions, context items, a working directory and a hidden flag, and are configured in one dialog. A new chat in a project starts from its instructions and context and in its folder. Every visible project is a sidebar section beside the groups. A chat's menus and the chat form add it to a project, and a chip under the chat form shows it. Tabs and pinned chats lead with their project's name, the search dialog lists projects, and the agent can read and edit them. A chat in a project shows in the project's section, not its group's. Assisted-by: Claude (Opus 5.5 Medium) --- .../app/chat/ChatForm/ChatForm.svelte | 45 +++- .../ChatFormActionAddDrawer.svelte | 25 ++- .../ChatFormActionAddDropdown.svelte | 14 +- .../ChatFormProjectChip.svelte | 63 ++++++ .../app/chat/ChatTabs/ChatTabs.svelte | 27 ++- .../app/chat/ChatTabs/ChatTabsItem.svelte | 15 +- .../chat/src/lib/components/app/chat/index.ts | 8 + .../app/dialogs/DialogSearch.svelte | 24 +- ui/apps/chat/src/lib/components/app/index.ts | 1 + .../SidebarNavigation.svelte | 16 +- .../SidebarNavigationConversationItem.svelte | 75 ++++++- .../SidebarNavigationConversationList.svelte | 72 +++++- .../SidebarNavigationProjectSection.svelte | 182 ++++++++++++++++ .../SidebarNavigationSearchResults.svelte | 2 + .../app/projects/DialogProject.svelte | 199 +++++++++++++++++ .../app/projects/DialogProjectPicker.svelte | 100 +++++++++ .../app/projects/ProjectContextList.svelte | 174 +++++++++++++++ .../app/projects/ProjectFolderPicker.svelte | 74 +++++++ .../app/projects/ProjectPrefix.svelte | 21 ++ .../app/projects/ProjectSubmenu.svelte | 137 ++++++++++++ .../src/lib/components/app/projects/index.ts | 50 +++++ .../constants/attachment-menu.constants.ts | 1 + .../src/lib/constants/database.constants.ts | 14 +- .../chat/src/lib/constants/icons.constants.ts | 9 +- ui/apps/chat/src/lib/constants/index.ts | 2 + .../lib/constants/message-export.constants.ts | 8 + .../chat/src/lib/constants/project-tools.ts | 82 +++++++ .../src/lib/constants/projects.constants.ts | 2 + .../src/lib/constants/tool-ui.constants.ts | 23 ++ .../chat/src/lib/constants/ui.constants.ts | 2 + ui/apps/chat/src/lib/enums/index.ts | 1 + ui/apps/chat/src/lib/enums/tools.enums.ts | 4 + ui/apps/chat/src/lib/enums/ui.enums.ts | 11 + .../services/conversation-transfer.service.ts | 117 +++++++--- .../chat/src/lib/services/database.service.ts | 58 ++++- .../src/lib/services/project-tools.service.ts | 157 +++++++++++++ .../src/lib/stores/agentic/index.svelte.ts | 10 + .../chat/src/lib/stores/chat/index.svelte.ts | 26 ++- .../lib/stores/conversations/index.svelte.ts | 56 +++++ .../conversations/preferences.svelte.ts | 16 ++ ui/apps/chat/src/lib/stores/index.ts | 3 + ui/apps/chat/src/lib/stores/init.ts | 2 + .../chat/src/lib/stores/projects.svelte.ts | 206 ++++++++++++++++++ ui/apps/chat/src/lib/stores/tools.svelte.ts | 5 + ui/apps/chat/src/lib/stores/ui.svelte.ts | 32 ++- ui/apps/chat/src/lib/types/database.d.ts | 2 + ui/apps/chat/src/lib/types/index.ts | 2 + ui/apps/chat/src/lib/types/projects.d.ts | 42 ++++ ui/apps/chat/src/lib/utils/index.ts | 2 + ui/apps/chat/src/lib/utils/project-prompt.ts | 66 ++++++ .../tests/client/project-tools.svelte.test.ts | 100 +++++++++ .../tests/client/projects-db.svelte.test.ts | 74 +++++++ 52 files changed, 2383 insertions(+), 76 deletions(-) create mode 100644 ui/apps/chat/src/lib/components/app/chat/ChatForm/ChatFormProjectChip/ChatFormProjectChip.svelte create mode 100644 ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigationProjectSection.svelte create mode 100644 ui/apps/chat/src/lib/components/app/projects/DialogProject.svelte create mode 100644 ui/apps/chat/src/lib/components/app/projects/DialogProjectPicker.svelte create mode 100644 ui/apps/chat/src/lib/components/app/projects/ProjectContextList.svelte create mode 100644 ui/apps/chat/src/lib/components/app/projects/ProjectFolderPicker.svelte create mode 100644 ui/apps/chat/src/lib/components/app/projects/ProjectPrefix.svelte create mode 100644 ui/apps/chat/src/lib/components/app/projects/ProjectSubmenu.svelte create mode 100644 ui/apps/chat/src/lib/components/app/projects/index.ts create mode 100644 ui/apps/chat/src/lib/constants/project-tools.ts create mode 100644 ui/apps/chat/src/lib/constants/projects.constants.ts create mode 100644 ui/apps/chat/src/lib/services/project-tools.service.ts create mode 100644 ui/apps/chat/src/lib/stores/projects.svelte.ts create mode 100644 ui/apps/chat/src/lib/types/projects.d.ts create mode 100644 ui/apps/chat/src/lib/utils/project-prompt.ts create mode 100644 ui/apps/chat/tests/client/project-tools.svelte.test.ts create mode 100644 ui/apps/chat/tests/client/projects-db.svelte.test.ts diff --git a/ui/apps/chat/src/lib/components/app/chat/ChatForm/ChatForm.svelte b/ui/apps/chat/src/lib/components/app/chat/ChatForm/ChatForm.svelte index 3c404086b635..052ace66fcf0 100644 --- a/ui/apps/chat/src/lib/components/app/chat/ChatForm/ChatForm.svelte +++ b/ui/apps/chat/src/lib/components/app/chat/ChatForm/ChatForm.svelte @@ -11,7 +11,8 @@ ChatFormCurrentWorkingDirectory, ChatFormInput, ChatFormInputFileInputInvisible, - ChatFormPickers + ChatFormPickers, + ChatFormProjectChip } from '#lib/components/app/index.ts'; import { CHAT_FORM_SINGLE_ROW_MAX_TEXT_PX, @@ -38,6 +39,7 @@ conversationsStore, deviceStore, modelsStore, + projectsStore, serverStore, settingsStore, toolsStore, @@ -137,6 +139,15 @@ conversationsStore.activeConversation?.cwd ?? conversationsStore.preferences.pendingCwd ); + // the project the chat is in, or the one picked for the chat about to start + let project = $derived.by(() => { + const projectId = + conversationsStore.activeConversation?.projectId ?? + conversationsStore.preferences.pendingProjectId; + + return projectId ? projectsStore.get(projectId) : undefined; + }); + let showWorkingDirectory = $derived(conversationsStore.preferences.hasEnabledCwdTools()); // On a desktop the chip under the form shows a directory once one is set, and the + menu // sets one until then. A phone has no chip: a chat shows it in its header (see @@ -823,7 +834,37 @@ > {/if} - {#if showWorkingDirectory} + {#if project} + +
+ + + {#if showWorkingDirectoryChip} + + {/if} + + {#if showWorkingDirectory} + + {/if} +
+ {:else if showWorkingDirectory} + + + {/snippet} + + + +

Change project

+
+ + +
+ void conversationsStore.assignActiveConversationProject(null)} + tooltip="Remove from project" + /> +
+ diff --git a/ui/apps/chat/src/lib/components/app/chat/ChatTabs/ChatTabs.svelte b/ui/apps/chat/src/lib/components/app/chat/ChatTabs/ChatTabs.svelte index 60f185e1b62f..2927c75599a2 100644 --- a/ui/apps/chat/src/lib/components/app/chat/ChatTabs/ChatTabs.svelte +++ b/ui/apps/chat/src/lib/components/app/chat/ChatTabs/ChatTabs.svelte @@ -12,7 +12,13 @@ UNNAMED_CHAT_LABEL } from '#lib/constants/index.ts'; import { useScrollCarousel } from '#lib/hooks/use-scroll-carousel.svelte.ts'; - import { chatStore, conversationsStore, tabsStore, uiStore } from '#lib/stores/index.ts'; + import { + chatStore, + conversationsStore, + projectsStore, + tabsStore, + uiStore + } from '#lib/stores/index.ts'; import type { MenuAction } from '#lib/types/index.ts'; import { resolveTabView } from '#lib/utils/index.ts'; import { page } from '$app/state'; @@ -28,15 +34,22 @@ view.ids.map((id) => id === NEW_CHAT_TAB_ID ? { href: view.hrefFor(id), icon: SquarePen, id, name: NEW_CHAT_LABEL } - : { - href: view.hrefFor(id), - id, - name: - conversationsStore.conversations.find((c) => c.id === id)?.name ?? UNNAMED_CHAT_LABEL - } + : chatTab(id) ) ); + // a project chat carries its project name before the title, like a breadcrumb + function chatTab(id: string) { + const conversation = conversationsStore.conversations.find((c) => c.id === id); + + return { + href: view.hrefFor(id), + id, + name: conversation?.name ?? UNNAMED_CHAT_LABEL, + prefix: conversation?.projectId ? projectsStore.get(conversation.projectId)?.name : undefined + }; + } + // hide the New chat button while a new-chat tab is already open let showNewChatButton = $derived(!view.ids.includes(NEW_CHAT_TAB_ID)); diff --git a/ui/apps/chat/src/lib/components/app/chat/ChatTabs/ChatTabsItem.svelte b/ui/apps/chat/src/lib/components/app/chat/ChatTabs/ChatTabsItem.svelte index d5c5509568c2..5089999cb413 100644 --- a/ui/apps/chat/src/lib/components/app/chat/ChatTabs/ChatTabsItem.svelte +++ b/ui/apps/chat/src/lib/components/app/chat/ChatTabs/ChatTabsItem.svelte @@ -2,6 +2,7 @@ import * as Tooltip from '@ggml-org/llama-ui/ui/tooltip'; import { cn } from '@ggml-org/llama-ui/utils'; import { Loader2, Square, X } from '@lucide/svelte'; + import { ProjectPrefix } from '#lib/components/app/index.ts'; import { ICON_CLASS_SM, ICON_CLASS_XS, @@ -19,6 +20,8 @@ icon?: Component; id: string; name: string; + /** Name of the project the chat belongs to, shown muted before the title. */ + prefix?: string; } interface Props { @@ -70,14 +73,15 @@ TAB_SURFACE_CLASS, // each tab sits in its context-menu trigger, so the first trigger marks // the first tab - 'relative max-w-52 min-w-0 shrink-0 gap-1 pr-1 [:first-child>&]:ml-2', + 'relative min-w-0 shrink-0 gap-1 pr-1 [:first-child>&]:ml-2', + tab.prefix ? 'max-w-80' : 'max-w-52', isLoading ? 'pl-1' : 'pl-3', isActive ? TAB_SURFACE_ACTIVE_CLASS : TAB_SURFACE_IDLE_CLASS )} > onAuxClick?.(tab.id, e)} @@ -117,6 +121,13 @@ /> {/if} + {#if tab.prefix} + + {/if} + {tab.name} diff --git a/ui/apps/chat/src/lib/components/app/chat/index.ts b/ui/apps/chat/src/lib/components/app/chat/index.ts index 7085eefd2c00..e4d495b9bf83 100644 --- a/ui/apps/chat/src/lib/components/app/chat/index.ts +++ b/ui/apps/chat/src/lib/components/app/chat/index.ts @@ -249,6 +249,14 @@ export { default as ChatFormInput } from './ChatForm/ChatFormInput/ChatFormInput */ export { default as ChatFormCurrentWorkingDirectory } from './ChatForm/ChatFormCurrentWorkingDirectory/ChatFormCurrentWorkingDirectory.svelte'; +/** + * **ChatFormProjectChip** - The chat's project under the chat form + * + * Shown beside the working directory. A click changes the project and the + * hover × takes the chat out of it. + */ +export { default as ChatFormProjectChip } from './ChatForm/ChatFormProjectChip/ChatFormProjectChip.svelte'; + /** * Shared popover wrapper for inline picker popovers (prompts, resources). * Provides consistent positioning, styling, and open/close behavior. diff --git a/ui/apps/chat/src/lib/components/app/dialogs/DialogSearch.svelte b/ui/apps/chat/src/lib/components/app/dialogs/DialogSearch.svelte index 035c3d4ca554..2e1e49242fe9 100644 --- a/ui/apps/chat/src/lib/components/app/dialogs/DialogSearch.svelte +++ b/ui/apps/chat/src/lib/components/app/dialogs/DialogSearch.svelte @@ -21,6 +21,7 @@ ICON_CLASS_DEFAULT, ICON_CLASS_SM, ICON_CLASS_XS, + PROJECT_ICON, SIDEBAR_ACTIONS_ITEMS } from '#lib/constants/index.ts'; import { KeyboardKey, SidebarAction } from '#lib/enums/index.ts'; @@ -36,6 +37,7 @@ conversationsStore, deviceStore, modelsDiscoverStore, + projectsStore, uiStore } from '#lib/stores/index.ts'; import type { DatabaseConversation } from '#lib/types/database.js'; @@ -98,17 +100,36 @@ conversation: DatabaseConversation, snippet?: ConversationSearchSnippet ): SearchEntry { + const project = conversation.projectId + ? projectsStore.get(conversation.projectId) + : undefined; + const time = formatRelativeTime(conversation.lastModified); + return { icon: MessageSquare, id: `chat-${conversation.id}`, label: conversation.name, - meta: formatRelativeTime(conversation.lastModified), + meta: project ? `${project.name} · ${time}` : time, pinned: conversation.pinned, run: () => close(() => goto(RouterService.chat(conversation.id))), snippet }; } + // hidden ones too: this is where a hidden project is found and shown again + const projectEntries = $derived.by((): SearchEntry[] => + projectsStore.projects + .filter((project) => matches(project.name)) + .slice(0, limit) + .map((project) => ({ + icon: PROJECT_ICON, + id: `project-${project.id}`, + label: project.name, + meta: project.hidden ? 'Hidden' : undefined, + run: () => close(() => uiStore.openProjectDialog({ projectId: project.id })) + })) + ); + const recentConversations = $derived( [...conversationsStore.conversations].sort((a, b) => b.lastModified - a.lastModified) ); @@ -286,6 +307,7 @@ loading: contentSearch.isSearching && !!needle, title: 'In messages' }, + { entries: projectEntries, title: 'Projects' }, { entries: suggestedEntries, title: 'Suggested models' }, { entries: actionEntries, title: 'Actions' }, { diff --git a/ui/apps/chat/src/lib/components/app/index.ts b/ui/apps/chat/src/lib/components/app/index.ts index 1ffd96ad6882..caad6ca89755 100644 --- a/ui/apps/chat/src/lib/components/app/index.ts +++ b/ui/apps/chat/src/lib/components/app/index.ts @@ -10,3 +10,4 @@ export * from './settings'; export * from './models'; export * from './navigation'; export * from './servers'; +export * from './projects'; diff --git a/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigation.svelte b/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigation.svelte index f36d5a2dbf79..fc3ea7ae4808 100644 --- a/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigation.svelte +++ b/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigation.svelte @@ -8,6 +8,8 @@ DialogDiscoverModels, DialogGroup, DialogGroupPicker, + DialogProject, + DialogProjectPicker, DialogSearch, DialogServers, DialogSettingsChat, @@ -310,7 +312,11 @@ } function selectConversation(id: string) { - navigateBehind(() => goto(RouterService.chat(id))); + const conversation = conversationsStore.conversations.find((conv) => conv.id === id); + + navigateBehind(() => + goto(conversation ? RouterService.conversation(conversation) : RouterService.chat(id)) + ); } async function handleEditConversation(id: string) { @@ -538,6 +544,10 @@ case SidebarAction.SEARCH: openSearch(); + break; + case SidebarAction.PROJECTS: + navigateBehind(() => goto(resolve(ROUTES.PROJECTS))); + break; case SidebarAction.MANAGE_MODELS: openDialog(() => uiStore.openModelsManager()); @@ -801,6 +811,10 @@ + + + + diff --git a/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigationConversationItem.svelte b/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigationConversationItem.svelte index a59aaddb827f..f238950f8b09 100644 --- a/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigationConversationItem.svelte +++ b/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigationConversationItem.svelte @@ -17,11 +17,17 @@ Trash2, Unlink } from '@lucide/svelte'; - import { ContextMenuActions, DropdownMenuActions } from '#lib/components/app/index.ts'; + import { + ContextMenuActions, + DropdownMenuActions, + ProjectPrefix, + ProjectSubmenu + } from '#lib/components/app/index.ts'; import { TruncatedText } from '#lib/components/app/index.ts'; import { FORK_TREE_DEPTH_PADDING, ICON_CLASS_DEFAULT, + PROJECT_ICON, ROW_LONG_PRESS_MS, SHORTCUT_DELETE_CONVERSATION, SHORTCUT_EDIT_CONVERSATION, @@ -41,7 +47,7 @@ tabsStore, uiStore } from '#lib/stores/index.ts'; - import type { MenuAction } from '#lib/types/index.ts'; + import type { MenuAction, Project } from '#lib/types/index.ts'; import { hapticTap } from '#lib/utils/index.ts'; import { onMount, tick } from 'svelte'; @@ -59,6 +65,8 @@ onEnterSelectionMode?: (id: string) => void; onSelectionClick?: (id: string, options: { shiftKey: boolean }) => void; onRowMouseDown?: (id: string, event: MouseEvent) => void; + /** Project shown before the title, where the list does not group the chat under it. */ + project?: Project; } let { @@ -74,7 +82,8 @@ onSelect, onSelectionClick, onStop, - onToggleSelect + onToggleSelect, + project }: Props = $props(); let renderActionsDropdown = $state(false); @@ -175,6 +184,38 @@ : []) ]); + function setProject(projectId: string | null) { + void conversationsStore.setConversationProject(conversation.id, projectId); + } + + // a phone has no flyouts: the same entry opens the project picker there + function handlePickProject(event: Event) { + event.stopPropagation(); + uiStore.openProjectPicker({ currentProjectId: conversation.projectId, onSelect: setProject }); + } + + // a chat in a project can move to another one or leave it, a loose chat can join one + let projectActions = $derived([ + { + icon: PROJECT_ICON, + label: conversation.projectId ? 'Change project' : 'Add to project', + onclick: handlePickProject, + submenu: projectSubmenu + }, + ...(conversation.projectId + ? [ + { + icon: Unlink, + label: 'Remove from project', + onclick: (event: Event) => { + event.stopPropagation(); + setProject(null); + } + } + ] + : []) + ]); + // the "more actions" dropdown and the right-click menu offer the same actions; the // shortcuts act on the active conversation, so only its row shows them let actions = $derived([ @@ -206,6 +247,7 @@ shortcut: isActive ? SHORTCUT_EDIT_CONVERSATION : undefined }, ...groupActions, + ...projectActions, { icon: Download, label: 'Export', @@ -422,11 +464,18 @@ {/if} - + + + {#if project} + + {/if} + + + {#if !isSelectionMode && renderActionsDropdown} @@ -454,6 +503,16 @@ /> {/snippet} +{#snippet projectSubmenu({ close, kind }: { close: () => void; kind: MenuKind })} + +{/snippet} +