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