fix(mobile): Stabilize thread feed layout and Markdown rendering #4036
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
- apps/mobile/src/features/threads/ThreadFeed.tsx lines 1410 to 1413OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1395,3 +1404,10 @@13951404 setViewportHeight((current) => (Math.abs(current - nextHeight) > 1 ? nextHeight : current));13961405 }, []);139714061407+ const handleContentSizeChange = useCallback((_width: number, height: number) => {1408+ setContentHeight((current) => (Math.abs(current - height) > 1 ? height : current));1409+ }, []);1410+ const contentUnderflowsViewport =1411+ contentHeight > 0 &&1412+ viewportHeight > 0 &&1413+ contentHeight + props.contentInsetEndEstimate < viewportHeight - CONTENT_FIT_EPSILON;
- @@ -257,8 +262,17 @@257262 // its end-scroll math matches the real resting position.258263 const nativeInsetOvercount =259264 props.usesAutomaticContentInsets === true && Platform.OS === "ios" ? insets.bottom : 0;265+ // heightAdjustment is added to measured composer height. Keep the safe-area266+ // under-report (UIKit automatic insets) and add breathing room above chrome.267+ const composerEndHeightAdjustment = THREAD_FEED_COMPOSER_GAP - nativeInsetOvercount;260268 const { contentInsetEndAdjustment, onComposerLayout } = useKeyboardChatComposerInset(261269 listRef,262270 composerOverlayRef,263- Math.max(0, estimatedOverlayHeight - nativeInsetOvercount),264- -nativeInsetOvercount,271+ Math.max(0, estimatedOverlayHeight + composerEndHeightAdjustment),272+ composerEndHeightAdjustment,273+ );274+ const handleComposerLayout = useCallback(275+ (event: LayoutChangeEvent) => {276+ onComposerLayout(event);277+ const height = event.nativeEvent.layout.height;278+ setComposerOverlayHeight((current) => (Math.abs(current - height) > 1 ? height : current));@@ -1395,3 +1404,10 @@13951404 setViewportHeight((current) => (Math.abs(current - nextHeight) > 1 ? nextHeight : current));13961405 }, []);139714061407+ const handleContentSizeChange = useCallback((_width: number, height: number) => {1408+ setContentHeight((current) => (Math.abs(current - height) > 1 ? height : current));1409+ }, []);1410+ const contentUnderflowsViewport =1411+ contentHeight > 0 &&1412+ viewportHeight > 0 &&1413+ contentHeight + props.contentInsetEndEstimate < viewportHeight - CONTENT_FIT_EPSILON;
- apps/mobile/src/features/threads/ThreadDetailScreen.tsx line 273Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -248,3 +252,9 @@248252 const composerOverlapHeight = composerChrome + composerBottomInset;249253 const activeWorkIndicatorHeight = props.activeWorkStartedAt ? WORKING_INDICATOR_HEIGHT : 0;250254 const estimatedOverlayHeight = composerOverlapHeight + activeWorkIndicatorHeight;255+ const [composerOverlayHeight, setComposerOverlayHeight] = useState(estimatedOverlayHeight);256+ useEffect(() => {257+ setComposerOverlayHeight((current) =>258+ Math.abs(current - estimatedOverlayHeight) > 1 ? estimatedOverlayHeight : current,259+ );260+ }, [estimatedOverlayHeight]);
- @@ -248,3 +252,10 @@248252 const composerOverlapHeight = composerChrome + composerBottomInset;249253 const activeWorkIndicatorHeight = props.activeWorkStartedAt ? WORKING_INDICATOR_HEIGHT : 0;250254 const estimatedOverlayHeight = composerOverlapHeight + activeWorkIndicatorHeight;255+ const [composerOverlayHeight, setComposerOverlayHeight] = useState(estimatedOverlayHeight);256+ useEffect(() => {257+ // A measured overlay can include approval or input cards that are not part258+ // of this baseline estimate. Keep that larger measurement until layout259+ // reports a new height, while ensuring chrome changes never under-estimate260+ // the composer inset.261+ setComposerOverlayHeight((current) => Math.max(current, estimatedOverlayHeight));
- apps/mobile/src/features/threads/ThreadDetailScreen.tsx lines 263 to 268OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -248,3 +252,17 @@248252 const composerOverlapHeight = composerChrome + composerBottomInset;249253 const activeWorkIndicatorHeight = props.activeWorkStartedAt ? WORKING_INDICATOR_HEIGHT : 0;250254 const estimatedOverlayHeight = composerOverlapHeight + activeWorkIndicatorHeight;255+ const [composerOverlayHeight, setComposerOverlayHeight] = useState(estimatedOverlayHeight);256+ useEffect(() => {257+ // A measured overlay can include approval or input cards that are not part258+ // of this baseline estimate. Keep that larger measurement until layout259+ // reports a new height, while ensuring chrome changes never under-estimate260+ // the composer inset.261+ setComposerOverlayHeight((current) => Math.max(current, estimatedOverlayHeight));262+ }, [estimatedOverlayHeight]);263+ useEffect(() => {264+ // Layout callbacks from the previous thread can arrive after navigation.265+ // Reset their larger measurement to this thread's known baseline; its own266+ // overlay layout will immediately replace it if it contains extra cards.267+ setComposerOverlayHeight(estimatedOverlayHeight);268+ }, [estimatedOverlayHeight, selectedThreadKey]);
- apps/mobile/src/features/threads/ThreadDetailScreen.tsx line 304Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -257,8 +279,19 @@257279 // its end-scroll math matches the real resting position.258280 const nativeInsetOvercount =259281 props.usesAutomaticContentInsets === true && Platform.OS === "ios" ? insets.bottom : 0;282+ // heightAdjustment is added to measured composer height. Keep the safe-area283+ // under-report (UIKit automatic insets) and add breathing room above chrome.284+ const composerEndHeightAdjustment = THREAD_FEED_COMPOSER_GAP - nativeInsetOvercount;260285 const { contentInsetEndAdjustment, onComposerLayout } = useKeyboardChatComposerInset(261286 listRef,262287 composerOverlayRef,263- Math.max(0, estimatedOverlayHeight - nativeInsetOvercount),264- -nativeInsetOvercount,288+ Math.max(0, estimatedOverlayHeight + composerEndHeightAdjustment),289+ composerEndHeightAdjustment,290+ );291+ const handleComposerLayout = useCallback(292+ (event: LayoutChangeEvent) => {293+ onComposerLayout(event);294+ const height = event.nativeEvent.layout.height;295+ setComposerOverlayHeight((current) => (Math.abs(current - height) > 1 ? height : current));296+ },297+ [onComposerLayout],apps/mobile/src/features/threads/ThreadFeed.tsx line 1441Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -1397,0 +1421,21 @@1421+ underflowCorrectionFrameRef.current = null;1422+ }1423+1424+ const previouslyUnderflowed = previousContentUnderflowsViewportRef.current;1425+ previousContentUnderflowsViewportRef.current = contentUnderflowsViewport;1426+ if (contentUnderflowsViewport) {1427+ underflowCorrectionFrameRef.current = requestAnimationFrame(() => {1428+ underflowCorrectionFrameRef.current = null;1429+ void props.listRef.current?.scrollToOffset({1430+ animated: false,1431+ offset: -anchorTopInset,1432+ });1433+ });1434+ return;1435+ }1436+1437+ // A disclosure transition owns its visible-content anchor, so consuming1438+ // the underflow transition without an end scroll is intentional there.1439+ if (previouslyUnderflowed && !disclosureToggleSettling) {1440+ void props.listRef.current?.scrollToEnd({ animated: true });1441+ }
juliusmarminge added labels🚀 Mobile Continuous Deployment
- @@ -255,3 +259,21 @@255259 const composerOverlapHeight = composerChrome + composerBottomInset;256260 const activeWorkIndicatorHeight = props.activeWorkStartedAt ? WORKING_INDICATOR_HEIGHT : 0;257261 const estimatedOverlayHeight = composerOverlapHeight + activeWorkIndicatorHeight;262+ const [composerOverlayHeight, setComposerOverlayHeight] = useState(estimatedOverlayHeight);263+ const estimatedOverlayHeightRef = useRef(estimatedOverlayHeight);264+ useEffect(() => {265+ estimatedOverlayHeightRef.current = estimatedOverlayHeight;266+ }, [estimatedOverlayHeight]);267+ useEffect(() => {268+ // A measured overlay can include approval or input cards that are not part269+ // of this baseline estimate. Keep that larger measurement until layout270+ // reports a new height, while ensuring chrome changes never under-estimate271+ // the composer inset.272+ setComposerOverlayHeight((current) => Math.max(current, estimatedOverlayHeight));273+ }, [estimatedOverlayHeight]);274+ useEffect(() => {275+ // Layout callbacks from the previous thread can arrive after navigation.276+ // Reset their larger measurement to this thread's known baseline; its own277+ // overlay layout will immediately replace it if it contains extra cards.278+ setComposerOverlayHeight(estimatedOverlayHeightRef.current);279+ }, [selectedThreadKey]);
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.


Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID:
7bb6af15-1007-4f8d-9a16-772c36b7da18You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment `@coderabbitai help` to get the list of available commands.