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