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 { extractConferenceLink } from '@/lib/calendar-event'
|
||||||
import { OnboardingModal } from '@/components/onboarding'
|
import { OnboardingModal } from '@/components/onboarding'
|
||||||
import { ComposioGoogleMigrationModal } from '@/components/composio-google-migration-modal'
|
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 { LiveNoteSidebar } from '@/components/live-note-sidebar'
|
||||||
import { BackgroundTaskDetail } from '@/components/background-task-detail'
|
import { BackgroundTaskDetail } from '@/components/background-task-detail'
|
||||||
import { BrowserPane } from '@/components/browser-pane/BrowserPane'
|
import { BrowserPane } from '@/components/browser-pane/BrowserPane'
|
||||||
|
|
@ -1253,6 +1253,8 @@ function App() {
|
||||||
|
|
||||||
// Search state
|
// Search state
|
||||||
const [isSearchOpen, setIsSearchOpen] = useState(false)
|
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
|
// Background tasks state
|
||||||
type BackgroundTaskItem = {
|
type BackgroundTaskItem = {
|
||||||
|
|
@ -5553,7 +5555,7 @@ function App() {
|
||||||
}}
|
}}
|
||||||
onOpenNote={(path) => navigateToFile(path)}
|
onOpenNote={(path) => navigateToFile(path)}
|
||||||
onOpenGraph={() => knowledgeActions.openGraph()}
|
onOpenGraph={() => knowledgeActions.openGraph()}
|
||||||
onOpenSearch={() => setIsSearchOpen(true)}
|
onOpenSearch={() => { setSearchDefaultScope('knowledge'); setIsSearchOpen(true) }}
|
||||||
onOpenBases={() => knowledgeActions.openBases()}
|
onOpenBases={() => knowledgeActions.openBases()}
|
||||||
onVoiceNoteCreated={handleVoiceNoteCreated}
|
onVoiceNoteCreated={handleVoiceNoteCreated}
|
||||||
/>
|
/>
|
||||||
|
|
@ -6016,7 +6018,8 @@ function App() {
|
||||||
</div>
|
</div>
|
||||||
<CommandPalette
|
<CommandPalette
|
||||||
open={isSearchOpen}
|
open={isSearchOpen}
|
||||||
onOpenChange={setIsSearchOpen}
|
onOpenChange={(o) => { setIsSearchOpen(o); if (!o) setSearchDefaultScope(undefined) }}
|
||||||
|
defaultScope={searchDefaultScope}
|
||||||
onSelectFile={navigateToFile}
|
onSelectFile={navigateToFile}
|
||||||
onSelectRun={(id) => { void navigateToView({ type: 'chat', runId: id }) }}
|
onSelectRun={(id) => { void navigateToView({ type: 'chat', runId: id }) }}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ interface SearchResult {
|
||||||
path: string
|
path: string
|
||||||
}
|
}
|
||||||
|
|
||||||
type SearchType = 'knowledge' | 'chat'
|
export type SearchType = 'knowledge' | 'chat'
|
||||||
|
|
||||||
function activeTabToTypes(section: ActiveSection): SearchType[] {
|
function activeTabToTypes(section: ActiveSection): SearchType[] {
|
||||||
if (section === 'knowledge') return ['knowledge']
|
if (section === 'knowledge') return ['knowledge']
|
||||||
|
|
@ -46,6 +46,9 @@ interface CommandPaletteProps {
|
||||||
onOpenChange: (open: boolean) => void
|
onOpenChange: (open: boolean) => void
|
||||||
onSelectFile: (path: string) => void
|
onSelectFile: (path: string) => void
|
||||||
onSelectRun: (runId: 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({
|
export function CommandPalette({
|
||||||
|
|
@ -53,6 +56,7 @@ export function CommandPalette({
|
||||||
onOpenChange,
|
onOpenChange,
|
||||||
onSelectFile,
|
onSelectFile,
|
||||||
onSelectRun,
|
onSelectRun,
|
||||||
|
defaultScope,
|
||||||
}: CommandPaletteProps) {
|
}: CommandPaletteProps) {
|
||||||
const { activeSection } = useSidebarSection()
|
const { activeSection } = useSidebarSection()
|
||||||
const searchInputRef = useRef<HTMLInputElement>(null)
|
const searchInputRef = useRef<HTMLInputElement>(null)
|
||||||
|
|
@ -61,7 +65,7 @@ export function CommandPalette({
|
||||||
const [results, setResults] = useState<SearchResult[]>([])
|
const [results, setResults] = useState<SearchResult[]>([])
|
||||||
const [isSearching, setIsSearching] = useState(false)
|
const [isSearching, setIsSearching] = useState(false)
|
||||||
const [activeTypes, setActiveTypes] = useState<Set<SearchType>>(
|
const [activeTypes, setActiveTypes] = useState<Set<SearchType>>(
|
||||||
() => new Set(activeTabToTypes(activeSection))
|
() => new Set(defaultScope ? [defaultScope] : activeTabToTypes(activeSection))
|
||||||
)
|
)
|
||||||
const debouncedQuery = useDebounce(query, 250)
|
const debouncedQuery = useDebounce(query, 250)
|
||||||
|
|
||||||
|
|
@ -69,9 +73,9 @@ export function CommandPalette({
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (open) {
|
if (open) {
|
||||||
setQuery('')
|
setQuery('')
|
||||||
setActiveTypes(new Set(activeTabToTypes(activeSection)))
|
setActiveTypes(new Set(defaultScope ? [defaultScope] : activeTabToTypes(activeSection)))
|
||||||
}
|
}
|
||||||
}, [open, activeSection])
|
}, [open, activeSection, defaultScope])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!open) return
|
if (!open) return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue