Open History to see the last commit
1import type {
2 EnvironmentProject,
3 EnvironmentThreadShell,
4} from "@t3tools/client-runtime/state/shell";
5import {
6 threadSearchMatchKey,
7 type EnvironmentThreadSearchMatch,
8} from "@t3tools/client-runtime/state/thread-search";
9import { LegendList } from "@legendapp/list/react-native";
10import type { MenuAction } from "@react-native-menu/menu";
11import { useAtomValue } from "@effect/atom-react";
12import { type EnvironmentId, resolveEnvironmentMachineKind } from "@t3tools/contracts";
13import { sortPinnedThreadsByOrderKey } from "@t3tools/client-runtime/state/thread-sort";
14import { useCallback, useEffect, useMemo, useRef, useState } from "react";
15import type { LayoutChangeEvent } from "react-native";
16import { Platform, Pressable, StyleSheet, TextInput, View } from "react-native";
17import { Gesture, GestureDetector } from "react-native-gesture-handler";
18import type { SwipeableMethods } from "react-native-gesture-handler/ReanimatedSwipeable";
19import { useSafeAreaInsets } from "react-native-safe-area-context";
20import type { SearchBarCommands } from "react-native-screens";
21
22import { AppText as Text } from "../../components/AppText";
23import { CompactBrandTitle } from "../../components/CompactBrandTitle";
24import { ControlPillMenu } from "../../components/ControlPill";
25import { SymbolView } from "../../components/AppSymbol";
26import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass";
27import { NativeStackScreenOptions } from "../../native/StackHeader";
28import { scopedProjectKey, scopedThreadKey } from "../../lib/scopedEntities";
29import { useProjects, useThreadShells } from "../../state/entities";
30import { useThreadSearch } from "../../state/queries";
31import { useThreadListV2Enabled } from "./use-thread-list-v2-enabled";
32import { useThreadListV2ShelfPreferences } from "./use-thread-list-v2-shelf-preferences";
33import { environmentServerConfigsAtom } from "../../state/server";
34import { usePendingNewTasks } from "../../state/use-pending-new-tasks";
35import { useWorkspaceState } from "../../state/workspace";
36import { useSavedRemoteConnections } from "../../state/use-remote-environment-registry";
37import { useHardwareKeyboardCommand } from "../keyboard/hardwareKeyboardCommands";
38import {
39 hasCustomHomeListOptions,
40 PROJECT_SORT_OPTIONS,
41 THREAD_SORT_OPTIONS,
42 useHomeListOptions,
43} from "../home/home-list-options";
44import { buildHomeListFilterMenu } from "../home/home-list-filter-menu";
45import {
46 buildHomeListLayout,
47 DEFAULT_GROUP_DISPLAY_STATE,
48 EMPTY_HOME_LIST_LAYOUT,
49 homeListItemsAreEqual,
50 nextGroupDisplayState,
51 type HomeGroupDisplayAction,
52 type HomeGroupDisplayState,
53 type HomeListItem,
54} from "../home/homeListItems";
55import { buildHomeProjectScopes, buildHomeThreadGroups } from "../home/homeThreadList";
56import { SwipeableScrollGateProvider, useSwipeableScrollGate } from "../home/thread-swipe-actions";
57import { usePendingTaskListActions } from "../home/usePendingTaskListActions";
58import { useThreadListActions } from "../home/useThreadListActions";
59import {
60 getConnectionAwareBrandHeaderOptions,
61 WorkspaceConnectionTitle,
62} from "../home/WorkspaceConnectionTitle";
63import { SidebarHeaderActions } from "./sidebar-header-actions";
64import { SidebarFilterButton } from "./sidebar-filter-button";
65import { createSidebarHeaderItems } from "./sidebar-native-header-items";
66import { SidebarNavigationShell } from "./sidebar-navigation-shell";
67import {
68 PendingTaskListRow,
69 ThreadListGroupHeader,
70 ThreadListRow,
71 ThreadListShowMoreRow,
72} from "./thread-list-items";
73import {
74 ThreadListV2PendingRow,
75 ThreadListV2Row,
76 ThreadListV2SettledShelfHeader,
77 ThreadListV2SnoozedShelfHeader,
78} from "./thread-list-v2-items";
79import {
80 buildThreadListV2Items,
81 buildThreadListV2ListItems,
82 THREAD_LIST_V2_SETTLED_INITIAL_COUNT,
83 THREAD_LIST_V2_SETTLED_PAGE_COUNT,
84 type ThreadListV2ListItem,
85} from "./threadListV2";
86
87/** The sidebar list serves both lists: v1 grouped items or, when the Thread
88 List v2 beta is on, flat v2 rows with queued tasks spliced in, and a settled
89 "Show more" pager. */
90type SidebarListItem =
91 | HomeListItem
92 | ThreadListV2ListItem
93 | { readonly type: "v2-show-more"; readonly key: string; readonly hiddenCount: number };
94
95const SIDEBAR_STICKY_HEADER_HEIGHT = 106;
96
97interface ThreadNavigationSidebarProps {
98 readonly width: number;
99 readonly visible: boolean;
100 readonly selectedThreadKey: string | null;
101 readonly onOpenSettings: () => void;
102 readonly onOpenEnvironmentSettings: () => void;
103 readonly onNewThreadInProject: (project: EnvironmentProject) => void;
104 readonly onSearchQueryChange: (query: string) => void;
105 readonly onSelectThread: (thread: EnvironmentThreadShell) => void;
106 readonly onRequestVisibility: () => void;
107 readonly searchQuery: string;
108}
109
110/**
111 * iPad/large-width sidebar column.
112 *
113 * On iOS the pane is hosted inside its own navigation-inert single-screen
114 * native stack (SidebarNavigationShell) so the header is a real
115 * UINavigationBar: large title, native bar-button items, and a
116 * UISearchController search field — the same chrome a UISplitViewController
117 * column gets. Other platforms keep the custom header chrome.
118 */
119export function ThreadNavigationSidebar(props: ThreadNavigationSidebarProps) {
120 if (Platform.OS !== "ios") {
121 return <ThreadNavigationSidebarPane {...props} nativeChrome={false} />;
122 }
123 return <NativeSidebarContainer {...props} />;
124}
125
126function NativeSidebarContainer(props: ThreadNavigationSidebarProps) {
127 return (
128 <View
129 testID="thread-navigation-sidebar"
130 className="flex-1 border-border bg-drawer"
131 style={{ borderRightWidth: StyleSheet.hairlineWidth, width: props.width }}
132 >
133 <SidebarNavigationShell>
134 <ThreadNavigationSidebarPane {...props} nativeChrome />
135 </SidebarNavigationShell>
136 </View>
137 );
138}
139
140function ThreadNavigationSidebarPane(
141 props: ThreadNavigationSidebarProps & { readonly nativeChrome: boolean },
142) {
143 const insets = useSafeAreaInsets();
144 const projects = useProjects();
145 const threads = useThreadShells();
146 const { environments: workspaceEnvironments, state: catalogState } = useWorkspaceState();
147 const { savedConnectionsById } = useSavedRemoteConnections();
148 const searchInputRef = useRef<TextInput>(null);
149 const searchBarRef = useRef<SearchBarCommands>(null);
150 const openSwipeableRef = useRef<SwipeableMethods | null>(null);
151 const sidebarScrollGesture = useMemo(() => Gesture.Native(), []);
152 const {
153 archiveThread,
154 confirmDeleteThread,
155 settleThread,
156 snoozeThread,
157 unsnoozeThread,
158 unsettleThread,
159 pinThread,
160 unpinThread,
161 movePinnedThread,
162 regenerateThreadTitle,
163 } = useThreadListActions();
164 const threadListV2Enabled = useThreadListV2Enabled();
165 const pendingTasks = usePendingNewTasks();
166 const { openPendingTask, confirmDeletePendingTask } = usePendingTaskListActions();
167 const environments = useMemo(
168 () =>
169 Object.values(savedConnectionsById)
170 .map((connection) => ({
171 environmentId: connection.environmentId,
172 label: connection.environmentLabel,
173 }))
174 .sort((left, right) => left.label.localeCompare(right.label)),
175 [savedConnectionsById],
176 );
177 const availableEnvironmentIds = useMemo(
178 () => new Set(environments.map((environment) => environment.environmentId)),
179 [environments],
180 );
181 const { options, setSelectedEnvironmentId, setProjectSortOrder, setThreadSortOrder } =
182 useHomeListOptions(availableEnvironmentIds);
183 const searchEnvironmentIds = useMemo(
184 () =>
185 options.selectedEnvironmentId === null
186 ? workspaceEnvironments
187 .filter((environment) => environment.connectionState === "connected")
188 .map((environment) => environment.environmentId)
189 : workspaceEnvironments.some(
190 (environment) =>
191 environment.environmentId === options.selectedEnvironmentId &&
192 environment.connectionState === "connected",
193 )
194 ? [options.selectedEnvironmentId]
195 : [],
196 [options.selectedEnvironmentId, workspaceEnvironments],
197 );
198 const threadSearch = useThreadSearch(searchEnvironmentIds, props.searchQuery);
199 const threadSearchMatchByKey = useMemo(() => {
200 const matches = new Map<string, EnvironmentThreadSearchMatch>();
201 for (const match of threadSearch.matches) {
202 if (match.source === "user" || match.source === "assistant") {
203 matches.set(threadSearchMatchKey(match), match);
204 }
205 }
206 return matches;
207 }, [threadSearch.matches]);
208 const matchedThreadKeys = useMemo(
209 () => new Set(threadSearch.matches.map(threadSearchMatchKey)),
210 [threadSearch.matches],
211 );
212 const [selectedProjectKey, setSelectedProjectKey] = useState<string | null>(null);
213 const projectScopes = useMemo(
214 () =>
215 buildHomeProjectScopes({
216 projects,
217 environmentId: options.selectedEnvironmentId,
218 projectGroupingMode: options.projectGroupingMode,
219 }),
220 [options.projectGroupingMode, options.selectedEnvironmentId, projects],
221 );
222 const projectFilterOptions = useMemo(
223 () =>
224 projectScopes.map((scope) => ({
225 key: scope.key,
226 label: scope.title,
227 })),
228 [projectScopes],
229 );
230 const projectTitleByProjectKey = useMemo(
231 () =>
232 new Map(
233 projectScopes.flatMap((scope) =>
234 scope.projectRefs.map(
235 (projectRef) =>
236 [
237 scopedProjectKey(projectRef.environmentId, projectRef.projectId),
238 scope.title,
239 ] as const,
240 ),
241 ),
242 ),
243 [projectScopes],
244 );
245 const selectedProjectScope = useMemo(
246 () =>
247 selectedProjectKey === null
248 ? null
249 : (projectScopes.find((scope) => scope.key === selectedProjectKey) ?? null),
250 [projectScopes, selectedProjectKey],
251 );
252 useEffect(() => {
253 if (
254 selectedProjectKey !== null &&
255 !projectFilterOptions.some((project) => project.key === selectedProjectKey)
256 ) {
257 setSelectedProjectKey(null);
258 }
259 }, [projectFilterOptions, selectedProjectKey]);
260 const selectedProjectRefs = useMemo(
261 () =>
262 selectedProjectScope === null
263 ? null
264 : new Set(
265 selectedProjectScope.projectRefs.map((projectRef) =>
266 scopedProjectKey(projectRef.environmentId, projectRef.projectId),
267 ),
268 ),
269 [selectedProjectScope],
270 );
271 const scopedProjects = useMemo(
272 () =>
273 threadListV2Enabled
274 ? []
275 : selectedProjectRefs === null
276 ? projects
277 : projects.filter((project) =>
278 selectedProjectRefs.has(scopedProjectKey(project.environmentId, project.id)),
279 ),
280 [threadListV2Enabled, projects, selectedProjectRefs],
281 );
282 const scopedThreads = useMemo(
283 () =>
284 threadListV2Enabled
285 ? []
286 : selectedProjectRefs === null
287 ? threads
288 : threads.filter((thread) =>
289 selectedProjectRefs.has(scopedProjectKey(thread.environmentId, thread.projectId)),
290 ),
291 [threadListV2Enabled, selectedProjectRefs, threads],
292 );
293 const scopedPendingTasks = useMemo(
294 () =>
295 threadListV2Enabled
296 ? []
297 : selectedProjectRefs === null
298 ? pendingTasks
299 : pendingTasks.filter((pendingTask) =>
300 selectedProjectRefs.has(
301 scopedProjectKey(pendingTask.message.environmentId, pendingTask.creation.projectId),
302 ),
303 ),
304 [threadListV2Enabled, pendingTasks, selectedProjectRefs],
305 );
306 const groups = useMemo(
307 () =>
308 threadListV2Enabled
309 ? []
310 : buildHomeThreadGroups({
311 projects: scopedProjects,
312 threads: scopedThreads,
313 pendingTasks: scopedPendingTasks,
314 environmentId: options.selectedEnvironmentId,
315 searchQuery: props.searchQuery,
316 matchedThreadKeys,
317 projectSortOrder: options.projectSortOrder,
318 threadSortOrder: options.threadSortOrder,
319 projectGroupingMode: options.projectGroupingMode,
320 }),
321 [
322 threadListV2Enabled,
323 matchedThreadKeys,
324 options,
325 props.searchQuery,
326 scopedPendingTasks,
327 scopedProjects,
328 scopedThreads,
329 ],
330 );
331 const [groupDisplayStates, setGroupDisplayStates] = useState<
332 ReadonlyMap<string, HomeGroupDisplayState>
333 >(() => new Map());
334 const updateGroupDisplay = useCallback((key: string, action: HomeGroupDisplayAction) => {
335 setGroupDisplayStates((previous) => {
336 const next = new Map(previous);
337 next.set(
338 key,
339 nextGroupDisplayState(previous.get(key) ?? DEFAULT_GROUP_DISPLAY_STATE, action),
340 );
341 return next;
342 });
343 }, []);
344 const hasSearchQuery = props.searchQuery.trim().length > 0;
345 const listLayout = useMemo(
346 () =>
347 threadListV2Enabled
348 ? EMPTY_HOME_LIST_LAYOUT
349 : buildHomeListLayout({
350 groups,
351 displayStates: groupDisplayStates,
352 showAllThreads: hasSearchQuery,
353 }),
354 [threadListV2Enabled, groups, groupDisplayStates, hasSearchQuery],
355 );
356 const projectByKey = useMemo(() => {
357 const map = new Map<string, EnvironmentProject>();
358 for (const project of projects) {
359 map.set(scopedProjectKey(project.environmentId, project.id), project);
360 }
361 return map;
362 }, [projects]);
363
364 // Thread List v2 (beta) support — same model as the compact Home list
365 // (HomeScreen.tsx): flat creation-order card block + settled recency tail.
366 // The settled tail renders in pages; expansion resets when the filter
367 // context changes so environment/search flips never inherit a deep page.
368 const [settledVisibleCount, setSettledVisibleCount] = useState(
369 THREAD_LIST_V2_SETTLED_INITIAL_COUNT,
370 );
371 const settledResetKey = `${options.selectedEnvironmentId ?? "all"}:${selectedProjectKey ?? "all"}:${props.searchQuery.trim()}`;
372 const lastSettledResetKeyRef = useRef(settledResetKey);
373 if (lastSettledResetKeyRef.current !== settledResetKey) {
374 lastSettledResetKeyRef.current = settledResetKey;
375 setSettledVisibleCount(THREAD_LIST_V2_SETTLED_INITIAL_COUNT);
376 }
377 const showMoreSettled = useCallback(
378 () => setSettledVisibleCount((count) => count + THREAD_LIST_V2_SETTLED_PAGE_COUNT),
379 [],
380 );
381 const {
382 loaded: shelfPreferencesLoaded,
383 settledShelfExpanded,
384 snoozedShelfExpanded,
385 toggleSettledShelf,
386 toggleSnoozedShelf,
387 } = useThreadListV2ShelfPreferences();
388 // The queued-start and snooze helpers need a clock while the pane stays open.
389 const [nowMinute, setNowMinute] = useState(() => new Date().toISOString().slice(0, 16));
390 // Snooze wake times are second-precise; a counter bumped exactly at the
391 // next wake boundary re-runs the partition with a fresh clock so a woken
392 // thread reappears immediately instead of on the next minute tick.
393 const [snoozeWakeTick, bumpSnoozeWakeTick] = useState(0);
394 useEffect(() => {
395 if (!threadListV2Enabled) return;
396 // Refresh immediately because the mount-time value can be hours old.
397 setNowMinute(new Date().toISOString().slice(0, 16));
398 const id = setInterval(() => setNowMinute(new Date().toISOString().slice(0, 16)), 60_000);
399 return () => clearInterval(id);
400 }, [threadListV2Enabled]);
401 // Threads on servers without the settlement capability never classify as
402 // settled (the user could neither un-settle nor pin them).
403 const serverConfigs = useAtomValue(environmentServerConfigsAtom);
404 const settlementEnvironmentIds = useMemo(() => {
405 const supported = new Set<EnvironmentId>();
406 for (const [environmentId, config] of serverConfigs) {
407 if (config.environment.capabilities.threadSettlement === true) {
408 supported.add(environmentId);
409 }
410 }
411 return supported;
412 }, [serverConfigs]);
413 const snoozeEnvironmentIds = useMemo(() => {
414 const supported = new Set<EnvironmentId>();
415 for (const [environmentId, config] of serverConfigs) {
416 if (config.environment.capabilities.threadSnooze === true) {
417 supported.add(environmentId);
418 }
419 }
420 return supported;
421 }, [serverConfigs]);
422 const pinningEnvironmentIds = useMemo(() => {
423 const supported = new Set<EnvironmentId>();
424 for (const [environmentId, config] of serverConfigs) {
425 if (config.environment.capabilities.threadPinning === true) {
426 supported.add(environmentId);
427 }
428 }
429 return supported;
430 }, [serverConfigs]);
431 const pinReorderEnvironmentIds = useMemo(() => {
432 const supported = new Set<EnvironmentId>();
433 for (const [environmentId, config] of serverConfigs) {
434 if (config.environment.capabilities.threadPinReorder === true) {
435 supported.add(environmentId);
436 }
437 }
438 return supported;
439 }, [serverConfigs]);
440 const titleRegenerationEnvironmentIds = useMemo(() => {
441 const supported = new Set<EnvironmentId>();
442 for (const [environmentId, config] of serverConfigs) {
443 if (config.environment.capabilities.threadTitleRegeneration === true) {
444 supported.add(environmentId);
445 }
446 }
447 return supported;
448 }, [serverConfigs]);
449 const machineByEnvironmentId = useMemo(
450 () =>
451 new Map(
452 [...serverConfigs].map(
453 ([environmentId, config]) =>
454 [environmentId, resolveEnvironmentMachineKind(config)] as const,
455 ),
456 ),
457 [serverConfigs],
458 );
459 // Canonical arranged pinned order for Move up/down flags — computed from
460 // all shells so search/scope filtering never disables a valid move.
461 const arrangedPinnedKeys = useMemo(() => {
462 const pinned = sortPinnedThreadsByOrderKey(
463 threads.filter(
464 (thread) =>
465 thread.pinnedAt != null &&
466 thread.archivedAt === null &&
467 pinReorderEnvironmentIds.has(thread.environmentId),
468 ),
469 );
470 return pinned.map((thread) => `${thread.environmentId}:${thread.id}`);
471 }, [pinReorderEnvironmentIds, threads]);
472 const threadListV2Layout = useMemo(() => {
473 if (!threadListV2Enabled)
474 return {
475 items: [],
476 hiddenSettledCount: 0,
477 snoozedCount: 0,
478 snoozedShelfHeaderIndex: null,
479 settledCount: 0,
480 settledShelfHeaderIndex: null,
481 nextSnoozeWakeAt: null,
482 };
483 return buildThreadListV2Items({
484 threads: threads.filter((thread) => thread.archivedAt === null),
485 environmentId: options.selectedEnvironmentId,
486 projectRefs: selectedProjectScope === null ? null : selectedProjectScope.projectRefs,
487 searchQuery: props.searchQuery,
488 matchedThreadKeys,
489 settlementEnvironmentIds,
490 snoozeEnvironmentIds,
491 settledLimit: settledVisibleCount,
492 now: new Date().toISOString(),
493 snoozedShelfExpanded,
494 settledShelfExpanded,
495 selectedThreadKey: props.selectedThreadKey ?? null,
496 });
497 }, [
498 nowMinute,
499 snoozeWakeTick,
500 snoozedShelfExpanded,
501 settledShelfExpanded,
502 props.selectedThreadKey,
503 options.selectedEnvironmentId,
504 props.searchQuery,
505 matchedThreadKeys,
506 settledVisibleCount,
507 settlementEnvironmentIds,
508 snoozeEnvironmentIds,
509 threadListV2Enabled,
510 threads,
511 selectedProjectScope,
512 ]);
513 // Re-partition the moment the earliest snooze expires (clamped to the
514 // signed-32-bit setTimeout range; far-future wakes re-arm at the clamp).
515 const nextSnoozeWakeAt = threadListV2Layout.nextSnoozeWakeAt;
516 useEffect(() => {
517 if (nextSnoozeWakeAt === null) return;
518 const wakeAtMs = Date.parse(nextSnoozeWakeAt);
519 if (Number.isNaN(wakeAtMs)) return;
520 const delayMs = Math.min(Math.max(0, wakeAtMs - Date.now()) + 50, 2_147_483_647);
521 const id = setTimeout(() => bumpSnoozeWakeTick((tick) => tick + 1), delayMs);
522 return () => clearTimeout(id);
523 // snoozeWakeTick must re-arm the timer even when nextSnoozeWakeAt is
524 // unchanged: after a clamped fire (wake beyond the 32-bit setTimeout
525 // range) the boundary string is identical and the chain would die.
526 }, [nextSnoozeWakeAt, snoozeWakeTick]);
527 const listItems = useMemo<readonly SidebarListItem[]>(() => {
528 if (!threadListV2Enabled) return listLayout.items;
529 // Queued offline tasks are not thread shells, so the v2 item builder
530 // never sees them; the shared splice puts them below the active block
531 // (mirrors the compact Home v2 list) where they stay visible and
532 // deletable while their environment is offline. Same environment scope
533 // and search filter as the list.
534 const v2SearchQuery = props.searchQuery.trim().toLocaleLowerCase();
535 const v2PendingTasks = pendingTasks.filter(
536 (pendingTask) =>
537 (options.selectedEnvironmentId === null ||
538 pendingTask.message.environmentId === options.selectedEnvironmentId) &&
539 (selectedProjectRefs === null ||
540 selectedProjectRefs.has(
541 scopedProjectKey(pendingTask.message.environmentId, pendingTask.creation.projectId),
542 )) &&
543 (v2SearchQuery.length === 0 ||
544 pendingTask.title.toLocaleLowerCase().includes(v2SearchQuery)),
545 );
546 const items: SidebarListItem[] = buildThreadListV2ListItems({
547 items: threadListV2Layout.items,
548 pendingTasks: v2PendingTasks,
549 snoozedCount: threadListV2Layout.snoozedCount,
550 snoozedShelfExpanded,
551 snoozedShelfHeaderIndex: threadListV2Layout.snoozedShelfHeaderIndex,
552 settledCount: threadListV2Layout.settledCount,
553 settledShelfExpanded,
554 settledShelfHeaderIndex: threadListV2Layout.settledShelfHeaderIndex,
555 snoozeLabelNow: `${nowMinute}:00.000Z`,
556 });
557 if (settledShelfExpanded && threadListV2Layout.hiddenSettledCount > 0) {
558 items.push({
559 type: "v2-show-more",
560 key: "v2-show-more",
561 hiddenCount: threadListV2Layout.hiddenSettledCount,
562 });
563 }
564 return items;
565 }, [
566 listLayout.items,
567 nowMinute,
568 options.selectedEnvironmentId,
569 pendingTasks,
570 props.searchQuery,
571 selectedProjectRefs,
572 settledShelfExpanded,
573 snoozedShelfExpanded,
574 threadListV2Enabled,
575 threadListV2Layout,
576 ]);
577 const listMenuActions = useMemo<MenuAction[]>(
578 () => [
579 {
580 id: "environment",
581 title: "Environment",
582 subactions: [
583 {
584 id: "environment:all",
585 title: "All environments",
586 subtitle: "Show threads from every environment",
587 state: options.selectedEnvironmentId === null ? "on" : "off",
588 },
589 ...environments.map((environment) => ({
590 id: `environment:${environment.environmentId}`,
591 title: environment.label,
592 state:
593 options.selectedEnvironmentId === environment.environmentId
594 ? ("on" as const)
595 : ("off" as const),
596 })),
597 ],
598 },
599 ...(projectFilterOptions.length === 0
600 ? []
601 : ([
602 {
603 id: "project",
604 title: "Project",
605 subactions: [
606 {
607 id: "project:all",
608 title: "All projects",
609 subtitle: "Show threads from every project",
610 state: selectedProjectKey === null ? "on" : "off",
611 },
612 ...projectFilterOptions.map((project) => ({
613 id: `project:${project.key}`,
614 title: project.label,
615 state: selectedProjectKey === project.key ? ("on" as const) : ("off" as const),
616 })),
617 ],
618 },
619 ] satisfies MenuAction[])),
620 // v2 lays the list out in fixed creation order — offering sort/group
621 // controls it silently ignores would be a lie. Environment still
622 // scopes the v2 partition, so it stays.
623 ...(threadListV2Enabled
624 ? []
625 : ([
626 {
627 id: "project-sort",
628 title: "Sort projects",
629 subactions: PROJECT_SORT_OPTIONS.map((option) => ({
630 id: `project-sort:${option.value}`,
631 title: option.label,
632 state: options.projectSortOrder === option.value ? "on" : "off",
633 })),
634 },
635 {
636 id: "thread-sort",
637 title: "Sort threads",
638 subactions: THREAD_SORT_OPTIONS.map((option) => ({
639 id: `thread-sort:${option.value}`,
640 title: option.label,
641 state: options.threadSortOrder === option.value ? "on" : "off",
642 })),
643 },
644 ] satisfies MenuAction[])),
645 ],
646 [environments, options, projectFilterOptions, selectedProjectKey, threadListV2Enabled],
647 );
648 const handleListMenuAction = useCallback(
649 ({ nativeEvent }: { readonly nativeEvent: { readonly event: string } }) => {
650 const event = nativeEvent.event;
651 if (event === "environment:all") {
652 setSelectedEnvironmentId(null);
653 return;
654 }
655 if (event.startsWith("environment:")) {
656 const environment = environments.find(
657 (candidate) => String(candidate.environmentId) === event.slice("environment:".length),
658 );
659 if (environment) setSelectedEnvironmentId(environment.environmentId);
660 return;
661 }
662 if (event === "project:all") {
663 setSelectedProjectKey(null);
664 return;
665 }
666 if (event.startsWith("project:")) {
667 const projectKey = event.slice("project:".length);
668 if (projectFilterOptions.some((project) => project.key === projectKey)) {
669 setSelectedProjectKey(projectKey);
670 }
671 return;
672 }
673 const projectSort = PROJECT_SORT_OPTIONS.find(
674 (option) => `project-sort:${option.value}` === event,
675 );
676 if (projectSort) {
677 setProjectSortOrder(projectSort.value);
678 return;
679 }
680 const threadSort = THREAD_SORT_OPTIONS.find(
681 (option) => `thread-sort:${option.value}` === event,
682 );
683 if (threadSort) {
684 setThreadSortOrder(threadSort.value);
685 return;
686 }
687 },
688 [
689 environments,
690 projectFilterOptions,
691 setProjectSortOrder,
692 setSelectedEnvironmentId,
693 setThreadSortOrder,
694 ],
695 );
696
697 const [measuredHeaderHeight, setMeasuredHeaderHeight] = useState<number | null>(null);
698 // The sticky header (title row, search field, optional connection status)
699 // is measured so the list inset always matches its real height — no
700 // hardcoded per-variant constants.
701 const stickyHeaderHeight = measuredHeaderHeight ?? insets.top + SIDEBAR_STICKY_HEADER_HEIGHT;
702 const topListInset = stickyHeaderHeight + 6;
703 const handleStickyHeaderLayout = useCallback((event: LayoutChangeEvent) => {
704 const nextHeight = Math.round(event.nativeEvent.layout.height);
705 setMeasuredHeaderHeight((current) => (current === nextHeight ? current : nextHeight));
706 }, []);
707 const handleSwipeableWillOpen = useCallback((methods: SwipeableMethods) => {
708 if (openSwipeableRef.current !== methods) {
709 openSwipeableRef.current?.close();
710 openSwipeableRef.current = methods;
711 }
712 }, []);
713 const handleSwipeableClose = useCallback((methods: SwipeableMethods) => {
714 if (openSwipeableRef.current === methods) {
715 openSwipeableRef.current = null;
716 }
717 }, []);
718 const handleSelectThread = useCallback(
719 (thread: EnvironmentThreadShell) => {
720 props.onSelectThread(thread);
721 openSwipeableRef.current?.close();
722 },
723 [props.onSelectThread],
724 );
725 const handleScrollBeginDrag = useCallback(() => {
726 openSwipeableRef.current?.close();
727 }, []);
728 const { swipeEnabled, scrollGateHandlers } = useSwipeableScrollGate({
729 onScrollBeginDrag: handleScrollBeginDrag,
730 });
731 // Project shells load after the first rows draw, so the maps they feed have
732 // to bust the recycler's memoization — otherwise a row keeps the blank
733 // favicon and fallback title it was first rendered with.
734 const listExtraData = useMemo(
735 () => ({
736 selectedThreadKey: props.selectedThreadKey ?? "",
737 projectByKey,
738 projectTitleByProjectKey,
739 savedConnectionsById,
740 serverConfigs,
741 snoozePresetMinute: nowMinute,
742 threadSearchMatchByKey,
743 }),
744 [
745 props.selectedThreadKey,
746 projectByKey,
747 projectTitleByProjectKey,
748 savedConnectionsById,
749 serverConfigs,
750 nowMinute,
751 threadSearchMatchByKey,
752 ],
753 );
754 const sidebarItemsAreEqual = useCallback(
755 (previous: SidebarListItem, item: SidebarListItem): boolean => {
756 if (previous.type === "v2-thread" && item.type === "v2-thread") {
757 return (
758 previous.key === item.key &&
759 previous.item.thread === item.item.thread &&
760 previous.item.variant === item.item.variant &&
761 previous.item.snoozed === item.item.snoozed &&
762 previous.item.pinned === item.item.pinned &&
763 previous.snoozeWakeLabelText === item.snoozeWakeLabelText
764 );
765 }
766 if (previous.type === "v2-show-more" && item.type === "v2-show-more") {
767 return previous.hiddenCount === item.hiddenCount;
768 }
769 if (previous.type === "v2-pending" && item.type === "v2-pending") {
770 return (
771 previous.pendingTask === item.pendingTask &&
772 previous.showPendingDivider === item.showPendingDivider
773 );
774 }
775 if (previous.type === "v2-snoozed-shelf" && item.type === "v2-snoozed-shelf") {
776 return previous.count === item.count && previous.expanded === item.expanded;
777 }
778 if (previous.type === "v2-settled-shelf" && item.type === "v2-settled-shelf") {
779 return previous.count === item.count && previous.expanded === item.expanded;
780 }
781 if (
782 previous.type === "v2-thread" ||
783 previous.type === "v2-show-more" ||
784 previous.type === "v2-pending" ||
785 previous.type === "v2-snoozed-shelf" ||
786 previous.type === "v2-settled-shelf" ||
787 item.type === "v2-thread" ||
788 item.type === "v2-show-more" ||
789 item.type === "v2-pending" ||
790 item.type === "v2-snoozed-shelf" ||
791 item.type === "v2-settled-shelf"
792 ) {
793 return false;
794 }
795 return homeListItemsAreEqual(previous, item);
796 },
797 [],
798 );
799 const focusSearch = useCallback(() => {
800 const focus = () => {
801 if (props.nativeChrome) {
802 searchBarRef.current?.focus();
803 return;
804 }
805 searchInputRef.current?.focus();
806 };
807 if (!props.visible) {
808 props.onRequestVisibility();
809 setTimeout(focus, 240);
810 } else {
811 focus();
812 }
813 return true;
814 }, [props.nativeChrome, props.onRequestVisibility, props.visible]);
815 useHardwareKeyboardCommand("focusSearch", focusSearch);
816 const renderListItem = useCallback(
817 ({ item }: { readonly item: SidebarListItem }) => {
818 switch (item.type) {
819 case "v2-pending": {
820 const pendingScopeKey = scopedProjectKey(
821 item.pendingTask.message.environmentId,
822 item.pendingTask.creation.projectId,
823 );
824 return (
825 <ThreadListV2PendingRow
826 pendingTask={item.pendingTask}
827 project={projectByKey.get(pendingScopeKey) ?? null}
828 projectTitle={projectTitleByProjectKey.get(pendingScopeKey)}
829 environmentLabel={
830 Object.keys(savedConnectionsById).length > 1
831 ? (savedConnectionsById[item.pendingTask.message.environmentId]
832 ?.environmentLabel ?? null)
833 : null
834 }
835 environmentMachine={machineByEnvironmentId.get(
836 item.pendingTask.message.environmentId,
837 )}
838 pane="sidebar"
839 showPendingDivider={item.showPendingDivider}
840 onSelectPendingTask={openPendingTask}
841 onDeletePendingTask={confirmDeletePendingTask}
842 />
843 );
844 }
845 case "v2-thread": {
846 const thread = item.item.thread;
847 const scopeKey = scopedProjectKey(thread.environmentId, thread.projectId);
848 return (
849 <ThreadListV2Row
850 thread={thread}
851 variant={item.item.variant}
852 snoozed={item.item.snoozed}
853 pinned={item.item.pinned}
854 snoozePresetMinute={nowMinute}
855 snoozeWakeLabelText={item.snoozeWakeLabelText}
856 project={projectByKey.get(scopeKey) ?? null}
857 projectTitle={projectTitleByProjectKey.get(scopeKey)}
858 providerDriver={
859 serverConfigs
860 .get(thread.environmentId)
861 ?.providers.find(
862 (provider) =>
863 provider.instanceId ===
864 (thread.session?.providerInstanceId ?? thread.modelSelection.instanceId),
865 )?.driver ?? null
866 }
867 environmentLabel={
868 Object.keys(savedConnectionsById).length > 1
869 ? (savedConnectionsById[thread.environmentId]?.environmentLabel ?? null)
870 : null
871 }
872 environmentMachine={machineByEnvironmentId.get(thread.environmentId)}
873 searchMatch={threadSearchMatchByKey.get(
874 threadSearchMatchKey({
875 environmentId: thread.environmentId,
876 threadId: thread.id,
877 }),
878 )}
879 searchQuery={props.searchQuery}
880 pane="sidebar"
881 selected={
882 scopedThreadKey(thread.environmentId, thread.id) === props.selectedThreadKey
883 }
884 fullSwipeWidth={props.width - 20}
885 onSelectThread={handleSelectThread}
886 onDeleteThread={confirmDeleteThread}
887 onArchiveThread={archiveThread}
888 onRegenerateThreadTitle={regenerateThreadTitle}
889 titleRegenerationSupported={titleRegenerationEnvironmentIds.has(thread.environmentId)}
890 settlementSupported={settlementEnvironmentIds.has(thread.environmentId)}
891 onSettleThread={settleThread}
892 snoozeSupported={snoozeEnvironmentIds.has(thread.environmentId)}
893 pinningSupported={pinningEnvironmentIds.has(thread.environmentId)}
894 pinReorderSupported={pinReorderEnvironmentIds.has(thread.environmentId)}
895 canMovePinnedUp={
896 arrangedPinnedKeys.indexOf(`${thread.environmentId}:${thread.id}`) > 0
897 }
898 canMovePinnedDown={(() => {
899 const index = arrangedPinnedKeys.indexOf(`${thread.environmentId}:${thread.id}`);
900 return index !== -1 && index < arrangedPinnedKeys.length - 1;
901 })()}
902 onSnoozeThread={snoozeThread}
903 onUnsnoozeThread={unsnoozeThread}
904 onUnsettleThread={unsettleThread}
905 onPinThread={pinThread}
906 onUnpinThread={unpinThread}
907 onMovePinnedThread={movePinnedThread}
908 onSwipeableClose={handleSwipeableClose}
909 onSwipeableWillOpen={handleSwipeableWillOpen}
910 simultaneousSwipeGesture={sidebarScrollGesture}
911 />
912 );
913 }
914 case "v2-snoozed-shelf":
915 return (
916 <ThreadListV2SnoozedShelfHeader
917 count={item.count}
918 disabled={!shelfPreferencesLoaded}
919 expanded={item.expanded}
920 onToggle={toggleSnoozedShelf}
921 pane="sidebar"
922 />
923 );
924 case "v2-settled-shelf":
925 return (
926 <ThreadListV2SettledShelfHeader
927 count={item.count}
928 disabled={!shelfPreferencesLoaded}
929 expanded={item.expanded}
930 onToggle={toggleSettledShelf}
931 pane="sidebar"
932 />
933 );
934 case "v2-show-more":
935 return (
936 <Pressable
937 accessibilityRole="button"
938 accessibilityLabel={`Show ${Math.min(item.hiddenCount, THREAD_LIST_V2_SETTLED_PAGE_COUNT)} more settled threads`}
939 onPress={showMoreSettled}
940 className="mx-4 mt-2 items-center rounded-lg border border-dashed border-border py-2.5"
941 style={({ pressed }) => ({ opacity: pressed ? 0.6 : 1 })}
942 >
943 <Text className="text-xs font-t3-medium text-foreground-muted">
944 Show more ({item.hiddenCount} settled hidden)
945 </Text>
946 </Pressable>
947 );
948 case "header":
949 return (
950 <ThreadListGroupHeader
951 variant="sidebar"
952 collapsed={item.collapsed}
953 isFirst={item.isFirst}
954 groupKey={item.group.key}
955 onGroupAction={updateGroupDisplay}
956 // Same gating as the compact Home list: aggregated groups have no
957 // single target project, and pending-project groups hold a
958 // placeholder shell rather than a real project.
959 newThreadTarget={item.group.newThreadTarget}
960 onNewThread={props.onNewThreadInProject}
961 project={item.group.representative}
962 threadCount={item.group.threads.length + item.group.pendingTasks.length}
963 title={item.group.title}
964 />
965 );
966 case "pending-task":
967 return (
968 <PendingTaskListRow
969 variant="sidebar"
970 pendingTask={item.pendingTask}
971 environmentLabel={
972 savedConnectionsById[item.pendingTask.message.environmentId]?.environmentLabel ??
973 null
974 }
975 environmentMachine={machineByEnvironmentId.get(
976 item.pendingTask.message.environmentId,
977 )}
978 isLast={item.isLast}
979 onSelectPendingTask={openPendingTask}
980 onDeletePendingTask={confirmDeletePendingTask}
981 />
982 );
983 case "thread": {
984 const thread = item.thread;
985 return (
986 <ThreadListRow
987 variant="sidebar"
988 thread={thread}
989 environmentLabel={
990 savedConnectionsById[thread.environmentId]?.environmentLabel ?? null
991 }
992 environmentMachine={machineByEnvironmentId.get(thread.environmentId)}
993 isLast={item.isLast}
994 searchMatch={threadSearchMatchByKey.get(
995 threadSearchMatchKey({
996 environmentId: thread.environmentId,
997 threadId: thread.id,
998 }),
999 )}
1000 searchQuery={props.searchQuery}
1001 selected={
1002 scopedThreadKey(thread.environmentId, thread.id) === props.selectedThreadKey
1003 }
1004 fullSwipeWidth={props.width - 20}
1005 onArchiveThread={archiveThread}
1006 onDeleteThread={confirmDeleteThread}
1007 onRegenerateThreadTitle={regenerateThreadTitle}
1008 titleRegenerationSupported={titleRegenerationEnvironmentIds.has(thread.environmentId)}
1009 onSelectThread={handleSelectThread}
1010 onSwipeableClose={handleSwipeableClose}
1011 onSwipeableWillOpen={handleSwipeableWillOpen}
1012 simultaneousSwipeGesture={sidebarScrollGesture}
1013 />
1014 );
1015 }
1016 case "show-more":
1017 return (
1018 <ThreadListShowMoreRow
1019 variant="sidebar"
1020 hiddenCount={item.hiddenCount}
1021 canShowLess={item.canShowLess}
1022 groupKey={item.groupKey}
1023 onGroupAction={updateGroupDisplay}
1024 />
1025 );
1026 }
1027 },
1028 [
1029 archiveThread,
1030 arrangedPinnedKeys,
1031 confirmDeletePendingTask,
1032 confirmDeleteThread,
1033 handleSelectThread,
1034 handleSwipeableClose,
1035 handleSwipeableWillOpen,
1036 machineByEnvironmentId,
1037 movePinnedThread,
1038 openPendingTask,
1039 pinReorderEnvironmentIds,
1040 pinThread,
1041 pinningEnvironmentIds,
1042 projectByKey,
1043 projectTitleByProjectKey,
1044 regenerateThreadTitle,
1045 props.onNewThreadInProject,
1046 props.searchQuery,
1047 props.selectedThreadKey,
1048 props.width,
1049 savedConnectionsById,
1050 serverConfigs,
1051 shelfPreferencesLoaded,
1052 threadSearchMatchByKey,
1053 titleRegenerationEnvironmentIds,
1054 settleThread,
1055 settlementEnvironmentIds,
1056 showMoreSettled,
1057 sidebarScrollGesture,
1058 snoozeEnvironmentIds,
1059 snoozeThread,
1060 nowMinute,
1061 toggleSettledShelf,
1062 toggleSnoozedShelf,
1063 unpinThread,
1064 unsettleThread,
1065 unsnoozeThread,
1066 updateGroupDisplay,
1067 ],
1068 );
1069 // v2 ignores the sort/group options, so only the environment filter can
1070 // light the "customized" state while the beta is on.
1071 const filterCustomized = threadListV2Enabled
1072 ? options.selectedEnvironmentId !== null || selectedProjectKey !== null
1073 : hasCustomHomeListOptions({ ...options, selectedProjectKey });
1074 const filterIcon = filterCustomized
1075 ? "line.3.horizontal.decrease.circle.fill"
1076 : "line.3.horizontal.decrease.circle";
1077 const filterMenu = useMemo(
1078 () =>
1079 buildHomeListFilterMenu({
1080 environments,
1081 projects: projectFilterOptions,
1082 selectedEnvironmentId: options.selectedEnvironmentId,
1083 selectedProjectKey,
1084 projectSortOrder: options.projectSortOrder,
1085 threadSortOrder: options.threadSortOrder,
1086 onEnvironmentChange: setSelectedEnvironmentId,
1087 onProjectChange: setSelectedProjectKey,
1088 onProjectSortOrderChange: setProjectSortOrder,
1089 onThreadSortOrderChange: setThreadSortOrder,
1090 listOrganization: !threadListV2Enabled,
1091 }),
1092 [
1093 environments,
1094 options,
1095 projectFilterOptions,
1096 selectedProjectKey,
1097 setProjectSortOrder,
1098 setSelectedEnvironmentId,
1099 setThreadSortOrder,
1100 threadListV2Enabled,
1101 ],
1102 );
1103 const nativeHeaderItems = useMemo(
1104 () =>
1105 createSidebarHeaderItems({
1106 filterIcon,
1107 filterMenu,
1108 onOpenSettings: props.onOpenSettings,
1109 }),
1110 [filterIcon, filterMenu, props.onOpenSettings],
1111 );
1112 // Snoozed threads need no special case: the shelf header is a list row
1113 // even while collapsed.
1114 const listEmpty = (
1115 <Text className="px-2 py-4 text-sm text-foreground-muted">
1116 {catalogState.isLoadingConnections
1117 ? "Loading threads…"
1118 : props.searchQuery.trim().length > 0
1119 ? threadSearch.isPending
1120 ? "Searching thread messages…"
1121 : "No matching threads"
1122 : selectedProjectScope !== null
1123 ? `No threads in ${selectedProjectScope.title}`
1124 : "No threads yet"}
1125 </Text>
1126 );
1127
1128 if (props.nativeChrome) {
1129 return (
1130 <>
1131 <NativeStackScreenOptions
1132 optionsVersion={[nativeHeaderItems, props.width]}
1133 options={{
1134 // Re-applies the shell's static brand slot with the
1135 // connection-status swap so reconnects surface in the header
1136 // instead of shifting the list.
1137 ...getConnectionAwareBrandHeaderOptions({
1138 headerWidth: props.width,
1139 trailingItemCount: nativeHeaderItems.length,
1140 onOpenEnvironments: props.onOpenEnvironmentSettings,
1141 fallbackTitleStyle: { fontSize: 18, fontWeight: "800" },
1142 }),
1143 headerSearchBarOptions: {
1144 ref: searchBarRef,
1145 autoCapitalize: "none",
1146 hideNavigationBar: false,
1147 // Keep the search bar pinned under the title — UIKit's default
1148 // hidesSearchBarWhenScrolling collapses it on scroll.
1149 hideWhenScrolling: false,
1150 obscureBackground: false,
1151 placeholder: "Search",
1152 placement: "stacked",
1153 onCancelButtonPress: () => {
1154 props.onSearchQueryChange("");
1155 },
1156 onChangeText: (event) => {
1157 props.onSearchQueryChange(event.nativeEvent.text);
1158 },
1159 },
1160 unstable_headerRightItems: () => nativeHeaderItems,
1161 }}
1162 />
1163 <View className="flex-1">
1164 <SwipeableScrollGateProvider enabled={swipeEnabled}>
1165 <GestureDetector gesture={sidebarScrollGesture}>
1166 <LegendList
1167 data={listItems}
1168 drawDistance={500}
1169 estimatedItemSize={64}
1170 extraData={listExtraData}
1171 getItemType={(item) => item.type}
1172 itemsAreEqual={sidebarItemsAreEqual}
1173 keyExtractor={(item) => item.key}
1174 renderItem={renderListItem}
1175 automaticallyAdjustsScrollIndicatorInsets={NATIVE_LIQUID_GLASS_SUPPORTED}
1176 contentInsetAdjustmentBehavior={
1177 NATIVE_LIQUID_GLASS_SUPPORTED ? "automatic" : "never"
1178 }
1179 contentContainerStyle={[
1180 styles.threadListContent,
1181 {
1182 paddingBottom: Math.max(insets.bottom, 16) + 16,
1183 paddingTop: 6,
1184 },
1185 ]}
1186 keyboardDismissMode="on-drag"
1187 keyboardShouldPersistTaps="handled"
1188 {...scrollGateHandlers}
1189 recycleItems
1190 scrollEventThrottle={16}
1191 showsVerticalScrollIndicator={false}
1192 style={styles.threadList}
1193 ListEmptyComponent={listEmpty}
1194 />
1195 </GestureDetector>
1196 </SwipeableScrollGateProvider>
1197 </View>
1198 </>
1199 );
1200 }
1201
1202 return (
1203 <View
1204 testID="thread-navigation-sidebar"
1205 className="flex-1 border-r border-border bg-drawer"
1206 style={{ width: props.width }}
1207 >
1208 <View className="flex-1" style={{ paddingBottom: insets.bottom }}>
1209 <SwipeableScrollGateProvider enabled={swipeEnabled}>
1210 <GestureDetector gesture={sidebarScrollGesture}>
1211 <LegendList
1212 data={listItems}
1213 drawDistance={500}
1214 estimatedItemSize={64}
1215 extraData={listExtraData}
1216 getItemType={(item) => item.type}
1217 itemsAreEqual={sidebarItemsAreEqual}
1218 keyExtractor={(item) => item.key}
1219 renderItem={renderListItem}
1220 contentContainerStyle={[
1221 styles.threadListContent,
1222 {
1223 paddingBottom:
1224 Platform.OS === "android"
1225 ? Math.max(insets.bottom, 16) + 88 - insets.bottom
1226 : 16 + insets.bottom,
1227 paddingTop: topListInset,
1228 },
1229 ]}
1230 keyboardDismissMode="on-drag"
1231 keyboardShouldPersistTaps="handled"
1232 {...scrollGateHandlers}
1233 recycleItems
1234 scrollEventThrottle={16}
1235 showsVerticalScrollIndicator={false}
1236 style={styles.threadList}
1237 ListEmptyComponent={listEmpty}
1238 />
1239 </GestureDetector>
1240 </SwipeableScrollGateProvider>
1241 </View>
1242
1243 <View
1244 className="absolute inset-x-0 top-0 z-[4] bg-drawer"
1245 collapsable={false}
1246 onLayout={handleStickyHeaderLayout}
1247 pointerEvents="auto"
1248 style={{ paddingTop: insets.top }}
1249 >
1250 <View className="h-[50px] flex-row items-end gap-0.5 pr-2 pl-5">
1251 {/* Title slot doubles as the connection status surface: while an
1252 environment reconnects, the brand fades to a status label in
1253 place (no layout shift in the list below). */}
1254 <WorkspaceConnectionTitle
1255 grow
1256 onPress={props.onOpenEnvironmentSettings}
1257 size="pageTitle"
1258 brand={
1259 <View className="h-11 flex-1 justify-center">
1260 <CompactBrandTitle allowFontScaling={false} />
1261 </View>
1262 }
1263 />
1264 <View className="flex-row items-center gap-2.5">
1265 <ControlPillMenu actions={listMenuActions} onPressAction={handleListMenuAction}>
1266 <SidebarFilterButton accessibilityLabel="Filter and sort threads" icon={filterIcon} />
1267 </ControlPillMenu>
1268 <SidebarHeaderActions onOpenSettings={props.onOpenSettings} />
1269 </View>
1270 </View>
1271
1272 <View className="mx-4 mt-[9px] h-[38px] flex-row items-center gap-1.5 rounded-xl bg-sidebar-search pr-2.5 pl-[11px]">
1273 <SymbolView
1274 name="magnifyingglass"
1275 size={15}
1276 tintColorClassName={"accent-foreground-muted"}
1277 type="monochrome"
1278 />
1279 <TextInput
1280 ref={searchInputRef}
1281 accessibilityLabel="Search threads"
1282 autoCapitalize="none"
1283 autoCorrect={false}
1284 clearButtonMode="while-editing"
1285 onChangeText={props.onSearchQueryChange}
1286 placeholder="Search"
1287 placeholderTextColorClassName={"accent-placeholder"}
1288 returnKeyType="search"
1289 className="h-[34px] flex-1 px-0 py-0 font-sans text-base text-foreground"
1290 value={props.searchQuery}
1291 />
1292 </View>
1293 </View>
1294 </View>
1295 );
1296}
1297
1298const styles = StyleSheet.create({
1299 threadList: {
1300 flex: 1,
1301 },
1302 threadListContent: {
1303 paddingHorizontal: 8,
1304 },
1305});