diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte index 333e645e22..fc663a3e2a 100644 --- a/src/lib/components/chat/Chat.svelte +++ b/src/lib/components/chat/Chat.svelte @@ -300,7 +300,7 @@ } }; - const showMessage = async (message) => { + const showMessage = async (message, ignoreSettings = false) => { await tick(); const _chatId = JSON.parse(JSON.stringify($chatId)); @@ -326,7 +326,7 @@ await tick(); await tick(); - if ($settings?.scrollOnBranchChange ?? true) { + if (($settings?.scrollOnBranchChange ?? true) || ignoreSettings) { const messageElement = document.getElementById(`message-${message.id}`); if (messageElement) { messageElement.scrollIntoView({ behavior: 'smooth' }); diff --git a/src/lib/components/chat/ChatControls.svelte b/src/lib/components/chat/ChatControls.svelte index d4ed1eb36a..cbb1c3faf8 100644 --- a/src/lib/components/chat/ChatControls.svelte +++ b/src/lib/components/chat/ChatControls.svelte @@ -13,12 +13,9 @@ showEmbeds } from '$lib/stores'; - import Modal from '../common/Modal.svelte'; import Controls from './Controls/Controls.svelte'; import CallOverlay from './MessageInput/CallOverlay.svelte'; import Drawer from '../common/Drawer.svelte'; - import Overview from './Overview.svelte'; - import EllipsisVertical from '../icons/EllipsisVertical.svelte'; import Artifacts from './Artifacts.svelte'; import Embeds from './ChatControls/Embeds.svelte'; @@ -154,24 +151,113 @@ } - - {#if !largeScreen} - {#if $showControls} - { - showControls.set(false); - }} +{#if !largeScreen} + {#if $showControls} + { + showControls.set(false); + }} + > +
+ {#if $showCallOverlay} +
+ { + showControls.set(false); + }} + /> +
+ {:else if $showEmbeds} + + {:else if $showArtifacts} + + {:else if $showOverview} + {#await import('./Overview.svelte') then { default: Overview }} + { + const node = e.node; + showMessage(node.data.message, true); + }} + onClose={() => { + showControls.set(false); + }} + /> + {/await} + {:else} + { + showControls.set(false); + }} + {models} + bind:chatFiles + bind:params + /> + {/if} +
+
+ {/if} +{:else} + + + {#if $showControls} + +
+ + {/if} + + { + if ($showControls && pane.isExpanded()) { + if (size < minSize) { + pane.resize(minSize); + } + + if (size < minSize) { + localStorage.chatControlsSize = 0; + } else { + // save the size in pixels to localStorage + const container = document.getElementById('chat-container'); + localStorage.chatControlsSize = Math.floor((size / 100) * container.clientWidth); + } + } + }} + onCollapse={() => { + showControls.set(false); + }} + collapsible={true} + class=" z-10 bg-white dark:bg-gray-850" + > + {#if $showControls} +
{#if $showCallOverlay} -
+
{:else if $showEmbeds} - + {:else if $showArtifacts} - + {:else if $showOverview} - { - showMessage(e.detail.node.data.message); - }} - on:close={() => { - showControls.set(false); - }} - /> + {#await import('./Overview.svelte') then { default: Overview }} + { + const node = e.node; + if (node?.data?.message?.favorite) { + history.messages[node.data.message.id].favorite = true; + } else { + history.messages[node.data.message.id].favorite = null; + } + + showMessage(node.data.message, true); + }} + onClose={() => { + showControls.set(false); + }} + /> + {/await} {:else} { @@ -209,101 +304,7 @@ /> {/if}
- +
{/if} - {:else} - - - {#if $showControls} - -
- - {/if} - - { - if ($showControls && pane.isExpanded()) { - if (size < minSize) { - pane.resize(minSize); - } - - if (size < minSize) { - localStorage.chatControlsSize = 0; - } else { - // save the size in pixels to localStorage - const container = document.getElementById('chat-container'); - localStorage.chatControlsSize = Math.floor((size / 100) * container.clientWidth); - } - } - }} - onCollapse={() => { - showControls.set(false); - }} - collapsible={true} - class=" z-10 bg-white dark:bg-gray-850" - > - {#if $showControls} -
-
- {#if $showCallOverlay} -
- { - showControls.set(false); - }} - /> -
- {:else if $showEmbeds} - - {:else if $showArtifacts} - - {:else if $showOverview} - { - if (e.detail.node.data.message.favorite) { - history.messages[e.detail.node.data.message.id].favorite = true; - } else { - history.messages[e.detail.node.data.message.id].favorite = null; - } - - showMessage(e.detail.node.data.message); - }} - on:close={() => { - showControls.set(false); - }} - /> - {:else} - { - showControls.set(false); - }} - {models} - bind:chatFiles - bind:params - /> - {/if} -
-
- {/if} -
- {/if} - + +{/if} diff --git a/src/lib/components/chat/Overview.svelte b/src/lib/components/chat/Overview.svelte index 5e0dd46be1..3708fa9061 100644 --- a/src/lib/components/chat/Overview.svelte +++ b/src/lib/components/chat/Overview.svelte @@ -1,206 +1,17 @@ -
-
-
- -
{$i18n.t('Chat Overview')}
-
- -
- - {#if $nodes.length > 0} - { - console.log(e.detail.node.data); - dispatch('nodeclick', e.detail); - selectedMessageId = e.detail.node.data.message.id; - fitView({ nodes: [{ id: selectedMessageId }] }); - }} - /> - {/if} -
+ + + diff --git a/src/lib/components/chat/Overview/View.svelte b/src/lib/components/chat/Overview/View.svelte new file mode 100644 index 0000000000..dc1276abec --- /dev/null +++ b/src/lib/components/chat/Overview/View.svelte @@ -0,0 +1,207 @@ + + +
+
+
+ +
{$i18n.t('Chat Overview')}
+
+ +
+ + {#if $nodes.length > 0} + { + onNodeClick(e.detail); + selectedMessageId = e.detail.node.data.message.id; + fitView({ nodes: [{ id: selectedMessageId }] }); + }} + /> + {/if} +