diff --git a/web/src/App.tsx b/web/src/App.tsx index 54e3ba7..5603657 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -1393,7 +1393,6 @@ function AppInner() { const [vadHangover, setVadHangover] = useState(() => loadNumberPref(VAD_HANGOVER_KEY, 0.3)); const [outputDevices, setOutputDevices] = useState([]); const [outputDeviceId, setOutputDeviceId] = useState(""); - const [outputDeviceLabel, setOutputDeviceLabel] = useState("System default"); const [inputDevices, setInputDevices] = useState([]); const [inputDeviceId, setInputDeviceId] = useState(() => localStorage.getItem(INPUT_DEVICE_KEY) ?? ""); const [playbackVolume, setPlaybackVolume] = useState(() => loadNumberPref(PLAYBACK_VOLUME_KEY, 1)); @@ -1476,7 +1475,7 @@ function AppInner() { useEffect(() => { activeTabRef.current = activeTab; - if (activeTab !== "channel") { + if (typeof activeTab === "number") { setPmThreads((prev) => { const thread = prev[activeTab]; if (!thread || !thread.unread) return prev; @@ -2006,9 +2005,8 @@ function AppInner() { socketRef.current?.send(JSON.stringify({ type: "setOutputMuted", muted: !outputMutedRef.current })); }; - const handleOutputDeviceChange = async (deviceId: string, label?: string) => { + const handleOutputDeviceChange = async (deviceId: string) => { setOutputDeviceId(deviceId); - setOutputDeviceLabel(label || (deviceId ? `Output ${deviceId.slice(0, 6)}` : "System default")); await audioPlayerRef.current?.setOutputDevice(deviceId); setSoundsOutputDevice(deviceId); }; @@ -2016,7 +2014,7 @@ function AppInner() { const handlePickOutputDevice = async () => { try { const device = await pickAudioOutputDevice(); - if (device) await handleOutputDeviceChange(device.deviceId, device.label); + if (device) await handleOutputDeviceChange(device.deviceId); } catch (error) { appendLog({ text: `Output device error: ${(error as Error).message}`, kind: "error" }); } diff --git a/web/src/voice.ts b/web/src/voice.ts index 00d11c4..0a39005 100644 --- a/web/src/voice.ts +++ b/web/src/voice.ts @@ -61,13 +61,12 @@ export class MicCapture { private deviceId?: string; private echoCancellation: boolean; private noiseSuppression: boolean; + private context: AudioContext; threshold: number; hangoverSeconds: number; - constructor( - private context: AudioContext, - options: MicCaptureOptions - ) { + constructor(context: AudioContext, options: MicCaptureOptions) { + this.context = context; this.onFrame = options.onFrame; this.onActivity = options.onActivity; this.onLevel = options.onLevel; @@ -222,8 +221,10 @@ export class AudioPlayer { private destination: MediaStreamAudioDestinationNode; private element: SinkableElement; private gain: GainNode; + private context: AudioContext; - constructor(private context: AudioContext) { + constructor(context: AudioContext) { + this.context = context; this.destination = context.createMediaStreamDestination(); this.gain = context.createGain(); this.gain.connect(this.destination);