Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

HomeScreen.tsx

1,234 lines46.1 KB

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