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

HomeScreen.tsx

1,236 lines46.2 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";
26import { useThemeColor } from "../../lib/useThemeColor";
27​
28import { AppText as Text } from "../../components/AppText";
29import { EmptyState } from "../../components/EmptyState";
30import type { WorkspaceEnvironment, WorkspaceState } from "../../state/workspaceModel";
31import type { SavedRemoteConnection } from "../../lib/connection";
32import { scopedProjectKey } from "../../lib/scopedEntities";
33import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass";
34import { mobilePreferencesAtom, updateMobilePreferencesAtom } from "../../state/preferences";
35import { useThreadSearch } from "../../state/queries";
36import { useThreadListV2Enabled } from "../threads/use-thread-list-v2-enabled";
37import { environmentServerConfigsAtom } from "../../state/server";
38import type { PendingNewTask } from "../../state/use-pending-new-tasks";
39import {
40 PendingTaskListRow,
41 ThreadListGroupHeader,
42 ThreadListRow,
43 ThreadListShowMoreRow,
44} from "../threads/thread-list-items";
45import {
46 ThreadListV2PendingRow,
47 ThreadListV2Row,
48 ThreadListV2SettledShelfHeader,
49 ThreadListV2SnoozedShelfHeader,
50} from "../threads/thread-list-v2-items";
51import {
52 buildThreadListV2Items,
53 buildThreadListV2ListItems,
54 THREAD_LIST_V2_SETTLED_INITIAL_COUNT,
55 THREAD_LIST_V2_SETTLED_PAGE_COUNT,
56 type ThreadListV2ChangeRequestState,
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;
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 };
199​
200function HomeTopContentSpacer() {
201 return <View className="h-4" />;
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, ThreadListV2ChangeRequestState>
495 >(() => new Map());
496 const handleChangeRequestState = useCallback(
497 (threadKey: string, changeRequest: ThreadListV2ChangeRequestState | 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 (existing?.linkedPullRequestKey ?? null) === (changeRequest?.linkedPullRequestKey ?? null)
504 ) {
505 return current;
506 }
507 const next = new Map(current);
508 if (changeRequest === null) {
509 next.delete(threadKey);
510 } else {
511 next.set(threadKey, changeRequest);
512 }
513 return next;
514 });
515 },
516 [],
517 );
518 const handleSettleThread = useCallback(
519 (thread: EnvironmentThreadShell) => {
520 void props.onSettleThread(thread);
521 },
522 [props.onSettleThread],
523 );
524 const handleSnoozeThread = useCallback(
525 (thread: EnvironmentThreadShell, snoozedUntil: string) => {
526 void props.onSnoozeThread(thread, snoozedUntil);
527 },
528 [props.onSnoozeThread],
529 );
530 const handleUnsnoozeThread = useCallback(
531 (thread: EnvironmentThreadShell) => {
532 void props.onUnsnoozeThread(thread);
533 },
534 [props.onUnsnoozeThread],
535 );
536 const handlePinThread = useCallback(
537 (thread: EnvironmentThreadShell) => {
538 void props.onPinThread(thread);
539 },
540 [props.onPinThread],
541 );
542 const handleMovePinnedThread = useCallback(
543 (thread: EnvironmentThreadShell, direction: "up" | "down") => {
544 void props.onMovePinnedThread(thread, direction);
545 },
546 [props.onMovePinnedThread],
547 );
548 const handleUnpinThread = useCallback(
549 (thread: EnvironmentThreadShell) => {
550 void props.onUnpinThread(thread);
551 },
552 [props.onUnpinThread],
553 );
554 const handleRegenerateThreadTitle = useCallback(
555 (thread: EnvironmentThreadShell) => {
556 void props.onRegenerateThreadTitle(thread);
557 },
558 [props.onRegenerateThreadTitle],
559 );
560 const handleDeleteThread = props.onDeleteThread;
561 const handleUnsettleThread = props.onUnsettleThread;
562 // The settled tail renders in pages; expansion resets when the filter
563 // context changes so environment/search flips never inherit a deep page.
564 const [settledVisibleCount, setSettledVisibleCount] = useState(
565 THREAD_LIST_V2_SETTLED_INITIAL_COUNT,
566 );
567 const settledResetKey = `${props.selectedEnvironmentId ?? "all"}:${v2ProjectScopeKey ?? "all"}:${props.searchQuery.trim()}`;
568 const lastSettledResetKeyRef = useRef(settledResetKey);
569 if (lastSettledResetKeyRef.current !== settledResetKey) {
570 lastSettledResetKeyRef.current = settledResetKey;
571 setSettledVisibleCount(THREAD_LIST_V2_SETTLED_INITIAL_COUNT);
572 }
573 const showMoreSettled = useCallback(
574 () => setSettledVisibleCount((count) => count + THREAD_LIST_V2_SETTLED_PAGE_COUNT),
575 [],
576 );
577 const {
578 loaded: shelfPreferencesLoaded,
579 settledShelfExpanded,
580 snoozedShelfExpanded,
581 toggleSettledShelf,
582 toggleSnoozedShelf,
583 } = useThreadListV2ShelfPreferences();
584 // now is quantized to the minute and ticks so the inactivity auto-settle
585 // boundary is actually crossed while the app stays open (mirrors web);
586 // without a clock dependency the partition memoizes a frozen "now".
587 const [nowMinute, setNowMinute] = useState(() => new Date().toISOString().slice(0, 16));
588 // Snooze wake times are second-precise; a counter bumped exactly at the
589 // next wake boundary re-runs the partition with a fresh clock so a woken
590 // thread reappears immediately instead of on the next minute tick.
591 const [snoozeWakeTick, bumpSnoozeWakeTick] = useState(0);
592 useEffect(() => {
593 if (!threadListV2Enabled) return;
594 // Refresh immediately on enable: the mount-time value can be hours old
595 // by the time the beta is switched on, which would misclassify the
596 // inactivity auto-settle boundary until the first tick.
597 setNowMinute(new Date().toISOString().slice(0, 16));
598 const id = setInterval(() => setNowMinute(new Date().toISOString().slice(0, 16)), 60_000);
599 return () => clearInterval(id);
600 }, [threadListV2Enabled]);
601 // Threads on servers without the settlement capability never classify as
602 // settled (the user could neither un-settle nor pin them).
603 const serverConfigs = useAtomValue(environmentServerConfigsAtom);
604 const settlementEnvironmentIds = useMemo(() => {
605 const supported = new Set<EnvironmentId>();
606 for (const [environmentId, config] of serverConfigs) {
607 if (config.environment.capabilities.threadSettlement === true) {
608 supported.add(environmentId);
609 }
610 }
611 return supported;
612 }, [serverConfigs]);
613 const snoozeEnvironmentIds = useMemo(() => {
614 const supported = new Set<EnvironmentId>();
615 for (const [environmentId, config] of serverConfigs) {
616 if (config.environment.capabilities.threadSnooze === true) {
617 supported.add(environmentId);
618 }
619 }
620 return supported;
621 }, [serverConfigs]);
622 const pinningEnvironmentIds = useMemo(() => {
623 const supported = new Set<EnvironmentId>();
624 for (const [environmentId, config] of serverConfigs) {
625 if (config.environment.capabilities.threadPinning === true) {
626 supported.add(environmentId);
627 }
628 }
629 return supported;
630 }, [serverConfigs]);
631 const pinReorderEnvironmentIds = useMemo(() => {
632 const supported = new Set<EnvironmentId>();
633 for (const [environmentId, config] of serverConfigs) {
634 if (config.environment.capabilities.threadPinReorder === true) {
635 supported.add(environmentId);
636 }
637 }
638 return supported;
639 }, [serverConfigs]);
640 const titleRegenerationEnvironmentIds = useMemo(() => {
641 const supported = new Set<EnvironmentId>();
642 for (const [environmentId, config] of serverConfigs) {
643 if (config.environment.capabilities.threadTitleRegeneration === true) {
644 supported.add(environmentId);
645 }
646 }
647 return supported;
648 }, [serverConfigs]);
649 // Canonical arranged pinned order (reorder-capable threads only) for the
650 // Move up/down position flags. Computed from all shells, not the rendered
651 // list, so search/scope filtering never disables or misdirects a move.
652 const arrangedPinnedKeys = useMemo(() => {
653 const pinned = sortPinnedThreadsByOrderKey(
654 props.threads.filter(
655 (thread) =>
656 thread.pinnedAt != null &&
657 thread.archivedAt === null &&
658 pinReorderEnvironmentIds.has(thread.environmentId),
659 ),
660 );
661 return pinned.map((thread) => `${thread.environmentId}:${thread.id}`);
662 }, [pinReorderEnvironmentIds, props.threads]);
663 const threadListV2Layout = useMemo(() => {
664 if (!threadListV2Enabled)
665 return {
666 items: [],
667 hiddenSettledCount: 0,
668 snoozedCount: 0,
669 snoozedShelfHeaderIndex: null,
670 settledCount: 0,
671 settledShelfHeaderIndex: null,
672 nextSnoozeWakeAt: null,
673 };
674 // Settled threads are live shells; archived threads keep their original
675 // "hidden from lists" meaning.
676 return buildThreadListV2Items({
677 threads: props.threads.filter((thread) => thread.archivedAt === null),
678 environmentId: props.selectedEnvironmentId,
679 projectRefs: v2ScopedProjectGroup === null ? null : v2ScopedProjectGroup.projectRefs,
680 searchQuery: props.searchQuery,
681 matchedThreadKeys,
682 changeRequestByKey,
683 autoSettleOnMerge,
684 settlementEnvironmentIds,
685 snoozeEnvironmentIds,
686 settledLimit: settledVisibleCount,
687 now: `${nowMinute}:00.000Z`,
688 snoozeNow: new Date().toISOString(),
689 snoozedShelfExpanded,
690 settledShelfExpanded,
691 selectedThreadKey: null,
692 });
693 }, [
694 changeRequestByKey,
695 autoSettleOnMerge,
696 nowMinute,
697 snoozeWakeTick,
698 snoozedShelfExpanded,
699 settledShelfExpanded,
700 settledVisibleCount,
701 settlementEnvironmentIds,
702 snoozeEnvironmentIds,
703 props.searchQuery,
704 props.selectedEnvironmentId,
705 props.threads,
706 matchedThreadKeys,
707 threadListV2Enabled,
708 v2ScopedProjectGroup,
709 ]);
710 // Re-partition the moment the earliest snooze expires (clamped to the
711 // signed-32-bit setTimeout range; far-future wakes re-arm at the clamp).
712 const nextSnoozeWakeAt = threadListV2Layout.nextSnoozeWakeAt;
713 useEffect(() => {
714 if (nextSnoozeWakeAt === null) return;
715 const wakeAtMs = Date.parse(nextSnoozeWakeAt);
716 if (Number.isNaN(wakeAtMs)) return;
717 const delayMs = Math.min(Math.max(0, wakeAtMs - Date.now()) + 50, 2_147_483_647);
718 const id = setTimeout(() => bumpSnoozeWakeTick((tick) => tick + 1), delayMs);
719 return () => clearTimeout(id);
720 // snoozeWakeTick must re-arm the timer even when nextSnoozeWakeAt is
721 // unchanged: after a clamped fire (wake beyond the 32-bit setTimeout
722 // range) the boundary string is identical and the chain would die.
723 }, [nextSnoozeWakeAt, snoozeWakeTick]);
724 // Queued tasks are not thread shells, so the v2 partition never sees them;
725 // they are spliced in below the active block and stay visible and deletable
726 // while their environment is offline. Same environment scope and search
727 // filter as the list itself.
728 const v2SearchQuery = props.searchQuery.trim().toLocaleLowerCase();
729 const v2PendingTasks = useMemo(
730 () =>
731 props.pendingTasks.filter(
732 (pendingTask) =>
733 (props.selectedEnvironmentId === null ||
734 pendingTask.message.environmentId === props.selectedEnvironmentId) &&
735 (v2ScopedProjectKeys === null ||
736 v2ScopedProjectKeys.has(
737 scopedProjectKey(pendingTask.message.environmentId, pendingTask.creation.projectId),
738 )) &&
739 (v2SearchQuery.length === 0 ||
740 pendingTask.title.toLocaleLowerCase().includes(v2SearchQuery)),
741 ),
742 [props.pendingTasks, props.selectedEnvironmentId, v2ScopedProjectKeys, v2SearchQuery],
743 );
744 const threadListV2Items = useMemo(
745 () =>
746 buildThreadListV2ListItems({
747 items: threadListV2Layout.items,
748 pendingTasks: v2PendingTasks,
749 snoozedCount: threadListV2Layout.snoozedCount,
750 snoozedShelfExpanded,
751 snoozedShelfHeaderIndex: threadListV2Layout.snoozedShelfHeaderIndex,
752 settledCount: threadListV2Layout.settledCount,
753 settledShelfExpanded,
754 settledShelfHeaderIndex: threadListV2Layout.settledShelfHeaderIndex,
755 snoozeLabelNow: `${nowMinute}:00.000Z`,
756 }),
757 [settledShelfExpanded, snoozedShelfExpanded, threadListV2Layout, v2PendingTasks],
758 );
759​
760 const renderV2Item = useCallback(
761 ({ item, index }: { readonly item: ThreadListV2ListItem; readonly index: number }) => {
762 const nextItem = threadListV2Items[index + 1];
763 const showTrailingDivider =
764 nextItem?.type === "v2-thread" ||
765 (nextItem?.type === "v2-pending" && !nextItem.showPendingDivider);
766 if (item.type === "v2-pending") {
767 const pendingScopeKey = scopedProjectKey(
768 item.pendingTask.message.environmentId,
769 item.pendingTask.creation.projectId,
770 );
771 return (
772 <ThreadListV2PendingRow
773 pendingTask={item.pendingTask}
774 project={projectByKey.get(pendingScopeKey) ?? null}
775 projectTitle={v2ProjectTitleByProjectKey.get(pendingScopeKey)}
776 environmentLabel={
777 Object.keys(props.savedConnectionsById).length > 1
778 ? (props.savedConnectionsById[item.pendingTask.message.environmentId]
779 ?.environmentLabel ?? null)
780 : null
781 }
782 showPendingDivider={item.showPendingDivider}
783 showTrailingDivider={showTrailingDivider}
784 onSelectPendingTask={props.onSelectPendingTask}
785 onDeletePendingTask={props.onDeletePendingTask}
786 />
787 );
788 }
789 if (item.type === "v2-snoozed-shelf") {
790 return (
791 <ThreadListV2SnoozedShelfHeader
792 count={item.count}
793 disabled={!shelfPreferencesLoaded}
794 expanded={item.expanded}
795 onToggle={toggleSnoozedShelf}
796 />
797 );
798 }
799 if (item.type === "v2-settled-shelf") {
800 return (
801 <ThreadListV2SettledShelfHeader
802 count={item.count}
803 disabled={!shelfPreferencesLoaded}
804 expanded={item.expanded}
805 onToggle={toggleSettledShelf}
806 />
807 );
808 }
809 const thread = item.item.thread;
810 return (
811 <ThreadListV2Row
812 thread={thread}
813 variant={item.item.variant}
814 snoozed={item.item.snoozed}
815 pinned={item.item.pinned}
816 snoozePresetMinute={nowMinute}
817 snoozeWakeLabelText={item.snoozeWakeLabelText}
818 showTrailingDivider={showTrailingDivider}
819 project={
820 projectByKey.get(scopedProjectKey(thread.environmentId, thread.projectId)) ?? null
821 }
822 projectTitle={v2ProjectTitleByProjectKey.get(
823 scopedProjectKey(thread.environmentId, thread.projectId),
824 )}
825 providerDriver={
826 serverConfigs
827 .get(thread.environmentId)
828 ?.providers.find(
829 (provider) =>
830 provider.instanceId ===
831 (thread.session?.providerInstanceId ?? thread.modelSelection.instanceId),
832 )?.driver ?? null
833 }
834 environmentLabel={
835 Object.keys(props.savedConnectionsById).length > 1
836 ? (props.savedConnectionsById[thread.environmentId]?.environmentLabel ?? null)
837 : null
838 }
839 searchMatch={threadSearchMatchByKey.get(
840 threadSearchMatchKey({
841 environmentId: thread.environmentId,
842 threadId: thread.id,
843 }),
844 )}
845 searchQuery={props.searchQuery}
846 onSelectThread={props.onSelectThread}
847 onDeleteThread={handleDeleteThread}
848 onArchiveThread={props.onArchiveThread}
849 onRegenerateThreadTitle={handleRegenerateThreadTitle}
850 titleRegenerationSupported={titleRegenerationEnvironmentIds.has(thread.environmentId)}
851 settlementSupported={settlementEnvironmentIds.has(thread.environmentId)}
852 onSettleThread={handleSettleThread}
853 snoozeSupported={snoozeEnvironmentIds.has(thread.environmentId)}
854 pinningSupported={pinningEnvironmentIds.has(thread.environmentId)}
855 pinReorderSupported={pinReorderEnvironmentIds.has(thread.environmentId)}
856 canMovePinnedUp={arrangedPinnedKeys.indexOf(`${thread.environmentId}:${thread.id}`) > 0}
857 canMovePinnedDown={(() => {
858 const index = arrangedPinnedKeys.indexOf(`${thread.environmentId}:${thread.id}`);
859 return index !== -1 && index < arrangedPinnedKeys.length - 1;
860 })()}
861 onSnoozeThread={handleSnoozeThread}
862 onUnsnoozeThread={handleUnsnoozeThread}
863 onUnsettleThread={handleUnsettleThread}
864 onPinThread={handlePinThread}
865 onUnpinThread={handleUnpinThread}
866 onMovePinnedThread={handleMovePinnedThread}
867 onChangeRequestState={handleChangeRequestState}
868 projectCwd={
869 projectCwdByKey.get(scopedProjectKey(thread.environmentId, thread.projectId)) ?? null
870 }
871 onSwipeableClose={handleSwipeableClose}
872 onSwipeableWillOpen={handleSwipeableWillOpen}
873 />
874 );
875 },
876 [
877 handleChangeRequestState,
878 handleDeleteThread,
879 arrangedPinnedKeys,
880 handleMovePinnedThread,
881 handlePinThread,
882 handleRegenerateThreadTitle,
883 handleSettleThread,
884 handleSnoozeThread,
885 handleUnpinThread,
886 handleUnsnoozeThread,
887 handleSwipeableClose,
888 handleSwipeableWillOpen,
889 handleUnsettleThread,
890 pinningEnvironmentIds,
891 pinReorderEnvironmentIds,
892 projectByKey,
893 projectCwdByKey,
894 props.onArchiveThread,
895 props.onDeletePendingTask,
896 props.onSelectPendingTask,
897 props.onSelectThread,
898 props.savedConnectionsById,
899 serverConfigs,
900 shelfPreferencesLoaded,
901 settlementEnvironmentIds,
902 snoozeEnvironmentIds,
903 threadListV2Items,
904 threadSearchMatchByKey,
905 titleRegenerationEnvironmentIds,
906 toggleSettledShelf,
907 toggleSnoozedShelf,
908 v2ProjectTitleByProjectKey,
909 props.searchQuery,
910 nowMinute,
911 ],
912 );
913 const v2KeyExtractor = useCallback((item: ThreadListV2ListItem) => item.key, []);
914​
915 // FlatList treats a changed extraData identity as "re-render every visible
916 // row", so an inline object literal would invalidate all rows on every
917 // HomeScreen render.
918 const v2ExtraData = useMemo(
919 () => ({
920 projectByKey,
921 projectCwdByKey,
922 projectTitleByProjectKey: v2ProjectTitleByProjectKey,
923 serverConfigs,
924 savedConnectionsById: props.savedConnectionsById,
925 searchQuery: props.searchQuery,
926 snoozePresetMinute: nowMinute,
927 threadSearchMatchByKey,
928 }),
929 [
930 projectByKey,
931 projectCwdByKey,
932 props.searchQuery,
933 props.savedConnectionsById,
934 serverConfigs,
935 nowMinute,
936 threadSearchMatchByKey,
937 v2ProjectTitleByProjectKey,
938 ],
939 );
940​
941 const extraData = useMemo(
942 () => ({
943 projectCwdByKey,
944 savedConnectionsById: props.savedConnectionsById,
945 searchQuery: props.searchQuery,
946 threadSearchMatchByKey,
947 }),
948 [projectCwdByKey, props.savedConnectionsById, props.searchQuery, threadSearchMatchByKey],
949 );
950​
951 const renderItem = useCallback(
952 ({ item }: LegendListRenderItemProps<HomeListItem>) => {
953 switch (item.type) {
954 case "header":
955 return (
956 <ThreadListGroupHeader
957 variant="compact"
958 collapsed={item.collapsed}
959 isFirst={item.isFirst}
960 groupKey={item.group.key}
961 onGroupAction={updateGroupDisplay}
962 // Aggregated groups (same repo across machines) have no single
963 // target project, and `pending-project:` groups hold a placeholder
964 // built from queued-task metadata rather than a real project shell,
965 // so the quick new-thread button is single-real-project only.
966 newThreadTarget={item.group.newThreadTarget}
967 onNewThread={props.onNewThreadInProject}
968 project={item.group.representative}
969 threadCount={item.group.threads.length + item.group.pendingTasks.length}
970 title={item.group.title}
971 />
972 );
973 case "pending-task":
974 return (
975 <PendingTaskListRow
976 variant="compact"
977 pendingTask={item.pendingTask}
978 environmentLabel={
979 props.savedConnectionsById[item.pendingTask.message.environmentId]
980 ?.environmentLabel ?? null
981 }
982 isLast={item.isLast}
983 onSelectPendingTask={props.onSelectPendingTask}
984 onDeletePendingTask={props.onDeletePendingTask}
985 />
986 );
987 case "thread": {
988 const thread = item.thread;
989 return (
990 <ThreadListRow
991 variant="compact"
992 thread={thread}
993 environmentLabel={
994 props.savedConnectionsById[thread.environmentId]?.environmentLabel ?? null
995 }
996 projectCwd={
997 projectCwdByKey.get(scopedProjectKey(thread.environmentId, thread.projectId)) ??
998 null
999 }
1000 isLast={item.isLast}
1001 searchMatch={threadSearchMatchByKey.get(
1002 threadSearchMatchKey({
1003 environmentId: thread.environmentId,
1004 threadId: thread.id,
1005 }),
1006 )}
1007 searchQuery={props.searchQuery}
1008 onArchiveThread={props.onArchiveThread}
1009 onDeleteThread={props.onDeleteThread}
1010 onRegenerateThreadTitle={handleRegenerateThreadTitle}
1011 titleRegenerationSupported={titleRegenerationEnvironmentIds.has(thread.environmentId)}
1012 onSelectThread={props.onSelectThread}
1013 onSwipeableClose={handleSwipeableClose}
1014 onSwipeableWillOpen={handleSwipeableWillOpen}
1015 />
1016 );
1018 case "show-more":
1019 return (
1020 <ThreadListShowMoreRow
1021 variant="compact"
1022 hiddenCount={item.hiddenCount}
1023 canShowLess={item.canShowLess}
1024 groupKey={item.groupKey}
1025 onGroupAction={updateGroupDisplay}
1026 />
1027 );
1029 },
1031 handleSwipeableClose,
1032 handleSwipeableWillOpen,
1033 handleRegenerateThreadTitle,
1034 projectCwdByKey,
1035 props.onArchiveThread,
1036 props.onDeletePendingTask,
1037 props.onDeleteThread,
1038 props.onNewThreadInProject,
1039 props.onSelectPendingTask,
1040 props.onSelectThread,
1041 props.searchQuery,
1042 props.savedConnectionsById,
1043 threadSearchMatchByKey,
1044 titleRegenerationEnvironmentIds,
1045 updateGroupDisplay,
1046 ],
1047 );
1048​
1049 const keyExtractor = useCallback((item: HomeListItem) => item.key, []);
1050​
1051 /* Empty states */
1052 // The signal must ignore the search/environment filters: an active query
1053 // that matches nothing needs the in-list "No results" state, not the
1054 // full-page "No threads yet". Settled threads are unarchived live shells,
1055 // so the v1 check already covers v2.
1056 const hasAnyThreads =
1057 props.threads.some((thread) => thread.archivedAt === null) || props.pendingTasks.length > 0;
1058 const hasResults = projectGroups.length > 0;
1059 const selectedEnvironmentLabel =
1060 props.selectedEnvironmentId === null
1061 ? null
1062 : (props.savedConnectionsById[props.selectedEnvironmentId]?.environmentLabel ??
1063 "this environment");
1064 // Connection state surfaces in the header title slot
1065 // (WorkspaceConnectionTitle) — nothing renders inside the list, so
1066 // reconnects never shift the rows.
1067 const emptyState = deriveEmptyState({
1068 catalogState: props.catalogState,
1069 projectCount: props.projects.length,
1070 });
1071​
1072 if (!hasAnyThreads) {
1073 return (
1074 <View
1075 className="flex-1 items-center justify-center bg-screen px-8"
1076 style={{
1077 paddingBottom: Math.max(insets.bottom, 24) + iosBottomToolbarClearance,
1078 paddingTop: NATIVE_LIQUID_GLASS_SUPPORTED ? insets.top + 72 : 0,
1079 }}
1081 <View className="w-full max-w-[430px]">
1082 <EmptyState
1083 title={emptyState.title}
1084 detail={emptyState.detail}
1085 actionLabel={!props.catalogState.hasReadyEnvironment ? "Add environment" : undefined}
1086 onAction={!props.catalogState.hasReadyEnvironment ? props.onAddConnection : undefined}
1087 variant="plain"
1088 />
1089 {emptyState.loading ? (
1090 <View className="mt-4 items-center">
1091 <ActivityIndicator color={accentColor} />
1092 </View>
1093 ) : null}
1094 </View>
1095 </View>
1096 );
1098​
1099 const listHeader = Platform.OS === "ios" ? null : <HomeTopContentSpacer />;
1100​
1101 // Project scoping lives in the header filter menu (no inline chip row on
1102 // mobile — the menu is the one filter surface).
1103 const v2ListHeader = listHeader;
1104​
1105 const listEmpty = !hasResults ? (
1106 hasSearchQuery && threadSearch.isPending ? null : hasSearchQuery ? (
1107 <EmptyState title="No results" detail={`No threads matching "${props.searchQuery}".`} />
1108 ) : selectedProjectScope !== null ? (
1109 <EmptyState
1110 title={`No threads in ${selectedProjectScope.title}`}
1111 detail="Choose another project or create a new task."
1112 />
1113 ) : selectedEnvironmentLabel ? (
1114 <EmptyState
1115 title={`No threads in ${selectedEnvironmentLabel}`}
1116 detail="Choose another environment or create a new task."
1117 />
1118 ) : (
1119 <EmptyState title="No threads yet" detail="Create a task to start a new coding session." />
1121 ) : null;
1122 // Self-contained: v1's listEmpty keys off projectGroups, which ignores the
1123 // v2 project scope, so it can be null (results elsewhere) while this list
1124 // is empty. Snoozed threads need no special empty state: their shelf header
1125 // is a list row even while collapsed.
1126 const v2ListEmpty =
1127 hasSearchQuery && threadSearch.isPending ? null : hasSearchQuery ? (
1128 <EmptyState title="No results" detail={`No threads matching "${props.searchQuery}".`} />
1129 ) : v2ScopedProjectGroup !== null ? (
1130 <EmptyState
1131 title={`No threads in ${v2ScopedProjectGroup.title}`}
1132 detail="Choose another project or create a new task."
1133 />
1134 ) : (
1135 listEmpty
1136 );
1137​
1138 if (threadListV2Enabled) {
1139 return (
1140 <View className="flex-1 bg-screen">
1141 <SwipeableScrollGateProvider enabled={swipeEnabled}>
1142 <FlatList
1143 data={threadListV2Items}
1144 renderItem={renderV2Item}
1145 keyExtractor={v2KeyExtractor}
1146 extraData={v2ExtraData}
1147 ListHeaderComponent={v2ListHeader}
1148 ListFooterComponent={
1149 settledShelfExpanded && threadListV2Layout.hiddenSettledCount > 0 ? (
1150 <Pressable
1151 accessibilityRole="button"
1152 accessibilityLabel={`Show ${Math.min(threadListV2Layout.hiddenSettledCount, THREAD_LIST_V2_SETTLED_PAGE_COUNT)} more settled threads`}
1153 onPress={showMoreSettled}
1154 className="mx-4 mt-2 items-center rounded-lg border border-dashed border-border py-2.5"
1155 style={({ pressed }) => ({ opacity: pressed ? 0.6 : 1 })}
1157 <Text className="text-xs font-t3-medium text-foreground-muted">
1158 Show more ({threadListV2Layout.hiddenSettledCount} settled hidden)
1159 </Text>
1160 </Pressable>
1161 ) : null
1163 ListEmptyComponent={v2ListEmpty}
1164 style={{ flex: 1 }}
1165 automaticallyAdjustsScrollIndicatorInsets={Platform.OS === "ios"}
1166 contentInsetAdjustmentBehavior={Platform.OS === "ios" ? "automatic" : "never"}
1167 showsVerticalScrollIndicator={false}
1168 keyboardDismissMode="on-drag"
1169 keyboardShouldPersistTaps="handled"
1170 {...scrollGateHandlers}
1171 scrollEventThrottle={16}
1172 contentContainerStyle={{
1173 paddingBottom:
1174 Platform.OS === "ios"
1175 ? Math.max(insets.bottom, 24) + 96 + iosBottomToolbarClearance
1176 : Math.max(insets.bottom, 16) + 88,
1177 }}
1178 />
1179 </SwipeableScrollGateProvider>
1180 </View>
1181 );
1183​
1184 return (
1185 <View className="flex-1 bg-screen">
1186 {/* Sticky headers are deliberately not wired up: LegendList's JS sticky
1187 implementation mispositions pinned headers at mount under iOS
1188 automatic content insets (headers render one nav-inset too low until
1189 the first scroll event) and blanks non-pinned headers after
1190 collapse/expand data changes. The flattened layout still exposes
1191 `stickyHeaderIndices` if this gets revisited. */}
1192 <SwipeableScrollGateProvider enabled={swipeEnabled}>
1193 <LegendList
1194 ref={listRef}
1195 data={listLayout.items}
1196 renderItem={renderItem}
1197 keyExtractor={keyExtractor}
1198 itemsAreEqual={homeListItemsAreEqual}
1199 drawDistance={500}
1200 estimatedItemSize={ESTIMATED_THREAD_ROW_HEIGHT}
1201 extraData={extraData}
1202 ListHeaderComponent={listHeader}
1203 ListEmptyComponent={listEmpty}
1204 style={{ flex: 1 }}
1205 automaticallyAdjustsScrollIndicatorInsets={NATIVE_LIQUID_GLASS_SUPPORTED}
1206 contentInsetAdjustmentBehavior={NATIVE_LIQUID_GLASS_SUPPORTED ? "automatic" : "never"}
1207 showsVerticalScrollIndicator={false}
1208 keyboardDismissMode="on-drag"
1209 keyboardShouldPersistTaps="handled"
1210 {...scrollGateHandlers}
1211 recycleItems
1212 scrollEventThrottle={16}
1213 contentContainerStyle={{
1214 // Android reserves room for the floating new-task FAB
1215 // (56 button + 16 gap + bottom inset). Pre-glass iOS shows a
1216 // standard 44pt bottom toolbar that overlays the list and is not
1217 // reflected in insets while contentInsetAdjustmentBehavior is
1218 // "never".
1219 paddingBottom:
1220 Platform.OS === "ios"
1221 ? Math.max(insets.bottom, 24) + 24 + iosBottomToolbarClearance
1222 : Math.max(insets.bottom, 16) + 88,
1223 }}
1224 scrollIndicatorInsets={
1225 Platform.OS === "ios"
1226 ? {
1227 bottom: Math.max(insets.bottom, 16) + 24 + iosBottomToolbarClearance,
1228 top: 0,
1230 : undefined
1232 />
1233 </SwipeableScrollGateProvider>
1234 </View>
1235 );