diff --git a/surfsense_web/app/quick-ask/page.tsx b/surfsense_web/app/quick-ask/page.tsx index 00d47ae48..e8191c913 100644 --- a/surfsense_web/app/quick-ask/page.tsx +++ b/surfsense_web/app/quick-ask/page.tsx @@ -12,18 +12,8 @@ import { PenLine, Search, } from "lucide-react"; -import { useRouter } from "next/navigation"; import { useEffect, useState } from "react"; import { searchSpacesAtom } from "@/atoms/search-spaces/search-space-query.atoms"; -import { - Command, - CommandEmpty, - CommandGroup, - CommandInput, - CommandItem, - CommandList, - CommandSeparator, -} from "@/components/ui/command"; import { DEFAULT_ACTIONS } from "./actions"; const ICONS: Record = { @@ -38,8 +28,7 @@ const ICONS: Record = { }; export default function QuickAskPage() { - const router = useRouter(); - const { data: searchSpaces = [] } = useAtomValue(searchSpacesAtom); + const { data: searchSpaces = [], isLoading } = useAtomValue(searchSpacesAtom); const [clipboardText, setClipboardText] = useState(""); useEffect(() => { @@ -49,77 +38,89 @@ export default function QuickAskPage() { }, []); const navigateToChat = (prompt: string, mode: string) => { - if (!searchSpaces.length) return; + if (!searchSpaces.length || !clipboardText) return; const spaceId = searchSpaces[0].id; const encoded = encodeURIComponent(prompt); - router.push(`/dashboard/${spaceId}/new-chat?quickAskPrompt=${encoded}&quickAskMode=${mode}`); + window.location.href = `/dashboard/${spaceId}/new-chat?quickAskPrompt=${encoded}&quickAskMode=${mode}`; }; const handleAction = (actionId: string) => { const action = DEFAULT_ACTIONS.find((a) => a.id === actionId); - if (!action || !clipboardText) return; - + if (!action) return; const prompt = action.prompt.replace("{selection}", clipboardText); navigateToChat(prompt, action.mode); }; - const handleAskAnything = () => { - if (!clipboardText) return; - navigateToChat(clipboardText, "explore"); - }; - const transformActions = DEFAULT_ACTIONS.filter((a) => a.group === "transform"); const exploreActions = DEFAULT_ACTIONS.filter((a) => a.group === "explore"); const knowledgeActions = DEFAULT_ACTIONS.filter((a) => a.group === "knowledge"); + const ready = !isLoading && clipboardText; + return ( -
- - - - No actions found. - - +
+
+ {!ready && ( +
Loading...
+ )} + {ready && ( +
+
Transform
{transformActions.map((action) => ( - handleAction(action.id)}> + ))} - - +
- +
Explore
{exploreActions.map((action) => ( - handleAction(action.id)}> + ))} -
- +
- +
Knowledge
{knowledgeActions.map((action) => ( - handleAction(action.id)}> + ))} -
- +
- - + +
+ )} +
); } diff --git a/surfsense_web/components/assistant-ui/thread.tsx b/surfsense_web/components/assistant-ui/thread.tsx index 1644b0163..195afc090 100644 --- a/surfsense_web/components/assistant-ui/thread.tsx +++ b/surfsense_web/components/assistant-ui/thread.tsx @@ -306,13 +306,6 @@ const Composer: FC = () => { const aui = useAui(); const hasAutoFocusedRef = useRef(false); - const [quickAskText, setQuickAskText] = useState(); - useEffect(() => { - window.electronAPI?.getQuickAskText().then((text) => { - if (text) setQuickAskText(text); - }); - }, []); - const isThreadEmpty = useAuiState(({ thread }) => thread.isEmpty); const isThreadRunning = useAuiState(({ thread }) => thread.isRunning); @@ -519,7 +512,6 @@ const Composer: FC = () => { onDocumentRemove={handleDocumentRemove} onSubmit={handleSubmit} onKeyDown={handleKeyDown} - initialText={quickAskText} className="min-h-[24px]" />