"use client"; import { useAtomValue } from "jotai"; import { BookOpen, Check, Globe, Languages, List, MessageSquare, Minimize2, PenLine, Search, } from "lucide-react"; import { useEffect, useState } from "react"; import { searchSpacesAtom } from "@/atoms/search-spaces/search-space-query.atoms"; import { DEFAULT_ACTIONS } from "./actions"; const ICONS: Record = { check: , minimize: , languages: , "pen-line": , "book-open": , list: , search: , globe: , }; export default function QuickAskPage() { const { data: searchSpaces = [], isLoading } = useAtomValue(searchSpacesAtom); const [clipboardText, setClipboardText] = useState(""); useEffect(() => { window.electronAPI?.getQuickAskText().then((text) => { if (text) setClipboardText(text); }); }, []); const navigateToChat = (prompt: string, mode: string) => { if (!searchSpaces.length || !clipboardText) return; const spaceId = searchSpaces[0].id; const encoded = encodeURIComponent(prompt); 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) return; const prompt = action.prompt.replace("{selection}", clipboardText); navigateToChat(prompt, action.mode); }; 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 (
{!ready && (
Loading...
)} {ready && (
Transform
{transformActions.map((action) => ( ))}
Explore
{exploreActions.map((action) => ( ))}
Knowledge
{knowledgeActions.map((action) => ( ))}
)}
); }