From 3411b4b145cdaf7f3aeda682d9104897e2e9f980 Mon Sep 17 00:00:00 2001 From: Jose Selesan Date: Thu, 29 Oct 2026 16:53:21 -0300 Subject: [PATCH] fix(web): let the list dictation run in the iOS home-screen app The floating button's commit made the multi-item dictation go through canDictate(), which treats an iOS home-screen app as unsupported. That rule belongs to the input's microphone, which dictates without asking for the microphone first; the multi-item flow asks with getUserMedia and works there, so both the empty list's card and the FAB said the browser could not dictate. Co-Authored-By: Claude Opus 5.5 --- apps/web/src/hooks/use-microphone-dictation.ts | 10 +++------- apps/web/src/lib/speech-recognition.ts | 8 +++++--- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/apps/web/src/hooks/use-microphone-dictation.ts b/apps/web/src/hooks/use-microphone-dictation.ts index 04e7fcf..dc374ac 100644 --- a/apps/web/src/hooks/use-microphone-dictation.ts +++ b/apps/web/src/hooks/use-microphone-dictation.ts @@ -1,11 +1,7 @@ import { useCallback, useEffect, useRef, useState } from 'react' import { splitDictation } from '@/lib/natural-input/dictation' -import { - canDictate, - getSpeechRecognition, - type SpeechRecognitionLike, -} from '@/lib/speech-recognition' +import { getSpeechRecognition, type SpeechRecognitionLike } from '@/lib/speech-recognition' export const DICTATION_MESSAGES = { denied: 'No tenemos permiso para usar el micrófono. Habilítalo en los ajustes del navegador.', @@ -55,7 +51,7 @@ type UseMicrophoneDictationOptions = { * capture. Unmounting aborts the recognition. */ export function useMicrophoneDictation({ onPhrases, onError }: UseMicrophoneDictationOptions) { - const [supported] = useState(() => canDictate()) + const [supported] = useState(() => getSpeechRecognition() !== null) const [status, setStatus] = useState('idle') // What has been heard so far, shown while listening. const [heard, setHeard] = useState('') @@ -72,7 +68,7 @@ export function useMicrophoneDictation({ onPhrases, onError }: UseMicrophoneDict const start = useCallback(() => { if (endRef.current) return - const SpeechRecognition = canDictate() ? getSpeechRecognition() : null + const SpeechRecognition = getSpeechRecognition() if (!SpeechRecognition) { callbacksRef.current.onError(DICTATION_MESSAGES.unsupported) return diff --git a/apps/web/src/lib/speech-recognition.ts b/apps/web/src/lib/speech-recognition.ts index b60ee15..f50b103 100644 --- a/apps/web/src/lib/speech-recognition.ts +++ b/apps/web/src/lib/speech-recognition.ts @@ -34,9 +34,11 @@ export function isIosStandalone(): boolean { } /** - * Whether this browser can dictate on its own. An iOS home-screen app exposes - * `webkitSpeechRecognition` but it does not work there, so it counts as unsupported - * (the keyboard's own dictation still works). + * Whether this browser can dictate a phrase without asking for the microphone first + * (the input's microphone). An iOS home-screen app exposes `webkitSpeechRecognition` + * but that flow does not work there, so it counts as unsupported (the keyboard's own + * dictation still works). Dictating several items does work there, because it asks + * for the microphone with `getUserMedia` first, so it checks `getSpeechRecognition()`. */ export function canDictate(): boolean { if (typeof window === 'undefined' || isIosStandalone()) return false