fix(app): stop Android chat jumping during streaming

The inverted list's native position maintenance fought the sticky-bottom controller as the live message grew. Let the controller exclusively own the Android sticky-bottom anchor while preserving position maintenance when reading history.
This commit is contained in:
Mohamed Boudra
2026-07-21 21:33:47 +02:00
parent 7d10791bad
commit cf9dfcf947
@@ -11,6 +11,7 @@ import {
FlatList, FlatList,
ActivityIndicator, ActivityIndicator,
Keyboard, Keyboard,
Platform,
View, View,
type LayoutChangeEvent, type LayoutChangeEvent,
type ListRenderItemInfo, type ListRenderItemInfo,
@@ -189,6 +190,12 @@ function NativeStreamViewport(props: StreamRenderInput & { strategy: StreamStrat
}, },
scrollToBottom, scrollToBottom,
}); });
// Android's maintainVisibleContentPosition ignores the list inversion transform and
// fights the controller's offset-zero correction while the live header grows.
const maintainVisibleContentPosition =
Platform.OS === "android" && bottomAnchorController.mode === "sticky-bottom"
? undefined
: DEFAULT_MAINTAIN_VISIBLE_CONTENT_POSITION;
useEffect(() => { useEffect(() => {
streamViewportMetricsRef.current = { streamViewportMetricsRef.current = {
@@ -414,7 +421,7 @@ function NativeStreamViewport(props: StreamRenderInput & { strategy: StreamStrat
onScroll={handleScroll} onScroll={handleScroll}
scrollEventThrottle={16} scrollEventThrottle={16}
onContentSizeChange={handleContentSizeChange} onContentSizeChange={handleContentSizeChange}
maintainVisibleContentPosition={DEFAULT_MAINTAIN_VISIBLE_CONTENT_POSITION} maintainVisibleContentPosition={maintainVisibleContentPosition}
initialNumToRender={40} initialNumToRender={40}
maxToRenderPerBatch={40} maxToRenderPerBatch={40}
updateCellsBatchingPeriod={0} updateCellsBatchingPeriod={0}