fix(mobile): keep the composer from covering the last message on thread open #4999
ClosedcarTloyal123(GitHub profile, opens in a new tab)wants to merge 1 commit into
main fromrefs/pull/4999/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
- apps/mobile/src/features/threads/ThreadDetailScreen.tsx line 237Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -218,3 +252,7 @@218252 Math.max(0, estimatedOverlayHeight - nativeInsetOvercount),219253 -nativeInsetOvercount,220254 );255+ // Mirrors the composer's real measured height into plain React state (see256+ // composerMeasuredHeight above) alongside the library's own shared-value report,257+ // so ThreadFeed can react to it even when it changes after ThreadFeed has mounted.258+ const handleComposerOverlayLayout = useCallback(
- apps/mobile/src/features/threads/ThreadDetailScreen.tsx line 261OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -218,3 +252,10 @@218252 Math.max(0, estimatedOverlayHeight - nativeInsetOvercount),219253 -nativeInsetOvercount,220254 );255+ // Mirrors the composer's real measured height into plain React state (see256+ // composerMeasuredHeight above) alongside the library's own shared-value report,257+ // so ThreadFeed can react to it even when it changes after ThreadFeed has mounted.258+ const handleComposerOverlayLayout = useCallback(259+ (event: LayoutChangeEvent) => {260+ onComposerLayout(event);261+ setComposerMeasuredHeight(event.nativeEvent.layout.height);
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:L
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- apps/mobile/src/features/threads/ThreadFeed.tsx line 1548Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -1531,2 +1540,19 @@1531- if (bottom > 0) {1532- props.listRef.current?.reportContentInset({ bottom });1540+ // Distinguishes the initial prime for a fresh list instance (must land before1541+ // its first positioning tick, above) from a later correction: the composer1542+ // overlay's real height can still change after this effect's first run for the1543+ // same mount — e.g. a pending approval / user-input card animating in once a1544+ // remote thread resolves — racing the list's own initial positioning, which1545+ // already ran against the overlay's pre-card height. (The sync status pill is1546+ // NOT part of this: it floats outside the measured overlay on purpose, so sync1547+ // toggling doesn't bounce the feed.) composerMeasuredHeight is plain React1548+ // state (unlike the shared value above) so its change re-triggers this effect;1549+ // when it does post-mount, re-pin to the corrected end so the last message1550+ // doesn't rest hidden under the now-taller composer.1551+ const isInitialMountForKey = lastReprimedMountKeyRef.current !== listMountKey;1552+ lastReprimedMountKeyRef.current = listMountKey;1553+ if (bottom <= 0) {1554+ return;1555+ }1556+ props.listRef.current?.reportContentInset({ bottom });1557+ if (!isInitialMountForKey && nearListEnd.value) {1558+ props.listRef.current?.scrollToEnd({ animated: true });
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:M
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/mobile/src/features/threads/ThreadDetailScreen.tsx line 195Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -181,3 +187,10 @@181187 const lastScrolledAnchorMessageIdRef = useRef<MessageId | null>(null);182188 const [composerExpanded, setComposerExpanded] = useState(false);183189 const [anchorMessageId, setAnchorMessageId] = useState<MessageId | null>(null);190+ // Plain React state mirror of the composer overlay's last real measured height191+ // (contentInsetEndAdjustment below is a reanimated shared value and mutating it192+ // doesn't re-render, so ThreadFeed can't depend on it to notice a late change).193+ // Threaded down so the feed can re-correct its position once the composer's true194+ // height — which the pill/pending-card logic below can only estimate ahead of time195+ // — is actually known, instead of trusting a stale pre-measurement guess forever.196+ const [composerMeasuredHeight, setComposerMeasuredHeight] = useState<number | null>(null);
- apps/mobile/src/features/threads/ThreadDetailScreen.tsx line 241OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -201,4 +222,20 @@201222 })();202223 const selectedThreadFeed = props.selectedThreadFeed;203224 const composerChrome = composerExpanded ? COMPOSER_EXPANDED_CHROME : COMPOSER_COLLAPSED_CHROME;204- const composerOverlapHeight = composerChrome + composerBottomInset;225+ // Whether a pending-approval / user-input card will render is knowable226+ // synchronously from these props — the same render pass that flips227+ // selectedThreadFeed from empty to populated. Reserving its conservative228+ // chrome now (rather than waiting for the composer's own onLayout to catch up)229+ // closes most of the gap where the feed's initial bottom inset could otherwise230+ // under-reserve for a thread that opens with a pending approval already231+ // active. The real onComposerLayout measurement (below) always overrides this232+ // estimate once it lands, so the estimate must only cover what that233+ // measurement will also cover: the cards render in normal flow inside the234+ // measured overlay and count; the connection/sync status pill is deliberately235+ // an absolutely-positioned overlay inside ThreadComposer and does NOT count —236+ // in either the estimate or the measurement. Syncing starts and stops on237+ // every fetch, and letting the pill grow the inset would bounce the feed up238+ // and down each time; it may briefly cover the last message instead.239+ const hasPendingOverlayCard =240+ props.activePendingApproval !== null || props.activePendingUserInput !== null;241+ const composerExtraChrome = hasPendingOverlayCard ? COMPOSER_PENDING_CARD_MIN_CHROME : 0;
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:L
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- apps/mobile/src/features/threads/ThreadFeed.tsx line 1535Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1526,4 +1529,5 @@15261529 // composer-height short of the end. Layout effect: it must land before the15271530 // list's first positioning tick or the one-shot initial scroll misses it.15281531 const listMountKey = `${props.threadId}:${props.feed.length === 0 ? "empty" : "filled"}`;1532+ const lastReprimedMountKeyRef = useRef<string | null>(null);15291533 useLayoutEffect(() => {
- @@ -218,3 +234,4 @@218234 Math.max(0, estimatedOverlayHeight - nativeInsetOvercount),219235 -nativeInsetOvercount,220236 );237+ const handleComposerOverlayLayout = useCallback(
- @@ -1526,9 +1531,18 @@15261531 // composer-height short of the end. Layout effect: it must land before the15271532 // list's first positioning tick or the one-shot initial scroll misses it.15281533 const listMountKey = `${props.threadId}:${props.feed.length === 0 ? "empty" : "filled"}`;1534+ const lastReprimedMountKeyRef = useRef<string | null>(null);15291535 useLayoutEffect(() => {15301536 const bottom = props.contentInsetEndAdjustment.value;1531- if (bottom > 0) {1532- props.listRef.current?.reportContentInset({ bottom });1537+ const isInitialMountForKey = lastReprimedMountKeyRef.current !== listMountKey;1538+ lastReprimedMountKeyRef.current = listMountKey;1539+ if (isInitialMountForKey) {1540+ nearListEnd.value = true;1541+ userDraggedSinceMountRef.current = false;1542+ }1543+ if (bottom <= 0) {1544+ return;15331545 }1534- }, [listMountKey, props.contentInsetEndAdjustment, props.listRef]);1546+ props.listRef.current?.reportContentInset({ bottom });1547+ if (!isInitialMountForKey && nearListEnd.value && !userDraggedSinceMountRef.current) {1548+ props.listRef.current?.scrollToEnd({ animated: true });
juliusmarminge closed this
Sign in to join this conversation.


macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed