The best way to control Claude Code, Codex and more from any computer or phone
fix(mobile): smooth expand/collapse when the feed is at the bottom (#33449)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Nov 9, 2026 at 08:43 UTC
7b248349bdc066b1488f52083662597ab22d6fe3
1 file changed
+33
-5
apps/mobile/src/features/threads/ThreadFeed.tsx
+33
-5
@@ -2568,8 +2568,11 @@ function useThreadFeedPresentation(
2568
}
2569
2570
type DisclosureLayout = {
2571
+ /** Each row's top relative to the anchor row's top, before the toggle. */
2572
positions: ReadonlyMap<string, number>;
2573
anchorIndex: number;
2574
+ /** Distance from the anchor's top to the end of the content, before the toggle. */
2575
+ anchorToEnd: number;
2576
list: LegendListRef;
2577
playing: boolean;
2578
};
@@ -2577,6 +2580,13 @@ const DISCLOSURE_DETAIL_DELAY_MS = 135;
2580
const DISCLOSURE_DETAIL_FADE_MS = 70;
2581
const unsubscribeNothing = () => {};
2582
2583
+function feedContentEnd(state: ReturnType<LegendListRef["getState"]>): number | undefined {
2584
+ const last = state.data.length - 1;
2585
+ if (last < 0) return undefined;
2586
+ const position = state.positionAtIndex(last);
2587
+ return position === undefined ? undefined : position + state.sizeAtIndex(last);
2588
+}
2589
+
2590
function DisclosureRow(props: {
2591
itemKey: string;
2592
index: number;
@@ -2587,18 +2597,35 @@ function DisclosureRow(props: {
2597
const previous = layout?.positions.get(itemKey);
2598
const subscribe = useCallback(
2599
(notify: () => void) => {
2590
- if (!layout || layout.playing || previous === undefined || previous <= 0)
2591
- return unsubscribeNothing;
2592
- return layout.list.getState().listenToPosition(itemKey, notify);
2600
+ if (!layout || layout.playing || previous === undefined) return unsubscribeNothing;
2601
+ const state = layout.list.getState();
2602
+ const stops = [
2603
+ state.listenToPosition(itemKey, notify),
2604
+ state.listen("totalSize", notify),
2605
+ state.listen("isAtEnd", notify),
2606
+ state.listen("isFollowingEnd", notify),
2607
+ ];
2608
+ return () => {
2609
+ for (const stop of stops) stop();
2610
+ };
2611
},
2612
[itemKey, layout, previous],
2613
);
2614
+ // Rows hold their old screen spot relative to whatever stays still: the content end
2615
+ // while the feed sits at the bottom (end follow, or a collapse that clamps the scroll),
2616
+ // otherwise the anchored disclosure row.
2617
const getOffset = () => {
2597
- if (!layout || layout.playing || previous === undefined || previous <= 0) return 0;
2618
+ if (!layout || layout.playing || previous === undefined) return 0;
2619
const state = layout.list.getState();
2620
const position = state.positionAtIndex(props.index);
2621
+ if (position === undefined) return 0;
2622
+ if (state.isFollowingEnd || state.isAtEnd) {
2623
+ const end = feedContentEnd(state);
2624
+ return end === undefined ? 0 : previous - layout.anchorToEnd - (position - end);
2625
+ }
2626
+ if (previous <= 0) return 0;
2627
const anchor = state.positionAtIndex(layout.anchorIndex);
2601
- return position === undefined || anchor === undefined ? 0 : previous - (position - anchor);
2628
+ return anchor === undefined ? 0 : previous - (position - anchor);
2629
};
2630
const offset = useSyncExternalStore(subscribe, getOffset, getOffset);
2631
const entering = !!layout && previous === undefined;
@@ -3386,6 +3413,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
3413
const motion = {
3414
positions,
3415
anchorIndex,
3416
+ anchorToEnd: (feedContentEnd(state) ?? anchor) - anchor,
3417
list,
3418
playing: false,
3419
};