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

ThreadNavigationSidebar.tsx

747 lines26.6 KB

1import { isLiquidGlassSupported, LiquidGlassView } from "@callstack/liquid-glass";
2import type { EnvironmentProject, EnvironmentThreadShell } from "@v12/client-runtime/state/shell";
3import { LegendList } from "@legendapp/list/react-native";
4import type { MenuAction } from "@react-native-menu/menu";
5import { useCallback, useMemo, useRef, useState, type ReactNode } from "react";
6import type { LayoutChangeEvent, NativeScrollEvent, NativeSyntheticEvent } from "react-native";
7import { Platform, StyleSheet, TextInput, View, useColorScheme } from "react-native";
8import { Gesture, GestureDetector } from "react-native-gesture-handler";
9import type { SwipeableMethods } from "react-native-gesture-handler/ReanimatedSwipeable";
10import { useSafeAreaInsets } from "react-native-safe-area-context";
11import type { SearchBarCommands } from "react-native-screens";
12import Svg, { Defs, LinearGradient, Rect, Stop } from "react-native-svg";
13​
14import { AppText as Text } from "../../components/AppText";
15import { ControlPillMenu } from "../../components/ControlPill";
16import { SymbolView } from "../../components/AppSymbol";
17import { NativeStackScreenOptions } from "../../native/StackHeader";
18import { scopedProjectKey, scopedThreadKey } from "../../lib/scopedEntities";
19import { useThemeColor } from "../../lib/useThemeColor";
20import { useProjects, useThreadShells } from "../../state/entities";
21import { usePendingNewTasks } from "../../state/use-pending-new-tasks";
22import { useWorkspaceState } from "../../state/workspace";
23import { useSavedRemoteConnections } from "../../state/use-remote-environment-registry";
24import { useHardwareKeyboardCommand } from "../keyboard/hardwareKeyboardCommands";
25import {
26 hasCustomHomeListOptions,
27 PROJECT_GROUPING_OPTIONS,
28 PROJECT_SORT_OPTIONS,
29 THREAD_SORT_OPTIONS,
30 useHomeListOptions,
31} from "../home/home-list-options";
32import { buildHomeListFilterMenu } from "../home/home-list-filter-menu";
33import {
34 buildHomeListLayout,
35 DEFAULT_GROUP_DISPLAY_STATE,
36 homeListItemsAreEqual,
37 nextGroupDisplayState,
38 type HomeGroupDisplayAction,
39 type HomeGroupDisplayState,
40 type HomeListItem,
41} from "../home/homeListItems";
42import { buildHomeThreadGroups } from "../home/homeThreadList";
43import { SwipeableScrollGateProvider, useSwipeableScrollGate } from "../home/thread-swipe-actions";
44import { usePendingTaskListActions } from "../home/usePendingTaskListActions";
45import { useThreadListActions } from "../home/useThreadListActions";
46import { WorkspaceConnectionStatus } from "../home/WorkspaceConnectionStatus";
47import { shouldShowWorkspaceConnectionStatus } from "../home/workspace-connection-status";
48import { SidebarHeaderActions } from "./sidebar-header-actions";
49import { SidebarFilterButton } from "./sidebar-filter-button";
50import { createSidebarHeaderItems } from "./sidebar-native-header-items";
51import { SidebarNavigationShell } from "./sidebar-navigation-shell";
52import {
53 PendingTaskListRow,
54 ThreadListGroupHeader,
55 ThreadListRow,
56 ThreadListShowMoreRow,
57} from "./thread-list-items";
58​
59/**
60 * Shared capsule behind the sidebar header buttons — a native liquid-glass
61 * surface on iOS 26+, a tinted pill everywhere else.
62 */
63function SidebarHeaderButtonGroup(props: {
64 readonly children: ReactNode;
65 readonly colorScheme: "light" | "dark";
66}) {
67 if (isLiquidGlassSupported) {
68 return (
69 <LiquidGlassView
70 colorScheme={props.colorScheme}
71 effect="regular"
72 interactive
73 style={styles.headerButtonGroup}
74 >
75 {props.children}
76 </LiquidGlassView>
77 );
78 }
79​
80 return (
81 <View
82 style={[
83 styles.headerButtonGroup,
84 props.colorScheme === "dark"
85 ? { backgroundColor: "rgba(118,118,128,0.24)", borderColor: "rgba(255,255,255,0.08)" }
86 : { backgroundColor: "rgba(255,255,255,0.72)", borderColor: "rgba(0,0,0,0.08)" },
87 { borderWidth: StyleSheet.hairlineWidth },
88 ]}
89 >
90 {props.children}
91 </View>
92 );
94​
95const SIDEBAR_STICKY_HEADER_HEIGHT = 106;
96const SIDEBAR_STICKY_HEADER_FADE_HEIGHT = 44;
97const SIDEBAR_HEADER_WASH_OPACITY = {
98 dark: [0.22, 0.14, 0.04],
99 light: [0.46, 0.3, 0.08],
100} as const;
101​
102interface ThreadNavigationSidebarProps {
103 readonly width: number;
104 readonly visible: boolean;
105 readonly selectedThreadKey: string | null;
106 readonly onOpenSettings: () => void;
107 readonly onOpenEnvironmentSettings: () => void;
108 readonly onNewThreadInProject: (project: EnvironmentProject) => void;
109 readonly onSearchQueryChange: (query: string) => void;
110 readonly onSelectThread: (thread: EnvironmentThreadShell) => void;
111 readonly onRequestVisibility: () => void;
112 readonly searchQuery: string;
114​
115/**
116 * iPad/large-width sidebar column.
117 *
118 * On iOS the pane is hosted inside its own navigation-inert single-screen
119 * native stack (SidebarNavigationShell) so the header is a real
120 * UINavigationBar: large title, native bar-button items, and a
121 * UISearchController search field — the same chrome a UISplitViewController
122 * column gets. Other platforms keep the custom header chrome.
123 */
124export function ThreadNavigationSidebar(props: ThreadNavigationSidebarProps) {
125 if (Platform.OS !== "ios") {
126 return <ThreadNavigationSidebarPane {...props} nativeChrome={false} />;
127 }
128 return <NativeSidebarContainer {...props} />;
130​
131function NativeSidebarContainer(props: ThreadNavigationSidebarProps) {
132 const backgroundColor = useThemeColor("--color-drawer");
133 const borderColor = useThemeColor("--color-border");
134​
135 return (
136 <View
137 testID="thread-navigation-sidebar"
138 className="flex-1"
139 style={{
140 width: props.width,
141 backgroundColor,
142 borderRightColor: borderColor,
143 borderRightWidth: StyleSheet.hairlineWidth,
144 }}
145 >
146 <SidebarNavigationShell>
147 <ThreadNavigationSidebarPane {...props} nativeChrome />
148 </SidebarNavigationShell>
149 </View>
150 );
152​
153function ThreadNavigationSidebarPane(
154 props: ThreadNavigationSidebarProps & { readonly nativeChrome: boolean },
155) {
156 const insets = useSafeAreaInsets();
157 const colorScheme = useColorScheme() === "dark" ? "dark" : "light";
158 const projects = useProjects();
159 const threads = useThreadShells();
160 const { state: catalogState } = useWorkspaceState();
161 const { savedConnectionsById } = useSavedRemoteConnections();
162 const [headerIsOverContent, setHeaderIsOverContent] = useState(false);
163 const searchInputRef = useRef<TextInput>(null);
164 const searchBarRef = useRef<SearchBarCommands>(null);
165 const openSwipeableRef = useRef<SwipeableMethods | null>(null);
166 const headerIsOverContentRef = useRef(false);
167 const sidebarScrollGesture = useMemo(() => Gesture.Native(), []);
168 const { archiveThread, confirmDeleteThread } = useThreadListActions();
169 const pendingTasks = usePendingNewTasks();
170 const { openPendingTask, confirmDeletePendingTask } = usePendingTaskListActions();
171 const environments = useMemo(
172 () =>
173 Object.values(savedConnectionsById)
174 .map((connection) => ({
175 environmentId: connection.environmentId,
176 label: connection.environmentLabel,
177 }))
178 .sort((left, right) => left.label.localeCompare(right.label)),
179 [savedConnectionsById],
180 );
181 const availableEnvironmentIds = useMemo(
182 () => new Set(environments.map((environment) => environment.environmentId)),
183 [environments],
184 );
185 const {
186 options,
187 setSelectedEnvironmentId,
188 setProjectGroupingMode,
189 setProjectSortOrder,
190 setThreadSortOrder,
191 } = useHomeListOptions(availableEnvironmentIds);
192 const groups = useMemo(
193 () =>
194 buildHomeThreadGroups({
195 projects,
196 threads,
197 pendingTasks,
198 environmentId: options.selectedEnvironmentId,
199 searchQuery: props.searchQuery,
200 projectSortOrder: options.projectSortOrder,
201 threadSortOrder: options.threadSortOrder,
202 projectGroupingMode: options.projectGroupingMode,
203 }),
204 [options, pendingTasks, projects, props.searchQuery, threads],
205 );
206 const [groupDisplayStates, setGroupDisplayStates] = useState<
207 ReadonlyMap<string, HomeGroupDisplayState>
208 >(() => new Map());
209 const updateGroupDisplay = useCallback((key: string, action: HomeGroupDisplayAction) => {
210 setGroupDisplayStates((previous) => {
211 const next = new Map(previous);
212 next.set(
213 key,
214 nextGroupDisplayState(previous.get(key) ?? DEFAULT_GROUP_DISPLAY_STATE, action),
215 );
216 return next;
217 });
218 }, []);
219 const hasSearchQuery = props.searchQuery.trim().length > 0;
220 const listLayout = useMemo(
221 () =>
222 buildHomeListLayout({
223 groups,
224 displayStates: groupDisplayStates,
225 showAllThreads: hasSearchQuery,
226 }),
227 [groups, groupDisplayStates, hasSearchQuery],
228 );
229 const projectCwdByKey = useMemo(() => {
230 const map = new Map<string, string>();
231 for (const project of projects) {
232 map.set(scopedProjectKey(project.environmentId, project.id), project.workspaceRoot);
233 }
234 return map;
235 }, [projects]);
236 const showsConnectionStatus = shouldShowWorkspaceConnectionStatus(catalogState);
237 const listMenuActions = useMemo<MenuAction[]>(
238 () => [
239 {
240 id: "environment",
241 title: "Environment",
242 subactions: [
243 {
244 id: "environment:all",
245 title: "All environments",
246 subtitle: "Show threads from every environment",
247 state: options.selectedEnvironmentId === null ? "on" : "off",
248 },
249 ...environments.map((environment) => ({
250 id: `environment:${environment.environmentId}`,
251 title: environment.label,
252 state:
253 options.selectedEnvironmentId === environment.environmentId
254 ? ("on" as const)
255 : ("off" as const),
256 })),
257 ],
258 },
259 {
260 id: "project-sort",
261 title: "Sort projects",
262 subactions: PROJECT_SORT_OPTIONS.map((option) => ({
263 id: `project-sort:${option.value}`,
264 title: option.label,
265 state: options.projectSortOrder === option.value ? "on" : "off",
266 })),
267 },
268 {
269 id: "thread-sort",
270 title: "Sort threads",
271 subactions: THREAD_SORT_OPTIONS.map((option) => ({
272 id: `thread-sort:${option.value}`,
273 title: option.label,
274 state: options.threadSortOrder === option.value ? "on" : "off",
275 })),
276 },
277 {
278 id: "project-grouping",
279 title: "Group projects",
280 subactions: PROJECT_GROUPING_OPTIONS.map((option) => ({
281 id: `project-grouping:${option.value}`,
282 title: option.label,
283 subtitle: option.subtitle,
284 state: options.projectGroupingMode === option.value ? "on" : "off",
285 })),
286 },
287 ],
288 [environments, options],
289 );
290 const handleListMenuAction = useCallback(
291 ({ nativeEvent }: { readonly nativeEvent: { readonly event: string } }) => {
292 const event = nativeEvent.event;
293 if (event === "environment:all") {
294 setSelectedEnvironmentId(null);
295 return;
296 }
297 if (event.startsWith("environment:")) {
298 const environment = environments.find(
299 (candidate) => String(candidate.environmentId) === event.slice("environment:".length),
300 );
301 if (environment) setSelectedEnvironmentId(environment.environmentId);
302 return;
303 }
304 const projectSort = PROJECT_SORT_OPTIONS.find(
305 (option) => `project-sort:${option.value}` === event,
306 );
307 if (projectSort) {
308 setProjectSortOrder(projectSort.value);
309 return;
310 }
311 const threadSort = THREAD_SORT_OPTIONS.find(
312 (option) => `thread-sort:${option.value}` === event,
313 );
314 if (threadSort) {
315 setThreadSortOrder(threadSort.value);
316 return;
317 }
318 const grouping = PROJECT_GROUPING_OPTIONS.find(
319 (option) => `project-grouping:${option.value}` === event,
320 );
321 if (grouping) setProjectGroupingMode(grouping.value);
322 },
323 [
324 environments,
325 setProjectGroupingMode,
326 setProjectSortOrder,
327 setSelectedEnvironmentId,
328 setThreadSortOrder,
329 ],
330 );
331​
332 const backgroundColor = useThemeColor("--color-drawer");
333 const borderColor = useThemeColor("--color-border");
334 const mutedColor = useThemeColor("--color-foreground-muted");
335 const placeholderColor = useThemeColor("--color-placeholder");
336 const headerFadeColor = String(backgroundColor);
337 const headerWashOpacity = SIDEBAR_HEADER_WASH_OPACITY[colorScheme];
338 const [measuredHeaderHeight, setMeasuredHeaderHeight] = useState<number | null>(null);
339 // The sticky header (title row, search field, optional connection status)
340 // is measured so the list inset always matches its real height — no
341 // hardcoded per-variant constants.
342 const stickyHeaderHeight = measuredHeaderHeight ?? insets.top + SIDEBAR_STICKY_HEADER_HEIGHT;
343 const topListInset = stickyHeaderHeight + 6;
344 const handleStickyHeaderLayout = useCallback((event: LayoutChangeEvent) => {
345 const nextHeight = Math.round(event.nativeEvent.layout.height);
346 setMeasuredHeaderHeight((current) => (current === nextHeight ? current : nextHeight));
347 }, []);
348 const handleSwipeableWillOpen = useCallback((methods: SwipeableMethods) => {
349 if (openSwipeableRef.current !== methods) {
350 openSwipeableRef.current?.close();
351 openSwipeableRef.current = methods;
352 }
353 }, []);
354 const handleSwipeableClose = useCallback((methods: SwipeableMethods) => {
355 if (openSwipeableRef.current === methods) {
356 openSwipeableRef.current = null;
357 }
358 }, []);
359 const handleSelectThread = useCallback(
360 (thread: EnvironmentThreadShell) => {
361 props.onSelectThread(thread);
362 openSwipeableRef.current?.close();
363 },
364 [props.onSelectThread],
365 );
366 const handleScroll = useCallback((event: NativeSyntheticEvent<NativeScrollEvent>) => {
367 const next = event.nativeEvent.contentOffset.y > 6;
368 if (headerIsOverContentRef.current === next) {
369 return;
370 }
371 headerIsOverContentRef.current = next;
372 setHeaderIsOverContent(next);
373 }, []);
374 const handleScrollBeginDrag = useCallback(() => {
375 openSwipeableRef.current?.close();
376 }, []);
377 const { swipeEnabled, scrollGateHandlers } = useSwipeableScrollGate({
378 onScroll: handleScroll,
379 onScrollBeginDrag: handleScrollBeginDrag,
380 });
381 const listExtraData = props.selectedThreadKey ?? "";
382 const focusSearch = useCallback(() => {
383 const focus = () => {
384 if (props.nativeChrome) {
385 searchBarRef.current?.focus();
386 return;
387 }
388 searchInputRef.current?.focus();
389 };
390 if (!props.visible) {
391 props.onRequestVisibility();
392 setTimeout(focus, 240);
393 } else {
394 focus();
395 }
396 return true;
397 }, [props.nativeChrome, props.onRequestVisibility, props.visible]);
398 useHardwareKeyboardCommand("focusSearch", focusSearch);
399 const renderListItem = useCallback(
400 ({ item }: { readonly item: HomeListItem }) => {
401 switch (item.type) {
402 case "header":
403 return (
404 <ThreadListGroupHeader
405 variant="sidebar"
406 collapsed={item.collapsed}
407 isFirst={item.isFirst}
408 groupKey={item.group.key}
409 onGroupAction={updateGroupDisplay}
410 // Same gating as the compact Home list: aggregated groups have no
411 // single target project, and pending-project groups hold a
412 // placeholder shell rather than a real project.
413 newThreadTarget={item.group.newThreadTarget}
414 onNewThread={props.onNewThreadInProject}
415 project={item.group.representative}
416 threadCount={item.group.threads.length + item.group.pendingTasks.length}
417 title={item.group.title}
418 />
419 );
420 case "pending-task":
421 return (
422 <PendingTaskListRow
423 variant="sidebar"
424 pendingTask={item.pendingTask}
425 environmentLabel={
426 savedConnectionsById[item.pendingTask.message.environmentId]?.environmentLabel ??
427 null
428 }
429 isLast={item.isLast}
430 onSelectPendingTask={openPendingTask}
431 onDeletePendingTask={confirmDeletePendingTask}
432 />
433 );
434 case "thread": {
435 const thread = item.thread;
436 return (
437 <ThreadListRow
438 variant="sidebar"
439 thread={thread}
440 environmentLabel={
441 savedConnectionsById[thread.environmentId]?.environmentLabel ?? null
442 }
443 projectCwd={
444 projectCwdByKey.get(scopedProjectKey(thread.environmentId, thread.projectId)) ??
445 null
446 }
447 isLast={item.isLast}
448 selected={
449 scopedThreadKey(thread.environmentId, thread.id) === props.selectedThreadKey
450 }
451 fullSwipeWidth={props.width - 20}
452 onArchiveThread={archiveThread}
453 onDeleteThread={confirmDeleteThread}
454 onSelectThread={handleSelectThread}
455 onSwipeableClose={handleSwipeableClose}
456 onSwipeableWillOpen={handleSwipeableWillOpen}
457 simultaneousSwipeGesture={sidebarScrollGesture}
458 />
459 );
460 }
461 case "show-more":
462 return (
463 <ThreadListShowMoreRow
464 variant="sidebar"
465 hiddenCount={item.hiddenCount}
466 canShowLess={item.canShowLess}
467 groupKey={item.groupKey}
468 onGroupAction={updateGroupDisplay}
469 />
470 );
471 }
472 },
473 [
474 archiveThread,
475 confirmDeletePendingTask,
476 confirmDeleteThread,
477 handleSelectThread,
478 handleSwipeableClose,
479 handleSwipeableWillOpen,
480 openPendingTask,
481 projectCwdByKey,
482 props.onNewThreadInProject,
483 props.selectedThreadKey,
484 props.width,
485 savedConnectionsById,
486 sidebarScrollGesture,
487 updateGroupDisplay,
488 ],
489 );
490 const filterIcon = hasCustomHomeListOptions(options)
491 ? "line.3.horizontal.decrease.circle.fill"
492 : "line.3.horizontal.decrease.circle";
493 const filterMenu = useMemo(
494 () =>
495 buildHomeListFilterMenu({
496 environments,
497 selectedEnvironmentId: options.selectedEnvironmentId,
498 projectSortOrder: options.projectSortOrder,
499 threadSortOrder: options.threadSortOrder,
500 projectGroupingMode: options.projectGroupingMode,
501 onEnvironmentChange: setSelectedEnvironmentId,
502 onProjectSortOrderChange: setProjectSortOrder,
503 onThreadSortOrderChange: setThreadSortOrder,
504 onProjectGroupingModeChange: setProjectGroupingMode,
505 }),
506 [
507 environments,
508 options,
509 setProjectGroupingMode,
510 setProjectSortOrder,
511 setSelectedEnvironmentId,
512 setThreadSortOrder,
513 ],
514 );
515 const nativeHeaderItems = useMemo(
516 () =>
517 createSidebarHeaderItems({
518 filterIcon,
519 filterMenu,
520 onOpenSettings: props.onOpenSettings,
521 }),
522 [filterIcon, filterMenu, props.onOpenSettings],
523 );
524 const listEmpty = (
525 <Text className="px-2 py-4 text-sm text-foreground-muted">
526 {catalogState.isLoadingConnections
527 ? "Loading threads…"
528 : props.searchQuery.trim().length > 0
529 ? "No matching threads"
530 : "No threads yet"}
531 </Text>
532 );
533​
534 if (props.nativeChrome) {
535 return (
536 <>
537 <NativeStackScreenOptions
538 options={{
539 headerSearchBarOptions: {
540 ref: searchBarRef,
541 autoCapitalize: "none",
542 hideNavigationBar: false,
543 // Keep the search bar pinned under the title — UIKit's default
544 // hidesSearchBarWhenScrolling collapses it on scroll.
545 hideWhenScrolling: false,
546 obscureBackground: false,
547 placeholder: "Search",
548 placement: "stacked",
549 onCancelButtonPress: () => {
550 props.onSearchQueryChange("");
551 },
552 onChangeText: (event) => {
553 props.onSearchQueryChange(event.nativeEvent.text);
554 },
555 },
556 unstable_headerRightItems: () => nativeHeaderItems,
557 }}
558 />
559 <View className="flex-1">
560 <SwipeableScrollGateProvider enabled={swipeEnabled}>
561 <GestureDetector gesture={sidebarScrollGesture}>
562 <LegendList
563 data={listLayout.items}
564 drawDistance={500}
565 estimatedItemSize={64}
566 extraData={listExtraData}
567 getItemType={(item) => item.type}
568 itemsAreEqual={homeListItemsAreEqual}
569 keyExtractor={(item) => item.key}
570 renderItem={renderListItem}
571 automaticallyAdjustsScrollIndicatorInsets
572 contentInsetAdjustmentBehavior="automatic"
573 contentContainerStyle={[
574 styles.threadListContent,
575 {
576 paddingBottom: Math.max(insets.bottom, 16) + 16,
577 paddingTop: 6,
578 },
579 ]}
580 keyboardDismissMode="on-drag"
581 keyboardShouldPersistTaps="handled"
582 {...scrollGateHandlers}
583 recycleItems
584 scrollEventThrottle={16}
585 showsVerticalScrollIndicator={false}
586 style={styles.threadList}
587 ListHeaderComponent={
588 showsConnectionStatus ? (
589 <View className="px-1.5 pt-0.5 pb-2">
590 <WorkspaceConnectionStatus
591 onPress={props.onOpenEnvironmentSettings}
592 state={catalogState}
593 variant="sidebar"
594 />
595 </View>
596 ) : null
597 }
598 ListEmptyComponent={listEmpty}
599 />
600 </GestureDetector>
601 </SwipeableScrollGateProvider>
602 </View>
603 </>
604 );
605 }
606​
607 return (
608 <View
609 testID="thread-navigation-sidebar"
610 className="flex-1"
611 style={{
612 width: props.width,
613 backgroundColor,
614 borderRightColor: borderColor,
615 borderRightWidth: StyleSheet.hairlineWidth,
616 }}
617 >
618 <View className="flex-1" style={{ paddingBottom: insets.bottom }}>
619 <SwipeableScrollGateProvider enabled={swipeEnabled}>
620 <GestureDetector gesture={sidebarScrollGesture}>
621 <LegendList
622 data={listLayout.items}
623 drawDistance={500}
624 estimatedItemSize={64}
625 extraData={listExtraData}
626 getItemType={(item) => item.type}
627 itemsAreEqual={homeListItemsAreEqual}
628 keyExtractor={(item) => item.key}
629 renderItem={renderListItem}
630 contentContainerStyle={[
631 styles.threadListContent,
632 {
633 paddingBottom: 16 + insets.bottom,
634 paddingTop: topListInset,
635 },
636 ]}
637 keyboardDismissMode="on-drag"
638 keyboardShouldPersistTaps="handled"
639 {...scrollGateHandlers}
640 recycleItems
641 scrollEventThrottle={16}
642 showsVerticalScrollIndicator={false}
643 style={styles.threadList}
644 ListEmptyComponent={listEmpty}
645 />
646 </GestureDetector>
647 </SwipeableScrollGateProvider>
648 </View>
649​
650 <View
651 className="absolute inset-x-0 top-0 z-[4]"
652 onLayout={handleStickyHeaderLayout}
653 pointerEvents="box-none"
654 style={{ paddingTop: insets.top }}
655 >
656 <View
657 className="absolute inset-x-0 top-0"
658 pointerEvents="none"
659 accessibilityElementsHidden
660 importantForAccessibility="no-hide-descendants"
661 style={{ height: stickyHeaderHeight + SIDEBAR_STICKY_HEADER_FADE_HEIGHT }}
662 >
663 <Svg width="100%" height="100%">
664 <Defs>
665 <LinearGradient id="sidebar-header-wash" x1="0%" x2="0%" y1="0%" y2="100%">
666 <Stop
667 offset="0%"
668 stopColor={headerFadeColor}
669 stopOpacity={headerIsOverContent ? headerWashOpacity[0] : 0}
670 />
671 <Stop
672 offset="58%"
673 stopColor={headerFadeColor}
674 stopOpacity={headerIsOverContent ? headerWashOpacity[1] : 0}
675 />
676 <Stop
677 offset="88%"
678 stopColor={headerFadeColor}
679 stopOpacity={headerIsOverContent ? headerWashOpacity[2] : 0}
680 />
681 <Stop offset="100%" stopColor={headerFadeColor} stopOpacity={0} />
682 </LinearGradient>
683 </Defs>
684 <Rect width="100%" height="100%" fill="url(#sidebar-header-wash)" />
685 </Svg>
686 </View>
687 <View className="h-[50px] flex-row items-end gap-0.5 pr-2 pl-5">
688 <Text className="flex-1 text-[34px] font-v12-bold text-foreground" numberOfLines={1}>
689 Threads
690 </Text>
691 <SidebarHeaderButtonGroup colorScheme={colorScheme}>
692 <ControlPillMenu actions={listMenuActions} onPressAction={handleListMenuAction}>
693 <SidebarFilterButton
694 grouped
695 accessibilityLabel="Filter and sort threads"
696 icon={filterIcon}
697 />
698 </ControlPillMenu>
699 <SidebarHeaderActions grouped onOpenSettings={props.onOpenSettings} />
700 </SidebarHeaderButtonGroup>
701 </View>
702​
703 <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]">
704 <SymbolView name="magnifyingglass" size={15} tintColor={mutedColor} type="monochrome" />
705 <TextInput
706 ref={searchInputRef}
707 accessibilityLabel="Search threads"
708 autoCapitalize="none"
709 autoCorrect={false}
710 clearButtonMode="while-editing"
711 onChangeText={props.onSearchQueryChange}
712 placeholder="Search"
713 placeholderTextColor={placeholderColor}
714 returnKeyType="search"
715 className="h-[34px] flex-1 px-0 py-0 font-sans text-base text-foreground"
716 value={props.searchQuery}
717 />
718 </View>
719​
720 {showsConnectionStatus ? (
721 <View className="px-3.5 pt-2.5">
722 <WorkspaceConnectionStatus
723 onPress={props.onOpenEnvironmentSettings}
724 state={catalogState}
725 variant="sidebar"
726 />
727 </View>
728 ) : null}
729 </View>
730 </View>
731 );
733​
734const styles = StyleSheet.create({
735 headerButtonGroup: {
736 alignItems: "center",
737 borderRadius: 22,
738 flexDirection: "row",
739 overflow: "hidden",
740 },
741 threadList: {
742 flex: 1,
743 },
744 threadListContent: {
745 paddingHorizontal: 8,
746 },
747});