autoscroll on next process group improvement

frdel committed Feb 8, 2026 at 21:16 UTC d3608d1925a1ed2ee8a75541d59b79d8f433d209
2 files changed +17
webui/index.js
+1
@@ -60,6 +60,7 @@ export async function sendMessage() {
60 }
61
62 // Sending a message is an explicit user intent to go to the bottom
63 + msgs.scrollOnNextProcessGroup();
64 forceScrollChatToBottom();
65
66 let response;
webui/js/messages.js
+16
@@ -26,6 +26,11 @@ let _chatHistory = null;
26
27 // state vars
28 let _massRender = false;
29 +let _scrollOnNextProcessGroup = null;
30 +
31 +export function scrollOnNextProcessGroup() {
32 + _scrollOnNextProcessGroup = "wait";
33 +}
34
35 // handlers for log message rendering
36 export function getMessageHandler(type) {
@@ -96,6 +101,13 @@ export function setMessages(messages) {
101 const shouldScroll = historyEmpty || !results[results.length - 1]?.dontScroll;
102
103 if (shouldScroll) mainScroller.reApplyScroll();
104 +
105 + if (_scrollOnNextProcessGroup === "scroll") {
106 + requestAnimationFrame(() => {
107 + mainScroller.scrollToBottom();
108 + _scrollOnNextProcessGroup = null;
109 + });
110 + }
111 }
112
113 // entrypoint called from poll/WS communication, this is how all messages are rendered and updated
@@ -213,6 +225,10 @@ function getOrCreateProcessGroup(id, allowCompleted = true) {
225 group.classList.add("embedded");
226 messageContainer.appendChild(group);
227
228 + if (_scrollOnNextProcessGroup === "wait") {
229 + _scrollOnNextProcessGroup = "scroll";
230 + }
231 +
232 appendToMessageGroup(messageContainer, "left");
233 return group;
234 }