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

HomeScreen.tsx

1,244 lines46.3 KB

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