diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte index 5a3bade59..a4f7f0cf7 100644 --- a/src/lib/components/chat/Chat.svelte +++ b/src/lib/components/chat/Chat.svelte @@ -143,6 +143,28 @@ })(); } + const showMessage = async (message) => { + let _messageId = JSON.parse(JSON.stringify(message.id)); + + let messageChildrenIds = history.messages[_messageId].childrenIds; + + while (messageChildrenIds.length !== 0) { + _messageId = messageChildrenIds.at(-1); + messageChildrenIds = history.messages[_messageId].childrenIds; + } + + history.currentId = _messageId; + + await tick(); + await tick(); + await tick(); + + const messageElement = document.getElementById(`message-${message.id}`); + if (messageElement) { + messageElement.scrollIntoView({ behavior: 'smooth', block: 'center' }); + } + }; + const chatEventHandler = async (event, cb) => { if (event.chat_id === $chatId) { await tick(); @@ -1812,6 +1834,7 @@ bind:files {submitPrompt} {stopResponse} + {showMessage} modelId={selectedModelIds?.at(0) ?? null} chatId={$chatId} {eventTarget} diff --git a/src/lib/components/chat/ChatControls.svelte b/src/lib/components/chat/ChatControls.svelte index c7abe2dd1..81608b8c3 100644 --- a/src/lib/components/chat/ChatControls.svelte +++ b/src/lib/components/chat/ChatControls.svelte @@ -21,6 +21,7 @@ export let eventTarget: EventTarget; export let submitPrompt: Function; export let stopResponse: Function; + export let showMessage: Function; export let files; export let modelId; @@ -126,6 +127,9 @@ {:else if $showOverview} { + showMessage(e.detail.node.data.message); + }} on:close={() => { showControls.set(false); }} diff --git a/src/lib/components/chat/Messages.svelte b/src/lib/components/chat/Messages.svelte index 3080bcac9..f62919b65 100644 --- a/src/lib/components/chat/Messages.svelte +++ b/src/lib/components/chat/Messages.svelte @@ -337,7 +337,11 @@
{#key chatId} {#each messages as message, messageIdx (message.id)} -
+
import { getContext, createEventDispatcher } from 'svelte'; import { useSvelteFlow, useNodesInitialized, useStore } from '@xyflow/svelte'; - import { SvelteFlow, Controls, Background, BackgroundVariant } from '@xyflow/svelte'; const dispatch = createEventDispatcher(); const i18n = getContext('i18n'); @@ -148,6 +147,6 @@
{#if $nodes.length > 0} - + dispatch('nodeclick', e.detail)} /> {/if}
diff --git a/src/lib/components/chat/Overview/Flow.svelte b/src/lib/components/chat/Overview/Flow.svelte index 93de776f0..f7ff30756 100644 --- a/src/lib/components/chat/Overview/Flow.svelte +++ b/src/lib/components/chat/Overview/Flow.svelte @@ -1,4 +1,8 @@