import { useRef, useState } from 'react'; import { defineMessages, useIntl } from '../i18n'; import { getInitialWorkingDir } from '../utils/workingDir'; const messages = defineMessages({ placeholder: { id: 'launcher.placeholder', defaultMessage: 'Ask goose anything...', }, }); export default function LauncherView() { const [query, setQuery] = useState(''); const inputRef = useRef(null); const intl = useIntl(); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); if (query.trim()) { const initialMessage = query; setQuery(''); window.electron.createChatWindow({ query: initialMessage, dir: getInitialWorkingDir() }); setTimeout(() => { window.electron.closeWindow(); }, 200); } }; const handleKeyDown = (e: React.KeyboardEvent) => { // Close on Escape if (e.key === 'Escape') { window.electron.closeWindow(); } }; return (
setQuery(e.target.value)} onKeyDown={handleKeyDown} className="w-full h-full bg-transparent text-text-primary text-xl px-6 outline-none placeholder:text-text-secondary" placeholder={intl.formatMessage(messages.placeholder)} autoFocus />
); }