Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

Chat: sending a message still scrolls to it when the reader had scrolled up (#4014)

Niko12219a0462a011ac
diff --git a/apps/host/src/screens/Chat.tsx b/apps/host/src/screens/Chat.tsx
index 385c3acc7..3fbc90d37 100644
--- a/apps/host/src/screens/Chat.tsx
+++ b/apps/host/src/screens/Chat.tsx
@@ -215,6 +215,7 @@ export function ChatScreen() {
const pinned = useRef(true);
/** When the reader last used the wheel, a finger, a key or the scrollbar on the transcript. */
const readerInput = useRef(0);
+ const messageCount = useRef(0);
/**
* Scrolls to the newest message and stays there.
*
@@ -271,7 +272,11 @@ export function ChatScreen() {
return;
// The reader's own scrolling decides (#4014): a wheel notch is about 100 px and used to land inside a 120 px band that pulled
// the view back on every token. `pinned` is set by the scroller's wheel, touch, key and scroll handlers below.
- if (pinned.current)
+ const count = session?.messages.length ?? 0;
+ const sent = count > messageCount.current && session?.messages.at(-1)?.role === 'user';
+ messageCount.current = count;
+ // Sending a message always brings the reader to it, as it did before; only the answer's growth waits for the reader.
+ if (pinned.current || sent)
scrollToLatest();
}, [session?.messages.length, session?.messages.at(-1)?.content, scrollToLatest]);
// Scroll position is remembered per conversation, so returning to one puts you
diff --git a/apps/host/tests/follow-scroll.test.mjs b/apps/host/tests/follow-scroll.test.mjs
index e724696a7..1fdc95fe0 100644
--- a/apps/host/tests/follow-scroll.test.mjs
+++ b/apps/host/tests/follow-scroll.test.mjs
@@ -34,6 +34,8 @@ test('the chat screen uses the reader-driven rule, not the 120 px band', async (
assert.doesNotMatch(chat, /clientHeight < 120/);
assert.match(chat, /followAfterScroll\(/);
assert.match(chat, /onWheel=/);
+ // sending a message still brings the reader to it, even from far up
+ assert.match(chat, /pinned\.current \|\| sent/);
// an upward wheel on a transcript that cannot scroll must not switch following off
assert.match(chat, /wheelLeavesBottom\(e\.deltaY\) && e\.currentTarget\.scrollTop > 0/);
});