The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 22:15 UTC
refactor(mobile): lists use LegendList, FlatList is a restricted import (#34513)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Nov 11, 2026 at 12:47 UTC
11f61a53276c0b954229700d7b9edbbd3a7a3215
13 files changed
+105
-283
apps/mobile/src/features/files/SourceFileSurface.tsx
+21
-23
@@ -1,10 +1,10 @@
1
+import { LegendList, type LegendListRef } from "@legendapp/list/react-native";
2
import { settlePromise } from "@t3tools/client-runtime/state/runtime";
3
import { useAtomValue } from "@effect/atom-react";
4
import { AsyncResult } from "effect/reactivity";
5
import type { ComponentType } from "react";
6
import { useLayoutEffect, useRef, useState } from "react";
7
import {
7
- FlatList,
8
Platform,
9
Pressable,
10
RefreshControl,
@@ -13,6 +13,7 @@ import {
13
useWindowDimensions,
14
View,
15
} from "react-native";
16
+import { NativeScrollView } from "../../native/NativeScrollViewMarker";
17
import { WebView } from "react-native-webview";
18
import { useSafeAreaInsets } from "react-native-safe-area-context";
19
import { AppText as Text } from "../../components/ui/AppText";
@@ -43,7 +44,6 @@ import {
44
selectableSourceHtml,
45
} from "./source-file-document";
46
import { sourceHighlightAtom } from "./sourceHighlightingState";
46
-import { createSourceLineScroll } from "./source-file-scroll";
47
48
interface SourceFileSurfaceProps {
49
readonly contents: string;
@@ -270,8 +270,7 @@ function JavaScriptSourceFileSurface(props: SourceFileSurfaceProps) {
270
const { codeSurface, codeWordBreak } = useAppearanceCodeSurface();
271
const { normalizedContents, lines, status, targetIndex, tokens } = useSourceFileModel(props);
272
const selectableTokens = props.selectable ? boundedSelectableSourceTokens(tokens) : null;
273
- const listRef = useRef<FlatList<string>>(null);
274
- const [lineScroll] = useState(createSourceLineScroll);
273
+ const listRef = useRef<LegendListRef>(null);
274
const { isPullRefreshing, handlePullToRefresh } = useSourceFileRefresh(props.onRefresh);
275
const refreshControl = props.onRefresh ? (
276
<RefreshControl refreshing={isPullRefreshing} onRefresh={() => void handlePullToRefresh()} />
@@ -283,15 +282,21 @@ function JavaScriptSourceFileSurface(props: SourceFileSurfaceProps) {
282
const usesTextSelection = props.selectable === true && !usesWebSelection;
283
284
// Layout effect so a pending jump is cancelled in the commit that swaps the file.
286
- // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- scrolls the FlatList to the target line and cancels a pending jump when the file changes
285
+ // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- scrolls the list to the target line and cancels a pending jump when the file changes
286
useLayoutEffect(() => {
287
if (targetIndex === null || !usesLineList) {
288
return;
289
}
291
- lineScroll.scrollToLine(listRef.current, targetIndex);
292
- return lineScroll.cancel;
290
+ const frame = requestAnimationFrame(() => {
291
+ void listRef.current?.scrollToIndex({
292
+ index: targetIndex,
293
+ animated: false,
294
+ viewPosition: 0.3,
295
+ });
296
+ });
297
+ return () => cancelAnimationFrame(frame);
298
// oxlint-disable-next-line react/exhaustive-effect-dependencies -- Opening another file at the same line index, or leaving selection mode, scrolls the remounted list to it.
294
- }, [lineScroll, props.path, targetIndex, usesLineList]);
299
+ }, [props.path, targetIndex, usesLineList]);
300
301
const { onLongPressLine } = props;
302
const renderLine = ({ item, index }: { item: string; index: number }) => (
@@ -385,33 +390,26 @@ function JavaScriptSourceFileSurface(props: SourceFileSurfaceProps) {
390
) : null;
391
392
const list = (
388
- <FlatList
393
+ <LegendList
394
ref={listRef}
395
+ // An embedded viewer sits inside another screen's scroll surface.
396
+ renderScrollComponent={props.embedded ? undefined : NativeScrollView}
397
contentInsetAdjustmentBehavior={usesAutomaticInsets ? "automatic" : "never"}
398
automaticallyAdjustsScrollIndicatorInsets={usesAutomaticInsets}
399
refreshControl={refreshControl}
400
data={lines}
401
keyExtractor={(_line, index) => String(index)}
395
- initialNumToRender={80}
396
- maxToRenderPerBatch={80}
397
- windowSize={12}
398
- {...(codeWordBreak
399
- ? {}
400
- : {
401
- getItemLayout: (_data, index) => ({
402
- length: codeSurface.rowHeight,
403
- offset: codeSurface.rowHeight * index,
404
- index,
405
- }),
406
- })}
402
+ extraData={{ tokens, targetIndex, codeSurface, codeWordBreak, onLongPressLine }}
403
+ estimatedItemSize={codeSurface.rowHeight}
404
+ getFixedItemSize={codeWordBreak ? undefined : () => codeSurface.rowHeight}
405
+ drawDistance={codeSurface.rowHeight * 40}
406
+ recycleItems
407
contentContainerStyle={{
408
minWidth: codeWordBreak ? undefined : "100%",
409
paddingBottom: codeSurface.rowHeight,
410
paddingTop: 8,
411
}}
412
renderItem={renderLine}
413
- onScrollToIndexFailed={lineScroll.onScrollToIndexFailed}
414
- onScrollBeginDrag={lineScroll.cancel}
413
/>
414
);
415
apps/mobile/src/features/files/source-file-scroll.test.ts
deleted
-156
@@ -1,156 +0,0 @@
1
-import { expect, it, vi } from "vite-plus/test";
2
-
3
-import { createSourceLineScroll } from "./source-file-scroll";
4
-
5
-const ROW_HEIGHT = 24;
6
-
7
-// Mirrors VirtualizedList.scrollToIndex without getItemLayout: indices past the highest
8
-// measured cell fail, and unmeasured indices below it scroll to an averaged estimate.
9
-function setup({
10
- lineCount = 1_203,
11
- measuredThrough = 79,
12
- rowHeight = (_index: number): number => ROW_HEIGHT,
13
-} = {}) {
14
- vi.useFakeTimers();
15
- vi.stubGlobal("requestAnimationFrame", (callback: () => void) => setTimeout(callback, 16));
16
- vi.stubGlobal("cancelAnimationFrame", (frame: ReturnType<typeof setTimeout>) =>
17
- clearTimeout(frame),
18
- );
19
- const measured = new Set<number>();
20
- const state = {
21
- lineCount,
22
- offset: 0,
23
- measure(from: number, to: number) {
24
- for (let index = from; index <= to; index += 1) measured.add(index);
25
- },
26
- };
27
- state.measure(0, measuredThrough);
28
- const offsetOf = (index: number) => {
29
- let offset = 0;
30
- for (let row = 0; row < index; row += 1) offset += rowHeight(row);
31
- return offset;
32
- };
33
- const averageItemLength = () => {
34
- let total = 0;
35
- for (const index of measured) total += rowHeight(index);
36
- return total / measured.size;
37
- };
38
- const scrollToIndex = vi.fn((params: { index: number }) => {
39
- if (params.index < 0 || params.index >= state.lineCount) {
40
- throw new Error(`scrollToIndex out of range: requested index ${params.index}`);
41
- }
42
- const highestMeasuredFrameIndex = Math.max(...measured);
43
- if (params.index > highestMeasuredFrameIndex) {
44
- scroll.onScrollToIndexFailed({
45
- index: params.index,
46
- averageItemLength: averageItemLength(),
47
- highestMeasuredFrameIndex,
48
- });
49
- return;
50
- }
51
- state.offset = measured.has(params.index)
52
- ? offsetOf(params.index)
53
- : averageItemLength() * params.index;
54
- });
55
- const scrollToOffset = vi.fn((params: { offset: number }) => {
56
- state.offset = params.offset;
57
- });
58
- const list = {
59
- get props() {
60
- return { data: { length: state.lineCount } };
61
- },
62
- scrollToIndex,
63
- scrollToOffset,
64
- };
65
- const scroll = createSourceLineScroll();
66
- return {
67
- scroll,
68
- list,
69
- state,
70
- offsetOf,
71
- scrollToIndex,
72
- scrollToOffset,
73
- [Symbol.dispose]: () => {
74
- vi.unstubAllGlobals();
75
- vi.useRealTimers();
76
- },
77
- };
78
-}
79
-
80
-it("lands on an already measured line", () => {
81
- using t = setup();
82
-
83
- t.scroll.scrollToLine(t.list, 40);
84
- vi.runAllTimers();
85
-
86
- expect(t.state.offset).toBe(t.offsetOf(40));
87
- expect(t.scrollToOffset).not.toHaveBeenCalled();
88
- expect(vi.getTimerCount()).toBe(0);
89
-});
90
-
91
-it("jumps near an unmeasured wrapped line, then lands on it once rows measure", () => {
92
- using t = setup({ rowHeight: (index) => (index >= 80 ? ROW_HEIGHT * 3 : ROW_HEIGHT) });
93
-
94
- t.scroll.scrollToLine(t.list, 899);
95
- expect(() => vi.advanceTimersToNextTimer()).not.toThrow();
96
- expect(t.state.offset).toBeGreaterThan(0);
97
-
98
- // The render batch after the estimated jump measures rows past the target first, so
99
- // the next scrollToIndex is accepted against an averaged estimate.
100
- t.state.measure(900, 979);
101
- vi.advanceTimersToNextTimer();
102
- expect(t.state.offset).not.toBe(t.offsetOf(899));
103
-
104
- t.state.measure(820, 899);
105
- vi.runAllTimers();
106
-
107
- expect(t.state.offset).toBe(t.offsetOf(899));
108
- expect(vi.getTimerCount()).toBe(0);
109
-});
110
-
111
-it("stops retrying when the target never measures", () => {
112
- using t = setup({ rowHeight: (index) => (index === 899 ? ROW_HEIGHT * 400 : ROW_HEIGHT) });
113
-
114
- t.scroll.scrollToLine(t.list, 899);
115
- expect(() => vi.runAllTimers()).not.toThrow();
116
-
117
- expect(t.scrollToIndex.mock.calls.length).toBeLessThanOrEqual(10);
118
- expect(vi.getTimerCount()).toBe(0);
119
-});
120
-
121
-it("ignores a line outside the document", () => {
122
- using t = setup({ lineCount: 12 });
123
-
124
- expect(() => t.scroll.scrollToLine(t.list, 899)).not.toThrow();
125
- vi.runAllTimers();
126
- expect(t.scrollToIndex).not.toHaveBeenCalled();
127
- expect(t.scrollToOffset).not.toHaveBeenCalled();
128
-});
129
-
130
-it("drops a pending jump when the document shrinks or the jump is cancelled", () => {
131
- using t = setup();
132
-
133
- t.scroll.scrollToLine(t.list, 899);
134
- vi.advanceTimersToNextTimer();
135
- t.state.lineCount = 12;
136
- expect(() => vi.runAllTimers()).not.toThrow();
137
-
138
- t.state.lineCount = 1_203;
139
- t.scroll.scrollToLine(t.list, 899);
140
- vi.advanceTimersToNextTimer();
141
- const calls = t.scrollToIndex.mock.calls.length;
142
- t.scroll.cancel();
143
- t.state.measure(80, 999);
144
- vi.runAllTimers();
145
- expect(t.scrollToIndex).toHaveBeenCalledTimes(calls);
146
-});
147
-
148
-it("a drag before the first frame cancels the jump", () => {
149
- using t = setup();
150
-
151
- t.scroll.scrollToLine(t.list, 40);
152
- t.scroll.cancel();
153
- vi.runAllTimers();
154
-
155
- expect(t.scrollToIndex).not.toHaveBeenCalled();
156
-});
apps/mobile/src/features/files/source-file-scroll.ts
deleted
-66
@@ -1,66 +0,0 @@
1
-interface SourceLineList {
2
- readonly props: { readonly data?: { readonly length: number } | null };
3
- scrollToIndex(params: { index: number; animated: boolean; viewPosition: number }): void;
4
- scrollToOffset(params: { offset: number; animated: boolean }): void;
5
-}
6
-
7
-const RETRY_DELAY_MS = 100;
8
-const MAX_RETRIES = 5;
9
-
10
-// Wrapped rows have no getItemLayout. VirtualizedList fails a jump past its highest measured
11
-// row and silently estimates an unmeasured row below it, so re-aim until the budget runs out.
12
-export function createSourceLineScroll() {
13
- let list: SourceLineList | null = null;
14
- let target: number | null = null;
15
- let retries = 0;
16
- let cancelPending: (() => void) | null = null;
17
-
18
- const cancel = () => {
19
- cancelPending?.();
20
- cancelPending = null;
21
- target = null;
22
- };
23
-
24
- const retry = () => {
25
- if (retries >= MAX_RETRIES) {
26
- target = null;
27
- return;
28
- }
29
- retries += 1;
30
- const timer = setTimeout(attempt, RETRY_DELAY_MS);
31
- cancelPending = () => clearTimeout(timer);
32
- };
33
-
34
- const attempt = () => {
35
- cancelPending = null;
36
- if (target === null || !list || target >= (list.props.data?.length ?? 0)) {
37
- target = null;
38
- return;
39
- }
40
- list.scrollToIndex({ index: target, animated: false, viewPosition: 0.3 });
41
- // A failed jump has already scheduled its retry.
42
- if (cancelPending === null) retry();
43
- };
44
-
45
- return {
46
- scrollToLine(nextList: SourceLineList | null, index: number) {
47
- cancel();
48
- list = nextList;
49
- if (!Number.isInteger(index) || index < 0) return;
50
- target = index;
51
- retries = 0;
52
- const frame = requestAnimationFrame(attempt);
53
- cancelPending = () => cancelAnimationFrame(frame);
54
- },
55
- onScrollToIndexFailed(info: {
56
- index: number;
57
- averageItemLength: number;
58
- highestMeasuredFrameIndex: number;
59
- }) {
60
- if (info.index !== target || !list) return;
61
- list.scrollToOffset({ offset: info.averageItemLength * info.index, animated: false });
62
- retry();
63
- },
64
- cancel,
65
- };
66
-}
apps/mobile/src/features/home/HomeScreen.tsx
+1
-1
@@ -240,7 +240,7 @@ function HomeScrollView(props: ComponentProps<typeof ScrollView>) {
240
}
241
242
function renderHomeScrollView(props: ScrollViewProps) {
243
- // FlatList clones this with cells and ref; keep the marker inside their actual ScrollView.
243
+ // The list passes its content and ref in these props; keep the marker inside the real ScrollView.
244
return <HomeScrollView {...props} />;
245
}
246
apps/mobile/src/features/keyboard/CommandPalette.tsx
+15
-14
@@ -1,3 +1,4 @@
1
+import { LegendList, type LegendListRef } from "@legendapp/list/react-native";
2
import { useAtomValue } from "@effect/atom-react";
3
import { uuidv4 } from "../../lib/uuid";
4
import { useNavigation } from "@react-navigation/native";
@@ -19,7 +20,6 @@ import {
20
} from "@t3tools/shared/paletteSearch";
21
import { useEffect, useMemo, useRef, useState } from "react";
22
import {
22
- FlatList,
23
KeyboardAvoidingView,
24
Modal,
25
Pressable,
@@ -240,7 +240,7 @@ export function CommandPalette(props: {
240
const pendingAction = useRef<(() => void) | null>(null);
241
const closing = useRef(false);
242
const inputRef = useRef<TextInputInstance>(null);
243
- const listRef = useRef<FlatList<CommandPaletteResult>>(null);
243
+ const listRef = useRef<LegendListRef>(null);
244
const { width, height } = useWindowDimensions();
245
// The palette floats above every column, so it keeps itself inside the window's side insets
246
// and to one side of a book fold.
@@ -663,22 +663,23 @@ export function CommandPalette(props: {
663
/>
664
</View>
665
</View>
666
- <FlatList
666
+ {/* oxlint-disable-next-line t3code/require-registered-list-scroll -- The palette is a modal with no navigation header to register with. */}
667
+ <LegendList
668
ref={listRef}
669
data={results}
669
- extraData={selectedKey}
670
+ extraData={{
671
+ selectedKey,
672
+ firstMessageIndex,
673
+ contentMatchByKey,
674
+ query: search.query,
675
+ }}
676
keyboardShouldPersistTaps="handled"
677
keyExtractor={(item) => item.key}
672
- getItemLayout={(_, index) => ({
673
- length: ROW_HEIGHT + (index === firstMessageIndex ? SECTION_LABEL_HEIGHT : 0),
674
- offset:
675
- ROW_HEIGHT * index +
676
- (firstMessageIndex !== -1 && index > firstMessageIndex
677
- ? SECTION_LABEL_HEIGHT
678
- : 0),
679
- index,
680
- })}
681
- contentContainerClassName="pb-2"
678
+ getFixedItemSize={(_, index) =>
679
+ ROW_HEIGHT + (index === firstMessageIndex ? SECTION_LABEL_HEIGHT : 0)
680
+ }
681
+ recycleItems
682
+ contentContainerStyle={{ paddingBottom: 8 }}
683
ListEmptyComponent={
684
<Text className="p-5 text-center text-foreground-muted">
685
{search.isPending ? "Searching…" : "No results"}
apps/mobile/src/features/pull-requests/PullRequestFilterSearchScreen.tsx
+8
-2
@@ -1,3 +1,5 @@
1
+import { NativeScrollView } from "../../native/NativeScrollViewMarker";
2
+import { LegendList } from "@legendapp/list/react-native";
3
import { useAtomValue } from "@effect/atom-react";
4
import { useNavigation, type StaticScreenProps } from "@react-navigation/native";
5
import {
@@ -9,7 +11,7 @@ import {
11
import * as Option from "effect/Option";
12
import { AsyncResult, Atom } from "effect/reactivity";
13
import { useState } from "react";
12
-import { FlatList, Platform } from "react-native";
14
+import { Platform } from "react-native";
15
16
import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
17
import { EmptyState } from "../../components/ui/EmptyState";
@@ -121,9 +123,13 @@ export function PullRequestFilterSearchScreen({
123
onQueryChange={setQuery}
124
>
125
{({ paddingBottom }) => (
124
- <FlatList
126
+ <LegendList
127
+ renderScrollComponent={NativeScrollView}
128
data={rows}
129
keyExtractor={(value) => value.toLowerCase()}
130
+ extraData={{ selected, colors, count: rows.length }}
131
+ estimatedItemSize={56}
132
+ recycleItems
133
className="flex-1"
134
contentInsetAdjustmentBehavior="automatic"
135
automaticallyAdjustKeyboardInsets={Platform.OS === "ios"}
apps/mobile/src/features/pull-requests/PullRequestLabelsScreen.tsx
+8
-2
@@ -1,10 +1,12 @@
1
+import { NativeScrollView } from "../../native/NativeScrollViewMarker";
2
+import { LegendList } from "@legendapp/list/react-native";
3
import { useAtomValue } from "@effect/atom-react";
4
import type { StaticScreenProps } from "@react-navigation/native";
5
import { squashAtomCommandFailure } from "@t3tools/client-runtime/state/runtime";
6
import type { PullRequestLabelCandidate } from "@t3tools/contracts";
7
import { AsyncResult } from "effect/reactivity";
8
import { useRef, useState } from "react";
7
-import { FlatList, Platform, View } from "react-native";
9
+import { Platform, View } from "react-native";
10
import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
11
import { AppText as Text } from "../../components/ui/AppText";
12
import { Button } from "../../components/ui/Button";
@@ -79,9 +81,13 @@ export function PullRequestLabelsScreen({ route }: StaticScreenProps<PullRequest
81
onQueryChange={setQuery}
82
>
83
{({ paddingBottom }) => (
82
- <FlatList
84
+ <LegendList
85
+ renderScrollComponent={NativeScrollView}
86
data={candidates}
87
keyExtractor={(candidate) => candidate.name}
88
+ extraData={{ pending, allowed, count: candidates.length }}
89
+ estimatedItemSize={72}
90
+ recycleItems
91
className="flex-1"
92
contentInsetAdjustmentBehavior="automatic"
93
automaticallyAdjustKeyboardInsets={Platform.OS === "ios"}
apps/mobile/src/features/pull-requests/PullRequestReviewersScreen.tsx
+7
-3
@@ -1,3 +1,4 @@
1
+import { LegendList, type LegendListRef } from "@legendapp/list/react-native";
2
import { AppBar, type AppBarSearch } from "../../components/ui/AppBar";
3
import { AsyncResult } from "effect/reactivity";
4
import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
@@ -13,7 +14,7 @@ import {
14
} from "@t3tools/client-runtime/pull-request-reviewers";
15
import type { PullRequestReviewerCandidate } from "@t3tools/contracts";
16
import { useRef, useState } from "react";
16
-import { FlatList, Pressable, ScrollView, View } from "react-native";
17
+import { Pressable, ScrollView, View } from "react-native";
18
import { NativeScrollView } from "../../native/NativeScrollViewMarker";
19
import { useContentTopInset, useSearchToolbarInset } from "../../components/ui/useBarInset";
20
import { AppText as Text, AppTextInput as TextInput } from "../../components/ui/AppText";
@@ -40,7 +41,7 @@ const TRUNCATED_LABELS: Record<ReviewerTruncation, (error: string | null) => str
41
export function PullRequestReviewersScreen({ route }: StaticScreenProps<PullRequestParams>) {
42
const navigation = useNavigation();
43
const contentTopInset = useContentTopInset();
43
- const listRef = useRef<FlatList<PullRequestReviewerCandidate>>(null);
44
+ const listRef = useRef<LegendListRef>(null);
45
const target = pullRequestTarget(route.params);
46
const detail = useEnvironmentQuery(composerPullRequests.detail(target));
47
const pr = detail.data;
@@ -150,10 +151,13 @@ export function PullRequestReviewersScreen({ route }: StaticScreenProps<PullRequ
151
search={reviewerSearch}
152
/>
153
{listCandidates ? (
153
- <FlatList
154
+ <LegendList
155
ref={listRef}
156
data={candidates}
157
keyExtractor={(candidate) => `${candidate.kind}:${candidate.id}`}
158
+ extraData={{ allowed, pending }}
159
+ estimatedItemSize={64}
160
+ recycleItems
161
renderScrollComponent={NativeScrollView}
162
contentInsetAdjustmentBehavior="automatic"
163
automaticallyAdjustKeyboardInsets
apps/mobile/src/features/review/ReviewSheet.tsx
+6
-3
@@ -2,6 +2,7 @@ import { settlePromise, squashAtomCommandFailure } from "@t3tools/client-runtime
2
import { AsyncResult } from "effect/reactivity";
3
import type { EnvironmentId, ThreadId } from "@t3tools/contracts";
4
import { formatDiffCount } from "@t3tools/client-runtime/diff-count";
5
+import { LegendList } from "@legendapp/list/react-native";
6
import { useNavigation, type StaticScreenProps } from "@react-navigation/native";
7
import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
8
import { AppBar } from "../../components/ui/AppBar";
@@ -10,7 +11,6 @@ import type { ReviewSectionItem } from "./reviewModel";
11
import { useReviewHeaderPresentation } from "./useReviewHeaderPresentation";
12
import { type Ref, type ReactElement, useImperativeHandle, useRef, useState } from "react";
13
import {
13
- FlatList,
14
Platform,
15
Pressable,
16
RefreshControl,
@@ -341,11 +341,14 @@ function ReviewFileNavigator({ files, sectionId, onSelectFile, ref }: ReviewFile
341
hideBottomBorder
342
/>
343
<ScreenContent insetHorizontal>
344
- <FlatList
344
+ <LegendList
345
renderScrollComponent={NativeScrollView}
346
data={files}
347
- extraData={selectedFileId}
347
+ // Rows keep their callback until extraData changes; it reads collapsed files.
348
+ extraData={[selectedFileId, handleSelectFile]}
349
keyExtractor={(file) => file.id}
350
+ estimatedItemSize={64}
351
+ recycleItems
352
contentInsetAdjustmentBehavior="automatic"
353
contentContainerStyle={{ paddingHorizontal: 8, paddingVertical: 8 }}
354
renderItem={renderFile}
apps/mobile/src/features/settings/ScheduledTaskPickerScreens.tsx
+8
-2
@@ -1,8 +1,10 @@
1
+import { NativeScrollView } from "../../native/NativeScrollViewMarker";
2
+import { LegendList } from "@legendapp/list/react-native";
3
import { useNavigation } from "@react-navigation/native";
4
import { isListedThreadLineage } from "@t3tools/contracts";
5
import * as Haptics from "expo-haptics";
6
import { useMemo, useState } from "react";
5
-import { FlatList, Platform } from "react-native";
7
+import { Platform } from "react-native";
8
import { useSafeAreaInsets } from "react-native-safe-area-context";
9
10
import { AppText as Text } from "../../components/ui/AppText";
@@ -237,9 +239,13 @@ export function ScheduledTaskThreadPickerRouteScreen() {
239
240
return (
241
<SettingsScreen title="Destination" search={search}>
240
- <FlatList
242
+ <LegendList
243
+ renderScrollComponent={NativeScrollView}
244
data={rows}
245
keyExtractor={(row) => row.key}
246
+ extraData={selectedKey}
247
+ estimatedItemSize={56}
248
+ recycleItems
249
className="flex-1"
250
contentInsetAdjustmentBehavior="automatic"
251
automaticallyAdjustKeyboardInsets={Platform.OS === "ios"}
apps/mobile/src/features/settings/SettingsVoiceModelsRouteScreen.tsx
+8
-2
@@ -1,9 +1,11 @@
1
+import { NativeScrollView } from "../../native/NativeScrollViewMarker";
2
+import { LegendList } from "@legendapp/list/react-native";
3
import { useAtomValue } from "@effect/atom-react";
4
import type { StaticScreenProps } from "@react-navigation/native";
5
import type { EnvironmentId } from "@t3tools/contracts";
6
import { AsyncResult } from "effect/reactivity";
7
import { useState } from "react";
6
-import { FlatList, Platform, View } from "react-native";
8
+import { Platform, View } from "react-native";
9
10
import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
11
import { AppText as Text } from "../../components/ui/AppText";
@@ -54,9 +56,13 @@ export function SettingsVoiceModelsRouteScreen({
56
onQueryChange={setQuery}
57
>
58
{({ paddingBottom }) => (
57
- <FlatList
59
+ <LegendList
60
+ renderScrollComponent={NativeScrollView}
61
data={models}
62
keyExtractor={(model) => model.id}
63
+ extraData={{ voice, language, count: models.length }}
64
+ estimatedItemSize={72}
65
+ recycleItems
66
className="flex-1"
67
contentInsetAdjustmentBehavior="automatic"
68
automaticallyAdjustKeyboardInsets={Platform.OS === "ios"}
apps/mobile/src/features/threads/ThreadArrangementSheet.tsx
+17
-9
@@ -1,3 +1,4 @@
1
+import { LegendList, type LegendListRef } from "@legendapp/list/react-native";
2
import { SheetHeader } from "../../components/ui/SheetHeader";
3
import { appAtomRegistry } from "../../state/atom-registry";
4
import { useAtomValue } from "@effect/atom-react";
@@ -5,7 +6,7 @@ import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell
6
import { effectiveSnoozed } from "@t3tools/client-runtime/state/thread-settled";
7
import { sortInboxThreadsByReturn } from "@t3tools/client-runtime/state/thread-inbox";
8
import { type ReactNode, useEffect, useMemo, useRef, useState } from "react";
8
-import { Animated, FlatList, Modal, Pressable, useWindowDimensions, View } from "react-native";
9
+import { Animated, Modal, Pressable, useWindowDimensions, View } from "react-native";
10
import { Gesture, GestureDetector, GestureHandlerRootView } from "react-native-gesture-handler";
11
import Reanimated, { ReduceMotion, useAnimatedStyle, withTiming } from "react-native-reanimated";
12
import { threadDragGapOffset } from "./threadDragGap";
@@ -250,7 +251,7 @@ function ThreadArrangementSheet(props: { onClose: () => void }) {
251
}
252
return result;
253
}, [sections, expanded, visibleSettled, settledCount, rowHeight, headerHeight]);
253
- const list = useRef<FlatList<Row>>(null);
254
+ const list = useRef<LegendListRef>(null);
255
const geometry = useRef({ height: 0, offset: 0 });
256
const drag = useRef<Drag | null>(null);
257
const frame = useRef<number | null>(null);
@@ -408,21 +409,28 @@ function ThreadArrangementSheet(props: { onClose: () => void }) {
409
className="flex-1"
410
style={{ overflow: "hidden" }}
411
>
411
- <FlatList
412
+ {/* oxlint-disable-next-line t3code/require-registered-list-scroll -- A full-screen Modal with an inline header; there is no navigation header to register with. */}
413
+ <LegendList
414
ref={list}
415
data={rows}
416
keyExtractor={(row) => row.key}
417
+ extraData={{
418
+ visiblePreview,
419
+ insertionOffset,
420
+ dropBusy,
421
+ pendingOrder,
422
+ listEnvironments,
423
+ planners,
424
+ configs,
425
+ }}
426
+ // Rows hold their drag gesture, so each keeps its own view.
427
+ recycleItems={false}
428
scrollEnabled={visiblePreview === null}
416
- removeClippedSubviews={false}
429
onScroll={(event) => {
430
geometry.current.offset = event.nativeEvent.contentOffset.y;
431
}}
432
scrollEventThrottle={16}
421
- getItemLayout={(_, index) => ({
422
- length: rows[index]!.height,
423
- offset: rows[index]!.offset,
424
- index,
425
- })}
433
+ getFixedItemSize={(row) => row.height}
434
renderItem={({ item }) => {
435
const thread = item.thread;
436
const planner =
vite.config.ts
+6
@@ -29,6 +29,12 @@ const TEST_CONFIG_PACKAGES = [
29
const isRepoRootTestRun = process.cwd() === import.meta.dirname;
30
31
const RESTRICTED_IMPORT_PATHS = [
32
+ {
33
+ name: "react-native",
34
+ importNames: ["FlatList"],
35
+ message:
36
+ "Use LegendList from @legendapp/list/react-native, with renderScrollComponent={NativeScrollView} in a screen. Pass whatever renderItem reads through extraData: rows only re-render when their item or extraData changes.",
37
+ },
38
{
39
name: "@t3tools/client-runtime",
40
message: