diff --git a/ui/apps/chat/src/app.css b/ui/apps/chat/src/app.css index 4c7fd90160a3..b5393ec5cfcc 100644 --- a/ui/apps/chat/src/app.css +++ b/ui/apps/chat/src/app.css @@ -23,6 +23,11 @@ --safe-area-bottom: env(safe-area-inset-bottom, 0px); /* where the phone's corner controls (menu toggle, context gauge, sidebar logo) sit */ --corner-control-top: calc(1rem + var(--safe-area-top)); + /* where the phone's bottom corner actions (a page's floating key) sit: as far in from + the side as up from the bottom, which keeps a 56px key about concentric with an + iPhone's rounded screen corner */ + --corner-control-side: 1.75rem; + --corner-control-bottom: calc(var(--corner-control-side) + var(--safe-area-bottom)); /* where a phone page's title starts: a row below the corner controls */ --page-top: calc(var(--corner-control-top) + 3.75rem); /* expanded desktop sidebar width, overridden once the user drags its edge */ @@ -75,6 +80,9 @@ /* the installed app's status bar already sets them apart from the screen's edge */ :root { --corner-control-top: calc(0.25rem + var(--safe-area-top)); + /* the home indicator is a short bar in the middle, so the corners beside it are + free: a corner action ignores its inset and keeps the same gap as from the side */ + --corner-control-bottom: var(--corner-control-side); } html { @@ -295,11 +303,15 @@ } /* While something is dragged, what it passes over takes no hover: only the - sections themselves stay targets, for the drop */ + sections themselves, and the projects in them, stay targets, for the drop */ body[data-sidebar-dragging] [data-sidebar-section] * { pointer-events: none; } + body[data-sidebar-dragging] [data-sidebar-section] [data-sidebar-section] { + pointer-events: auto; + } + .sidebar-drag-overlay { position: fixed; z-index: 1000; diff --git a/ui/apps/chat/src/lib/components/app/actions/FloatingActionButton.svelte b/ui/apps/chat/src/lib/components/app/actions/FloatingActionButton.svelte new file mode 100644 index 000000000000..0689c01a6dbe --- /dev/null +++ b/ui/apps/chat/src/lib/components/app/actions/FloatingActionButton.svelte @@ -0,0 +1,30 @@ + + + + + + diff --git a/ui/apps/chat/src/lib/components/app/actions/index.ts b/ui/apps/chat/src/lib/components/app/actions/index.ts index 8b0279d06216..7a1db73a293a 100644 --- a/ui/apps/chat/src/lib/components/app/actions/index.ts +++ b/ui/apps/chat/src/lib/components/app/actions/index.ts @@ -14,3 +14,6 @@ export { default as ActionIconCopyToClipboard } from './ActionIconCopyToClipboar /** A round matte glass key: a phone's corner keys and the key back to a chat's bottom. */ export { default as GlassKey } from './GlassKey.svelte'; + +/** A page's main action on a phone: a round key pinned to the bottom-right corner. */ +export { default as FloatingActionButton } from './FloatingActionButton.svelte'; 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 2d368fd80bac..503c09875447 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 @@ -9,7 +9,8 @@ ChatFormCurrentWorkingDirectory, ChatFormInput, ChatFormInputFileInputInvisible, - ChatFormPickers + ChatFormPickers, + ChatFormProjectChip } from '#lib/components/app/index.ts'; import { CHAT_FORM_SINGLE_ROW_MAX_TEXT_PX, @@ -35,6 +36,7 @@ conversationsStore, deviceStore, modelsStore, + projectsStore, serverStore, settingsStore, toolsStore, @@ -139,6 +141,14 @@ 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 active = conversationsStore.activeConversation; + const projectId = active ? active.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 @@ -806,7 +816,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/ChatMessages/ChatMessage/ChatMessageAssistant/ChatMessageAssistant.svelte b/ui/apps/chat/src/lib/components/app/chat/ChatMessages/ChatMessage/ChatMessageAssistant/ChatMessageAssistant.svelte index c37b0447fd29..7e0e0e4c036d 100644 --- a/ui/apps/chat/src/lib/components/app/chat/ChatMessages/ChatMessage/ChatMessageAssistant/ChatMessageAssistant.svelte +++ b/ui/apps/chat/src/lib/components/app/chat/ChatMessages/ChatMessage/ChatMessageAssistant/ChatMessageAssistant.svelte @@ -235,7 +235,8 @@ --assistant-min-height-offset: calc( var(--last-user-message-height, 19rem) + var(--chat-form-height, 6rem) + var(--chat-form-bottom-position, 0.5rem) + var(--chat-form-padding-top, 6rem) + - var(--assistant-margin-top, 3rem) + var(--chat-tabs-offset, 0px) + var(--assistant-margin-top, 3rem) + var(--chat-tabs-offset, 0px) + + var(--chat-header-height, 0px) ); min-height: calc(100dvh - var(--assistant-min-height-offset)); @@ -243,7 +244,8 @@ --assistant-min-height-offset: calc( var(--last-user-message-height, 18rem) + var(--chat-form-height, 6rem) + var(--chat-form-bottom-position, 1rem) + var(--chat-form-padding-top, 6rem) + - var(--assistant-margin-top, 3rem) + var(--chat-tabs-offset, 0px) + var(--assistant-margin-top, 3rem) + var(--chat-tabs-offset, 0px) + + var(--chat-header-height, 0px) ); } } 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 959016a26538..515dca042fa9 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/ChatScreen/ChatScreen.svelte b/ui/apps/chat/src/lib/components/app/chat/ChatScreen/ChatScreen.svelte index 128d20a0a845..97c74861c62e 100644 --- a/ui/apps/chat/src/lib/components/app/chat/ChatScreen/ChatScreen.svelte +++ b/ui/apps/chat/src/lib/components/app/chat/ChatScreen/ChatScreen.svelte @@ -24,8 +24,7 @@ CHAT_FORM_MOVE_OUT_MS, CHAT_FORM_MOVE_SHIFT_PX, CHAT_FORM_MOVE_TO_BOTTOM_IN_MS, - CHAT_FORM_MOVE_TO_BOTTOM_OUT_MS, - ROUTES + CHAT_FORM_MOVE_TO_BOTTOM_OUT_MS } from '#lib/constants/index.ts'; import { useChatScreenActiveModel } from '#lib/hooks/use-chat-screen-active-model.svelte.ts'; import { useChatScreenDragAndDrop } from '#lib/hooks/use-chat-screen-drag-and-drop.svelte.ts'; @@ -44,12 +43,25 @@ import { parseFilesToMessageExtras } from '#lib/utils/browser-only.ts'; import { disableScrollHandling, onNavigate } from '$app/navigation'; import { page } from '$app/state'; - import { tick, untrack } from 'svelte'; + import { type Snippet, tick, untrack } from 'svelte'; import { fade } from 'svelte/transition'; - let { showCenteredEmpty = false } = $props(); + interface Props { + /** Sits above the messages. */ + header?: Snippet; + /** Scrolls away under the header, e.g. a title. */ + intro?: Snippet; + /** Takes the place of the messages, with the form at the bottom. */ + overview?: Snippet; + /** Sit between the intro and the overview, e.g. a project's instructions and context. */ + panels?: Snippet; + showCenteredEmpty?: boolean; + } + + let { header, intro, overview, panels, showCenteredEmpty = false }: Props = $props(); let emptyFileNames = $state([]); + let headerHeight = $state(0); let showDeleteDialog = $state(false); let showEmptyFileDialog = $state(false); let isEmpty = $derived( @@ -291,6 +303,7 @@
0 ? `${headerHeight}px` : undefined} class="chat-screen flex grow flex-col min-h-[calc(100dvh-1rem)] md:min-h-[calc(100dvh-var(--chat-tabs-offset,0px))] px-4 md:py-0 pt-(--page-top) pb-48 md:pb-4" ondragenter={dragAndDrop.dragHandlers.dragenter} ondragleave={dragAndDrop.dragHandlers.dragleave} @@ -320,7 +333,31 @@
{/if} - {#if !isEmpty} + {#if header} + +
+
+ {@render header()} +
+
+ {/if} + + {#if panels} + +
+ {@render intro?.()} + + {@render panels()} + + {@render overview?.()} +
+ {:else if overview} +
+ {@render overview()} +
+ {:else if !isEmpty} - {#if stick.farFromBottom && page.url.hash.includes(ROUTES.CHAT) && page.params.id} + {#if stick.farFromBottom && page.params.id} stick.scrollToBottom('smooth')} /> {/if} 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 c4a68a2dbfc8..bf9a4d586a06 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 @@ -14,31 +14,45 @@ import { useScrollCarousel } from '#lib/hooks/use-scroll-carousel.svelte.ts'; import { chatStore, conversationsStore, tabsStore, uiStore } from '#lib/stores/index.ts'; import type { MenuAction } from '#lib/types/index.ts'; - import { resolveTabView } from '#lib/utils/index.ts'; + import { projectNewChatTabId, projectOfNewChatTab, resolveTabView } from '#lib/utils/index.ts'; + import { goto } from '$app/navigation'; import { page } from '$app/state'; - import { tick } from 'svelte'; + import { type Snippet, tick } from 'svelte'; + + interface Props { + /** Sits before the tabs, e.g. the breadcrumb of a project view. */ + leading?: Snippet; + } + + let { leading }: Props = $props(); const carousel = useScrollCarousel(); - let view = $derived(resolveTabView(page, tabsStore.openTabs)); + let view = $derived(resolveTabView(page, tabsStore.openTabs, conversationsStore.conversations)); let activeId = $derived(view.activeId); let tabs = $derived( - 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 - } - ) + view.ids.map((id) => { + if (id === NEW_CHAT_TAB_ID || projectOfNewChatTab(id)) { + return { href: view.hrefFor(id), icon: SquarePen, id, name: NEW_CHAT_LABEL }; + } + + return { + href: view.hrefFor(id), + id, + name: conversationsStore.conversations.find((c) => c.id === id)?.name ?? UNNAMED_CHAT_LABEL + }; + }) ); - // hide the New chat button while a new-chat tab is already open - let showNewChatButton = $derived(!view.ids.includes(NEW_CHAT_TAB_ID)); + // the new-chat tab of the view: the regular one, or the project's own + let newChatTabId = $derived( + view.projectId ? projectNewChatTabId(view.projectId) : NEW_CHAT_TAB_ID + ); + + // hide the New chat button while that tab is already open + let showNewChatButton = $derived(!view.ids.includes(newChatTabId)); let loadingIds = $derived(new Set(chatStore.getAllLoadingChats())); @@ -46,6 +60,11 @@ void tabsStore.close(id, id === activeId, view); } + function openNewChat() { + void tabsStore.openInNewTab(newChatTabId); + void goto(view.hrefFor(newChatTabId)); + } + function handleStop(id: string, event: MouseEvent) { event.stopPropagation(); void chatStore.stopGenerationForChat(id); @@ -135,44 +154,48 @@ : CHAT_TABS_MAX_WIDTH.COLLAPSED_SIDEBAR ]} > -
- - {#each tabs as tab (tab.id)} - - tabsStore.activate(id)} - onAuxClick={handleAuxClick} - onClose={handleClose} - onStop={handleStop} - {tab} - /> - - {/each} - - {#if showNewChatButton} - void tabsStore.openInNewTab(NEW_CHAT_TAB_ID, { activate: true })} - /> - {/if} - - -
- -
+
+ {#if leading} +
{@render leading()}
+ {/if} + +
+ + {#each tabs as tab (tab.id)} + + void goto(view.hrefFor(id))} + onAuxClick={handleAuxClick} + onClose={handleClose} + onStop={handleStop} + {tab} + /> + + {/each} + + {#if showNewChatButton} + + {/if} + + +
+ +
+
diff --git a/ui/apps/chat/src/lib/components/app/chat/ChatTabs/ChatTabsNewChatButton.svelte b/ui/apps/chat/src/lib/components/app/chat/ChatTabs/ChatTabsNewChatButton.svelte index a3a8f1439bbb..35affb808ba1 100644 --- a/ui/apps/chat/src/lib/components/app/chat/ChatTabs/ChatTabsNewChatButton.svelte +++ b/ui/apps/chat/src/lib/components/app/chat/ChatTabs/ChatTabsNewChatButton.svelte @@ -4,10 +4,11 @@ import { ICON_CLASS_DEFAULT } from '#lib/constants/index.ts'; interface Props { + label?: string; onclick?: () => void; } - let { onclick }: Props = $props(); + let { label = 'New chat', onclick }: Props = $props(); @@ -15,8 +16,8 @@ {#snippet child({ props })}