The best way to control Claude Code, Codex and more from any computer or phone
fix(mobile): folding the Duo keeps the thread's end or the reader's line in place (#23147)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 21, 2026 at 17:58 UTC
5ed2ea245eef3c0b17395099a31c4801ddeb1a52
5 files changed
+347
-95
apps/mobile/src/features/threads/ThreadFeed.tsx
+32
-12
@@ -204,6 +204,7 @@ import type { ThreadContentPresentation } from "./threadContentPresentation";
204
import {
205
resolveThreadFeedLiveFollow,
206
resolveThreadFeedReflowAnchor,
207
+ resolveThreadFeedReflowOffset,
208
resolveThreadFeedReflowScroll,
209
type ThreadFeedLiveFollowEvent,
210
type ThreadFeedReflowAnchor,
@@ -293,6 +294,9 @@ const FEED_PADDING_TOP = 12;
294
// scrolls for 100ms after it compensates a size change, and a deferred restore could land
295
// under a drag that starts meanwhile.
296
const FEED_REFLOW_SETTLE_MS = 200;
297
+// A fold resizes the feed in steps about 200ms apart. Holding the place taken at the first step
298
+// across all of them keeps a passing moment off the end from re-anchoring the rest to a row.
299
+const FEED_REFLOW_HOLD_MS = 600;
300
const USER_BUBBLE_HORIZONTAL_PADDING = 3.5 * 3.5;
301
const ASSISTANT_ROW_HORIZONTAL_PADDING = 3.5;
302
const THREAD_FEED_DISCLOSURE_ENTER_TRANSITION = FadeIn.delay(
@@ -1984,8 +1988,11 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
1988
// A width change re-wraps every row at once, and LegendList re-measures them over the next
1989
// commits. Its end threshold and MVCP only see the new geometry, so the reader's place is
1990
// taken before any row lands: the end while following, otherwise the row under the header.
1991
+ // On iOS, LegendList keeps that place in the same commit as every re-measure. Android's
1992
+ // list moves only while its MVCP is on, which following turns off, so it restores after.
1993
// undefined: no reflow. null: a reflow with nothing to restore.
1994
const reflowAnchorRef = useRef<ThreadFeedReflowAnchor | null | undefined>(undefined);
1995
+ const reflowAnchorsSizeChanges = Platform.OS === "ios";
1996
const [reflowFollowsEnd, setReflowFollowsEnd] = useState(false);
1997
const [reflowSettleRevision, setReflowSettleRevision] = useState(0);
1998
const listHeaderSizeRef = useRef(0);
@@ -2482,20 +2489,19 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
2489
2490
const feedThreadKey = scopedThreadKey(props.environmentId, props.threadId);
2491
const workGroupScrollPositions = new Map<string, ThreadWorkGroupScrollPosition>();
2485
- useEffect(() => {
2492
+ // Only a new thread or a send resets following. Listed as dependencies, these handlers also ran
2493
+ // whenever a parent passed a new follow callback, as a fold does: following re-armed under a
2494
+ // reader and a width reflow lost its place mid-fold.
2495
+ const resetEndFollow = useEffectEvent((_trigger: unknown) => {
2496
clearUserScrollSettle();
2497
userScrollSessionRef.current = false;
2498
cancelReflow();
2499
transitionEndFollow({ type: "reset" });
2490
- }, [cancelReflow, clearUserScrollSettle, feedThreadKey, transitionEndFollow]);
2500
+ });
2501
+ useEffect(() => resetEndFollow(feedThreadKey), [feedThreadKey]);
2502
useEffect(() => {
2492
- if (props.submittedMessageId !== null) {
2493
- clearUserScrollSettle();
2494
- userScrollSessionRef.current = false;
2495
- cancelReflow();
2496
- transitionEndFollow({ type: "reset" });
2497
- }
2498
- }, [cancelReflow, clearUserScrollSettle, props.submittedMessageId, transitionEndFollow]);
2503
+ if (props.submittedMessageId !== null) resetEndFollow(props.submittedMessageId);
2504
+ }, [props.submittedMessageId]);
2505
2506
useEffect(() => {
2507
reportHeaderMaterialVisibility(false);
@@ -2531,7 +2537,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
2537
? resolveThreadFeedReflowAnchor(listState, reflowLayout(), endFollowEnabledRef.current)
2538
: null;
2539
reflowAnchorRef.current = anchor;
2534
- if (anchor === "end") {
2540
+ if (anchor === "end" && !reflowAnchorsSizeChanges) {
2541
// The list may already have judged the first new sizes against its own threshold, so
2542
// pin the end once; the lifted threshold keeps it there as later rows re-measure.
2543
setReflowFollowsEnd(true);
@@ -2544,17 +2550,30 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
2550
const anchor = reflowAnchorRef.current;
2551
cancelReflow();
2552
const list = listRef.current;
2547
- if (!anchor || anchor === "end" || !list || userScrollSessionRef.current) return;
2553
+ if (reflowAnchorsSizeChanges || !anchor || anchor === "end" || !list) return;
2554
+ if (userScrollSessionRef.current) return;
2555
if (loadedListKeyRef.current !== listMountKey) return;
2556
const target = resolveThreadFeedReflowScroll(anchor, list.getState(), reflowLayout());
2557
if (target) void list.scrollToIndex({ ...target, viewPosition: 0, animated: false });
2558
});
2559
useEffect(() => {
2560
if (reflowSettleRevision === 0) return;
2554
- const timeout = setTimeout(() => settleReflow(), FEED_REFLOW_SETTLE_MS);
2561
+ const timeout = setTimeout(
2562
+ () => settleReflow(),
2563
+ reflowAnchorsSizeChanges ? FEED_REFLOW_HOLD_MS : FEED_REFLOW_SETTLE_MS,
2564
+ );
2565
return () => clearTimeout(timeout);
2566
}, [reflowSettleRevision]);
2567
2568
+ const holdReflowAnchor = () => {
2569
+ const anchor = reflowAnchorRef.current;
2570
+ if (anchor === "end") return Number.POSITIVE_INFINITY;
2571
+ const list = listRef.current;
2572
+ return anchor && list
2573
+ ? resolveThreadFeedReflowOffset(anchor, list.getState(), reflowLayout())
2574
+ : undefined;
2575
+ };
2576
+
2577
const handleViewportLayout = (event: LayoutChangeEvent) => {
2578
const nextWidth = Math.round(event.nativeEvent.layout.width);
2579
const nextHeight = Math.round(event.nativeEvent.layout.height);
@@ -2946,6 +2965,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
2965
// A reflow grows every visible row at once, well past the near-end threshold
2966
// that otherwise lets a status-bar tap leave the end.
2967
maintainScrollAtEndThreshold={reflowFollowsEnd ? Number.POSITIVE_INFINITY : undefined}
2968
+ sizeChangeAnchor={reflowAnchorsSizeChanges ? holdReflowAnchor : undefined}
2969
maintainVisibleContentPosition={
2970
endFollowEnabled && !disclosureToggleSettling ? false : maintainVisibleContentPosition
2971
}
apps/mobile/src/features/threads/thread-feed-live-follow.test.ts
+28
@@ -3,6 +3,7 @@ import { describe, expect, it } from "vite-plus/test";
3
import {
4
resolveThreadFeedLiveFollow,
5
resolveThreadFeedReflowAnchor,
6
+ resolveThreadFeedReflowOffset,
7
resolveThreadFeedReflowScroll,
8
resolveThreadFeedSubmissionAnchor,
9
resolveThreadWorkGroupInitialScroll,
@@ -243,6 +244,33 @@ describe("width reflow anchors", () => {
244
});
245
});
246
247
+ it.each([
248
+ { change: "narrows", replySize: 4_000 },
249
+ { change: "widens", replySize: 1_000 },
250
+ ])(
251
+ "holds the reader 60% into a reply on each re-measure as the feed $change",
252
+ ({ replySize }) => {
253
+ const anchor = resolveThreadFeedReflowAnchor(readingReply, layout, false);
254
+ if (anchor === null || anchor === "end") throw new Error("expected a row anchor");
255
+ const rows = [
256
+ { id: "question", size: 400 * (replySize / 2_000) },
257
+ { id: "reply", size: replySize },
258
+ { id: "follow-up", size: 300 },
259
+ ];
260
+ const offset = resolveThreadFeedReflowOffset(
261
+ anchor,
262
+ feedState(rows, readingReply.scroll),
263
+ layout,
264
+ );
265
+ if (offset === undefined) throw new Error("expected an offset");
266
+ expect(resolveThreadFeedReflowAnchor(feedState(rows, offset), layout, false)).toEqual({
267
+ key: "reply",
268
+ offsetWithinRow: 0.6 * replySize,
269
+ size: replySize,
270
+ });
271
+ },
272
+ );
273
+
274
it("leaves a reader at the top of the thread where they are", () => {
275
expect(resolveThreadFeedReflowAnchor(feedState(wide, -layout.headerInset), layout, false)).toBe(
276
null,
apps/mobile/src/features/threads/thread-feed-live-follow.ts
+26
-6
@@ -141,18 +141,38 @@ export function resolveThreadFeedReflowAnchor(
141
return row && size ? { key: row.rowId, offsetWithinRow: row.offsetWithinRow, size } : null;
142
}
143
144
-export function resolveThreadFeedReflowScroll(
144
+function resolveReflowAnchorPoint(
145
anchor: ThreadFeedReflowRowAnchor,
146
state: ThreadFeedReflowListState,
147
- layout: ThreadFeedReflowLayout,
148
-): { readonly index: number; readonly viewOffset: number } | null {
147
+) {
148
const index = state.indexByKey(anchor.key);
149
const top = index === undefined ? undefined : state.positionAtIndex(index);
150
const size = state.sizes.get(anchor.key);
151
if (index === undefined || top === undefined || size === undefined) return null;
152
// Rewrapped text grows with its row, so the reader's line sits at the same share of the
153
// row rather than the same pixel offset into it.
155
- const offsetWithinRow = (anchor.offsetWithinRow * size) / anchor.size;
156
- if (Math.abs(readingLine(state, layout) - (top + offsetWithinRow)) < 1) return null;
157
- return { index, viewOffset: layout.headerInset - offsetWithinRow };
154
+ return { index, top, offsetWithinRow: (anchor.offsetWithinRow * size) / anchor.size };
155
+}
156
+
157
+/** The scroll offset that puts the reader's line back under the header at the current sizes. */
158
+export function resolveThreadFeedReflowOffset(
159
+ anchor: ThreadFeedReflowRowAnchor,
160
+ state: ThreadFeedReflowListState,
161
+ layout: ThreadFeedReflowLayout,
162
+): number | undefined {
163
+ const point = resolveReflowAnchorPoint(anchor, state);
164
+ return point
165
+ ? point.top + point.offsetWithinRow - layout.headerInset + layout.rowsTop
166
+ : undefined;
167
+}
168
+
169
+export function resolveThreadFeedReflowScroll(
170
+ anchor: ThreadFeedReflowRowAnchor,
171
+ state: ThreadFeedReflowListState,
172
+ layout: ThreadFeedReflowLayout,
173
+): { readonly index: number; readonly viewOffset: number } | null {
174
+ const point = resolveReflowAnchorPoint(anchor, state);
175
+ if (!point) return null;
176
+ if (Math.abs(readingLine(state, layout) - (point.top + point.offsetWithinRow)) < 1) return null;
177
+ return { index: point.index, viewOffset: layout.headerInset - point.offsetWithinRow };
178
}
patches/@legendapp__list@3.3.5.patch
+257
-73
@@ -1,5 +1,21 @@
1
+diff --git a/animated.d.ts b/animated.d.ts
2
+index 14beb98c0bfed9c60611b7d164670798011182ac..9fb0ca056d9dda4d4abeef2bb9bafcf70d0fa243 100644
3
+--- a/animated.d.ts
4
++++ b/animated.d.ts
5
+@@ -284,6 +284,11 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
6
+ * - true enables both behaviors; false disables both.
7
+ */
8
+ maintainVisibleContentPosition?: boolean | MaintainVisibleContentPositionConfig<ItemT>;
9
++ /**
10
++ * T3 patch: the scroll offset a change in item or list size should leave, read in the same pass
11
++ * that repositions the items so the adjustment commits with them. `undefined` keeps the default.
12
++ */
13
++ sizeChangeAnchor?: () => number | undefined;
14
+ /**
15
+ * Keeps an item visually anchored to the start by adding trailing space when the content below it underflows.
16
+ */
17
diff --git a/keyboard.d.ts b/keyboard.d.ts
2
-index 367945c..0ac7bf8 100644
18
+index 367945cdfa8a8c260b7a127657a75c016c9ab46f..0ac7bf8b8e9c386058b2374199e58fe8c92d39b3 100644
19
--- a/keyboard.d.ts
20
+++ b/keyboard.d.ts
21
@@ -279,7 +279,7 @@ type KeyboardChatComposerInsetListRef = {
@@ -23,7 +39,7 @@ index 367945c..0ac7bf8 100644
39
} & React.RefAttributes<LegendListRef>) => React.ReactElement | null;
40
41
diff --git a/keyboard.js b/keyboard.js
26
-index 6645bcb..321c4c3 100644
42
+index 6645bcbb1f77c36c432035eaf8b2d6d924fc8bda..321c4c305129dd3ce3f06127c47d51720a73fb83 100644
43
--- a/keyboard.js
44
+++ b/keyboard.js
45
@@ -33,19 +33,22 @@ if (typeof __DEV__ !== "undefined" && __DEV__ && !reactNativeKeyboardController.
@@ -119,7 +135,7 @@ index 6645bcb..321c4c3 100644
135
renderScrollComponent: memoList,
136
...rest
137
diff --git a/keyboard.mjs b/keyboard.mjs
122
-index 87b38b9..111eb24 100644
138
+index 87b38b9607c2eba6b407c2acfd520633bdb0e7c2..111eb242ba9d9ade1cb912550f7df85cf4f361ee 100644
139
--- a/keyboard.mjs
140
+++ b/keyboard.mjs
141
@@ -1,7 +1,7 @@
@@ -224,10 +240,22 @@ index 87b38b9..111eb24 100644
240
renderScrollComponent: memoList,
241
...rest
242
diff --git a/react-native.d.ts b/react-native.d.ts
227
-index ce1fe00..3ccf6f1 100644
243
+index ce1fe00001c9e5aee6c6ea8bb2d4757d4586d002..ca6e596aa53327a097a388ffd545a4c6191f24e6 100644
244
--- a/react-native.d.ts
245
+++ b/react-native.d.ts
230
-@@ -293,6 +293,12 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
246
+@@ -284,6 +284,11 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
247
+ * - true enables both behaviors; false disables both.
248
+ */
249
+ maintainVisibleContentPosition?: boolean | MaintainVisibleContentPositionConfig<ItemT>;
250
++ /**
251
++ * T3 patch: the scroll offset a change in item or list size should leave, read in the same pass
252
++ * that repositions the items so the adjustment commits with them. `undefined` keeps the default.
253
++ */
254
++ sizeChangeAnchor?: () => number | undefined;
255
+ /**
256
+ * Keeps an item visually anchored to the start by adding trailing space when the content below it underflows.
257
+ */
258
+@@ -293,6 +298,12 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
259
* The adjustment is also rendered as real content padding so the browser scroll range includes it.
260
*/
261
contentInsetEndAdjustment?: number;
@@ -241,7 +269,7 @@ index ce1fe00..3ccf6f1 100644
269
* Number of columns to render items in.
270
* @default 1
271
diff --git a/react-native.js b/react-native.js
244
-index b3c5a30..5ac6bbe 100644
272
+index b3c5a306b293f797a8b338adfca3060c0f6db22b..3c67a536d850d8c508336cf0f10c0c898ea67f12 100644
273
--- a/react-native.js
274
+++ b/react-native.js
275
@@ -717,6 +717,15 @@ function hasActiveInitialScroll(state) {
@@ -358,7 +386,7 @@ index b3c5a30..5ac6bbe 100644
386
scheduleFallbackCheck(100);
387
} else if (shouldFinishZeroTarget || shouldFinishAfterObservedScroll || canFinishInitialScrollWithoutNativeProgress || canFinishAfterSilentNativeDispatch || numChecks > maxChecks) {
388
finishScrollTo(ctx);
361
-@@ -1560,15 +1590,28 @@ function doMaintainScrollAtEnd(ctx) {
389
+@@ -1560,15 +1590,33 @@ function doMaintainScrollAtEnd(ctx) {
390
} = state;
391
const isWithinMaintainScrollAtEndThreshold = peek$(ctx, "isWithinMaintainScrollAtEndThreshold");
392
const shouldMaintainScrollAtEnd = !!(isWithinMaintainScrollAtEndThreshold && maintainScrollAtEnd && didContainersLayout);
@@ -370,6 +398,11 @@ index b3c5a30..5ac6bbe 100644
398
state.pendingMaintainScrollAtEnd = shouldMaintainScrollAtEnd;
399
return false;
400
}
401
++ // T3 patch: a caller anchor already placed this pass's offset; a later scroll would move it.
402
++ if (state.props.sizeChangeAnchor && !state.mvcpDataChanged && state.props.sizeChangeAnchor() !== void 0) {
403
++ state.pendingMaintainScrollAtEnd = false;
404
++ return shouldMaintainScrollAtEnd;
405
++ }
406
if (shouldMaintainScrollAtEnd) {
407
state.pendingMaintainScrollAtEnd = false;
408
+ const maintainAnchoredEndSpace = state.props.anchoredEndSpace;
@@ -388,7 +421,7 @@ index b3c5a30..5ac6bbe 100644
421
}
422
if (!state.maintainingScrollAtEnd) {
423
const pendingState = maintainScrollAtEnd.animated ? "pending-animated" : "pending-instant";
391
-@@ -1591,9 +1634,18 @@ function doMaintainScrollAtEnd(ctx) {
424
+@@ -1591,9 +1639,18 @@ function doMaintainScrollAtEnd(ctx) {
425
y: 0
426
});
427
} else {
@@ -410,7 +443,7 @@ index b3c5a30..5ac6bbe 100644
443
}
444
setTimeout(
445
() => {
413
-@@ -1624,6 +1676,10 @@ function doMaintainScrollAtEnd(ctx) {
446
+@@ -1624,6 +1681,10 @@ function doMaintainScrollAtEnd(ctx) {
447
function requestAdjust(ctx, positionDiff, dataChanged) {
448
const state = ctx.state;
449
if (Math.abs(positionDiff) > 0.1) {
@@ -421,7 +454,7 @@ index b3c5a30..5ac6bbe 100644
454
const needsScrollWorkaround = Platform.OS === "android" && !IsNewArchitecture && dataChanged && state.scroll <= positionDiff;
455
const doit = () => {
456
if (needsScrollWorkaround) {
424
-@@ -1728,7 +1784,9 @@ function getPredictedNativeClamp(state, unresolvedAmount, totalSize) {
457
+@@ -1728,7 +1789,9 @@ function getPredictedNativeClamp(state, unresolvedAmount, totalSize) {
458
if (Math.abs(unresolvedAmount) <= MVCP_POSITION_EPSILON) {
459
return 0;
460
}
@@ -432,7 +465,7 @@ index b3c5a30..5ac6bbe 100644
465
const clampDelta = maxScroll - state.scroll;
466
if (unresolvedAmount < 0) {
467
return Math.max(unresolvedAmount, Math.min(0, clampDelta));
435
-@@ -1790,7 +1848,7 @@ function resolvePendingNativeMVCPAdjust(ctx, newScroll) {
468
+@@ -1790,7 +1853,7 @@ function resolvePendingNativeMVCPAdjust(ctx, newScroll) {
469
settlePendingNativeMVCPAdjust(ctx, remainingAfterManual, nativeDelta);
470
return true;
471
}
@@ -441,7 +474,43 @@ index b3c5a30..5ac6bbe 100644
474
const distanceToClamp = Math.abs(newScroll - expectedNativeClampScroll);
475
const isAtExpectedNativeClamp = distanceToClamp <= NATIVE_END_CLAMP_EPSILON;
476
if (isAtExpectedNativeClamp) {
444
-@@ -1923,7 +1981,7 @@ function prepareMVCP(ctx, dataChanged) {
477
+@@ -1811,7 +1874,35 @@ function resolvePendingNativeMVCPAdjust(ctx, newScroll) {
478
+ }
479
+ return false;
480
+ }
481
++// T3 patch: a caller anchor decides where a size change leaves the scroll position. It is read in
482
++// the same pass that repositions the items, so the adjustment commits with the new positions.
483
+ function prepareMVCP(ctx, dataChanged) {
484
++ // T3 patch: a data change skips the caller anchor, so end maintenance must still run after it.
485
++ ctx.state.mvcpDataChanged = !!dataChanged;
486
++ const sizeChangeAnchor = dataChanged ? void 0 : ctx.state.props.sizeChangeAnchor;
487
++ const restore = prepareDefaultMVCP(ctx, dataChanged);
488
++ if (!sizeChangeAnchor || ctx.state.scrollingTo !== void 0) {
489
++ return restore;
490
++ }
491
++ return () => {
492
++ const target = sizeChangeAnchor();
493
++ if (target === void 0) {
494
++ restore == null ? void 0 : restore();
495
++ return;
496
++ }
497
++ // Content that shrinks under an offset past its new end pulls the native offset back to
498
++ // that end by itself; only the rest of the way to the target is adjusted.
499
++ const endOffset = clampScrollOffset(ctx, Number.POSITIVE_INFINITY);
500
++ if (ctx.state.scroll > endOffset) {
501
++ ctx.state.scroll = endOffset;
502
++ }
503
++ const positionDiff = clampScrollOffset(ctx, target) - ctx.state.scroll;
504
++ if (Math.abs(positionDiff) > MVCP_POSITION_EPSILON) {
505
++ requestAdjust(ctx, positionDiff, false);
506
++ }
507
++ };
508
++}
509
++function prepareDefaultMVCP(ctx, dataChanged) {
510
+ const state = ctx.state;
511
+ const { idsInView, positions, props } = state;
512
+ const {
513
+@@ -1923,7 +2014,7 @@ function prepareMVCP(ctx, dataChanged) {
514
if (diff > 0) {
515
diff = Math.max(0, totalSize - state.scroll - state.scrollLength);
516
} else {
@@ -450,7 +519,7 @@ index b3c5a30..5ac6bbe 100644
519
state.scroll = maxScroll;
520
state.scrollPending = maxScroll;
521
diff = 0;
453
-@@ -2320,8 +2378,121 @@ function scrollToIndex(ctx, {
522
+@@ -2320,8 +2411,121 @@ function scrollToIndex(ctx, {
523
}
524
525
// src/core/initialScroll.ts
@@ -572,7 +641,7 @@ index b3c5a30..5ac6bbe 100644
641
const requestedIndex = target.index;
642
const index = requestedIndex !== void 0 ? clampScrollIndex(requestedIndex, ctx.state.props.data.length) : void 0;
643
const itemSize = getItemSizeAtIndex(ctx, index);
575
-@@ -2747,7 +2918,9 @@ function clearFinishedBootstrapInitialScrollTargetIfMovedAway(ctx) {
644
+@@ -2747,7 +2951,9 @@ function clearFinishedBootstrapInitialScrollTargetIfMovedAway(ctx) {
645
return;
646
}
647
if (didFinishedInitialScrollMoveAwayFromTarget(ctx, initialScroll)) {
@@ -583,7 +652,7 @@ index b3c5a30..5ac6bbe 100644
652
if (!shouldKeepEndTargetAlive) {
653
if (shouldPreserveInitialScrollForFooterLayout(initialScroll)) {
654
clearPendingInitialScrollFooterLayout(ctx, {
586
-@@ -4672,7 +4845,8 @@ function maybeUpdateAnchoredEndSpace(ctx) {
655
+@@ -4672,7 +4878,8 @@ function maybeUpdateAnchoredEndSpace(ctx) {
656
contentBelowAnchor = Math.max(0, contentBelowAnchor - ctx.scrollAxisGap);
657
contentBelowAnchor += (ctx.values.get("footerSize") || 0) + getStylePaddingEnd(state.props);
658
isReady = !hasUnknownTailSize;
@@ -593,7 +662,7 @@ index b3c5a30..5ac6bbe 100644
662
} else if (anchorIndex >= 0) {
663
isReady = false;
664
}
596
-@@ -4692,6 +4866,12 @@ function maybeUpdateAnchoredEndSpace(ctx) {
665
+@@ -4692,6 +4899,12 @@ function maybeUpdateAnchoredEndSpace(ctx) {
666
updateScroll(ctx, state.scroll, true, { markHasScrolled: false });
667
}
668
(_b = anchoredEndSpace == null ? void 0 : anchoredEndSpace.onReady) == null ? void 0 : _b.call(anchoredEndSpace, { anchorIndex: nextAnchorIndex, anchorKey: nextAnchorKey, size: nextSize });
@@ -606,15 +675,20 @@ index b3c5a30..5ac6bbe 100644
675
}
676
return nextSize;
677
}
609
-@@ -5715,6 +5895,7 @@ var ContainersLayer = typedMemo(function ContainersLayer2({
678
+@@ -5715,8 +5928,11 @@ var ContainersLayer = typedMemo(function ContainersLayer2({
679
horizontal
680
}) {
681
const ctx = useStateContext();
682
+ const SizeComponent = ctx.state.props.sizeComponentInternal;
683
const columnWrapperStyle = ctx.columnWrapperStyle;
615
- const animSize = useValue$("totalSize");
684
+- const animSize = useValue$("totalSize");
685
++ // T3 patch: on the new architecture an animated value commits on its own, ahead of the item
686
++ // positions and their scroll compensation; a rendered size commits with them.
687
++ const animSize = IsNewArchitecture ? useArr$(["totalSize"])[0] || 0 : useValue$("totalSize");
688
const [readyToRender, numColumns, otherAxisSize = 0] = useArr$(["readyToRender", "numColumns", "otherAxisSize"]);
617
-@@ -5725,6 +5906,13 @@ var ContainersLayer = typedMemo(function ContainersLayer2({
689
+ const isVisible = useFreshDataTransitionVisibility(!!readyToRender, freshDataTransitionEpoch);
690
+ const style = horizontal ? {
691
+@@ -5725,6 +5941,13 @@ var ContainersLayer = typedMemo(function ContainersLayer2({
692
opacity: isVisible ? 1 : 0,
693
width: animSize
694
} : { height: animSize, minWidth: otherAxisSize, opacity: isVisible ? 1 : 0 };
@@ -628,7 +702,7 @@ index b3c5a30..5ac6bbe 100644
702
if (columnWrapperStyle) {
703
const { columnGap, rowGap, gap } = columnWrapperStyle;
704
const gapX = columnGap || gap || 0;
631
-@@ -5745,7 +5933,8 @@ var ContainersLayer = typedMemo(function ContainersLayer2({
705
+@@ -5745,7 +5968,8 @@ var ContainersLayer = typedMemo(function ContainersLayer2({
706
}
707
}
708
}
@@ -638,7 +712,7 @@ index b3c5a30..5ac6bbe 100644
712
});
713
var Containers = typedMemo(function Containers2({
714
freshDataTransitionEpoch,
641
-@@ -5896,7 +6085,12 @@ var StyleSheet = ReactNative.StyleSheet;
715
+@@ -5896,7 +6120,12 @@ var StyleSheet = ReactNative.StyleSheet;
716
717
// src/components/ListComponent.tsx
718
var AlignItemsAtEndSpacer = typedMemo(function AlignItemsAtEndSpacer2({ horizontal }) {
@@ -651,7 +725,7 @@ index b3c5a30..5ac6bbe 100644
725
if (alignItemsAtEndPadding <= 0) {
726
return null;
727
}
654
-@@ -5929,8 +6123,12 @@ var ListComponent = typedMemo(function ListComponent2({
728
+@@ -5929,8 +6158,12 @@ var ListComponent = typedMemo(function ListComponent2({
729
refScrollView,
730
renderScrollComponent,
731
onLayoutFooter,
@@ -664,7 +738,7 @@ index b3c5a30..5ac6bbe 100644
738
scrollAdjustHandler,
739
snapToIndices,
740
stickyHeaderConfig,
667
-@@ -6001,7 +6199,17 @@ var ListComponent = typedMemo(function ListComponent2({
741
+@@ -6001,7 +6234,17 @@ var ListComponent = typedMemo(function ListComponent2({
742
SnapOrScroll,
743
{
744
...rest,
@@ -683,7 +757,7 @@ index b3c5a30..5ac6bbe 100644
757
contentContainerStyle: [
758
horizontal ? { height: "100%" } : {},
759
contentContainerStyle,
686
-@@ -6010,7 +6218,10 @@ var ListComponent = typedMemo(function ListComponent2({
760
+@@ -6010,7 +6253,10 @@ var ListComponent = typedMemo(function ListComponent2({
761
],
762
contentOffset: initialContentOffset !== void 0 ? horizontal ? { x: initialContentOffset, y: 0 } : { x: 0, y: initialContentOffset } : void 0,
763
horizontal,
@@ -695,7 +769,17 @@ index b3c5a30..5ac6bbe 100644
769
onLayout,
770
onScroll: onScroll2,
771
ref: refScrollView,
698
-@@ -6751,7 +6962,7 @@ function createImperativeHandle(ctx, scheduleImperativeScrollCommit) {
772
+@@ -6267,7 +6513,8 @@ function handleLayout(ctx, layoutParam, setCanRender) {
773
+ if (scrollLength > 0) {
774
+ doInitialAllocateContainers(ctx);
775
+ }
776
+- if (needsCalculate) {
777
++ // T3 patch: a shorter list keeps a caller anchor too, such as the end.
778
++ if (needsCalculate || state.props.sizeChangeAnchor) {
779
+ calculateItemsInView(ctx, { doMVCP: true });
780
+ }
781
+ if (didChange || otherAxisSize !== prevOtherAxisSize) {
782
+@@ -6751,7 +6998,7 @@ function createImperativeHandle(ctx, scheduleImperativeScrollCommit) {
783
endBuffered: state.endBuffered,
784
getAverageItemSizes: () => getAverageItemSizes(state),
785
indexByKey: (key) => state.indexByKey.get(key),
@@ -704,7 +788,7 @@ index b3c5a30..5ac6bbe 100644
788
isAtStart: peek$(ctx, "isAtStart"),
789
isEndReached: state.isEndReached,
790
isNearEnd: peek$(ctx, "isNearEnd"),
707
-@@ -7075,6 +7286,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
791
+@@ -7075,6 +7322,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
792
dataVersion,
793
drawDistance = 250,
794
contentInsetEndAdjustment,
@@ -712,7 +796,15 @@ index b3c5a30..5ac6bbe 100644
796
estimatedItemSize = 100,
797
estimatedListSize,
798
extraData,
715
-@@ -7132,10 +7344,12 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
799
+@@ -7096,6 +7344,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
800
+ maintainScrollAtEnd = false,
801
+ maintainScrollAtEndThreshold = 0.1,
802
+ maintainVisibleContentPosition: maintainVisibleContentPositionProp,
803
++ sizeChangeAnchor,
804
+ numColumns: numColumnsProp = 1,
805
+ overrideItemLayout,
806
+ onEndReached,
807
+@@ -7132,10 +7381,12 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
808
const animatedPropsInternal = props.animatedPropsInternal;
809
const anchoredEndSpaceOwner = (_a3 = props.anchoredEndSpaceOwnerInternal) != null ? _a3 : "list";
810
const positionComponentInternal = props.positionComponentInternal;
@@ -725,7 +817,7 @@ index b3c5a30..5ac6bbe 100644
817
stickyPositionComponentInternal: _stickyPositionComponentInternal,
818
...restProps
819
} = rest;
728
-@@ -7200,7 +7414,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
820
+@@ -7200,7 +7451,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
821
const combinedRef = useCombinedRef(refScroller, refScrollView);
822
const keyExtractor = keyExtractorProp != null ? keyExtractorProp : ((_item, index) => index.toString());
823
const stickyHeaderIndices = stickyHeaderIndicesProp;
@@ -734,7 +826,7 @@ index b3c5a30..5ac6bbe 100644
826
const previousContentInsetEndAdjustmentRef = React2.useRef(contentInsetEndAdjustmentResolved);
827
const alwaysRenderIndices = React2.useMemo(() => {
828
const indices = getAlwaysRenderIndices(alwaysRender, dataProp, keyExtractor, anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorIndex);
737
-@@ -7341,6 +7555,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
829
+@@ -7341,6 +7592,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
830
contentContainerAlignItems: contentContainerStyle.alignItems,
831
contentInset,
832
contentInsetEndAdjustment: contentInsetEndAdjustmentResolved,
@@ -742,7 +834,15 @@ index b3c5a30..5ac6bbe 100644
834
data: dataProp,
835
dataKey,
836
dataVersion,
745
-@@ -7372,6 +7587,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
837
+@@ -7354,6 +7606,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
838
+ maintainScrollAtEnd: maintainScrollAtEndConfig,
839
+ maintainScrollAtEndThreshold,
840
+ maintainVisibleContentPosition: maintainVisibleContentPositionConfig,
841
++ sizeChangeAnchor,
842
+ numColumns: numColumnsProp,
843
+ onEndReached,
844
+ onEndReachedThreshold,
845
+@@ -7372,6 +7625,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
846
renderItem,
847
rtl,
848
snapToIndices,
@@ -750,7 +850,7 @@ index b3c5a30..5ac6bbe 100644
850
stickyHeaderIndicesArr: stickyHeaderIndices != null ? stickyHeaderIndices : [],
851
stickyHeaderIndicesSet: React2.useMemo(() => new Set(stickyHeaderIndices != null ? stickyHeaderIndices : []), [stickyHeaderIndices == null ? void 0 : stickyHeaderIndices.join(",")]),
852
stickyPositionComponentInternal,
753
-@@ -7423,6 +7639,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
853
+@@ -7423,6 +7677,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
854
return void 0;
855
}
856
const resolvedOffset = (_a4 = initialScroll.contentOffset) != null ? _a4 : resolveInitialScrollOffset(ctx, initialScroll);
@@ -764,7 +864,7 @@ index b3c5a30..5ac6bbe 100644
864
return usesBootstrapInitialScroll && ((_b2 = state.initialScrollSession) == null ? void 0 : _b2.kind) === "bootstrap" && Platform.OS === "web" ? void 0 : resolvedOffset;
865
}, [usesBootstrapInitialScroll]);
866
React2.useLayoutEffect(() => {
767
-@@ -7547,6 +7770,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
867
+@@ -7547,6 +7808,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
868
[
869
dataKey,
870
dataVersion,
@@ -772,7 +872,7 @@ index b3c5a30..5ac6bbe 100644
872
memoizedLastItemKeys.join(","),
873
numColumnsProp,
874
nextScrollAxisGap,
775
-@@ -7643,6 +7867,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
875
+@@ -7643,6 +7905,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
876
() => ({
877
getRenderedItem: (key) => getRenderedItem(ctx, key),
878
onMomentumScrollEnd: (event) => {
@@ -780,7 +880,7 @@ index b3c5a30..5ac6bbe 100644
880
checkFinishedScrollFallback(ctx);
881
if (state.props.onMomentumScrollEnd) {
882
state.props.onMomentumScrollEnd(event);
783
-@@ -7651,6 +7876,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
883
+@@ -7651,6 +7914,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
884
onScroll: (event) => onScroll(ctx, event),
885
onScrollBeginDrag: (event) => {
886
var _a4, _b2;
@@ -789,7 +889,7 @@ index b3c5a30..5ac6bbe 100644
889
prepareReachedEdgeForNextUserScroll(ctx);
890
(_b2 = (_a4 = state.props).onScrollBeginDrag) == null ? void 0 : _b2.call(_a4, event);
891
},
792
-@@ -7676,11 +7903,18 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
892
+@@ -7676,11 +7941,18 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
893
ListFooterComponent,
894
ListFooterComponentStyle,
895
ListHeaderComponent,
@@ -809,7 +909,7 @@ index b3c5a30..5ac6bbe 100644
909
recycleItems,
910
refreshControl: refreshControlElement ? stylePaddingTopState > 0 ? React2__namespace.cloneElement(refreshControlElement, {
911
diff --git a/react-native.mjs b/react-native.mjs
812
-index 40e87cd..93aac74 100644
912
+index 40e87cda8c9bc79a889e5542f29af429a24b24d4..c1b68df0f53d566c98a4820b39079396a09f1208 100644
913
--- a/react-native.mjs
914
+++ b/react-native.mjs
915
@@ -696,6 +696,15 @@ function hasActiveInitialScroll(state) {
@@ -926,7 +1026,7 @@ index 40e87cd..93aac74 100644
1026
scheduleFallbackCheck(100);
1027
} else if (shouldFinishZeroTarget || shouldFinishAfterObservedScroll || canFinishInitialScrollWithoutNativeProgress || canFinishAfterSilentNativeDispatch || numChecks > maxChecks) {
1028
finishScrollTo(ctx);
929
-@@ -1539,15 +1569,28 @@ function doMaintainScrollAtEnd(ctx) {
1029
+@@ -1539,15 +1569,33 @@ function doMaintainScrollAtEnd(ctx) {
1030
} = state;
1031
const isWithinMaintainScrollAtEndThreshold = peek$(ctx, "isWithinMaintainScrollAtEndThreshold");
1032
const shouldMaintainScrollAtEnd = !!(isWithinMaintainScrollAtEndThreshold && maintainScrollAtEnd && didContainersLayout);
@@ -938,6 +1038,11 @@ index 40e87cd..93aac74 100644
1038
state.pendingMaintainScrollAtEnd = shouldMaintainScrollAtEnd;
1039
return false;
1040
}
1041
++ // T3 patch: a caller anchor already placed this pass's offset; a later scroll would move it.
1042
++ if (state.props.sizeChangeAnchor && !state.mvcpDataChanged && state.props.sizeChangeAnchor() !== void 0) {
1043
++ state.pendingMaintainScrollAtEnd = false;
1044
++ return shouldMaintainScrollAtEnd;
1045
++ }
1046
if (shouldMaintainScrollAtEnd) {
1047
state.pendingMaintainScrollAtEnd = false;
1048
+ const maintainAnchoredEndSpace = state.props.anchoredEndSpace;
@@ -956,7 +1061,7 @@ index 40e87cd..93aac74 100644
1061
}
1062
if (!state.maintainingScrollAtEnd) {
1063
const pendingState = maintainScrollAtEnd.animated ? "pending-animated" : "pending-instant";
959
-@@ -1570,9 +1613,18 @@ function doMaintainScrollAtEnd(ctx) {
1064
+@@ -1570,9 +1618,18 @@ function doMaintainScrollAtEnd(ctx) {
1065
y: 0
1066
});
1067
} else {
@@ -978,7 +1083,7 @@ index 40e87cd..93aac74 100644
1083
}
1084
setTimeout(
1085
() => {
981
-@@ -1603,6 +1655,10 @@ function doMaintainScrollAtEnd(ctx) {
1086
+@@ -1603,6 +1660,10 @@ function doMaintainScrollAtEnd(ctx) {
1087
function requestAdjust(ctx, positionDiff, dataChanged) {
1088
const state = ctx.state;
1089
if (Math.abs(positionDiff) > 0.1) {
@@ -989,7 +1094,7 @@ index 40e87cd..93aac74 100644
1094
const needsScrollWorkaround = Platform.OS === "android" && !IsNewArchitecture && dataChanged && state.scroll <= positionDiff;
1095
const doit = () => {
1096
if (needsScrollWorkaround) {
992
-@@ -1707,7 +1763,9 @@ function getPredictedNativeClamp(state, unresolvedAmount, totalSize) {
1097
+@@ -1707,7 +1768,9 @@ function getPredictedNativeClamp(state, unresolvedAmount, totalSize) {
1098
if (Math.abs(unresolvedAmount) <= MVCP_POSITION_EPSILON) {
1099
return 0;
1100
}
@@ -1000,7 +1105,7 @@ index 40e87cd..93aac74 100644
1105
const clampDelta = maxScroll - state.scroll;
1106
if (unresolvedAmount < 0) {
1107
return Math.max(unresolvedAmount, Math.min(0, clampDelta));
1003
-@@ -1769,7 +1827,7 @@ function resolvePendingNativeMVCPAdjust(ctx, newScroll) {
1108
+@@ -1769,7 +1832,7 @@ function resolvePendingNativeMVCPAdjust(ctx, newScroll) {
1109
settlePendingNativeMVCPAdjust(ctx, remainingAfterManual, nativeDelta);
1110
return true;
1111
}
@@ -1009,7 +1114,43 @@ index 40e87cd..93aac74 100644
1114
const distanceToClamp = Math.abs(newScroll - expectedNativeClampScroll);
1115
const isAtExpectedNativeClamp = distanceToClamp <= NATIVE_END_CLAMP_EPSILON;
1116
if (isAtExpectedNativeClamp) {
1012
-@@ -1902,7 +1960,7 @@ function prepareMVCP(ctx, dataChanged) {
1117
+@@ -1790,7 +1853,35 @@ function resolvePendingNativeMVCPAdjust(ctx, newScroll) {
1118
+ }
1119
+ return false;
1120
+ }
1121
++// T3 patch: a caller anchor decides where a size change leaves the scroll position. It is read in
1122
++// the same pass that repositions the items, so the adjustment commits with the new positions.
1123
+ function prepareMVCP(ctx, dataChanged) {
1124
++ // T3 patch: a data change skips the caller anchor, so end maintenance must still run after it.
1125
++ ctx.state.mvcpDataChanged = !!dataChanged;
1126
++ const sizeChangeAnchor = dataChanged ? void 0 : ctx.state.props.sizeChangeAnchor;
1127
++ const restore = prepareDefaultMVCP(ctx, dataChanged);
1128
++ if (!sizeChangeAnchor || ctx.state.scrollingTo !== void 0) {
1129
++ return restore;
1130
++ }
1131
++ return () => {
1132
++ const target = sizeChangeAnchor();
1133
++ if (target === void 0) {
1134
++ restore == null ? void 0 : restore();
1135
++ return;
1136
++ }
1137
++ // Content that shrinks under an offset past its new end pulls the native offset back to
1138
++ // that end by itself; only the rest of the way to the target is adjusted.
1139
++ const endOffset = clampScrollOffset(ctx, Number.POSITIVE_INFINITY);
1140
++ if (ctx.state.scroll > endOffset) {
1141
++ ctx.state.scroll = endOffset;
1142
++ }
1143
++ const positionDiff = clampScrollOffset(ctx, target) - ctx.state.scroll;
1144
++ if (Math.abs(positionDiff) > MVCP_POSITION_EPSILON) {
1145
++ requestAdjust(ctx, positionDiff, false);
1146
++ }
1147
++ };
1148
++}
1149
++function prepareDefaultMVCP(ctx, dataChanged) {
1150
+ const state = ctx.state;
1151
+ const { idsInView, positions, props } = state;
1152
+ const {
1153
+@@ -1902,7 +1993,7 @@ function prepareMVCP(ctx, dataChanged) {
1154
if (diff > 0) {
1155
diff = Math.max(0, totalSize - state.scroll - state.scrollLength);
1156
} else {
@@ -1018,7 +1159,7 @@ index 40e87cd..93aac74 100644
1159
state.scroll = maxScroll;
1160
state.scrollPending = maxScroll;
1161
diff = 0;
1021
-@@ -2299,8 +2357,121 @@ function scrollToIndex(ctx, {
1162
+@@ -2299,8 +2390,121 @@ function scrollToIndex(ctx, {
1163
}
1164
1165
// src/core/initialScroll.ts
@@ -1140,7 +1281,7 @@ index 40e87cd..93aac74 100644
1281
const requestedIndex = target.index;
1282
const index = requestedIndex !== void 0 ? clampScrollIndex(requestedIndex, ctx.state.props.data.length) : void 0;
1283
const itemSize = getItemSizeAtIndex(ctx, index);
1143
-@@ -2726,7 +2897,9 @@ function clearFinishedBootstrapInitialScrollTargetIfMovedAway(ctx) {
1284
+@@ -2726,7 +2930,9 @@ function clearFinishedBootstrapInitialScrollTargetIfMovedAway(ctx) {
1285
return;
1286
}
1287
if (didFinishedInitialScrollMoveAwayFromTarget(ctx, initialScroll)) {
@@ -1151,7 +1292,7 @@ index 40e87cd..93aac74 100644
1292
if (!shouldKeepEndTargetAlive) {
1293
if (shouldPreserveInitialScrollForFooterLayout(initialScroll)) {
1294
clearPendingInitialScrollFooterLayout(ctx, {
1154
-@@ -4651,7 +4824,8 @@ function maybeUpdateAnchoredEndSpace(ctx) {
1295
+@@ -4651,7 +4857,8 @@ function maybeUpdateAnchoredEndSpace(ctx) {
1296
contentBelowAnchor = Math.max(0, contentBelowAnchor - ctx.scrollAxisGap);
1297
contentBelowAnchor += (ctx.values.get("footerSize") || 0) + getStylePaddingEnd(state.props);
1298
isReady = !hasUnknownTailSize;
@@ -1161,7 +1302,7 @@ index 40e87cd..93aac74 100644
1302
} else if (anchorIndex >= 0) {
1303
isReady = false;
1304
}
1164
-@@ -4671,6 +4845,12 @@ function maybeUpdateAnchoredEndSpace(ctx) {
1305
+@@ -4671,6 +4878,12 @@ function maybeUpdateAnchoredEndSpace(ctx) {
1306
updateScroll(ctx, state.scroll, true, { markHasScrolled: false });
1307
}
1308
(_b = anchoredEndSpace == null ? void 0 : anchoredEndSpace.onReady) == null ? void 0 : _b.call(anchoredEndSpace, { anchorIndex: nextAnchorIndex, anchorKey: nextAnchorKey, size: nextSize });
@@ -1174,15 +1315,20 @@ index 40e87cd..93aac74 100644
1315
}
1316
return nextSize;
1317
}
1177
-@@ -5694,6 +5874,7 @@ var ContainersLayer = typedMemo(function ContainersLayer2({
1318
+@@ -5694,8 +5907,11 @@ var ContainersLayer = typedMemo(function ContainersLayer2({
1319
horizontal
1320
}) {
1321
const ctx = useStateContext();
1322
+ const SizeComponent = ctx.state.props.sizeComponentInternal;
1323
const columnWrapperStyle = ctx.columnWrapperStyle;
1183
- const animSize = useValue$("totalSize");
1324
+- const animSize = useValue$("totalSize");
1325
++ // T3 patch: on the new architecture an animated value commits on its own, ahead of the item
1326
++ // positions and their scroll compensation; a rendered size commits with them.
1327
++ const animSize = IsNewArchitecture ? useArr$(["totalSize"])[0] || 0 : useValue$("totalSize");
1328
const [readyToRender, numColumns, otherAxisSize = 0] = useArr$(["readyToRender", "numColumns", "otherAxisSize"]);
1185
-@@ -5704,6 +5885,13 @@ var ContainersLayer = typedMemo(function ContainersLayer2({
1329
+ const isVisible = useFreshDataTransitionVisibility(!!readyToRender, freshDataTransitionEpoch);
1330
+ const style = horizontal ? {
1331
+@@ -5704,6 +5920,13 @@ var ContainersLayer = typedMemo(function ContainersLayer2({
1332
opacity: isVisible ? 1 : 0,
1333
width: animSize
1334
} : { height: animSize, minWidth: otherAxisSize, opacity: isVisible ? 1 : 0 };
@@ -1196,7 +1342,7 @@ index 40e87cd..93aac74 100644
1342
if (columnWrapperStyle) {
1343
const { columnGap, rowGap, gap } = columnWrapperStyle;
1344
const gapX = columnGap || gap || 0;
1199
-@@ -5724,7 +5912,8 @@ var ContainersLayer = typedMemo(function ContainersLayer2({
1345
+@@ -5724,7 +5947,8 @@ var ContainersLayer = typedMemo(function ContainersLayer2({
1346
}
1347
}
1348
}
@@ -1206,7 +1352,7 @@ index 40e87cd..93aac74 100644
1352
});
1353
var Containers = typedMemo(function Containers2({
1354
freshDataTransitionEpoch,
1209
-@@ -5875,7 +6064,12 @@ var StyleSheet = StyleSheet$1;
1355
+@@ -5875,7 +6099,12 @@ var StyleSheet = StyleSheet$1;
1356
1357
// src/components/ListComponent.tsx
1358
var AlignItemsAtEndSpacer = typedMemo(function AlignItemsAtEndSpacer2({ horizontal }) {
@@ -1219,7 +1365,7 @@ index 40e87cd..93aac74 100644
1365
if (alignItemsAtEndPadding <= 0) {
1366
return null;
1367
}
1222
-@@ -5908,8 +6102,12 @@ var ListComponent = typedMemo(function ListComponent2({
1368
+@@ -5908,8 +6137,12 @@ var ListComponent = typedMemo(function ListComponent2({
1369
refScrollView,
1370
renderScrollComponent,
1371
onLayoutFooter,
@@ -1232,7 +1378,7 @@ index 40e87cd..93aac74 100644
1378
scrollAdjustHandler,
1379
snapToIndices,
1380
stickyHeaderConfig,
1235
-@@ -5980,7 +6178,17 @@ var ListComponent = typedMemo(function ListComponent2({
1381
+@@ -5980,7 +6213,17 @@ var ListComponent = typedMemo(function ListComponent2({
1382
SnapOrScroll,
1383
{
1384
...rest,
@@ -1251,7 +1397,7 @@ index 40e87cd..93aac74 100644
1397
contentContainerStyle: [
1398
horizontal ? { height: "100%" } : {},
1399
contentContainerStyle,
1254
-@@ -5989,7 +6197,10 @@ var ListComponent = typedMemo(function ListComponent2({
1400
+@@ -5989,7 +6232,10 @@ var ListComponent = typedMemo(function ListComponent2({
1401
],
1402
contentOffset: initialContentOffset !== void 0 ? horizontal ? { x: initialContentOffset, y: 0 } : { x: 0, y: initialContentOffset } : void 0,
1403
horizontal,
@@ -1263,7 +1409,17 @@ index 40e87cd..93aac74 100644
1409
onLayout,
1410
onScroll: onScroll2,
1411
ref: refScrollView,
1266
-@@ -6730,7 +6941,7 @@ function createImperativeHandle(ctx, scheduleImperativeScrollCommit) {
1412
+@@ -6246,7 +6492,8 @@ function handleLayout(ctx, layoutParam, setCanRender) {
1413
+ if (scrollLength > 0) {
1414
+ doInitialAllocateContainers(ctx);
1415
+ }
1416
+- if (needsCalculate) {
1417
++ // T3 patch: a shorter list keeps a caller anchor too, such as the end.
1418
++ if (needsCalculate || state.props.sizeChangeAnchor) {
1419
+ calculateItemsInView(ctx, { doMVCP: true });
1420
+ }
1421
+ if (didChange || otherAxisSize !== prevOtherAxisSize) {
1422
+@@ -6730,7 +6977,7 @@ function createImperativeHandle(ctx, scheduleImperativeScrollCommit) {
1423
endBuffered: state.endBuffered,
1424
getAverageItemSizes: () => getAverageItemSizes(state),
1425
indexByKey: (key) => state.indexByKey.get(key),
@@ -1272,7 +1428,7 @@ index 40e87cd..93aac74 100644
1428
isAtStart: peek$(ctx, "isAtStart"),
1429
isEndReached: state.isEndReached,
1430
isNearEnd: peek$(ctx, "isNearEnd"),
1275
-@@ -7054,6 +7265,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1431
+@@ -7054,6 +7301,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1432
dataVersion,
1433
drawDistance = 250,
1434
contentInsetEndAdjustment,
@@ -1280,7 +1436,15 @@ index 40e87cd..93aac74 100644
1436
estimatedItemSize = 100,
1437
estimatedListSize,
1438
extraData,
1283
-@@ -7111,10 +7323,12 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1439
+@@ -7075,6 +7323,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1440
+ maintainScrollAtEnd = false,
1441
+ maintainScrollAtEndThreshold = 0.1,
1442
+ maintainVisibleContentPosition: maintainVisibleContentPositionProp,
1443
++ sizeChangeAnchor,
1444
+ numColumns: numColumnsProp = 1,
1445
+ overrideItemLayout,
1446
+ onEndReached,
1447
+@@ -7111,10 +7360,12 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1448
const animatedPropsInternal = props.animatedPropsInternal;
1449
const anchoredEndSpaceOwner = (_a3 = props.anchoredEndSpaceOwnerInternal) != null ? _a3 : "list";
1450
const positionComponentInternal = props.positionComponentInternal;
@@ -1293,7 +1457,7 @@ index 40e87cd..93aac74 100644
1457
stickyPositionComponentInternal: _stickyPositionComponentInternal,
1458
...restProps
1459
} = rest;
1296
-@@ -7179,7 +7393,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1460
+@@ -7179,7 +7430,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1461
const combinedRef = useCombinedRef(refScroller, refScrollView);
1462
const keyExtractor = keyExtractorProp != null ? keyExtractorProp : ((_item, index) => index.toString());
1463
const stickyHeaderIndices = stickyHeaderIndicesProp;
@@ -1302,7 +1466,7 @@ index 40e87cd..93aac74 100644
1466
const previousContentInsetEndAdjustmentRef = useRef(contentInsetEndAdjustmentResolved);
1467
const alwaysRenderIndices = useMemo(() => {
1468
const indices = getAlwaysRenderIndices(alwaysRender, dataProp, keyExtractor, anchoredEndSpace == null ? void 0 : anchoredEndSpace.anchorIndex);
1305
-@@ -7320,6 +7534,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1469
+@@ -7320,6 +7571,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1470
contentContainerAlignItems: contentContainerStyle.alignItems,
1471
contentInset,
1472
contentInsetEndAdjustment: contentInsetEndAdjustmentResolved,
@@ -1310,7 +1474,15 @@ index 40e87cd..93aac74 100644
1474
data: dataProp,
1475
dataKey,
1476
dataVersion,
1313
-@@ -7351,6 +7566,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1477
+@@ -7333,6 +7585,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1478
+ maintainScrollAtEnd: maintainScrollAtEndConfig,
1479
+ maintainScrollAtEndThreshold,
1480
+ maintainVisibleContentPosition: maintainVisibleContentPositionConfig,
1481
++ sizeChangeAnchor,
1482
+ numColumns: numColumnsProp,
1483
+ onEndReached,
1484
+ onEndReachedThreshold,
1485
+@@ -7351,6 +7604,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1486
renderItem,
1487
rtl,
1488
snapToIndices,
@@ -1318,7 +1490,7 @@ index 40e87cd..93aac74 100644
1490
stickyHeaderIndicesArr: stickyHeaderIndices != null ? stickyHeaderIndices : [],
1491
stickyHeaderIndicesSet: useMemo(() => new Set(stickyHeaderIndices != null ? stickyHeaderIndices : []), [stickyHeaderIndices == null ? void 0 : stickyHeaderIndices.join(",")]),
1492
stickyPositionComponentInternal,
1321
-@@ -7402,6 +7618,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1493
+@@ -7402,6 +7656,13 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1494
return void 0;
1495
}
1496
const resolvedOffset = (_a4 = initialScroll.contentOffset) != null ? _a4 : resolveInitialScrollOffset(ctx, initialScroll);
@@ -1332,7 +1504,7 @@ index 40e87cd..93aac74 100644
1504
return usesBootstrapInitialScroll && ((_b2 = state.initialScrollSession) == null ? void 0 : _b2.kind) === "bootstrap" && Platform.OS === "web" ? void 0 : resolvedOffset;
1505
}, [usesBootstrapInitialScroll]);
1506
useLayoutEffect(() => {
1335
-@@ -7526,6 +7749,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1507
+@@ -7526,6 +7787,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1508
[
1509
dataKey,
1510
dataVersion,
@@ -1340,7 +1512,7 @@ index 40e87cd..93aac74 100644
1512
memoizedLastItemKeys.join(","),
1513
numColumnsProp,
1514
nextScrollAxisGap,
1343
-@@ -7622,6 +7846,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1515
+@@ -7622,6 +7884,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1516
() => ({
1517
getRenderedItem: (key) => getRenderedItem(ctx, key),
1518
onMomentumScrollEnd: (event) => {
@@ -1348,7 +1520,7 @@ index 40e87cd..93aac74 100644
1520
checkFinishedScrollFallback(ctx);
1521
if (state.props.onMomentumScrollEnd) {
1522
state.props.onMomentumScrollEnd(event);
1351
-@@ -7630,6 +7855,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1523
+@@ -7630,6 +7893,8 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1524
onScroll: (event) => onScroll(ctx, event),
1525
onScrollBeginDrag: (event) => {
1526
var _a4, _b2;
@@ -1357,7 +1529,7 @@ index 40e87cd..93aac74 100644
1529
prepareReachedEdgeForNextUserScroll(ctx);
1530
(_b2 = (_a4 = state.props).onScrollBeginDrag) == null ? void 0 : _b2.call(_a4, event);
1531
},
1360
-@@ -7655,11 +7882,18 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1532
+@@ -7655,11 +7920,18 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
1533
ListFooterComponent,
1534
ListFooterComponentStyle,
1535
ListHeaderComponent,
@@ -1377,7 +1549,7 @@ index 40e87cd..93aac74 100644
1549
recycleItems,
1550
refreshControl: refreshControlElement ? stylePaddingTopState > 0 ? React2.cloneElement(refreshControlElement, {
1551
diff --git a/react-native.web.js b/react-native.web.js
1380
-index 914d2da..8b88b09 100644
1552
+index 914d2dafaafa001c9ab6791a0a0581659295e333..8b88b09d1269acef77c6ce0f8aaa1049d4fa26e9 100644
1553
--- a/react-native.web.js
1554
+++ b/react-native.web.js
1555
@@ -5651,6 +5651,18 @@ var ContainerSlot = typedMemo(function ContainerSlot2(props) {
@@ -1412,7 +1584,7 @@ index 914d2da..8b88b09 100644
1584
}
1585
}
1586
diff --git a/react-native.web.mjs b/react-native.web.mjs
1415
-index 95465f2..d7cbe1c 100644
1587
+index 95465f2ab89ce41a10553f58af83618f7310e83c..d7cbe1cb43449cc29822b2646deabbddd67f1e7d 100644
1588
--- a/react-native.web.mjs
1589
+++ b/react-native.web.mjs
1590
@@ -5630,6 +5630,18 @@ var ContainerSlot = typedMemo(function ContainerSlot2(props) {
@@ -1447,7 +1619,7 @@ index 95465f2..d7cbe1c 100644
1619
}
1620
}
1621
diff --git a/react.js b/react.js
1450
-index 914d2da..86dbd9a 100644
1622
+index 914d2dafaafa001c9ab6791a0a0581659295e333..86dbd9a5c7345577e4a8a435041ecb68257ae9f1 100644
1623
--- a/react.js
1624
+++ b/react.js
1625
@@ -4702,7 +4702,8 @@ function maybeUpdateAnchoredEndSpace(ctx) {
@@ -1525,7 +1697,7 @@ index 914d2da..86dbd9a 100644
1697
scrollBy();
1698
if (resetPaddingRafRef.current !== void 0) {
1699
diff --git a/react.mjs b/react.mjs
1528
-index 95465f2..cff49dc 100644
1700
+index 95465f2ab89ce41a10553f58af83618f7310e83c..cff49dc5c769cab264b8527a268851295c44aa33 100644
1701
--- a/react.mjs
1702
+++ b/react.mjs
1703
@@ -4681,7 +4681,8 @@ function maybeUpdateAnchoredEndSpace(ctx) {
@@ -1603,10 +1775,22 @@ index 95465f2..cff49dc 100644
1775
scrollBy();
1776
if (resetPaddingRafRef.current !== void 0) {
1777
diff --git a/reanimated.d.ts b/reanimated.d.ts
1606
-index e504332..2ce6383 100644
1778
+index e5043320700b12f34f4c0babbc341f85ca8135c1..e8cbd461325a2e2e9ffd61de26a85ae4d108555c 100644
1779
--- a/reanimated.d.ts
1780
+++ b/reanimated.d.ts
1609
-@@ -294,6 +294,12 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
1781
+@@ -285,6 +285,11 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
1782
+ * - true enables both behaviors; false disables both.
1783
+ */
1784
+ maintainVisibleContentPosition?: boolean | MaintainVisibleContentPositionConfig<ItemT>;
1785
++ /**
1786
++ * T3 patch: the scroll offset a change in item or list size should leave, read in the same pass
1787
++ * that repositions the items so the adjustment commits with them. `undefined` keeps the default.
1788
++ */
1789
++ sizeChangeAnchor?: () => number | undefined;
1790
+ /**
1791
+ * Keeps an item visually anchored to the start by adding trailing space when the content below it underflows.
1792
+ */
1793
+@@ -294,6 +299,12 @@ interface LegendListSpecificProps<ItemT, TItemType extends string | undefined> {
1794
* The adjustment is also rendered as real content padding so the browser scroll range includes it.
1795
*/
1796
contentInsetEndAdjustment?: number;
@@ -1620,7 +1804,7 @@ index e504332..2ce6383 100644
1804
* Number of columns to render items in.
1805
* @default 1
1806
diff --git a/reanimated.js b/reanimated.js
1623
-index f1265fa..fc03be2 100644
1807
+index f1265fad74189591b5aae86cf2e3a31f9c0fdb02..fc03be2190c046f743ffde45ed189ee7868d0cec 100644
1808
--- a/reanimated.js
1809
+++ b/reanimated.js
1810
@@ -115,8 +115,10 @@ var ReanimatedPositionView = typedMemo(function ReanimatedPositionViewComponent(
@@ -1783,7 +1967,7 @@ index f1265fa..fc03be2 100644
1967
renderScrollComponent: renderReanimatedScrollComponent,
1968
...IsNewArchitecture ? { stickyPositionComponentInternal } : {}
1969
diff --git a/reanimated.mjs b/reanimated.mjs
1786
-index 29a00d5..6ab9292 100644
1970
+index 29a00d5dc084fd408a0e0a0a4d64e856d0ed1525..6ab929250c8924e2d9919ee09a4f774238fbb90a 100644
1971
--- a/reanimated.mjs
1972
+++ b/reanimated.mjs
1973
@@ -1,7 +1,7 @@
pnpm-lock.yaml
+4
-4
@@ -333,7 +333,7 @@ patchedDependencies:
333
'@expo/metro-config@58.0.14': 90fa980e8b6480631fb2fbb04559834e3c612db40c550cd828f11be297d8d760
334
'@expo/ui@58.0.20': 5a26480373850c1a7943919aa21f904151b335a0cb01042109e0746def37923e
335
'@ff-labs/fff-node@0.11.0': cc71fcec015f4d39bc96ae2e2bf6b0ca678124c722c66a7841efce9d34b5983c
336
- '@legendapp/list@3.3.5': e6383c516a0d67b65333d6fd38d2203734bf24b054b0b0767b034189205aed32
336
+ '@legendapp/list@3.3.5': 7b62e3a8814279aef02146d986ba3b50763ffd04e38ff36ce132e2065600ade3
337
'@pierre/diffs@1.5.2': 2ec81ba1e8ce4681095a3473c2bf78e630417740c622720ef624febb467c25fc
338
'@react-native-ai/apple@0.12.0': 2d09870c2848d185cb05b53ed823a46e12dba519324d8dd8e584e28731990f9d
339
'@react-native-menu/menu@2.0.0': a4866ecfcd44f318043de839d20110c17e14909004900f002ffe12050376f2ba
@@ -515,7 +515,7 @@ importers:
515
version: 58.0.20(patch_hash=5a26480373850c1a7943919aa21f904151b335a0cb01042109e0746def37923e)(@babel/core@7.29.7(supports-color@8.1.1))(expo@58.0.14)(react-dom@19.3.0(react@19.3.0))(react-native-worklets@0.13.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)(supports-color@8.1.1))(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)
516
'@legendapp/list':
517
specifier: 'catalog:'
518
- version: 3.3.5(patch_hash=e6383c516a0d67b65333d6fd38d2203734bf24b054b0b0767b034189205aed32)(react-dom@19.3.0(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)
518
+ version: 3.3.5(patch_hash=7b62e3a8814279aef02146d986ba3b50763ffd04e38ff36ce132e2065600ade3)(react-dom@19.3.0(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)
519
'@material/material-color-utilities':
520
specifier: 0.3.0
521
version: 0.3.0
@@ -1012,7 +1012,7 @@ importers:
1012
version: 0.9.0
1013
'@legendapp/list':
1014
specifier: 'catalog:'
1015
- version: 3.3.5(patch_hash=e6383c516a0d67b65333d6fd38d2203734bf24b054b0b0767b034189205aed32)(react-dom@19.3.0(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)
1015
+ version: 3.3.5(patch_hash=7b62e3a8814279aef02146d986ba3b50763ffd04e38ff36ce132e2065600ade3)(react-dom@19.3.0(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)
1016
'@noble/hashes':
1017
specifier: 'catalog:'
1018
version: 1.8.0
@@ -14926,7 +14926,7 @@ snapshots:
14926
dependencies:
14927
jsbi: 4.3.2
14928
14929
- '@legendapp/list@3.3.5(patch_hash=e6383c516a0d67b65333d6fd38d2203734bf24b054b0b0767b034189205aed32)(react-dom@19.3.0(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)':
14929
+ '@legendapp/list@3.3.5(patch_hash=7b62e3a8814279aef02146d986ba3b50763ffd04e38ff36ce132e2065600ade3)(react-dom@19.3.0(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)':
14930
dependencies:
14931
react: 19.3.0
14932
use-sync-external-store: 1.6.0(react@19.3.0)