From ca333509a218703a2ee13ac1a170d277e3e42375 Mon Sep 17 00:00:00 2001 From: Valentin Haudiquet Date: Sat, 28 Nov 2026 19:00:56 +0100 Subject: [PATCH] fix(web): stop the chat scroll bouncing on multiline input The auto-resize reset the textarea to auto before measuring, which collapsed it to one row for a frame. That resized the chat viewport, the browser clamped its scroll to the old bottom, and the next input scrolled back. Measure the content in a hidden copy instead. The composer reports a height change, and the room keeps the chat at the bottom only when the reader is already there. Typing and deleting lines now keeps the chat at the bottom without the jump. --- web/app/assets/css/main.css | 21 ++++++++++++ web/app/components/ChatComposer.vue | 50 ++++++++++++++++++++++++++--- web/app/pages/room/[id].vue | 13 ++++++-- 3 files changed, 78 insertions(+), 6 deletions(-) diff --git a/web/app/assets/css/main.css b/web/app/assets/css/main.css index ab5f280..69c1cd7 100644 --- a/web/app/assets/css/main.css +++ b/web/app/assets/css/main.css @@ -1354,6 +1354,7 @@ button { overflow-y: auto; font-size: var(--fs-ui); line-height: var(--lh-body); + overflow-wrap: anywhere; scrollbar-width: thin; } @@ -1361,6 +1362,26 @@ button { color: var(--faint); } +.composer-sizer { + position: fixed; + top: -10000px; + left: -10000px; + height: 0; + min-height: 0; + max-height: none; + overflow: hidden; + visibility: hidden; + pointer-events: none; + border: 0; + padding: var(--sp-1) var(--sp-2); + font: inherit; + font-size: var(--fs-ui); + line-height: var(--lh-body); + white-space: pre-wrap; + overflow-wrap: anywhere; + resize: none; +} + .composer-actions { display: flex; align-items: center; diff --git a/web/app/components/ChatComposer.vue b/web/app/components/ChatComposer.vue index 4166f90..1bc83d0 100644 --- a/web/app/components/ChatComposer.vue +++ b/web/app/components/ChatComposer.vue @@ -1,25 +1,42 @@ @@ -105,6 +137,16 @@ onBeforeUnmount(() => { @input="onInput" @keydown="onKeydown" /> +
Enter sends, Shift+Enter adds a line.
diff --git a/web/app/pages/room/[id].vue b/web/app/pages/room/[id].vue index 0d95db9..a80edb5 100644 --- a/web/app/pages/room/[id].vue +++ b/web/app/pages/room/[id].vue @@ -637,7 +637,7 @@ let stickScheduled = false /// Keep the newest turn card or message in view while the log grows, /// unless the reader has scrolled away from the bottom. function scheduleStick() { - if (!stick.value || stickScheduled) return + if (!stick.value || suspendAutoScroll || stickScheduled) return stickScheduled = true void nextTick(() => { stickScheduled = false @@ -708,6 +708,10 @@ async function loadOlder() { } } +function onComposerResized() { + scheduleStick() +} + async function onSent(message: Message) { addMessage(message, true) stick.value = true @@ -858,7 +862,12 @@ onBeforeUnmount(() => {

{{ typingText }}

- +