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.
This commit is contained in:
2026-06-04 12:12:07 -04:00
parent 895fb9ac0b
commit e64698b0ab
+6
View File
@@ -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;