From 373d1ee92be0523d99e36710163708d9b706ba35 Mon Sep 17 00:00:00 2001 From: Arjun <6592213+arkml@users.noreply.github.com> Date: Thu, 28 May 2026 00:33:38 +0530 Subject: [PATCH] search defaults to knowledge --- apps/x/apps/renderer/src/App.tsx | 9 ++++++--- .../x/apps/renderer/src/components/search-dialog.tsx | 12 ++++++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/apps/x/apps/renderer/src/App.tsx b/apps/x/apps/renderer/src/App.tsx index dd671eda..690c6790 100644 --- a/apps/x/apps/renderer/src/App.tsx +++ b/apps/x/apps/renderer/src/App.tsx @@ -80,7 +80,7 @@ import { splitFrontmatter, joinFrontmatter } from '@/lib/frontmatter' import { extractConferenceLink } from '@/lib/calendar-event' import { OnboardingModal } from '@/components/onboarding' import { ComposioGoogleMigrationModal } from '@/components/composio-google-migration-modal' -import { CommandPalette, type CommandPaletteMention } from '@/components/search-dialog' +import { CommandPalette, type CommandPaletteMention, type SearchType } from '@/components/search-dialog' import { LiveNoteSidebar } from '@/components/live-note-sidebar' import { BackgroundTaskDetail } from '@/components/background-task-detail' import { BrowserPane } from '@/components/browser-pane/BrowserPane' @@ -1253,6 +1253,8 @@ function App() { // Search state const [isSearchOpen, setIsSearchOpen] = useState(false) + // Optional scope override for the next time search opens (cleared on close). + const [searchDefaultScope, setSearchDefaultScope] = useState(undefined) // Background tasks state type BackgroundTaskItem = { @@ -5553,7 +5555,7 @@ function App() { }} onOpenNote={(path) => navigateToFile(path)} onOpenGraph={() => knowledgeActions.openGraph()} - onOpenSearch={() => setIsSearchOpen(true)} + onOpenSearch={() => { setSearchDefaultScope('knowledge'); setIsSearchOpen(true) }} onOpenBases={() => knowledgeActions.openBases()} onVoiceNoteCreated={handleVoiceNoteCreated} /> @@ -6016,7 +6018,8 @@ function App() { { setIsSearchOpen(o); if (!o) setSearchDefaultScope(undefined) }} + defaultScope={searchDefaultScope} onSelectFile={navigateToFile} onSelectRun={(id) => { void navigateToView({ type: 'chat', runId: id }) }} /> diff --git a/apps/x/apps/renderer/src/components/search-dialog.tsx b/apps/x/apps/renderer/src/components/search-dialog.tsx index 56f0875a..4e50fa0b 100644 --- a/apps/x/apps/renderer/src/components/search-dialog.tsx +++ b/apps/x/apps/renderer/src/components/search-dialog.tsx @@ -21,7 +21,7 @@ interface SearchResult { path: string } -type SearchType = 'knowledge' | 'chat' +export type SearchType = 'knowledge' | 'chat' function activeTabToTypes(section: ActiveSection): SearchType[] { if (section === 'knowledge') return ['knowledge'] @@ -46,6 +46,9 @@ interface CommandPaletteProps { onOpenChange: (open: boolean) => void onSelectFile: (path: string) => void onSelectRun: (runId: string) => void + // Overrides the sidebar-section default for the initial scope (e.g. the + // knowledge view opens search scoped to knowledge). + defaultScope?: SearchType } export function CommandPalette({ @@ -53,6 +56,7 @@ export function CommandPalette({ onOpenChange, onSelectFile, onSelectRun, + defaultScope, }: CommandPaletteProps) { const { activeSection } = useSidebarSection() const searchInputRef = useRef(null) @@ -61,7 +65,7 @@ export function CommandPalette({ const [results, setResults] = useState([]) const [isSearching, setIsSearching] = useState(false) const [activeTypes, setActiveTypes] = useState>( - () => new Set(activeTabToTypes(activeSection)) + () => new Set(defaultScope ? [defaultScope] : activeTabToTypes(activeSection)) ) const debouncedQuery = useDebounce(query, 250) @@ -69,9 +73,9 @@ export function CommandPalette({ useEffect(() => { if (open) { setQuery('') - setActiveTypes(new Set(activeTabToTypes(activeSection))) + setActiveTypes(new Set(defaultScope ? [defaultScope] : activeTabToTypes(activeSection))) } - }, [open, activeSection]) + }, [open, activeSection, defaultScope]) useEffect(() => { if (!open) return