"use client"; import { BookOpen, Check, Globe, Languages, List, MessageSquare, Minimize2, PenLine, Search, } from "lucide-react"; import { useEffect, useState } from "react"; 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 [clipboardText, setClipboardText] = useState(""); useEffect(() => { window.electronAPI?.getQuickAskText().then((text) => { if (text) setClipboardText(text); }); }, []); const handleAction = (actionId: string) => { const action = DEFAULT_ACTIONS.find((a) => a.id === actionId); if (!action || !clipboardText) return; const prompt = action.prompt.replace("{selection}", clipboardText); const encoded = encodeURIComponent(prompt); const mode = action.mode; window.location.href = `/dashboard?quickAskPrompt=${encoded}&quickAskMode=${mode}`; }; const handleAskAnything = () => { if (!clipboardText) return; const encoded = encodeURIComponent(clipboardText); window.location.href = `/dashboard?quickAskPrompt=${encoded}&quickAskMode=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...
); }