Skip to content

Commit d07ffbe

Browse files
authored
fix(mobile): keep iOS chat rows aligned after measurement (#11813)
1 parent caf8b5d commit d07ffbe

1 file changed

Lines changed: 3 additions & 14 deletions

File tree

‎apps/mobile/src/features/threads/ThreadFeed.tsx‎

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ import { isPdfFile } from "../../lib/filePreview";
8383
import { flattenThemeColor } from "../../lib/mobileTheme";
8484
import { PresentationSource } from "../../components/NativePresentation";
8585
import { useSafeAreaInsets } from "react-native-safe-area-context";
86-
import Animated, { FadeIn, LinearTransition, type SharedValue } from "react-native-reanimated";
86+
import Animated, { FadeIn, type SharedValue } from "react-native-reanimated";
8787
import { useUniwindTheme } from "../../lib/useUniwindTheme";
8888
import { IOS_NAV_BAR_HEIGHT } from "../../lib/layoutMetrics";
8989
import { useFontFamily } from "../../lib/useFontFamily";
@@ -216,8 +216,6 @@ function formatMessageTime(input: string): string {
216216
// Fixed heights mirror renderFeedEntry's classNames and are only used while
217217
// text fits at the current font settings. Larger accessibility text is measured.
218218
const TURN_FOLD_HEIGHT = 42; // min-h-11 (38.5) + mb-1 (3.5), with the mobile 14px rem
219-
const THREAD_FEED_LAYOUT_TRANSITION = LinearTransition.duration(THREAD_DISCLOSURE_TRANSITION_MS);
220-
const THREAD_FEED_IMMEDIATE_TRANSITION = LinearTransition.duration(0);
221219
// Tailwind spacing on the mobile 14px rem: px-3.5 on the user bubble, px-1 on
222220
// assistant rows. Images size their frame from these before their own layout.
223221
const USER_BUBBLE_HORIZONTAL_PADDING = 3.5 * 3.5;
@@ -2825,17 +2823,8 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
28252823
entry.type === "message" ? `message:${entry.message.role}` : entry.type
28262824
}
28272825
getFixedItemSize={getFixedItemSize}
2828-
// Android can retain stale native row positions when layout transitions
2829-
// race the measurements arriving during sync, even with duration 0.
2830-
// Keep its rows on LegendList's non-animated positioning path. On iOS,
2831-
// keep a transition installed between disclosures so containers don't remount.
2832-
itemLayoutAnimation={
2833-
Platform.OS === "android"
2834-
? undefined
2835-
: disclosureToggleSettling
2836-
? THREAD_FEED_LAYOUT_TRANSITION
2837-
: THREAD_FEED_IMMEDIATE_TRANSITION
2838-
}
2826+
// Virtualized rows must move with their measurements. Native layout
2827+
// transitions can retain stale positions during sync, even at duration 0.
28392828
onItemSizeChanged={handleItemSizeChanged}
28402829
// Measure rows well before they scroll into view so estimate→actual
28412830
// corrections land offscreen instead of under the user's finger.

0 commit comments

Comments
 (0)