diff --git a/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx b/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx index d331ca3f80..4cd73883a2 100644 --- a/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx +++ b/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx @@ -43,7 +43,9 @@ interface AdaptiveWorkspaceContextValue { readonly layout: Layout; readonly panes: WorkspacePaneLayout; readonly fileInspector: FileInspectorPaneLayout; + readonly primarySidebarSearchQuery: string; readonly activateAuxiliaryPaneRole: (role: WorkspaceAuxiliaryPaneRole) => () => void; + readonly setPrimarySidebarSearchQuery: (query: string) => void; readonly showAuxiliaryPane: (role: WorkspaceAuxiliaryPaneRole) => void; readonly toggleAuxiliaryPane: () => void; readonly togglePrimarySidebar: () => void; @@ -65,7 +67,9 @@ const AdaptiveWorkspaceContext = createContext({ layout: compactLayout, panes: compactPanes, fileInspector: compactFileInspector, + primarySidebarSearchQuery: "", activateAuxiliaryPaneRole: () => () => undefined, + setPrimarySidebarSearchQuery: () => undefined, showAuxiliaryPane: () => undefined, toggleAuxiliaryPane: () => undefined, togglePrimarySidebar: () => undefined, @@ -102,6 +106,7 @@ export function AdaptiveWorkspaceLayout(props: { readonly children: ReactNode }) const [fileInspectorPreferredWidth, setFileInspectorPreferredWidth] = useState( null, ); + const [primarySidebarSearchQuery, setPrimarySidebarSearchQuery] = useState(""); const [focusedAuxiliaryPaneRole, setFocusedAuxiliaryPaneRole] = useState(null); const params = useGlobalSearchParams<{ @@ -238,7 +243,9 @@ export function AdaptiveWorkspaceLayout(props: { readonly children: ReactNode }) layout, panes, fileInspector, + primarySidebarSearchQuery, activateAuxiliaryPaneRole, + setPrimarySidebarSearchQuery, showAuxiliaryPane, toggleAuxiliaryPane, togglePrimarySidebar, @@ -249,7 +256,9 @@ export function AdaptiveWorkspaceLayout(props: { readonly children: ReactNode }) fileInspector, layout, panes, + primarySidebarSearchQuery, showAuxiliaryPane, + setPrimarySidebarSearchQuery, setAuxiliaryPaneWidth, toggleAuxiliaryPane, togglePrimarySidebar, @@ -329,7 +338,9 @@ export function AdaptiveWorkspaceLayout(props: { readonly children: ReactNode }) selectedThreadKey={selectedThreadKey} onOpenSettings={handleOpenSettings} onSelectThread={handleSelectThread} + onSearchQueryChange={setPrimarySidebarSearchQuery} onStartNewTask={handleStartNewTask} + searchQuery={primarySidebarSearchQuery} /> ) : null} diff --git a/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx b/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx index e134ba2e64..911a2d2f6b 100644 --- a/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx +++ b/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx @@ -249,9 +249,11 @@ export function ThreadNavigationSidebar(props: { readonly visible: boolean; readonly selectedThreadKey: string | null; readonly onOpenSettings: () => void; + readonly onSearchQueryChange: (query: string) => void; readonly onSelectThread: (thread: EnvironmentThreadShell) => void; readonly onStartNewTask: () => void; readonly onRequestVisibility: () => void; + readonly searchQuery: string; }) { const insets = useSafeAreaInsets(); const colorScheme = useColorScheme() === "dark" ? "dark" : "light"; @@ -260,7 +262,6 @@ export function ThreadNavigationSidebar(props: { const threads = useThreadShells(); const { state: catalogState } = useWorkspaceState(); const { savedConnectionsById } = useSavedRemoteConnections(); - const [searchQuery, setSearchQuery] = useState(""); const [headerIsOverContent, setHeaderIsOverContent] = useState(false); const searchInputRef = useRef(null); const openSwipeableRef = useRef(null); @@ -294,12 +295,12 @@ export function ThreadNavigationSidebar(props: { projects, threads, environmentId: options.selectedEnvironmentId, - searchQuery, + searchQuery: props.searchQuery, projectSortOrder: options.projectSortOrder, threadSortOrder: options.threadSortOrder, projectGroupingMode: options.projectGroupingMode, }), - [options, projects, searchQuery, threads], + [options, projects, props.searchQuery, threads], ); const listItems = useMemo>( () => @@ -451,7 +452,7 @@ export function ThreadNavigationSidebar(props: { const selectedPressedBackgroundColor = "rgba(255,255,255,0.16)"; const pressedBackgroundColor = useThemeColor("--color-subtle"); const listThemeKey = `${colorScheme}:${String(backgroundColor)}:${String(selectedBackgroundColor)}`; - const listExtraData = `${listThemeKey}:${props.selectedThreadKey ?? ""}`; + const listExtraData = `${listThemeKey}:${props.selectedThreadKey ?? ""}:${props.searchQuery}`; const headerFadeColor = String(backgroundColor); const headerWashOpacity = SIDEBAR_HEADER_WASH_OPACITY[colorScheme]; const usesNativeSidebarChrome = Platform.OS === "ios"; @@ -703,7 +704,7 @@ export function ThreadNavigationSidebar(props: { {catalogState.isLoadingConnections ? "Loading threads…" - : searchQuery.trim().length > 0 + : props.searchQuery.trim().length > 0 ? "No matching threads" : "No threads yet"} @@ -772,7 +773,7 @@ export function ThreadNavigationSidebar(props: { {catalogState.isLoadingConnections ? "Loading threads…" - : searchQuery.trim().length > 0 + : props.searchQuery.trim().length > 0 ? "No matching threads" : "No threads yet"} @@ -857,12 +858,12 @@ export function ThreadNavigationSidebar(props: { autoCapitalize="none" autoCorrect={false} clearButtonMode="while-editing" - onChangeText={setSearchQuery} + onChangeText={props.onSearchQueryChange} placeholder="Search" placeholderTextColor={placeholderColor} returnKeyType="search" style={[styles.searchInput, { color: foregroundColor }]} - value={searchQuery} + value={props.searchQuery} /> diff --git a/apps/mobile/src/features/threads/ThreadRouteScreen.tsx b/apps/mobile/src/features/threads/ThreadRouteScreen.tsx index 0fa74fdd9e..94b2d758ac 100644 --- a/apps/mobile/src/features/threads/ThreadRouteScreen.tsx +++ b/apps/mobile/src/features/threads/ThreadRouteScreen.tsx @@ -222,6 +222,7 @@ function ThreadRouteContent( fileInspector, layout, panes, + setPrimarySidebarSearchQuery, showAuxiliaryPane, toggleAuxiliaryPane, togglePrimarySidebar, @@ -720,7 +721,15 @@ function ThreadRouteContent( ? { ref: threadSearchBarRef, allowToolbarIntegration: true, + autoCapitalize: "none", hideNavigationBar: false, + obscureBackground: false, + onCancelButtonPress: () => { + setPrimarySidebarSearchQuery(""); + }, + onChangeText: (event) => { + setPrimarySidebarSearchQuery(event.nativeEvent.text); + }, placeholder: "Search", placement: "integratedButton", }