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

ThreadNavigationSidebar.tsx

1,308 lines48.4 KB

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