From e64698b0abceaaec631ecc28e6329b5ce309442c Mon Sep 17 00:00:00 2001 From: hobokenchicken Date: Thu, 4 Jun 2026 12:12:07 -0400 Subject: [PATCH] fix: graceful mic-unavailable handling over HTTP navigator.mediaDevices.getUserMedia() requires a secure context (HTTPS or localhost). When accessed over plain HTTP, the API is undefined. Now shows a friendly chat message instead of a cryptic TypeError in the console. --- frontend/src/hooks/useConversation.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/frontend/src/hooks/useConversation.ts b/frontend/src/hooks/useConversation.ts index 29507bd..abb403e 100644 --- a/frontend/src/hooks/useConversation.ts +++ b/frontend/src/hooks/useConversation.ts @@ -193,6 +193,12 @@ export function useConversation() { // ── Audio ── const startRecording = useCallback(async () => { + // Check if mediaDevices is available (requires HTTPS/localhost) + if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) { + addMessage('kira', 'Your browser needs HTTPS to use the microphone. Try accessing Kira through the HTTPS address instead!'); + return; + } + try { const stream = await navigator.mediaDevices.getUserMedia({ audio: true }); streamRef.current = stream;