Pull uncommitted work: fix mobile thread scroll jump (worktree 20990773)

Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
Theo BrowneandClaude Fable 5 committed 2026-07-04 04:15:42 -07:00
1 parent dd8c6493fd
commit e899698f2f
2 files changed
+30 -11

No files matched your search

@@ -19,7 +19,7 @@ import { useHeaderHeight } from "expo-router/build/react-navigation/elements";
import { memo, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
import { View, type GestureResponderEvent } from "react-native";
import { Gesture, GestureDetector } from "react-native-gesture-handler";
import { KeyboardStickyView } from "react-native-keyboard-controller";
import { KeyboardController, KeyboardStickyView } from "react-native-keyboard-controller";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { runOnJS } from "react-native-reanimated";
@@ -291,16 +291,31 @@ export const ThreadDetailScreen = memo(function ThreadDetailScreen(props: Thread
return;
}
lastScrolledAnchorMessageIdRef.current = anchorMessageId;
void scrollMessageToEnd({ animated: true, closeKeyboard: false }).catch(() => {
if (
selectedThreadKeyRef.current !== targetThreadKey ||
lastScrolledAnchorMessageIdRef.current !== anchorMessageId
) {
return;
}
lastScrolledAnchorMessageIdRef.current = null;
freeze.set(false);
});
// Wait for the keyboard dismissal (started by blur() on send) to finish
// before scrolling: scrollMessageToEnd freezes keyboard-driven inset
// updates while it runs, and a close event swallowed by that freeze
// leaves the keyboard padding permanently applied — overshooting the
// anchor and leaving a phantom bottom inset once the reply streams in.
void KeyboardController.dismiss()
.then(() => {
if (
selectedThreadKeyRef.current !== targetThreadKey ||
lastScrolledAnchorMessageIdRef.current !== anchorMessageId
) {
return;
}
return scrollMessageToEnd({ animated: true, closeKeyboard: false });
})
.catch(() => {
if (
selectedThreadKeyRef.current !== targetThreadKey ||
lastScrolledAnchorMessageIdRef.current !== anchorMessageId
) {
return;
}
lastScrolledAnchorMessageIdRef.current = null;
freeze.set(false);
});
});
return () => cancelAnimationFrame(frame);
}, [
@@ -1456,6 +1456,10 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
ref={props.listRef}
key={props.threadId}
style={{ flex: 1 }}
// RN 0.81+ drops touches inside the contentInset area
// (facebook/react-native#54123); the anchored end space after a send
// is pure inset, so without this the blank region can't be scrolled.
applyWorkaroundForContentInsetHitTestBug
automaticallyAdjustsScrollIndicatorInsets={false}
scrollIndicatorInsets={{ top: topContentInset, bottom: 0 }}
{...(anchoredEndSpace ? { anchoredEndSpace } : {})}