mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-06-03 19:25:19 +02:00
search defaults to knowledge
This commit is contained in:
parent
0af48ecd4a
commit
373d1ee92b
2 changed files with 14 additions and 7 deletions
|
|
@ -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<SearchType | undefined>(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() {
|
|||
</div>
|
||||
<CommandPalette
|
||||
open={isSearchOpen}
|
||||
onOpenChange={setIsSearchOpen}
|
||||
onOpenChange={(o) => { setIsSearchOpen(o); if (!o) setSearchDefaultScope(undefined) }}
|
||||
defaultScope={searchDefaultScope}
|
||||
onSelectFile={navigateToFile}
|
||||
onSelectRun={(id) => { void navigateToView({ type: 'chat', runId: id }) }}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -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<HTMLInputElement>(null)
|
||||
|
|
@ -61,7 +65,7 @@ export function CommandPalette({
|
|||
const [results, setResults] = useState<SearchResult[]>([])
|
||||
const [isSearching, setIsSearching] = useState(false)
|
||||
const [activeTypes, setActiveTypes] = useState<Set<SearchType>>(
|
||||
() => 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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue