Open History to see the last commit
1import { createThreadMovePlanner } from "../threads/threadOrder";
2import {
3 LegendList,
4 type LegendListRef,
5 type LegendListRenderItemProps,
6} from "@legendapp/list/react-native";
7import {
8 type EnvironmentProject,
9 type EnvironmentThreadShell,
10} from "@t3tools/client-runtime/state/shell";
11import {
12 threadSearchMatchKey,
13 type EnvironmentThreadSearchMatch,
14} from "@t3tools/client-runtime/state/thread-search";
15import {
16 type EnvironmentId,
17 resolveEnvironmentMachineKind,
18 type SidebarProjectGroupingMode,
19 type SidebarThreadSortOrder,
20} from "@t3tools/contracts";
21import { useAtomSet, useAtomValue } from "@effect/atom-react";
22import { AsyncResult } from "effect/unstable/reactivity";
23import { useFocusEffect } from "@react-navigation/native";
24import { useCallback, useEffect, useMemo, useRef, useState } from "react";
25import { ActivityIndicator, FlatList, Platform, Pressable, View } from "react-native";
26import type { SwipeableMethods } from "react-native-gesture-handler/ReanimatedSwipeable";
27import { useSafeAreaInsets } from "react-native-safe-area-context";
28
29import { AppText as Text } from "../../components/AppText";
30import { EmptyState } from "../../components/EmptyState";
31import type { WorkspaceEnvironment, WorkspaceState } from "../../state/workspaceModel";
32import type { SavedRemoteConnection } from "../../lib/connection";
33import { scopedProjectKey } from "../../lib/scopedEntities";
34import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass";
35import { mobilePreferencesAtom, updateMobilePreferencesAtom } from "../../state/preferences";
36import { useThreadSearch } from "../../state/queries";
37import { useThreadListV2Enabled } from "../threads/use-thread-list-v2-enabled";
38import { usePendingThreadOrder } from "../../state/thread-order";
39import { environmentServerConfigsAtom } from "../../state/server";
40import type { PendingNewTask } from "../../state/use-pending-new-tasks";
41import { useQueuedThreadKeys } from "../../state/use-thread-outbox";
42import {
43 PendingTaskListRow,
44 ThreadListGroupHeader,
45 ThreadListRow,
46 ThreadListShowMoreRow,
47} from "../threads/thread-list-items";
48import {
49 ThreadListV2PendingRow,
50 ThreadListV2Row,
51 ThreadListV2SettledShelfHeader,
52 ThreadListV2SnoozedShelfHeader,
53} from "../threads/thread-list-v2-items";
54import {
55 buildThreadListV2Items,
56 getThreadListV2OrderedSection,
57 buildThreadListV2ListItems,
58 THREAD_LIST_V2_SETTLED_INITIAL_COUNT,
59 THREAD_LIST_V2_SETTLED_PAGE_COUNT,
60 type ThreadListV2ListItem,
61} from "../threads/threadListV2";
62import { useThreadListV2ShelfPreferences } from "../threads/use-thread-list-v2-shelf-preferences";
63import type { HomeListFilterMenuEnvironment } from "./home-list-filter-menu";
64import {
65 buildHomeListLayout,
66 DEFAULT_GROUP_DISPLAY_STATE,
67 EMPTY_HOME_LIST_LAYOUT,
68 homeListItemsAreEqual,
69 nextGroupDisplayState,
70 type HomeGroupDisplayAction,
71 type HomeGroupDisplayState,
72 type HomeListItem,
73} from "./homeListItems";
74import {
75 buildHomeProjectScopes,
76 buildHomeThreadGroups,
77 sortHomeProjectScopes,
78 type HomeProjectSortOrder,
79} from "./homeThreadList";
80import { SwipeableScrollGateProvider, useSwipeableScrollGate } from "./thread-swipe-actions";
81
82/* ─── Types ──────────────────────────────────────────────────────────── */
83
84interface HomeScreenProps {
85 readonly projects: ReadonlyArray<EnvironmentProject>;
86 readonly threads: ReadonlyArray<EnvironmentThreadShell>;
87 readonly pendingTasks: ReadonlyArray<PendingNewTask>;
88 readonly catalogState: WorkspaceState;
89 readonly savedConnectionsById: Readonly<Record<string, SavedRemoteConnection>>;
90 readonly environments: ReadonlyArray<
91 HomeListFilterMenuEnvironment & Pick<WorkspaceEnvironment, "connectionState">
92 >;
93 readonly searchQuery: string;
94 readonly selectedEnvironmentId: EnvironmentId | null;
95 readonly selectedProjectKey: string | null;
96 readonly projectSortOrder: HomeProjectSortOrder;
97 readonly threadSortOrder: SidebarThreadSortOrder;
98 readonly projectGroupingMode: SidebarProjectGroupingMode;
99 readonly onSearchQueryChange: (query: string) => void;
100 readonly onEnvironmentChange: (environmentId: EnvironmentId | null) => void;
101 readonly onProjectChange: (projectKey: string | null) => void;
102 readonly onProjectSortOrderChange: (sortOrder: HomeProjectSortOrder) => void;
103 readonly onThreadSortOrderChange: (sortOrder: SidebarThreadSortOrder) => void;
104 readonly onAddConnection: () => void;
105 readonly onOpenSettings: () => void;
106 readonly onStartNewTask: () => void;
107 readonly onSelectThread: (thread: EnvironmentThreadShell) => void;
108 readonly onArchiveThread: (thread: EnvironmentThreadShell) => void;
109 readonly onDeleteThread: (thread: EnvironmentThreadShell) => void;
110 /** Resolves true iff the settle was dispatched and succeeded. */
111 readonly onSettleThread: (thread: EnvironmentThreadShell) => Promise<boolean>;
112 readonly onSnoozeThread: (
113 thread: EnvironmentThreadShell,
114 snoozedUntil: string,
115 ) => Promise<boolean>;
116 readonly onUnsnoozeThread: (thread: EnvironmentThreadShell) => Promise<boolean>;
117 readonly onUnsettleThread: (thread: EnvironmentThreadShell) => void;
118 readonly onPinThread: (thread: EnvironmentThreadShell) => Promise<boolean>;
119 readonly onUnpinThread: (thread: EnvironmentThreadShell) => Promise<boolean>;
120 readonly onMoveThread: (
121 thread: EnvironmentThreadShell,
122 direction: "up" | "down",
123 ) => Promise<boolean>;
124 readonly onRegenerateThreadTitle: (thread: EnvironmentThreadShell) => Promise<boolean>;
125 readonly onSelectPendingTask: (pendingTask: PendingNewTask) => void;
126 readonly onDeletePendingTask: (pendingTask: PendingNewTask) => void;
127 readonly onNewThreadOnBranch: (thread: EnvironmentThreadShell) => void;
128 readonly onNewThreadInProject: (project: EnvironmentProject) => void;
129}
130
131/* ─── Layout constants ───────────────────────────────────────────────── */
132
133const ESTIMATED_THREAD_ROW_HEIGHT = 72;
134const PRE_LIQUID_GLASS_BOTTOM_TOOLBAR_HEIGHT = 44;
135/**
136 * Top spacing between the list and the Android custom header. The Android
137 * header (AndroidHomeHeader) is rendered in-flow above this screen and
138 * already consumes the top safe-area inset, so the list only needs breathing
139 * room here.
140 */
141
142function deriveEmptyState(props: {
143 readonly catalogState: WorkspaceState;
144 readonly projectCount: number;
145}): { readonly title: string; readonly detail: string; readonly loading: boolean } {
146 const { catalogState } = props;
147 if (catalogState.isLoadingConnections) {
148 return {
149 title: "Loading environments",
150 detail: "Checking saved environments on this device.",
151 loading: true,
152 };
153 }
154
155 if (!catalogState.hasConnections) {
156 return {
157 title: "No environments connected",
158 detail: "Add an environment to load projects and start coding sessions.",
159 loading: false,
160 };
161 }
162
163 if (
164 (catalogState.connectionState === "available" ||
165 catalogState.connectionState === "offline" ||
166 catalogState.connectionState === "error") &&
167 !catalogState.hasLoadedShellSnapshot
168 ) {
169 return {
170 title: "Environment unavailable",
171 detail:
172 catalogState.connectionError ??
173 "The saved environment is offline. Check the URL or start the environment, then retry.",
174 loading: false,
175 };
176 }
177
178 if (
179 catalogState.hasConnectingEnvironment &&
180 !catalogState.hasLoadedShellSnapshot &&
181 catalogState.connectionError === null
182 ) {
183 return {
184 title: "Connecting to environment",
185 detail: "Loading projects and threads from the saved environment.",
186 loading: true,
187 };
188 }
189
190 if (props.projectCount === 0 && catalogState.hasLoadedShellSnapshot) {
191 return {
192 title: "No projects found",
193 detail: "The connected environment did not report any projects.",
194 loading: false,
195 };
196 }
197
198 return {
199 title: "No threads yet",
200 detail: "Create a task to start a new coding session in one of your connected projects.",
201 loading: false,
202 };
203}
204
205function HomeTopContentSpacer() {
206 return <View className="h-4" />;
207}
208
209/* ─── Main screen ────────────────────────────────────────────────────── */
210
211export function HomeScreen(props: HomeScreenProps) {
212 const [groupDisplayStates, setGroupDisplayStates] = useState<
213 ReadonlyMap<string, HomeGroupDisplayState>
214 >(() => new Map());
215 const preferencesResult = useAtomValue(mobilePreferencesAtom);
216 const threadListV2Enabled = useThreadListV2Enabled();
217 const queuedThreadKeys = useQueuedThreadKeys();
218 const savePreferences = useAtomSet(updateMobilePreferencesAtom);
219 const openSwipeableRef = useRef<SwipeableMethods | null>(null);
220 const listRef = useRef<LegendListRef | null>(null);
221 const insets = useSafeAreaInsets();
222 const iosBottomToolbarClearance =
223 Platform.OS === "ios" && !NATIVE_LIQUID_GLASS_SUPPORTED
224 ? PRE_LIQUID_GLASS_BOTTOM_TOOLBAR_HEIGHT
225 : 0;
226 const searchEnvironmentIds = useMemo(
227 () =>
228 props.selectedEnvironmentId === null
229 ? props.environments
230 .filter((environment) => environment.connectionState === "connected")
231 .map((environment) => environment.environmentId)
232 : props.environments.some(
233 (environment) =>
234 environment.environmentId === props.selectedEnvironmentId &&
235 environment.connectionState === "connected",
236 )
237 ? [props.selectedEnvironmentId]
238 : [],
239 [props.environments, props.selectedEnvironmentId],
240 );
241 const threadSearch = useThreadSearch(searchEnvironmentIds, props.searchQuery);
242 const threadSearchMatchByKey = useMemo(() => {
243 const matches = new Map<string, EnvironmentThreadSearchMatch>();
244 for (const match of threadSearch.matches) {
245 if (match.source === "user" || match.source === "assistant") {
246 matches.set(threadSearchMatchKey(match), match);
247 }
248 }
249 return matches;
250 }, [threadSearch.matches]);
251 const matchedThreadKeys = useMemo(
252 () => new Set(threadSearch.matches.map(threadSearchMatchKey)),
253 [threadSearch.matches],
254 );
255 const effectiveGroupDisplayStates = useMemo(() => {
256 const next = new Map(groupDisplayStates);
257 if (!AsyncResult.isSuccess(preferencesResult)) {
258 return next;
259 }
260 for (const key of preferencesResult.value.collapsedProjectGroups ?? []) {
261 const existing = next.get(key);
262 next.set(key, {
263 ...(existing ?? DEFAULT_GROUP_DISPLAY_STATE),
264 collapsed: true,
265 });
266 }
267 return next;
268 }, [groupDisplayStates, preferencesResult]);
269 const effectiveGroupDisplayStatesRef = useRef(effectiveGroupDisplayStates);
270 effectiveGroupDisplayStatesRef.current = effectiveGroupDisplayStates;
271
272 const updateGroupDisplay = useCallback(
273 (key: string, action: HomeGroupDisplayAction) => {
274 const next = new Map(effectiveGroupDisplayStatesRef.current);
275 next.set(key, nextGroupDisplayState(next.get(key) ?? DEFAULT_GROUP_DISPLAY_STATE, action));
276 effectiveGroupDisplayStatesRef.current = next;
277 setGroupDisplayStates(next);
278 if (action === "toggle-collapsed") {
279 const collapsedProjectGroups: string[] = [];
280 for (const [groupKey, state] of next) {
281 if (state.collapsed) {
282 collapsedProjectGroups.push(groupKey);
283 }
284 }
285 savePreferences({ collapsedProjectGroups });
286 }
287 },
288 [savePreferences],
289 );
290
291 const handleSwipeableWillOpen = useCallback((methods: SwipeableMethods) => {
292 if (openSwipeableRef.current !== methods) {
293 openSwipeableRef.current?.close();
294 openSwipeableRef.current = methods;
295 }
296 }, []);
297
298 const handleSwipeableClose = useCallback((methods: SwipeableMethods) => {
299 if (openSwipeableRef.current === methods) {
300 openSwipeableRef.current = null;
301 }
302 }, []);
303
304 const handleScrollBeginDrag = useCallback(() => {
305 openSwipeableRef.current?.close();
306 }, []);
307 const { swipeEnabled, scrollGateHandlers } = useSwipeableScrollGate({
308 onScrollBeginDrag: handleScrollBeginDrag,
309 });
310
311 const projectScopes = useMemo(
312 () =>
313 buildHomeProjectScopes({
314 projects: props.projects,
315 environmentId: props.selectedEnvironmentId,
316 projectGroupingMode: props.projectGroupingMode,
317 }),
318 [props.projectGroupingMode, props.projects, props.selectedEnvironmentId],
319 );
320 const selectedProjectScope = useMemo(
321 () =>
322 props.selectedProjectKey === null
323 ? null
324 : (projectScopes.find(
325 (scope) =>
326 scope.key === props.selectedProjectKey ||
327 scope.projectRefs.some(
328 (projectRef) =>
329 scopedProjectKey(projectRef.environmentId, projectRef.projectId) ===
330 props.selectedProjectKey,
331 ),
332 ) ?? null),
333 [projectScopes, props.selectedProjectKey],
334 );
335 const selectedProjectRefKeys = useMemo(
336 () =>
337 selectedProjectScope === null
338 ? null
339 : new Set(
340 selectedProjectScope.projectRefs.map((projectRef) =>
341 scopedProjectKey(projectRef.environmentId, projectRef.projectId),
342 ),
343 ),
344 [selectedProjectScope],
345 );
346 const scopedProjects = useMemo(
347 () =>
348 threadListV2Enabled
349 ? []
350 : selectedProjectRefKeys === null
351 ? props.projects
352 : props.projects.filter((project) =>
353 selectedProjectRefKeys.has(scopedProjectKey(project.environmentId, project.id)),
354 ),
355 [threadListV2Enabled, props.projects, selectedProjectRefKeys],
356 );
357 const scopedThreads = useMemo(
358 () =>
359 threadListV2Enabled
360 ? []
361 : selectedProjectRefKeys === null
362 ? props.threads
363 : props.threads.filter((thread) =>
364 selectedProjectRefKeys.has(scopedProjectKey(thread.environmentId, thread.projectId)),
365 ),
366 [threadListV2Enabled, props.threads, selectedProjectRefKeys],
367 );
368 const scopedPendingTasks = useMemo(
369 () =>
370 threadListV2Enabled
371 ? []
372 : selectedProjectRefKeys === null
373 ? props.pendingTasks
374 : props.pendingTasks.filter((pendingTask) =>
375 selectedProjectRefKeys.has(
376 scopedProjectKey(pendingTask.environmentId, pendingTask.projectId),
377 ),
378 ),
379 [threadListV2Enabled, props.pendingTasks, selectedProjectRefKeys],
380 );
381
382 const projectGroups = useMemo(
383 () =>
384 threadListV2Enabled
385 ? []
386 : buildHomeThreadGroups({
387 projects: scopedProjects,
388 threads: scopedThreads,
389 pendingTasks: scopedPendingTasks,
390 queuedThreadKeys,
391 environmentId: props.selectedEnvironmentId,
392 searchQuery: props.searchQuery,
393 matchedThreadKeys,
394 projectSortOrder: props.projectSortOrder,
395 threadSortOrder: props.threadSortOrder,
396 projectGroupingMode: props.projectGroupingMode,
397 }),
398 [
399 threadListV2Enabled,
400 queuedThreadKeys,
401 props.projectGroupingMode,
402 props.projectSortOrder,
403 props.searchQuery,
404 props.selectedEnvironmentId,
405 props.threadSortOrder,
406 matchedThreadKeys,
407 scopedPendingTasks,
408 scopedProjects,
409 scopedThreads,
410 ],
411 );
412
413 const hasSearchQuery = props.searchQuery.trim().length > 0;
414 const listLayout = useMemo(
415 () =>
416 threadListV2Enabled
417 ? EMPTY_HOME_LIST_LAYOUT
418 : buildHomeListLayout({
419 groups: projectGroups,
420 displayStates: effectiveGroupDisplayStates,
421 showAllThreads: hasSearchQuery,
422 }),
423 [threadListV2Enabled, projectGroups, effectiveGroupDisplayStates, hasSearchQuery],
424 );
425
426 const projectByKey = useMemo(() => {
427 const map = new Map<string, EnvironmentProject>();
428 for (const project of props.projects) {
429 map.set(scopedProjectKey(project.environmentId, project.id), project);
430 }
431 return map;
432 }, [props.projects]);
433
434 const v2ProjectScopeKey = props.selectedProjectKey;
435 const v2ScopeProjects = useMemo(
436 () =>
437 sortHomeProjectScopes({
438 scopes: projectScopes,
439 threads: props.threads,
440 pendingTasks: props.pendingTasks,
441 projectSortOrder: props.projectSortOrder,
442 }),
443 [
444 props.pendingTasks,
445 props.projects,
446 props.projectSortOrder,
447 props.selectedEnvironmentId,
448 props.threads,
449 projectScopes,
450 ],
451 );
452 const v2ScopedProjectGroup = useMemo(
453 () =>
454 v2ProjectScopeKey === null
455 ? null
456 : (v2ScopeProjects.find(
457 (scope) =>
458 scope.key === v2ProjectScopeKey ||
459 scope.projectRefs.some(
460 (projectRef) =>
461 scopedProjectKey(projectRef.environmentId, projectRef.projectId) ===
462 v2ProjectScopeKey,
463 ),
464 ) ?? null),
465 [v2ProjectScopeKey, v2ScopeProjects],
466 );
467 const v2ProjectTitleByProjectKey = useMemo(
468 () =>
469 new Map(
470 v2ScopeProjects.flatMap((scope) =>
471 scope.projectRefs.map(
472 (projectRef) =>
473 [
474 scopedProjectKey(projectRef.environmentId, projectRef.projectId),
475 scope.title,
476 ] as const,
477 ),
478 ),
479 ),
480 [v2ScopeProjects],
481 );
482 const v2ScopedProjectKeys = useMemo(
483 () =>
484 v2ScopedProjectGroup === null
485 ? null
486 : new Set(
487 v2ScopedProjectGroup.projectRefs.map((projectRef) =>
488 scopedProjectKey(projectRef.environmentId, projectRef.projectId),
489 ),
490 ),
491 [v2ScopedProjectGroup],
492 );
493 // Thread List v2 (beta): one flat list in creation order, no grouping.
494 // Settled threads collapse into a recency tail below the card block.
495 // Settled threads stay in the live shell stream (settled ≠ archived), so
496 // the partition works directly off live shells — no snapshot merging or
497 // optimistic holds.
498 const handleSettleThread = props.onSettleThread;
499 const handleSnoozeThread = useCallback(
500 (thread: EnvironmentThreadShell, snoozedUntil: string) => {
501 void props.onSnoozeThread(thread, snoozedUntil);
502 },
503 [props.onSnoozeThread],
504 );
505 const handleUnsnoozeThread = useCallback(
506 (thread: EnvironmentThreadShell) => {
507 void props.onUnsnoozeThread(thread);
508 },
509 [props.onUnsnoozeThread],
510 );
511 const handlePinThread = useCallback(
512 (thread: EnvironmentThreadShell) => {
513 void props.onPinThread(thread);
514 },
515 [props.onPinThread],
516 );
517 const handleMoveThread = useCallback(
518 (thread: EnvironmentThreadShell, direction: "up" | "down") => {
519 void props.onMoveThread(thread, direction);
520 },
521 [props.onMoveThread],
522 );
523 const handleUnpinThread = useCallback(
524 (thread: EnvironmentThreadShell) => {
525 void props.onUnpinThread(thread);
526 },
527 [props.onUnpinThread],
528 );
529 const handleRegenerateThreadTitle = useCallback(
530 (thread: EnvironmentThreadShell) => {
531 void props.onRegenerateThreadTitle(thread);
532 },
533 [props.onRegenerateThreadTitle],
534 );
535 const handleDeleteThread = props.onDeleteThread;
536 const handleUnsettleThread = props.onUnsettleThread;
537 // The settled tail renders in pages; expansion resets when the filter
538 // context changes so environment/search flips never inherit a deep page.
539 const [settledVisibleCount, setSettledVisibleCount] = useState(
540 THREAD_LIST_V2_SETTLED_INITIAL_COUNT,
541 );
542 const settledResetKey = `${props.selectedEnvironmentId ?? "all"}:${v2ProjectScopeKey ?? "all"}:${props.searchQuery.trim()}`;
543 const lastSettledResetKeyRef = useRef(settledResetKey);
544 if (lastSettledResetKeyRef.current !== settledResetKey) {
545 lastSettledResetKeyRef.current = settledResetKey;
546 setSettledVisibleCount(THREAD_LIST_V2_SETTLED_INITIAL_COUNT);
547 }
548 const showMoreSettled = useCallback(
549 () => setSettledVisibleCount((count) => count + THREAD_LIST_V2_SETTLED_PAGE_COUNT),
550 [],
551 );
552 const {
553 loaded: shelfPreferencesLoaded,
554 settledShelfExpanded,
555 snoozedShelfExpanded,
556 toggleSettledShelf,
557 toggleSnoozedShelf,
558 } = useThreadListV2ShelfPreferences();
559 // The queued-start and snooze helpers need a clock while the list stays open.
560 const [nowMinute, setNowMinute] = useState(() => new Date().toISOString().slice(0, 16));
561 // Snooze wake times are second-precise; a counter bumped exactly at the
562 // next wake boundary re-runs the partition with a fresh clock so a woken
563 // thread reappears immediately instead of on the next minute tick.
564 const [snoozeWakeTick, bumpSnoozeWakeTick] = useState(0);
565 useFocusEffect(
566 useCallback(() => {
567 if (!threadListV2Enabled) return;
568 // Refresh immediately on enable or focus because the previous value can be hours old.
569 setNowMinute(new Date().toISOString().slice(0, 16));
570 const id = setInterval(() => setNowMinute(new Date().toISOString().slice(0, 16)), 60_000);
571 return () => clearInterval(id);
572 }, [threadListV2Enabled]),
573 );
574 // Threads on servers without the settlement capability never classify as
575 // settled (the user could neither un-settle nor pin them).
576 const serverConfigs = useAtomValue(environmentServerConfigsAtom);
577 const settlementEnvironmentIds = useMemo(() => {
578 const supported = new Set<EnvironmentId>();
579 for (const [environmentId, config] of serverConfigs) {
580 if (config.environment.capabilities.threadSettlement === true) {
581 supported.add(environmentId);
582 }
583 }
584 return supported;
585 }, [serverConfigs]);
586 const snoozeEnvironmentIds = useMemo(() => {
587 const supported = new Set<EnvironmentId>();
588 for (const [environmentId, config] of serverConfigs) {
589 if (config.environment.capabilities.threadSnooze === true) {
590 supported.add(environmentId);
591 }
592 }
593 return supported;
594 }, [serverConfigs]);
595 const pinningEnvironmentIds = useMemo(() => {
596 const supported = new Set<EnvironmentId>();
597 for (const [environmentId, config] of serverConfigs) {
598 if (config.environment.capabilities.threadPinning === true) {
599 supported.add(environmentId);
600 }
601 }
602 return supported;
603 }, [serverConfigs]);
604 const pinReorderEnvironmentIds = useMemo(() => {
605 const supported = new Set<EnvironmentId>();
606 for (const [environmentId, config] of serverConfigs) {
607 if (config.environment.capabilities.threadPinReorder === true) {
608 supported.add(environmentId);
609 }
610 }
611 return supported;
612 }, [serverConfigs]);
613 const activeReorderEnvironmentIds = useMemo(() => {
614 const supported = new Set<EnvironmentId>();
615 for (const [environmentId, config] of serverConfigs) {
616 if (config.environment.capabilities.threadActiveReorder === true) {
617 supported.add(environmentId);
618 }
619 }
620 return supported;
621 }, [serverConfigs]);
622 const titleRegenerationEnvironmentIds = useMemo(() => {
623 const supported = new Set<EnvironmentId>();
624 for (const [environmentId, config] of serverConfigs) {
625 if (config.environment.capabilities.threadTitleRegeneration === true) {
626 supported.add(environmentId);
627 }
628 }
629 return supported;
630 }, [serverConfigs]);
631 const machineByEnvironmentId = useMemo(
632 () =>
633 new Map(
634 [...serverConfigs].map(
635 ([environmentId, config]) =>
636 [environmentId, resolveEnvironmentMachineKind(config)] as const,
637 ),
638 ),
639 [serverConfigs],
640 );
641 const pendingOrder = usePendingThreadOrder(nowMinute, snoozeWakeTick);
642 const threadMovePlanners = useMemo(() => {
643 const sectionPlanner = (section: "pinned" | "active") =>
644 createThreadMovePlanner({
645 allThreads: props.threads,
646 section,
647 reorderableEnvironmentIds: new Set(
648 [...serverConfigs].flatMap(([id, config]) =>
649 (section === "pinned"
650 ? config.environment.capabilities.threadPinReorder
651 : config.environment.capabilities.threadActiveReorder) === true
652 ? [id]
653 : [],
654 ),
655 ),
656 ordered: getThreadListV2OrderedSection({
657 threads: props.threads,
658 section,
659 pendingOrder,
660 now: new Date().toISOString(),
661 settlementEnvironmentIds,
662 snoozeEnvironmentIds,
663 queuedThreadKeys,
664 }),
665 });
666 return { pinned: sectionPlanner("pinned"), active: sectionPlanner("active") };
667 }, [
668 serverConfigs,
669 props.threads,
670 pendingOrder,
671 queuedThreadKeys,
672 settlementEnvironmentIds,
673 snoozeEnvironmentIds,
674 nowMinute,
675 snoozeWakeTick,
676 ]);
677 const threadListV2Layout = useMemo(() => {
678 if (!threadListV2Enabled)
679 return {
680 items: [],
681 hiddenSettledCount: 0,
682 snoozedCount: 0,
683 snoozedShelfHeaderIndex: null,
684 settledCount: 0,
685 settledShelfHeaderIndex: null,
686 nextSnoozeWakeAt: null,
687 };
688 // Settled threads are live shells; archived threads keep their original
689 // "hidden from lists" meaning.
690 return buildThreadListV2Items({
691 pendingOrder,
692 threads: props.threads.filter((thread) => thread.archivedAt === null),
693 environmentId: props.selectedEnvironmentId,
694 projectRefs: v2ScopedProjectGroup === null ? null : v2ScopedProjectGroup.projectRefs,
695 searchQuery: props.searchQuery,
696 matchedThreadKeys,
697 settlementEnvironmentIds,
698 snoozeEnvironmentIds,
699 queuedThreadKeys,
700 settledLimit: settledVisibleCount,
701 now: new Date().toISOString(),
702 snoozedShelfExpanded,
703 settledShelfExpanded,
704 selectedThreadKey: null,
705 });
706 }, [
707 pendingOrder,
708 queuedThreadKeys,
709 nowMinute,
710 snoozeWakeTick,
711 snoozedShelfExpanded,
712 settledShelfExpanded,
713 settledVisibleCount,
714 settlementEnvironmentIds,
715 snoozeEnvironmentIds,
716 props.searchQuery,
717 props.selectedEnvironmentId,
718 props.threads,
719 matchedThreadKeys,
720 threadListV2Enabled,
721 v2ScopedProjectGroup,
722 ]);
723 // Re-partition the moment the earliest snooze expires (clamped to the
724 // signed-32-bit setTimeout range; far-future wakes re-arm at the clamp).
725 const nextSnoozeWakeAt = threadListV2Layout.nextSnoozeWakeAt;
726 useEffect(() => {
727 if (nextSnoozeWakeAt === null) return;
728 const wakeAtMs = Date.parse(nextSnoozeWakeAt);
729 if (Number.isNaN(wakeAtMs)) return;
730 const delayMs = Math.min(Math.max(0, wakeAtMs - Date.now()) + 50, 2_147_483_647);
731 const id = setTimeout(() => bumpSnoozeWakeTick((tick) => tick + 1), delayMs);
732 return () => clearTimeout(id);
733 // snoozeWakeTick must re-arm the timer even when nextSnoozeWakeAt is
734 // unchanged: after a clamped fire (wake beyond the 32-bit setTimeout
735 // range) the boundary string is identical and the chain would die.
736 }, [nextSnoozeWakeAt, snoozeWakeTick]);
737 // Queued tasks are not thread shells, so the v2 partition never sees them;
738 // they are spliced in below the active block and stay visible and deletable
739 // while their environment is offline. Same environment scope and search
740 // filter as the list itself.
741 const v2SearchQuery = props.searchQuery.trim().toLocaleLowerCase();
742 const v2PendingTasks = useMemo(
743 () =>
744 props.pendingTasks.filter(
745 (pendingTask) =>
746 (props.selectedEnvironmentId === null ||
747 pendingTask.environmentId === props.selectedEnvironmentId) &&
748 (v2ScopedProjectKeys === null ||
749 v2ScopedProjectKeys.has(
750 scopedProjectKey(pendingTask.environmentId, pendingTask.projectId),
751 )) &&
752 (v2SearchQuery.length === 0 ||
753 pendingTask.title.toLocaleLowerCase().includes(v2SearchQuery)),
754 ),
755 [props.pendingTasks, props.selectedEnvironmentId, v2ScopedProjectKeys, v2SearchQuery],
756 );
757 const threadListV2Items = useMemo(
758 () =>
759 buildThreadListV2ListItems({
760 items: threadListV2Layout.items,
761 pendingTasks: v2PendingTasks,
762 snoozedCount: threadListV2Layout.snoozedCount,
763 snoozedShelfExpanded,
764 snoozedShelfHeaderIndex: threadListV2Layout.snoozedShelfHeaderIndex,
765 settledCount: threadListV2Layout.settledCount,
766 settledShelfExpanded,
767 settledShelfHeaderIndex: threadListV2Layout.settledShelfHeaderIndex,
768 snoozeLabelNow: `${nowMinute}:00.000Z`,
769 }),
770 [settledShelfExpanded, snoozedShelfExpanded, threadListV2Layout, v2PendingTasks],
771 );
772
773 const renderV2Item = useCallback(
774 ({ item, index }: { readonly item: ThreadListV2ListItem; readonly index: number }) => {
775 const nextItem = threadListV2Items[index + 1];
776 const showTrailingDivider =
777 nextItem?.type === "v2-thread" ||
778 (nextItem?.type === "v2-pending" && !nextItem.showPendingDivider);
779 if (item.type === "v2-pending") {
780 const pendingScopeKey = scopedProjectKey(
781 item.pendingTask.environmentId,
782 item.pendingTask.projectId,
783 );
784 return (
785 <ThreadListV2PendingRow
786 pendingTask={item.pendingTask}
787 project={projectByKey.get(pendingScopeKey) ?? null}
788 projectTitle={v2ProjectTitleByProjectKey.get(pendingScopeKey)}
789 environmentLabel={
790 Object.keys(props.savedConnectionsById).length > 1
791 ? (props.savedConnectionsById[item.pendingTask.environmentId]?.environmentLabel ??
792 null)
793 : null
794 }
795 environmentMachine={machineByEnvironmentId.get(item.pendingTask.environmentId)}
796 showPendingDivider={item.showPendingDivider}
797 showTrailingDivider={showTrailingDivider}
798 onSelectPendingTask={props.onSelectPendingTask}
799 onDeletePendingTask={props.onDeletePendingTask}
800 />
801 );
802 }
803 if (item.type === "v2-snoozed-shelf") {
804 return (
805 <ThreadListV2SnoozedShelfHeader
806 count={item.count}
807 disabled={!shelfPreferencesLoaded}
808 expanded={item.expanded}
809 onToggle={toggleSnoozedShelf}
810 />
811 );
812 }
813 if (item.type === "v2-settled-shelf") {
814 return (
815 <ThreadListV2SettledShelfHeader
816 count={item.count}
817 disabled={!shelfPreferencesLoaded}
818 expanded={item.expanded}
819 onToggle={toggleSettledShelf}
820 />
821 );
822 }
823 const thread = item.item.thread;
824 const movePlanner = item.item.pinned ? threadMovePlanners.pinned : threadMovePlanners.active;
825 const movedId = `${thread.environmentId}:${thread.id}`;
826 return (
827 <ThreadListV2Row
828 onNewThreadOnBranch={props.onNewThreadOnBranch}
829 thread={thread}
830 variant={item.item.variant}
831 hasQueuedMessages={queuedThreadKeys.has(movedId)}
832 snoozed={item.item.snoozed}
833 pinned={item.item.pinned}
834 snoozePresetMinute={nowMinute}
835 snoozeWakeLabelText={item.snoozeWakeLabelText}
836 showTrailingDivider={showTrailingDivider}
837 project={
838 projectByKey.get(scopedProjectKey(thread.environmentId, thread.projectId)) ?? null
839 }
840 projectTitle={v2ProjectTitleByProjectKey.get(
841 scopedProjectKey(thread.environmentId, thread.projectId),
842 )}
843 providerDriver={
844 serverConfigs
845 .get(thread.environmentId)
846 ?.providers.find(
847 (provider) =>
848 provider.instanceId ===
849 (thread.session?.providerInstanceId ?? thread.modelSelection.instanceId),
850 )?.driver ?? null
851 }
852 environmentLabel={
853 Object.keys(props.savedConnectionsById).length > 1
854 ? (props.savedConnectionsById[thread.environmentId]?.environmentLabel ?? null)
855 : null
856 }
857 environmentMachine={machineByEnvironmentId.get(thread.environmentId)}
858 searchMatch={threadSearchMatchByKey.get(
859 threadSearchMatchKey({
860 environmentId: thread.environmentId,
861 threadId: thread.id,
862 }),
863 )}
864 searchQuery={props.searchQuery}
865 onSelectThread={props.onSelectThread}
866 onDeleteThread={handleDeleteThread}
867 onArchiveThread={props.onArchiveThread}
868 onRegenerateThreadTitle={handleRegenerateThreadTitle}
869 titleRegenerationSupported={titleRegenerationEnvironmentIds.has(thread.environmentId)}
870 settlementSupported={settlementEnvironmentIds.has(thread.environmentId)}
871 onSettleThread={handleSettleThread}
872 snoozeSupported={snoozeEnvironmentIds.has(thread.environmentId)}
873 pinningSupported={pinningEnvironmentIds.has(thread.environmentId)}
874 reorderSupported={
875 item.item.pinned
876 ? pinReorderEnvironmentIds.has(thread.environmentId)
877 : activeReorderEnvironmentIds.has(thread.environmentId)
878 }
879 canMoveUp={pendingOrder === null && movePlanner(movedId, "up") !== null}
880 canMoveDown={pendingOrder === null && movePlanner(movedId, "down") !== null}
881 onSnoozeThread={handleSnoozeThread}
882 onUnsnoozeThread={handleUnsnoozeThread}
883 onUnsettleThread={handleUnsettleThread}
884 onPinThread={handlePinThread}
885 onUnpinThread={handleUnpinThread}
886 onMoveThread={handleMoveThread}
887 onSwipeableClose={handleSwipeableClose}
888 onSwipeableWillOpen={handleSwipeableWillOpen}
889 />
890 );
891 },
892 [
893 handleDeleteThread,
894 activeReorderEnvironmentIds,
895 threadMovePlanners,
896 pendingOrder,
897 queuedThreadKeys,
898 handleMoveThread,
899 handlePinThread,
900 handleRegenerateThreadTitle,
901 handleSettleThread,
902 handleSnoozeThread,
903 handleUnpinThread,
904 handleUnsnoozeThread,
905 handleSwipeableClose,
906 handleSwipeableWillOpen,
907 handleUnsettleThread,
908 pinningEnvironmentIds,
909 machineByEnvironmentId,
910 pinReorderEnvironmentIds,
911 projectByKey,
912 props.onArchiveThread,
913 props.onDeletePendingTask,
914 props.onSelectPendingTask,
915 props.onSelectThread,
916 props.onNewThreadOnBranch,
917 props.savedConnectionsById,
918 serverConfigs,
919 shelfPreferencesLoaded,
920 settlementEnvironmentIds,
921 snoozeEnvironmentIds,
922 threadListV2Items,
923 threadSearchMatchByKey,
924 titleRegenerationEnvironmentIds,
925 toggleSettledShelf,
926 toggleSnoozedShelf,
927 v2ProjectTitleByProjectKey,
928 props.searchQuery,
929 nowMinute,
930 ],
931 );
932 const v2KeyExtractor = useCallback((item: ThreadListV2ListItem) => item.key, []);
933
934 // FlatList treats a changed extraData identity as "re-render every visible
935 // row", so an inline object literal would invalidate all rows on every
936 // HomeScreen render.
937 const v2ExtraData = useMemo(
938 () => ({
939 projectByKey,
940 projectTitleByProjectKey: v2ProjectTitleByProjectKey,
941 serverConfigs,
942 savedConnectionsById: props.savedConnectionsById,
943 searchQuery: props.searchQuery,
944 snoozePresetMinute: nowMinute,
945 threadSearchMatchByKey,
946 }),
947 [
948 projectByKey,
949 props.searchQuery,
950 props.savedConnectionsById,
951 serverConfigs,
952 nowMinute,
953 threadSearchMatchByKey,
954 v2ProjectTitleByProjectKey,
955 ],
956 );
957
958 const extraData = useMemo(
959 () => ({
960 savedConnectionsById: props.savedConnectionsById,
961 searchQuery: props.searchQuery,
962 threadSearchMatchByKey,
963 }),
964 [props.savedConnectionsById, props.searchQuery, threadSearchMatchByKey],
965 );
966
967 const renderItem = useCallback(
968 ({ item }: LegendListRenderItemProps<HomeListItem>) => {
969 switch (item.type) {
970 case "header":
971 return (
972 <ThreadListGroupHeader
973 variant="compact"
974 collapsed={item.collapsed}
975 isFirst={item.isFirst}
976 groupKey={item.group.key}
977 onGroupAction={updateGroupDisplay}
978 // Aggregated groups (same repo across machines) have no single
979 // target project, and `pending-project:` groups hold a placeholder
980 // built from queued-task metadata rather than a real project shell,
981 // so the quick new-thread button is single-real-project only.
982 newThreadTarget={item.group.newThreadTarget}
983 onNewThread={props.onNewThreadInProject}
984 project={item.group.representative}
985 threadCount={item.group.threads.length + item.group.pendingTasks.length}
986 title={item.group.title}
987 />
988 );
989 case "pending-task":
990 return (
991 <PendingTaskListRow
992 variant="compact"
993 pendingTask={item.pendingTask}
994 environmentLabel={
995 props.savedConnectionsById[item.pendingTask.environmentId]?.environmentLabel ?? null
996 }
997 environmentMachine={machineByEnvironmentId.get(item.pendingTask.environmentId)}
998 isLast={item.isLast}
999 onSelectPendingTask={props.onSelectPendingTask}
1000 onDeletePendingTask={props.onDeletePendingTask}
1001 />
1002 );
1003 case "thread": {
1004 const thread = item.thread;
1005 return (
1006 <ThreadListRow
1007 onNewThreadOnBranch={props.onNewThreadOnBranch}
1008 variant="compact"
1009 thread={thread}
1010 hasQueuedMessages={queuedThreadKeys.has(`${thread.environmentId}:${thread.id}`)}
1011 environmentLabel={
1012 props.savedConnectionsById[thread.environmentId]?.environmentLabel ?? null
1013 }
1014 environmentMachine={machineByEnvironmentId.get(thread.environmentId)}
1015 isLast={item.isLast}
1016 searchMatch={threadSearchMatchByKey.get(
1017 threadSearchMatchKey({
1018 environmentId: thread.environmentId,
1019 threadId: thread.id,
1020 }),
1021 )}
1022 searchQuery={props.searchQuery}
1023 onArchiveThread={props.onArchiveThread}
1024 onDeleteThread={props.onDeleteThread}
1025 onRegenerateThreadTitle={handleRegenerateThreadTitle}
1026 titleRegenerationSupported={titleRegenerationEnvironmentIds.has(thread.environmentId)}
1027 onSelectThread={props.onSelectThread}
1028 onSwipeableClose={handleSwipeableClose}
1029 onSwipeableWillOpen={handleSwipeableWillOpen}
1030 />
1031 );
1032 }
1033 case "show-more":
1034 return (
1035 <ThreadListShowMoreRow
1036 variant="compact"
1037 hiddenCount={item.hiddenCount}
1038 canShowLess={item.canShowLess}
1039 groupKey={item.groupKey}
1040 onGroupAction={updateGroupDisplay}
1041 />
1042 );
1043 }
1044 },
1045 [
1046 handleSwipeableClose,
1047 handleSwipeableWillOpen,
1048 handleRegenerateThreadTitle,
1049 machineByEnvironmentId,
1050 queuedThreadKeys,
1051 props.onArchiveThread,
1052 props.onDeletePendingTask,
1053 props.onDeleteThread,
1054 props.onNewThreadInProject,
1055 props.onSelectPendingTask,
1056 props.onSelectThread,
1057 props.onNewThreadOnBranch,
1058 props.searchQuery,
1059 props.savedConnectionsById,
1060 threadSearchMatchByKey,
1061 titleRegenerationEnvironmentIds,
1062 updateGroupDisplay,
1063 ],
1064 );
1065
1066 const keyExtractor = useCallback((item: HomeListItem) => item.key, []);
1067
1068 /* Empty states */
1069 // The signal must ignore the search/environment filters: an active query
1070 // that matches nothing needs the in-list "No results" state, not the
1071 // full-page "No threads yet". Settled threads are unarchived live shells,
1072 // so the v1 check already covers v2.
1073 const hasAnyThreads =
1074 props.threads.some((thread) => thread.archivedAt === null) || props.pendingTasks.length > 0;
1075 const hasResults = threadListV2Enabled ? threadListV2Items.length > 0 : projectGroups.length > 0;
1076 const selectedEnvironmentLabel =
1077 props.selectedEnvironmentId === null
1078 ? null
1079 : (props.savedConnectionsById[props.selectedEnvironmentId]?.environmentLabel ??
1080 "this environment");
1081 // Connection state surfaces in the header title slot
1082 // (WorkspaceConnectionTitle) — nothing renders inside the list, so
1083 // reconnects never shift the rows.
1084 const emptyState = deriveEmptyState({
1085 catalogState: props.catalogState,
1086 projectCount: props.projects.length,
1087 });
1088
1089 if (!hasAnyThreads) {
1090 return (
1091 <View
1092 className="flex-1 items-center justify-center bg-screen px-8"
1093 style={{
1094 paddingBottom: Math.max(insets.bottom, 24) + iosBottomToolbarClearance,
1095 paddingTop: NATIVE_LIQUID_GLASS_SUPPORTED ? insets.top + 72 : 0,
1096 }}
1097 >
1098 <View className="w-full max-w-[430px]">
1099 <EmptyState
1100 title={emptyState.title}
1101 detail={emptyState.detail}
1102 actionLabel={!props.catalogState.hasReadyEnvironment ? "Add environment" : undefined}
1103 onAction={!props.catalogState.hasReadyEnvironment ? props.onAddConnection : undefined}
1104 variant="plain"
1105 />
1106 {emptyState.loading ? (
1107 <View className="mt-4 items-center">
1108 <ActivityIndicator colorClassName={"accent-icon-muted"} />
1109 </View>
1110 ) : null}
1111 </View>
1112 </View>
1113 );
1114 }
1115
1116 const listHeader = Platform.OS === "ios" ? null : <HomeTopContentSpacer />;
1117
1118 // Project scoping lives in the header filter menu (no inline chip row on
1119 // mobile — the menu is the one filter surface).
1120 const v2ListHeader = listHeader;
1121
1122 const listEmpty = !hasResults ? (
1123 hasSearchQuery && threadSearch.isPending ? null : hasSearchQuery ? (
1124 <EmptyState title="No results" detail={`No threads matching "${props.searchQuery}".`} />
1125 ) : selectedProjectScope !== null ? (
1126 <EmptyState
1127 title={`No threads in ${selectedProjectScope.title}`}
1128 detail="Choose another project or create a new task."
1129 />
1130 ) : selectedEnvironmentLabel ? (
1131 <EmptyState
1132 title={`No threads in ${selectedEnvironmentLabel}`}
1133 detail="Choose another environment or create a new task."
1134 />
1135 ) : (
1136 <EmptyState title="No threads yet" detail="Create a task to start a new coding session." />
1137 )
1138 ) : null;
1139 // Use the v2 project scope for its empty state. Snoozed threads need no
1140 // special empty state: their shelf header is a list row even while collapsed.
1141 const v2ListEmpty =
1142 hasSearchQuery && threadSearch.isPending ? null : hasSearchQuery ? (
1143 <EmptyState title="No results" detail={`No threads matching "${props.searchQuery}".`} />
1144 ) : v2ScopedProjectGroup !== null ? (
1145 <EmptyState
1146 title={`No threads in ${v2ScopedProjectGroup.title}`}
1147 detail="Choose another project or create a new task."
1148 />
1149 ) : (
1150 listEmpty
1151 );
1152
1153 if (threadListV2Enabled) {
1154 return (
1155 <View className="flex-1 bg-screen">
1156 <SwipeableScrollGateProvider enabled={swipeEnabled}>
1157 <FlatList
1158 data={threadListV2Items}
1159 renderItem={renderV2Item}
1160 keyExtractor={v2KeyExtractor}
1161 extraData={v2ExtraData}
1162 ListHeaderComponent={v2ListHeader}
1163 ListFooterComponent={
1164 settledShelfExpanded && threadListV2Layout.hiddenSettledCount > 0 ? (
1165 <Pressable
1166 accessibilityRole="button"
1167 accessibilityLabel={`Show ${Math.min(threadListV2Layout.hiddenSettledCount, THREAD_LIST_V2_SETTLED_PAGE_COUNT)} more settled threads`}
1168 onPress={showMoreSettled}
1169 className="mx-4 mt-2 items-center rounded-lg border border-dashed border-border py-2.5"
1170 style={({ pressed }) => ({ opacity: pressed ? 0.6 : 1 })}
1171 >
1172 <Text className="text-xs font-t3-medium text-foreground-muted">
1173 Show more ({threadListV2Layout.hiddenSettledCount} settled hidden)
1174 </Text>
1175 </Pressable>
1176 ) : null
1177 }
1178 ListEmptyComponent={v2ListEmpty}
1179 style={{ flex: 1 }}
1180 automaticallyAdjustsScrollIndicatorInsets={Platform.OS === "ios"}
1181 contentInsetAdjustmentBehavior={Platform.OS === "ios" ? "automatic" : "never"}
1182 showsVerticalScrollIndicator={false}
1183 keyboardDismissMode="on-drag"
1184 keyboardShouldPersistTaps="handled"
1185 {...scrollGateHandlers}
1186 scrollEventThrottle={16}
1187 contentContainerStyle={{
1188 paddingBottom:
1189 Platform.OS === "ios"
1190 ? Math.max(insets.bottom, 24) + 96 + iosBottomToolbarClearance
1191 : Math.max(insets.bottom, 16) + 88,
1192 }}
1193 />
1194 </SwipeableScrollGateProvider>
1195 </View>
1196 );
1197 }
1198
1199 return (
1200 <View className="flex-1 bg-screen">
1201 {/* Sticky headers are deliberately not wired up: LegendList's JS sticky
1202 implementation mispositions pinned headers at mount under iOS
1203 automatic content insets (headers render one nav-inset too low until
1204 the first scroll event) and blanks non-pinned headers after
1205 collapse/expand data changes. The flattened layout still exposes
1206 `stickyHeaderIndices` if this gets revisited. */}
1207 <SwipeableScrollGateProvider enabled={swipeEnabled}>
1208 <LegendList
1209 ref={listRef}
1210 data={listLayout.items}
1211 renderItem={renderItem}
1212 keyExtractor={keyExtractor}
1213 itemsAreEqual={homeListItemsAreEqual}
1214 drawDistance={500}
1215 estimatedItemSize={ESTIMATED_THREAD_ROW_HEIGHT}
1216 extraData={extraData}
1217 ListHeaderComponent={listHeader}
1218 ListEmptyComponent={listEmpty}
1219 style={{ flex: 1 }}
1220 automaticallyAdjustsScrollIndicatorInsets={NATIVE_LIQUID_GLASS_SUPPORTED}
1221 contentInsetAdjustmentBehavior={NATIVE_LIQUID_GLASS_SUPPORTED ? "automatic" : "never"}
1222 showsVerticalScrollIndicator={false}
1223 keyboardDismissMode="on-drag"
1224 keyboardShouldPersistTaps="handled"
1225 {...scrollGateHandlers}
1226 recycleItems
1227 scrollEventThrottle={16}
1228 contentContainerStyle={{
1229 // Android reserves room for the floating new-task FAB
1230 // (56 button + 16 gap + bottom inset). Pre-glass iOS shows a
1231 // standard 44pt bottom toolbar that overlays the list and is not
1232 // reflected in insets while contentInsetAdjustmentBehavior is
1233 // "never".
1234 paddingBottom:
1235 Platform.OS === "ios"
1236 ? Math.max(insets.bottom, 24) + 24 + iosBottomToolbarClearance
1237 : Math.max(insets.bottom, 16) + 88,
1238 }}
1239 scrollIndicatorInsets={
1240 Platform.OS === "ios"
1241 ? {
1242 bottom: Math.max(insets.bottom, 16) + 24 + iosBottomToolbarClearance,
1243 top: 0,
1244 }
1245 : undefined
1246 }
1247 />
1248 </SwipeableScrollGateProvider>
1249 </View>
1250 );
1251}