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