diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte index 7a22133795..7a34004800 100644 --- a/src/lib/components/chat/Chat.svelte +++ b/src/lib/components/chat/Chat.svelte @@ -991,7 +991,7 @@ } else if (type === 'chat:message:follow_ups') { message.followUps = data.follow_ups; - if (autoScroll) { + if (shouldAutoScrollResponse()) { scrollToBottom('smooth'); } } else if (type === 'chat:outlet') { @@ -2105,9 +2105,14 @@ await messagesRef?.scrollToTop(); }; + const shouldAutoScrollResponse = () => + autoScroll && ($settings?.scrollOnResponseGeneration ?? true); + let scrollRAF = null; let contentsRAF = null; - const scheduleScrollToBottom = () => { + const scheduleResponseScrollToBottom = () => { + if (!shouldAutoScrollResponse()) return; + if (!scrollRAF) { scrollRAF = requestAnimationFrame(async () => { scrollRAF = null; @@ -2426,7 +2431,7 @@ history.messages[message.id] = message; await tick(); - if (autoScroll) { + if (shouldAutoScrollResponse()) { scrollToBottom(); } @@ -2447,9 +2452,7 @@ console.log(data); await tick(); - if (autoScroll) { - scheduleScrollToBottom(); - } + scheduleResponseScrollToBottom(); }; ////////////////////////// @@ -3209,7 +3212,9 @@ } await tick(); - scrollToBottom(); + if (shouldAutoScrollResponse()) { + scrollToBottom(); + } }; const handleOpenAIError = async (error, responseMessage) => { @@ -3282,7 +3287,7 @@ history.messages[history.currentId] = responseMessage; - if (autoScroll) { + if (shouldAutoScrollResponse()) { scrollToBottom(); } } @@ -3430,9 +3435,7 @@ history.messages[messageId] = message; } - if (autoScroll) { - scheduleScrollToBottom(); - } + scheduleResponseScrollToBottom(); } await saveChatHandler(_chatId, history); diff --git a/src/lib/components/chat/Settings/Interface.svelte b/src/lib/components/chat/Settings/Interface.svelte index 01e6de14cc..5a1605bb93 100644 --- a/src/lib/components/chat/Settings/Interface.svelte +++ b/src/lib/components/chat/Settings/Interface.svelte @@ -32,6 +32,7 @@ let widescreenMode = false; let splitLargeChunks = false; let scrollOnBranchChange = true; + let scrollOnResponseGeneration = true; let showFilesOnTerminalSelect = true; let userLocation = false; @@ -250,6 +251,7 @@ widescreenMode = $settings?.widescreenMode ?? false; splitLargeChunks = $settings?.splitLargeChunks ?? false; scrollOnBranchChange = $settings?.scrollOnBranchChange ?? true; + scrollOnResponseGeneration = $settings?.scrollOnResponseGeneration ?? true; showFilesOnTerminalSelect = $settings?.showFilesOnTerminalSelect ?? true; temporaryChatByDefault = $settings?.temporaryChatByDefault ?? false; @@ -929,6 +931,28 @@
++ {$i18n.t('Follow assistant responses as they are generated.')} +
+