import { useState } from "react"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; import { Checkbox } from "@/components/ui/checkbox"; import { Search, Loader2 } from "lucide-react"; import { type SearchRequest } from "@shared/schema"; interface SearchInterfaceProps { onSearch: (request: SearchRequest) => void; isLoading?: boolean; } export default function SearchInterface({ onSearch, isLoading }: SearchInterfaceProps) { const [query, setQuery] = useState(""); const [searchType, setSearchType] = useState<"semantic" | "keyword" | "hybrid">("semantic"); const [sourceTypes, setSourceTypes] = useState(["pdf", "web", "academic", "code"]); const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); if (!query.trim()) return; onSearch({ query: query.trim(), searchType, filters: { sourceTypes: sourceTypes.length > 0 ? sourceTypes : undefined, }, limit: 10, offset: 0, }); }; const handleSourceTypeChange = (sourceType: string, checked: boolean) => { setSourceTypes(prev => checked ? [...prev, sourceType] : prev.filter(type => type !== sourceType) ); }; const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === "Enter" && !e.shiftKey) { e.preventDefault(); handleSubmit(e); } else if (e.key === "Escape") { setQuery(""); } }; return (
setQuery(e.target.value)} onKeyDown={handleKeyDown} className="pl-11 focus:ring-2 focus:ring-blue-500 focus:border-blue-500" disabled={isLoading} aria-label="Search knowledge base" />
{/* Search Filters */}
{[ { id: "pdf", label: "PDFs" }, { id: "web", label: "Web Pages" }, { id: "academic", label: "Academic Papers" }, { id: "code", label: "Code Repositories" } ].map(({ id, label }) => (
handleSourceTypeChange(id, !!checked)} />
))}
{/* AI Development Tools */}

AI Development Tools

Access external AI platforms and services

); }