"use client"; import { useAtomValue } from "jotai"; import { BookOpen, Check, Globe, Languages, List, MessageSquare, Minimize2, 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 = { check: , minimize: , languages: , "pen-line": , "book-open": , list: , search: , globe: , }; export default function QuickAskPage() { const router = useRouter(); const { data: searchSpaces = [] } = 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) return; const spaceId = searchSpaces[0].id; const encoded = encodeURIComponent(prompt); router.push(`/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; 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"); return (
No actions found. {transformActions.map((action) => ( handleAction(action.id)}> {ICONS[action.icon]} {action.name} ))} {exploreActions.map((action) => ( handleAction(action.id)}> {ICONS[action.icon]} {action.name} ))} {knowledgeActions.map((action) => ( handleAction(action.id)}> {ICONS[action.icon]} {action.name} ))} Ask anything...
); }