Commit b15588f3 by michaelpastushkov

fix

parent 12e79c3d
...@@ -202,7 +202,7 @@ ...@@ -202,7 +202,7 @@
z-index: 1100; z-index: 1100;
/* above composer/footer */ /* above composer/footer */
display: none; display: none;
/* hidden initially */ /* hard-hidden until armed */
align-items: center; align-items: center;
justify-content: center; justify-content: center;
border: 1px solid #ced4da; border: 1px solid #ced4da;
...@@ -324,6 +324,9 @@ ...@@ -324,6 +324,9 @@
let firstRequestDone = false; let firstRequestDone = false;
let controller = null; let controller = null;
// HARD STOP guard: do not show button until conversation starts
let scrollBtnArmed = false;
// --- render helpers --- // --- render helpers ---
function renderMarkdown(targetEl, md) { function renderMarkdown(targetEl, md) {
const html = marked.parse(md, { breaks: true, gfm: true, headerIds: false }); const html = marked.parse(md, { breaks: true, gfm: true, headerIds: false });
...@@ -382,8 +385,12 @@ ...@@ -382,8 +385,12 @@
} }
function updateScrollButton() { function updateScrollButton() {
// Hard stop: never show until armed
if (!scrollBtnArmed) {
scrollDownBtn.style.display = 'none';
return;
}
const needs = isOverflowingAny() && !atBottom(); const needs = isOverflowingAny() && !atBottom();
// hidden initially (no overflow) and whenever you’re at the bottom
scrollDownBtn.style.display = needs ? 'inline-flex' : 'none'; scrollDownBtn.style.display = needs ? 'inline-flex' : 'none';
} }
...@@ -405,6 +412,9 @@ ...@@ -405,6 +412,9 @@
if (!firstRequestDone) { welcomeLogo?.remove(); firstRequestDone = true; } if (!firstRequestDone) { welcomeLogo?.remove(); firstRequestDone = true; }
// Arm the scroll button the moment a real conversation starts
scrollBtnArmed = true;
const autoStick = atBottom(); const autoStick = atBottom();
const userMsg = document.createElement('div'); const userMsg = document.createElement('div');
...@@ -496,7 +506,7 @@ ...@@ -496,7 +506,7 @@
window.addEventListener('scroll', updateScrollButton, { passive: true }); window.addEventListener('scroll', updateScrollButton, { passive: true });
window.addEventListener('resize', updateScrollButton); window.addEventListener('resize', updateScrollButton);
// Observe content changes to recalc button visibility // Observe content changes to recalc button visibility (only after armed)
const threadObserver = new MutationObserver(() => { const threadObserver = new MutationObserver(() => {
requestAnimationFrame(updateScrollButton); requestAnimationFrame(updateScrollButton);
}); });
...@@ -507,7 +517,10 @@ ...@@ -507,7 +517,10 @@
try { await fetch('/api/clear', { method: 'GET' }); } catch (_) { } try { await fetch('/api/clear', { method: 'GET' }); } catch (_) { }
await loadLocale(CURRENT_LOCALE); await loadLocale(CURRENT_LOCALE);
inputText.focus(); inputText.focus();
updateScrollButton(); // initial -> hidden if no overflow // Force-hide at startup no matter what
scrollBtnArmed = false;
scrollDownBtn.style.display = 'none';
updateScrollButton();
}); });
</script> </script>
</body> </body>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment