From 7b8ade0968b0484b0ff28237dd59ab7988004948 Mon Sep 17 00:00:00 2001 From: Philipinho <16838612+Philipinho@users.noreply.github.com> Date: Mon, 17 Aug 2026 20:09:53 +0100 Subject: [PATCH] feat(ai): pre-warm the vector namespace --- .../src/ee/ai/services/ai-search-service.ts | 8 ++++++++ .../search/components/search-spotlight.tsx | 15 +++++++++++++++ apps/client/src/lib/config.ts | 4 ++++ apps/server/src/common/events/event.contants.ts | 1 - apps/server/src/core/user/user.controller.ts | 8 -------- apps/server/src/ee | 2 +- .../src/integrations/static/static.module.ts | 4 ++++ 7 files changed, 32 insertions(+), 10 deletions(-) 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)};`;