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