fix(voice): show mic button on HTTP; graceful error for non-secure contexts

This commit is contained in:
2026-04-07 20:06:57 -04:00
parent 6d57840dc7
commit 56b687c9f4
+10 -2
View File
@@ -5,6 +5,7 @@ import { useVoiceRecorder } from '@/composables/useVoiceRecorder'
import { useSilenceDetector } from '@/composables/useSilenceDetector'
import { useChatStore } from '@/stores/chat'
import { useSettingsStore } from '@/stores/settings'
import { useToastStore } from '@/stores/toast'
import type { Note } from '@/types/note'
const props = withDefaults(defineProps<{
@@ -124,8 +125,15 @@ async function toggleVoice() {
async function startRecording() {
if (!voiceEnabled.value || recorder.recording.value) return
if (!recorder.isSupported) {
useToastStore().show('Microphone requires HTTPS or localhost', 'error')
return
}
await recorder.startRecording()
if (recorder.error.value) return
if (recorder.error.value) {
useToastStore().show(recorder.error.value, 'error')
return
}
if (recorder.stream.value) {
silenceDetector.start(recorder.stream.value, () => stopRecording())
}
@@ -224,7 +232,7 @@ defineExpose({ focus, prefill })
<!-- PTT mic -->
<button
v-if="voiceEnabled && recorder.isSupported"
v-if="voiceEnabled"
class="btn-icon btn-mic"
:class="{ 'mic-recording': recorder.recording.value, 'mic-transcribing': transcribingVoice }"
@click.prevent="toggleVoice"