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

ThreadNavigationSidebar.tsx

750 lines26.6 KB

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