From 00ee7974f6b4624050ca0065f303d1cca2d4da57 Mon Sep 17 00:00:00 2001 From: "DESKTOP-RTLN3BA\\$punk" Date: Tue, 7 Apr 2026 13:13:16 -0700 Subject: [PATCH] fix(desktop): pasteback issues in quick ask - Updated the quick ask window URL to include a query parameter for quick assist mode. - Introduced a constant to detect quick assist mode based on the URL parameter in the assistant message component. - Simplified state management for quick assist detection, improving component performance and clarity. --- surfsense_desktop/src/modules/quick-ask.ts | 3 ++- .../components/assistant-ui/assistant-message.tsx | 13 ++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/surfsense_desktop/src/modules/quick-ask.ts b/surfsense_desktop/src/modules/quick-ask.ts index d5a2a9c2e..b738a864d 100644 --- a/surfsense_desktop/src/modules/quick-ask.ts +++ b/surfsense_desktop/src/modules/quick-ask.ts @@ -57,7 +57,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(); @@ -84,6 +84,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 (