Skip to content

Commit 91493ac

Browse files
committed
fix(ui): mic permissions error logic
1 parent adc62f0 commit 91493ac

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

ui/src/stores/streamStore.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,8 @@ function schedulePostConnectWarnings(
206206

207207
if (decision.shouldWatch && attempt.watch) {
208208
const watchRef = attempt.watch;
209-
attempt.healthEffect.timeout(() => {
209+
// Use setTimeout instead of healthEffect.timeout() which fires immediately
210+
setTimeout(() => {
210211
if (get().status !== 'connected') return;
211212
if (watchRef.status.peek() !== 'live') {
212213
set({
@@ -218,15 +219,23 @@ function schedulePostConnectWarnings(
218219

219220
if (decision.shouldPublish && attempt.microphone) {
220221
const microphoneRef = attempt.microphone;
221-
attempt.healthEffect.timeout(() => {
222+
223+
// Track if the microphone source was EVER acquired during the 10-second window.
224+
// This prevents false errors when the source signal transiently goes falsy.
225+
let wasEverReady = Boolean(microphoneRef.source.peek()) || get().micStatus === 'ready';
226+
attempt.healthEffect.subscribe(microphoneRef.source, (value) => {
227+
if (value) wasEverReady = true;
228+
});
229+
230+
// Use setTimeout instead of healthEffect.timeout() which fires immediately
231+
setTimeout(() => {
222232
if (get().status !== 'connected') return;
223-
if (!microphoneRef.source.peek()) {
224-
set({
225-
micStatus: 'error',
226-
errorMessage:
227-
'Connected to relay, but microphone is not available. Check browser permissions and selected input device.',
228-
});
229-
}
233+
if (wasEverReady) return;
234+
set({
235+
micStatus: 'error',
236+
errorMessage:
237+
'Connected to relay, but microphone is not available. Check browser permissions and selected input device.',
238+
});
230239
}, 10_000);
231240
}
232241
}

0 commit comments

Comments
 (0)