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