diff --git a/packages/ui/src/components/prompt-input.tsx b/packages/ui/src/components/prompt-input.tsx index f128791b..3b56c468 100644 --- a/packages/ui/src/components/prompt-input.tsx +++ b/packages/ui/src/components/prompt-input.tsx @@ -1,5 +1,5 @@ import { Suspense, createEffect, createSignal, lazy, on, onCleanup, Show } from "solid-js" -import { ArrowBigUp, ArrowBigDown, Loader2, Mic, Square } from "lucide-solid" +import { ArrowBigUp, ArrowBigDown, Loader2, Mic } from "lucide-solid" import ExpandButton from "./expand-button" import { clearAttachments, removeAttachment } from "../stores/attachments" import { resolvePastedPlaceholders } from "../lib/prompt-placeholders" @@ -464,6 +464,32 @@ export default function PromptInput(props: PromptInputProps) { const instance = () => getActiveInstance() + let voiceButtonPressed = false + + const beginVoicePress = (event?: PointerEvent | KeyboardEvent) => { + if (voiceButtonPressed || props.disabled || voiceInput.isTranscribing() || !voiceInput.canUseVoiceInput()) return + voiceButtonPressed = true + + if (event instanceof PointerEvent) { + const target = event.currentTarget + if (target instanceof HTMLElement) { + try { + target.setPointerCapture(event.pointerId) + } catch { + // no-op + } + } + } + + void voiceInput.startRecording() + } + + const endVoicePress = () => { + if (!voiceButtonPressed) return + voiceButtonPressed = false + voiceInput.stopRecording() + } + return (