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('Response Auto-Scroll')} +
+ +
+ { + saveSettings({ scrollOnResponseGeneration }); + }} + /> +
+
+

+ {$i18n.t('Follow assistant responses as they are generated.')} +

+
+
diff --git a/src/lib/components/chat/SettingsModal.svelte b/src/lib/components/chat/SettingsModal.svelte index 79321cc8fb..9280f8bde6 100644 --- a/src/lib/components/chat/SettingsModal.svelte +++ b/src/lib/components/chat/SettingsModal.svelte @@ -259,8 +259,13 @@ 'pastelargetextasfile', 'reset background', 'resetbackground', + 'disable auto scroll', + 'disableautoscroll', 'response auto copy', + 'response auto scroll', + 'response auto-scroll', 'responseautocopy', + 'responseautoscroll', 'rich text input for chat', 'richtextinputforchat', 'right to left', diff --git a/src/lib/i18n/locales/en-GB/translation.json b/src/lib/i18n/locales/en-GB/translation.json index eb9b1c5f9d..16ad0352d6 100644 --- a/src/lib/i18n/locales/en-GB/translation.json +++ b/src/lib/i18n/locales/en-GB/translation.json @@ -1257,6 +1257,7 @@ "Format Markdown in previews and compact content surfaces.": "", "Format Markdown syntax in assistant responses.": "", "Format Markdown syntax in your own messages.": "", + "Follow assistant responses as they are generated.": "", "Formatting may be inconsistent from source.": "", "Forward": "", "Forwards system user OAuth access token to authenticate": "", @@ -2177,6 +2178,7 @@ "Reset Vector Storage/Knowledge": "", "Reset view": "", "Response": "", + "Response Auto-Scroll": "", "Response notifications cannot be activated as the website permissions have been denied. Please visit your browser settings to grant the necessary access.": "", "Response Splitting": "", "Response Watermark": "", diff --git a/src/lib/i18n/locales/en-US/translation.json b/src/lib/i18n/locales/en-US/translation.json index 4751ce3291..c14841a9a7 100644 --- a/src/lib/i18n/locales/en-US/translation.json +++ b/src/lib/i18n/locales/en-US/translation.json @@ -1257,6 +1257,7 @@ "Format Markdown in previews and compact content surfaces.": "", "Format Markdown syntax in assistant responses.": "", "Format Markdown syntax in your own messages.": "", + "Follow assistant responses as they are generated.": "", "Formatting may be inconsistent from source.": "", "Forward": "", "Forwards system user OAuth access token to authenticate": "", @@ -2177,6 +2178,7 @@ "Reset Vector Storage/Knowledge": "", "Reset view": "", "Response": "", + "Response Auto-Scroll": "", "Response notifications cannot be activated as the website permissions have been denied. Please visit your browser settings to grant the necessary access.": "", "Response Splitting": "", "Response Watermark": "", diff --git a/src/lib/stores/index.ts b/src/lib/stores/index.ts index fc3dfac5be..0738337035 100644 --- a/src/lib/stores/index.ts +++ b/src/lib/stores/index.ts @@ -234,6 +234,7 @@ type Settings = { iframeSandboxAllowForms?: boolean; iframeSandboxAllowSameOrigin?: boolean; scrollOnBranchChange?: boolean; + scrollOnResponseGeneration?: boolean; showFilesOnTerminalSelect?: boolean; directConnections?: null; chatBubble?: boolean;