Open History to see the last commit
1import { useActiveNewTask } from "../../state/active-new-task";
2import { ThreadUndoNotice } from "../home/ThreadUndoNotice";
3import { useAndroidControlSizing } from "../../components/ui/useAndroidControlSizing";
4import { pickableProjectGroups } from "@t3tools/client-runtime/state/project-grouping";
5import {
6 useAppearancePreferences,
7 useAndroidFloatingTabs,
8} from "../settings/appearance/AppearancePreferencesProvider";
9import type {
10 EnvironmentProject,
11 EnvironmentThreadShell,
12} from "@t3tools/client-runtime/state/shell";
13import { threadSearchMatchKey } from "@t3tools/client-runtime/state/thread-search";
14import { AnimatedLegendList } from "@legendapp/list/reanimated";
15import { THREAD_SIDEBAR_ROW_LAYOUT } from "./threadListAnimations";
16import { useAtomValue } from "@effect/atom-react";
17import { useMemo, useRef, useState } from "react";
18import { Platform, StyleSheet, View } from "react-native";
19import { GestureDetector, useNativeGesture } from "react-native-gesture-handler";
20import type { SwipeableMethods } from "react-native-gesture-handler/ReanimatedSwipeable";
21import { FLOATING_TABS } from "../layout/workspace/floating-workspace-tabs";
22import { useSafeAreaInsets } from "react-native-safe-area-context";
23
24import { AppText as Text } from "../../components/ui/AppText";
25import { Button } from "../../components/ui/Button";
26import { scopedProjectKey, scopedThreadKey } from "../../lib/scopedEntities";
27import { useProjects } from "../../state/entities";
28import { steadyNavigationThreadShellsAtom } from "../../state/threads";
29import { useThreadSearch } from "../../state/queries";
30import { useThreadListV2ShelfPreferences } from "./use-thread-list-v2-shelf-preferences";
31import { useThreadListNow } from "./use-thread-list-now";
32import { usePendingThreadOrder } from "../../state/thread-order";
33import { threadListEnvironmentsAtom } from "../../state/presentation";
34import {
35 useLaunchingThreads,
36 usePendingNewTasks,
37 type PendingNewTask,
38} from "../../state/use-pending-new-tasks";
39import { useQueuedThreadKeys } from "../../state/use-thread-outbox";
40import { useWorkspaceState } from "../../state/workspace";
41import { useSavedRemoteConnections } from "../../state/use-remote-environment-registry";
42import { useThreadListV2 } from "./useThreadListV2";
43import { useThreadJumpShortcuts } from "../keyboard/threadKeyboardShortcuts";
44import { requestThreadMessageJump } from "./threadMessageJump";
45import { useThreadListSearchMatches } from "./useThreadListSearchMatches";
46import { useHomeListOptions } from "../home/home-list-options";
47import { buildHomeListFilterMenuItems } from "../home/home-list-filter-menu";
48import {
49 buildHomeProjectScopes,
50 resolveHomeProjectFilterScope,
51 sortHomeProjectScopes,
52} from "../home/homeThreadList";
53import { SwipeableScrollGateProvider, useSwipeableScrollGate } from "../home/thread-swipe-actions";
54import { usePendingTaskListActions } from "../home/usePendingTaskListActions";
55import { useThreadListActions } from "../home/useThreadListActions";
56import { useFabScroll } from "../home/FabScrollContext";
57import { WorkspaceListHeader } from "../layout/workspace/WorkspaceListHeader";
58import { WorkspaceSidebarColumn } from "../layout/workspace/WorkspaceSidebarColumn";
59import {
60 ThreadListV2PendingRow,
61 ThreadListV2Row,
62 ThreadListV2SettledShelfHeader,
63 ThreadListV2ShowMoreRow,
64 ThreadListV2SnoozedShelfHeader,
65 ThreadListV2WorkingShelfHeader,
66} from "./thread-list-v2-items";
67import { useThreadRowProviderInstanceResolver } from "./thread-provider-instance";
68import type { ThreadPrPresentation } from "../../state/thread-pr-presentation";
69import { ThreadPrDemandProvider } from "../../state/thread-pr-demand";
70import {
71 isThreadListV2ListItem,
72 threadListV2ListItemsAreEqual,
73 THREAD_LIST_V2_SETTLED_INITIAL_COUNT,
74 THREAD_LIST_V2_SETTLED_PAGE_COUNT,
75 type ThreadListV2ListItem,
76} from "./threadListV2";
77import { useSelectWorkspaceDetail } from "../layout/workspace/useSelectWorkspaceDetail";
78import { NativeScrollView } from "../../native/NativeScrollViewMarker";
79
80type SidebarListItem =
81 | ThreadListV2ListItem
82 | {
83 readonly type: "v2-show-more";
84 readonly key: string;
85 readonly hiddenCount: number;
86 readonly state?: "loading" | "failed";
87 };
88
89interface ThreadNavigationSidebarProps {
90 readonly width: number;
91 readonly visible: boolean;
92 readonly selectedThreadKey: string | null;
93 readonly onOpenSettings: () => void;
94 readonly onOpenEnvironmentSettings: () => void;
95 readonly onNewThreadOnBranch: (thread: EnvironmentThreadShell) => void;
96 readonly onNewThreadInProject: (project: EnvironmentProject) => void;
97 readonly onOpenPendingTask: (pendingTask: PendingNewTask) => void;
98 readonly onSearchQueryChange: (query: string) => void;
99 readonly onSelectThread: (thread: EnvironmentThreadShell) => void;
100 readonly onOpenThreadPullRequests: (
101 thread: EnvironmentThreadShell,
102 pr: ThreadPrPresentation,
103 ) => void;
104 readonly onRequestVisibility: () => void;
105 readonly searchQuery: string;
106}
107
108export function ThreadNavigationSidebar(props: ThreadNavigationSidebarProps) {
109 return (
110 <ThreadPrDemandProvider visible={props.visible}>
111 <WorkspaceSidebarColumn width={props.width}>
112 <ThreadNavigationSidebarPane {...props} />
113 </WorkspaceSidebarColumn>
114 </ThreadPrDemandProvider>
115 );
116}
117
118function ThreadNavigationSidebarPane(props: ThreadNavigationSidebarProps) {
119 const floatingTabsEnabled = useAndroidFloatingTabs();
120 const { themeVariables: materialTheme } = useAppearancePreferences();
121 const drawerColor = materialTheme["--color-drawer"];
122
123 const insets = useSafeAreaInsets();
124 const { fabClearance, fabSize } = useAndroidControlSizing();
125 const projects = useProjects();
126 const threads = useAtomValue(steadyNavigationThreadShellsAtom);
127 const { environments: workspaceEnvironments, state: catalogState } = useWorkspaceState();
128 const { savedConnectionsById } = useSavedRemoteConnections();
129 const openSwipeableRef = useRef<SwipeableMethods | null>(null);
130 const sidebarScrollGesture = useNativeGesture();
131 const {
132 archiveThread,
133 confirmDeleteThread,
134 settleThread,
135 snoozeThread,
136 unsnoozeThread,
137 unsettleThread,
138 pinThread,
139 unpinThread,
140 setThreadAutoSettle,
141 moveThread,
142 renameThread,
143 regenerateThreadTitle,
144 } = useThreadListActions();
145 const pendingTasks = usePendingNewTasks();
146 const launchingThreads = useLaunchingThreads(threads);
147 const activeNewTask = useActiveNewTask();
148 const queuedThreadKeys = useQueuedThreadKeys();
149 const selectDetail = useSelectWorkspaceDetail();
150 const { confirmDeletePendingTask } = usePendingTaskListActions((params) =>
151 selectDetail({ name: "Thread", params }),
152 );
153 const environments = Object.values(savedConnectionsById)
154 .map((connection) => ({
155 environmentId: connection.environmentId,
156 label: connection.environmentLabel,
157 }))
158 .sort((left, right) => left.label.localeCompare(right.label));
159 const availableEnvironmentIds = new Set(
160 environments.map((environment) => environment.environmentId),
161 );
162 const { options, setSelectedEnvironmentId, setSelectedProjectKey } =
163 useHomeListOptions(availableEnvironmentIds);
164 const searchEnvironmentIds =
165 options.selectedEnvironmentId === null
166 ? workspaceEnvironments
167 .filter((environment) => environment.connectionState === "connected")
168 .map((environment) => environment.environmentId)
169 : workspaceEnvironments.some(
170 (environment) =>
171 environment.environmentId === options.selectedEnvironmentId &&
172 environment.connectionState === "connected",
173 )
174 ? [options.selectedEnvironmentId]
175 : [];
176 const projectScopes = useMemo(
177 () =>
178 buildHomeProjectScopes({
179 projects,
180 environmentId: options.selectedEnvironmentId,
181 projectGroupingMode: options.projectGroupingMode,
182 }),
183 [projects, options.selectedEnvironmentId, options.projectGroupingMode],
184 );
185 const projectFilterOptions = pickableProjectGroups(
186 sortHomeProjectScopes({
187 scopes: projectScopes,
188 threads,
189 pendingTasks: [],
190 projectSortOrder: "updated_at",
191 }),
192 ).map((scope) => ({
193 key: scope.key,
194 label: scope.title,
195 }));
196 const projectTitleByProjectKey = useMemo(
197 () =>
198 new Map(
199 projectScopes.flatMap((scope) =>
200 scope.projectRefs.map(
201 (projectRef) =>
202 [
203 scopedProjectKey(projectRef.environmentId, projectRef.projectId),
204 scope.title,
205 ] as const,
206 ),
207 ),
208 ),
209 [projectScopes],
210 );
211 const selectedProjectScope = resolveHomeProjectFilterScope(projectScopes, projects, options);
212 const threadSearch = useThreadSearch(
213 searchEnvironmentIds,
214 props.searchQuery,
215 selectedProjectScope === null
216 ? {}
217 : { projectIds: selectedProjectScope.projectRefs.map((ref) => ref.projectId) },
218 );
219 // This map reaches LegendList's extraData, which re-renders every row whenever it changes
220 // identity; the hook keeps it stable.
221 const threadSearchMatchByKey = useThreadListSearchMatches(threads, threadSearch);
222 const selectedProjectKey = selectedProjectScope?.key ?? null;
223 const projectByKey = useMemo(() => {
224 const map = new Map<string, EnvironmentProject>();
225 for (const project of projects) {
226 map.set(scopedProjectKey(project.environmentId, project.id), project);
227 }
228 return map;
229 }, [projects]);
230
231 const [settledVisibleCount, setSettledVisibleCount] = useState(
232 THREAD_LIST_V2_SETTLED_INITIAL_COUNT,
233 );
234 const settledResetKey = `${options.selectedEnvironmentId ?? "all"}:${selectedProjectKey ?? "all"}:${props.searchQuery.trim()}`;
235 const [lastSettledResetKey, setLastSettledResetKey] = useState(settledResetKey);
236 if (lastSettledResetKey !== settledResetKey) {
237 setLastSettledResetKey(settledResetKey);
238 setSettledVisibleCount(THREAD_LIST_V2_SETTLED_INITIAL_COUNT);
239 }
240 const showMoreSettled = () =>
241 setSettledVisibleCount((count) => count + THREAD_LIST_V2_SETTLED_PAGE_COUNT);
242 const {
243 loaded: shelfPreferencesLoaded,
244 settledShelfExpanded,
245 snoozedShelfExpanded,
246 workingShelfEnabled,
247 workingShelfExpanded,
248 toggleSettledShelf,
249 toggleSnoozedShelf,
250 toggleWorkingShelf,
251 } = useThreadListV2ShelfPreferences();
252 const now = useThreadListNow(threads);
253 const listEnvironments = useAtomValue(threadListEnvironmentsAtom);
254 const {
255 providersByEnvironmentId,
256 machineByEnvironmentId,
257 settlementEnvironmentIds,
258 snoozeEnvironmentIds,
259 snoozePresetsByEnvironmentId,
260 pinningEnvironmentIds,
261 autoSettleOptOutEnvironmentIds,
262 pinReorderEnvironmentIds,
263 activeReorderEnvironmentIds,
264 titleRegenerationEnvironmentIds,
265 } = listEnvironments;
266 const resolveProviderInstance = useThreadRowProviderInstanceResolver(providersByEnvironmentId);
267 const pendingOrder = usePendingThreadOrder();
268 const {
269 layout: threadListV2Layout,
270 items: threadListV2Items,
271 contentOnlyThreadKeys,
272 olderSettledShelf,
273 } = useThreadListV2({
274 threads: launchingThreads,
275 pendingTasks,
276 environmentId: options.selectedEnvironmentId,
277 projectRefs: selectedProjectScope === null ? null : selectedProjectScope.projectRefs,
278 searchQuery: props.searchQuery,
279 searchMatches: threadSearchMatchByKey,
280 settlementEnvironmentIds,
281 snoozeEnvironmentIds,
282 pinReorderEnvironmentIds,
283 activeReorderEnvironmentIds,
284 queuedThreadKeys,
285 settledLimit: settledVisibleCount,
286 now,
287 pendingOrder,
288 shelfPreferencesLoaded,
289 workingShelfEnabled,
290 workingShelfExpanded,
291 snoozedShelfExpanded,
292 settledShelfExpanded,
293 selectedThreadKey: props.selectedThreadKey ?? null,
294 });
295 const listItems: readonly SidebarListItem[] =
296 settledShelfExpanded && threadListV2Layout.hiddenSettledCount > 0
297 ? [
298 ...threadListV2Items,
299 {
300 type: "v2-show-more",
301 key: "v2-show-more",
302 hiddenCount: threadListV2Layout.hiddenSettledCount,
303 ...(olderSettledShelf.loading
304 ? { state: "loading" as const }
305 : olderSettledShelf.failed
306 ? { state: "failed" as const }
307 : {}),
308 },
309 ]
310 : threadListV2Items;
311
312 const handleSwipeableWillOpen = (methods: SwipeableMethods) => {
313 if (openSwipeableRef.current !== methods) {
314 openSwipeableRef.current?.close();
315 openSwipeableRef.current = methods;
316 }
317 };
318 const handleSwipeableClose = (methods: SwipeableMethods) => {
319 if (openSwipeableRef.current === methods) {
320 openSwipeableRef.current = null;
321 }
322 };
323 // Destructure callback props; capturing all props would invalidate these row-closing handlers on unrelated changes.
324 const { onSelectThread, onOpenThreadPullRequests } = props;
325 // A row listed for a message match opens the thread at that message, by
326 // tap or by shortcut.
327 const handleSelectThread = (thread: EnvironmentThreadShell) => {
328 const key = threadSearchMatchKey({ environmentId: thread.environmentId, threadId: thread.id });
329 const messageId = contentOnlyThreadKeys.has(key)
330 ? threadSearchMatchByKey.get(key)?.messageId
331 : undefined;
332 if (messageId) {
333 requestThreadMessageJump(scopedThreadKey(thread.environmentId, thread.id), messageId);
334 }
335 onSelectThread(thread);
336 openSwipeableRef.current?.close();
337 };
338 const handleOpenThreadPullRequests = (
339 thread: EnvironmentThreadShell,
340 pr: ThreadPrPresentation,
341 ) => {
342 onOpenThreadPullRequests(thread, pr);
343 openSwipeableRef.current?.close();
344 };
345 const handleScrollBeginDrag = () => {
346 openSwipeableRef.current?.close();
347 };
348 const onFabScroll = useFabScroll();
349 const { swipeEnabled, scrollGateHandlers } = useSwipeableScrollGate({
350 onScroll: onFabScroll,
351 onScrollBeginDrag: handleScrollBeginDrag,
352 });
353 // Recycle equality needs project/search data for titles and favicons; keep the minute clock on items to limit updates.
354 const listExtraData = {
355 activeNewTask,
356 selectedThreadKey: props.selectedThreadKey ?? "",
357 projectByKey,
358 projectTitleByProjectKey,
359 savedConnectionsById,
360 listEnvironments,
361 threadSearchMatchByKey,
362 workingShelfEnabled,
363 };
364 useThreadJumpShortcuts(listItems, handleSelectThread);
365 const sidebarItemsAreEqual = (previous: SidebarListItem, item: SidebarListItem): boolean => {
366 if (isThreadListV2ListItem(previous) && isThreadListV2ListItem(item)) {
367 return threadListV2ListItemsAreEqual(previous, item);
368 }
369 if (previous.type === "v2-show-more" && item.type === "v2-show-more") {
370 return previous.hiddenCount === item.hiddenCount && previous.state === item.state;
371 }
372 return false;
373 };
374 const renderListItem = ({ item }: { readonly item: SidebarListItem }) => {
375 switch (item.type) {
376 case "v2-pending": {
377 const pendingScopeKey = scopedProjectKey(
378 item.pendingTask.environmentId,
379 item.pendingTask.projectId,
380 );
381 return (
382 <ThreadListV2PendingRow
383 pendingTask={item.pendingTask}
384 selected={
385 activeNewTask?.pendingKey === item.pendingTask.key ||
386 (item.pendingTask.kind === "pending" &&
387 scopedThreadKey(
388 item.pendingTask.environmentId,
389 item.pendingTask.message.threadId,
390 ) === props.selectedThreadKey)
391 }
392 project={projectByKey.get(pendingScopeKey) ?? null}
393 projectTitle={projectTitleByProjectKey.get(pendingScopeKey)}
394 environmentLabel={
395 Object.keys(savedConnectionsById).length > 1
396 ? (savedConnectionsById[item.pendingTask.environmentId]?.environmentLabel ?? null)
397 : null
398 }
399 environmentMachine={machineByEnvironmentId.get(item.pendingTask.environmentId)}
400 pane="sidebar"
401 showPendingDivider={item.showPendingDivider}
402 onSelectPendingTask={props.onOpenPendingTask}
403 onDeletePendingTask={confirmDeletePendingTask}
404 fullSwipeWidth={props.width - 20}
405 onSwipeableClose={handleSwipeableClose}
406 onSwipeableWillOpen={handleSwipeableWillOpen}
407 simultaneousSwipeGesture={sidebarScrollGesture}
408 />
409 );
410 }
411 case "v2-thread": {
412 const thread = item.item.thread;
413 const scopeKey = scopedProjectKey(thread.environmentId, thread.projectId);
414 return (
415 <ThreadListV2Row
416 onNewThreadOnBranch={props.onNewThreadOnBranch}
417 thread={thread}
418 variant={item.item.variant}
419 hasQueuedMessages={item.hasQueuedMessages}
420 snoozed={item.item.snoozed}
421 pinned={item.item.pinned}
422 wokeAt={item.item.wokeAt}
423 snoozePresetMinute={item.snoozePresetMinute ?? ""}
424 snoozeWakeLabelText={item.snoozeWakeLabelText}
425 timeLabel={item.timeLabel}
426 project={projectByKey.get(scopeKey) ?? null}
427 providerInstance={resolveProviderInstance(thread)}
428 providers={providersByEnvironmentId.get(thread.environmentId)}
429 environmentLabel={
430 Object.keys(savedConnectionsById).length > 1
431 ? (savedConnectionsById[thread.environmentId]?.environmentLabel ?? null)
432 : null
433 }
434 environmentMachine={machineByEnvironmentId.get(thread.environmentId)}
435 searchMatch={
436 // Only rows listed for their messages show one and open at it.
437 contentOnlyThreadKeys.has(
438 threadSearchMatchKey({ environmentId: thread.environmentId, threadId: thread.id }),
439 )
440 ? threadSearchMatchByKey.get(
441 threadSearchMatchKey({
442 environmentId: thread.environmentId,
443 threadId: thread.id,
444 }),
445 )
446 : undefined
447 }
448 searchQuery={threadSearch.query}
449 pane="sidebar"
450 selected={
451 !activeNewTask &&
452 scopedThreadKey(thread.environmentId, thread.id) === props.selectedThreadKey
453 }
454 fullSwipeWidth={props.width - 20}
455 onSelectThread={handleSelectThread}
456 onOpenThreadPullRequests={handleOpenThreadPullRequests}
457 onDeleteThread={confirmDeleteThread}
458 onArchiveThread={archiveThread}
459 onRenameThread={renameThread}
460 onRegenerateThreadTitle={regenerateThreadTitle}
461 titleRegenerationSupported={titleRegenerationEnvironmentIds.has(thread.environmentId)}
462 settlementSupported={settlementEnvironmentIds.has(thread.environmentId)}
463 onSettleThread={settleThread}
464 snoozeSupported={snoozeEnvironmentIds.has(thread.environmentId)}
465 snoozePresets={snoozePresetsByEnvironmentId.get(thread.environmentId)}
466 pinningSupported={pinningEnvironmentIds.has(thread.environmentId)}
467 autoSettleOptOutSupported={autoSettleOptOutEnvironmentIds.has(thread.environmentId)}
468 reorderSupported={
469 item.item.pinned
470 ? pinReorderEnvironmentIds.has(thread.environmentId)
471 : !workingShelfEnabled && activeReorderEnvironmentIds.has(thread.environmentId)
472 }
473 canMoveUp={item.canMoveUp}
474 canMoveDown={item.canMoveDown}
475 onSnoozeThread={snoozeThread}
476 onUnsnoozeThread={unsnoozeThread}
477 onUnsettleThread={unsettleThread}
478 onPinThread={pinThread}
479 onUnpinThread={unpinThread}
480 onSetThreadAutoSettle={setThreadAutoSettle}
481 onMoveThread={moveThread}
482 onSwipeableClose={handleSwipeableClose}
483 onSwipeableWillOpen={handleSwipeableWillOpen}
484 simultaneousSwipeGesture={sidebarScrollGesture}
485 />
486 );
487 }
488 case "v2-working-shelf":
489 return (
490 <ThreadListV2WorkingShelfHeader
491 count={item.count}
492 disabled={item.disabled}
493 expanded={item.expanded}
494 onToggle={toggleWorkingShelf}
495 pane="sidebar"
496 />
497 );
498 case "v2-snoozed-shelf":
499 return (
500 <ThreadListV2SnoozedShelfHeader
501 count={item.count}
502 disabled={item.disabled}
503 expanded={item.expanded}
504 onToggle={toggleSnoozedShelf}
505 pane="sidebar"
506 />
507 );
508 case "v2-settled-shelf":
509 return (
510 <ThreadListV2SettledShelfHeader
511 count={item.count}
512 disabled={item.disabled}
513 expanded={item.expanded}
514 onToggle={toggleSettledShelf}
515 pane="sidebar"
516 />
517 );
518 case "v2-show-more":
519 return (
520 <ThreadListV2ShowMoreRow
521 pane="sidebar"
522 hiddenCount={item.hiddenCount}
523 {...(item.state === undefined ? {} : { state: item.state })}
524 onPress={() => {
525 olderSettledShelf.retry();
526 showMoreSettled();
527 }}
528 />
529 );
530 }
531 };
532 const header = (
533 <WorkspaceListHeader
534 accessibilityLabel="T3 Code, Threads"
535 onOpenEnvironments={props.onOpenEnvironmentSettings}
536 onOpenSettings={props.onOpenSettings}
537 search={{
538 value: props.searchQuery,
539 onChangeText: props.onSearchQueryChange,
540 placeholder: "Search",
541 accessibilityLabel: "Search threads",
542 }}
543 filter={{
544 customized: options.selectedEnvironmentId !== null || selectedProjectKey !== null,
545 items: buildHomeListFilterMenuItems({
546 environments,
547 projects: projectFilterOptions,
548 selectedEnvironmentId: options.selectedEnvironmentId,
549 selectedProjectKey,
550 onEnvironmentChange: setSelectedEnvironmentId,
551 onProjectChange: setSelectedProjectKey,
552 }),
553 }}
554 sidebar={{
555 width: props.width,
556 visible: props.visible,
557 onRequestVisibility: props.onRequestVisibility,
558 }}
559 />
560 );
561 const showAddEnvironment =
562 !catalogState.isLoadingConnections &&
563 !catalogState.hasReadyEnvironment &&
564 !catalogState.hasConnectingEnvironment;
565 const listEmpty = (
566 <View>
567 <Text
568 className={
569 Platform.OS === "android"
570 ? "px-4 py-4 text-center text-sm text-drawer-foreground-muted"
571 : "px-2 py-4 text-sm text-drawer-foreground-muted"
572 }
573 >
574 {catalogState.isLoadingConnections
575 ? "Loading threads…"
576 : showAddEnvironment
577 ? "No environments connected"
578 : props.searchQuery.trim().length > 0
579 ? threadSearch.isPending
580 ? "Searching thread messages…"
581 : "No matching threads"
582 : selectedProjectScope !== null
583 ? `No threads in ${selectedProjectScope.title}`
584 : "No threads yet"}
585 </Text>
586 {showAddEnvironment ? (
587 <View className={Platform.OS === "android" ? "self-center" : "px-2"}>
588 <Button
589 tone="primary"
590 size="compact"
591 icon="plus"
592 label="Add environment"
593 onPress={props.onOpenEnvironmentSettings}
594 />
595 </View>
596 ) : null}
597 </View>
598 );
599
600 if (Platform.OS === "ios") {
601 return (
602 <>
603 {header}
604 <View className="flex-1">
605 <SwipeableScrollGateProvider enabled={swipeEnabled}>
606 <GestureDetector gesture={sidebarScrollGesture}>
607 <AnimatedLegendList
608 renderScrollComponent={NativeScrollView}
609 itemLayoutAnimation={THREAD_SIDEBAR_ROW_LAYOUT}
610 data={listItems}
611 drawDistance={500}
612 estimatedItemSize={64}
613 extraData={listExtraData}
614 getItemType={(item) => item.type}
615 itemsAreEqual={sidebarItemsAreEqual}
616 keyExtractor={(item) => item.key}
617 renderItem={renderListItem}
618 automaticallyAdjustsScrollIndicatorInsets
619 // The column lays the list under its bar, glass or solid; UIKit insets it past both.
620 contentInsetAdjustmentBehavior="automatic"
621 contentContainerStyle={[
622 styles.threadListContent,
623 {
624 paddingBottom: Math.max(insets.bottom, 16) + 16,
625 paddingTop: 6,
626 },
627 ]}
628 keyboardDismissMode="on-drag"
629 keyboardShouldPersistTaps="handled"
630 {...scrollGateHandlers}
631 recycleItems
632 scrollEventThrottle={16}
633 showsVerticalScrollIndicator={false}
634 style={styles.threadList}
635 ListEmptyComponent={listEmpty}
636 />
637 </GestureDetector>
638 </SwipeableScrollGateProvider>
639 <ThreadUndoNotice visible={props.visible} />
640 </View>
641 </>
642 );
643 }
644
645 // Android: the bar floats below the list.
646 return (
647 <View testID="thread-navigation-sidebar" className="flex-1 bg-header">
648 <View
649 className="flex-1"
650 style={{
651 marginHorizontal: 4,
652 paddingBottom: insets.bottom,
653 backgroundColor: drawerColor,
654 borderTopLeftRadius: 28,
655 borderTopRightRadius: 28,
656 overflow: "hidden",
657 }}
658 >
659 {listItems.length === 0 ? (
660 <View className="flex-1 items-center justify-center">{listEmpty}</View>
661 ) : (
662 <SwipeableScrollGateProvider enabled={swipeEnabled}>
663 <GestureDetector gesture={sidebarScrollGesture}>
664 {/* oxlint-disable-next-line t3code/require-registered-list-scroll -- The Android sidebar has no native header to register with. */}
665 <AnimatedLegendList
666 itemLayoutAnimation={THREAD_SIDEBAR_ROW_LAYOUT}
667 data={listItems}
668 drawDistance={500}
669 estimatedItemSize={64}
670 extraData={listExtraData}
671 getItemType={(item) => item.type}
672 itemsAreEqual={sidebarItemsAreEqual}
673 keyExtractor={(item) => item.key}
674 renderItem={renderListItem}
675 contentContainerStyle={{
676 paddingBottom: floatingTabsEnabled
677 ? FLOATING_TABS.bottom + FLOATING_TABS.edge + fabSize
678 : Math.max(insets.bottom, 16) + fabClearance - insets.bottom,
679 paddingTop: 6,
680 }}
681 keyboardDismissMode="on-drag"
682 keyboardShouldPersistTaps="handled"
683 {...scrollGateHandlers}
684 recycleItems
685 scrollEventThrottle={16}
686 showsVerticalScrollIndicator={false}
687 style={styles.threadList}
688 ListEmptyComponent={listEmpty}
689 />
690 </GestureDetector>
691 </SwipeableScrollGateProvider>
692 )}
693 </View>
694 {header}
695 <ThreadUndoNotice visible={props.visible} />
696 </View>
697 );
698}
699
700const styles = StyleSheet.create({
701 threadList: {
702 flex: 1,
703 },
704 threadListContent: {
705 paddingHorizontal: 8,
706 },
707});