From 0cd245bcbb46d894989e1ddd688d6640ba6ac537 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Fri, 13 Mar 2026 12:58:56 -0700 Subject: [PATCH] UI: Make autoscroll more robust after the optimizations --- js/main.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/js/main.js b/js/main.js index 0cefaa6e..a8bbbc71 100644 --- a/js/main.js +++ b/js/main.js @@ -181,6 +181,13 @@ const observer = new MutationObserver(function() { typing.parentNode.classList.add("visible-dots"); document.getElementById("stop").style.display = "flex"; document.getElementById("Generate").style.display = "none"; + // If the user is near the bottom, ensure auto-scroll is enabled + // for the new reply. This catches cases where isScrolled was + // incorrectly set to true by layout shifts during page load, etc. + const diff = targetElement.scrollHeight - targetElement.clientHeight; + if (Math.abs(targetElement.scrollTop - diff) <= 10 || diff <= 0) { + window.isScrolled = false; + } } else { typing.parentNode.classList.remove("visible-dots"); document.getElementById("stop").style.display = "none";