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