Matthias Nott
2026-03-07 5700a2d3c3dc409a8bde3cfa971beeb9b897435f
components/chat/MessageList.tsx
....@@ -13,14 +13,23 @@
1313
1414 export function MessageList({ messages, isTyping, onDeleteMessage }: MessageListProps) {
1515 const listRef = useRef<FlatList<Message>>(null);
16
+ const prevLengthRef = useRef(0);
17
+
18
+ // Track the last message's content so transcript reflections trigger a scroll
19
+ const lastContent = messages.length > 0 ? messages[messages.length - 1].content : "";
1620
1721 useEffect(() => {
1822 if (messages.length > 0) {
23
+ // If the message count changed by more than 1, it's a session switch —
24
+ // snap to bottom instantly instead of visibly scrolling down.
25
+ const delta = Math.abs(messages.length - prevLengthRef.current);
26
+ const animated = delta === 1;
1927 setTimeout(() => {
20
- listRef.current?.scrollToEnd({ animated: true });
28
+ listRef.current?.scrollToEnd({ animated });
2129 }, 50);
2230 }
23
- }, [messages.length, isTyping]);
31
+ prevLengthRef.current = messages.length;
32
+ }, [messages.length, isTyping, lastContent]);
2433
2534 // Play from a voice message and auto-chain all consecutive assistant voice messages after it
2635 const handlePlayVoice = useCallback(async (messageId: string) => {
....@@ -61,9 +70,6 @@
6170 />
6271 )}
6372 contentContainerStyle={{ paddingVertical: 12 }}
64
- onContentSizeChange={() => {
65
- listRef.current?.scrollToEnd({ animated: false });
66
- }}
6773 showsVerticalScrollIndicator={false}
6874 ListFooterComponent={
6975 <>