fix: reset scroll ref on conversation change

prevLengthRef.current was never zeroed when conversationId changed,
so the first batch of messages in a new (shorter) conversation would
not trigger scrollIntoView. Reset it in the polling useEffect cleanup.
This commit is contained in:
2026-08-12 18:03:19 +02:00
parent 455d304885
commit ee19de5f94

View File

@@ -32,7 +32,7 @@ export default function MessageList({ conversationId, refreshKey }: Props) {
load();
// ponytail: polling every 3s — replace with WebSocket when server supports it
const id = setInterval(load, 3000);
return () => { cancelled = true; clearInterval(id); };
return () => { cancelled = true; clearInterval(id); prevLengthRef.current = 0; };
// Fix 2: refreshKey in deps triggers immediate reload after send
}, [conversationId, refreshKey]);