diff --git a/apps/client/src/ee/ai/services/ai-search-service.ts b/apps/client/src/ee/ai/services/ai-search-service.ts index 8c2af64a8..d580a2090 100644 --- a/apps/client/src/ee/ai/services/ai-search-service.ts +++ b/apps/client/src/ee/ai/services/ai-search-service.ts @@ -15,6 +15,14 @@ export interface IAiSearchResponse { }>; } +export async function hintVectorCache(): Promise { + try { + await api.post("/ai/vector-cache-hint"); + } catch { + // best-effort cache hint + } +} + export async function aiAnswers( params: IPageSearchParams, onChunk?: (chunk: { content?: string; sources?: any[] }) => void, diff --git a/apps/client/src/features/search/components/search-spotlight.tsx b/apps/client/src/features/search/components/search-spotlight.tsx index 4c5269f15..3ada7ab1f 100644 --- a/apps/client/src/features/search/components/search-spotlight.tsx +++ b/apps/client/src/features/search/components/search-spotlight.tsx @@ -13,11 +13,16 @@ import { SearchResultItem } from "./search-result-item.tsx"; import { AiSearchResult } from "../../../ee/ai/components/ai-search-result.tsx"; import { useHasFeature } from "@/ee/hooks/use-feature"; import { Feature } from "@/ee/features"; +import { useAtomValue } from "jotai"; +import { workspaceAtom } from "@/features/user/atoms/current-user-atom.ts"; +import { hintVectorCache } from "@/ee/ai/services/ai-search-service.ts"; +import { getAiVectorDriver } from "@/lib/config.ts"; interface SearchSpotlightProps { spaceId?: string; } export function SearchSpotlight({ spaceId }: SearchSpotlightProps) { + const workspace = useAtomValue(workspaceAtom); const { t } = useTranslation(); const hasAiFeature = useHasFeature(Feature.AI); const hasAttachmentIndexing = useHasFeature(Feature.ATTACHMENT_INDEXING); @@ -96,6 +101,15 @@ export function SearchSpotlight({ spaceId }: SearchSpotlightProps) { /> )); + const handleSpotlightOpen = () => { + if ( + workspace?.settings?.ai?.search === true && + getAiVectorDriver() === "turbopuffer" + ) { + hintVectorCache(); + } + }; + const handleFiltersChange = (newFilters: any) => { setFilters(newFilters); }; @@ -115,6 +129,7 @@ export function SearchSpotlight({ spaceId }: SearchSpotlightProps) { window.CONFIG=${JSON.stringify(configString)};`;