diff --git a/surfsense_desktop/src/modules/quick-ask.ts b/surfsense_desktop/src/modules/quick-ask.ts index d700b421a..b31ae1bcd 100644 --- a/surfsense_desktop/src/modules/quick-ask.ts +++ b/surfsense_desktop/src/modules/quick-ask.ts @@ -58,7 +58,7 @@ function createQuickAskWindow(x: number, y: number): BrowserWindow { const spaceId = pendingSearchSpaceId; const route = spaceId ? `/dashboard/${spaceId}/new-chat` : '/dashboard'; - quickAskWindow.loadURL(`http://localhost:${getServerPort()}${route}`); + quickAskWindow.loadURL(`http://localhost:${getServerPort()}${route}?quickAssist=true`); quickAskWindow.once('ready-to-show', () => { quickAskWindow?.show(); @@ -85,6 +85,7 @@ function createQuickAskWindow(x: number, y: number): BrowserWindow { async function openQuickAsk(text: string): Promise { pendingText = text; + pendingMode = 'quick-assist'; pendingSearchSpaceId = await getActiveSearchSpaceId(); const cursor = screen.getCursorScreenPoint(); const pos = clampToScreen(cursor.x, cursor.y, 450, 750); diff --git a/surfsense_web/components/assistant-ui/assistant-message.tsx b/surfsense_web/components/assistant-ui/assistant-message.tsx index 49853b0b5..605d9d518 100644 --- a/surfsense_web/components/assistant-ui/assistant-message.tsx +++ b/surfsense_web/components/assistant-ui/assistant-message.tsx @@ -90,6 +90,11 @@ import { useMediaQuery } from "@/hooks/use-media-query"; import { useElectronAPI } from "@/hooks/use-platform"; import { cn } from "@/lib/utils"; +// Captured once at module load — survives client-side navigations that strip the query param. +const IS_QUICK_ASSIST_WINDOW = + typeof window !== "undefined" && + new URLSearchParams(window.location.search).get("quickAssist") === "true"; + // Dynamically import video presentation tool to avoid loading Babel and Remotion in main bundle const GenerateVideoPresentationToolUI = dynamic( () => @@ -465,14 +470,8 @@ const AssistantActionBar: FC = () => { const isLast = useAuiState((s) => s.message.isLast); const aui = useAui(); const api = useElectronAPI(); - const [isQuickAssist, setIsQuickAssist] = useState(false); - useEffect(() => { - if (!api?.getQuickAskMode) return; - api.getQuickAskMode().then((mode) => { - if (mode) setIsQuickAssist(true); - }); - }, [api]); + const isQuickAssist = !!api?.replaceText && IS_QUICK_ASSIST_WINDOW; return (