fix(voice): follow a new chat request once the log is full

The conversation is kept to its newest 60 messages, so once full it no
longer grows as a message is sent, and a reader who had scrolled up was
left behind by their own request. The view now spots a send by the newest
user message's id instead of the list's length.
This commit is contained in:
Sameh Khamis committed 2026-11-03 15:54:54 -08:00
1 parent 51b561815c
commit eed6162753
2 files changed
+39 -1

No files matched your search

+4 -1
View File
@@ -37,9 +37,12 @@ const onListScroll = () => {
const el = list.value;
if (el) stuck = el.scrollHeight - el.scrollTop - el.clientHeight < 24;
};
// A send is a new newest user message. The log is capped, so a full one
// does not grow as it takes a message: compare ids, not lengths.
const lastSent = (list) => list?.findLast((entry) => entry.role === 'user')?.id;
watch(messages, (next, previous) => {
const sent =
next.length > (previous?.length ?? 0) && next.at(-1)?.role === 'user';
next.at(-1)?.role === 'user' && lastSent(next) !== lastSent(previous);
if (!stuck && !sent) return;
void nextTick(() => {
if (list.value) list.value.scrollTop = list.value.scrollHeight;