From a4309f3e0cd4c5413e408a5bce32cb73dc6c480a Mon Sep 17 00:00:00 2001 From: Lotus CI Date: Tue, 30 Jun 2026 18:39:50 -0400 Subject: [PATCH] lotus: don't call AudioContext.setSinkId with an undefined device id audioOutputId comes from `useMediaDevices().audioOutput.selected$?.id`, which is undefined until a device is selected. On the Tauri desktop webview the observable emits undefined first, so setSinkId(undefined) threw "The provided value is not of type 'AudioSinkOptions'" on every call join (repeatedly). Guard on a string (the default device is the empty string, still valid). Co-Authored-By: Claude Opus 4.8 --- src/useAudioContext.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/useAudioContext.tsx b/src/useAudioContext.tsx index 4a7c031c..92d5b48f 100644 --- a/src/useAudioContext.tsx +++ b/src/useAudioContext.tsx @@ -178,7 +178,13 @@ export function useAudioContext( if ( audioContext && "setSinkId" in audioContext && - !controlledAudioDevices + !controlledAudioDevices && + // Skip until a device is actually selected. audioOutputId is undefined + // before MediaDevices resolves (e.g. on the Tauri desktop webview, where + // the selected$ observable emits undefined first); setSinkId(undefined) + // throws "The provided value is not of type 'AudioSinkOptions'". The + // default device is represented by the empty string, which is still valid. + typeof audioOutputId === "string" ) { // https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/setSinkId // @ts-expect-error - setSinkId doesn't exist yet in types, maybe because it's not supported everywhere.