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

ThreadNavigationSidebar.tsx

1,347 lines49.3 KB

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