Repository navigation
Done
Labels
vouch:trustedAuthor is trusted by repo permissions or the VOUCHED list.
Description
Before submitting
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area
apps/web
Steps to reproduce
- Open Settings → Voice with a USB microphone connected and microphone access already granted.
- Move the USB microphone to the top of the microphone list.
- Click Refresh microphones.
- Unplug the USB microphone before the refresh finishes.
- Watch the USB microphone row as the two updates arrive.
Expected behavior
Once the microphone shows Not connected, it stays disconnected until it is plugged back in.
Actual behavior
The row changes from Not connected back to In use when the older refresh finishes.
Impact
Minor bug or occasional failure. People who unplug their preferred microphone during a slow refresh can see the wrong active input until another refresh.
Version or commit
main at d6cdb4f161. The cause is at apps/web/src/components/settings/VoiceSettingsPanel.tsx:1338.
Environment
Linux x64 boat.dev default machine, a fresh checkout.
Logs or stack traces
The unplugged microphone remains marked Not connectedAutomated repro
Fails in 2 of 2 runs on main: apply the patch with git apply, then run the command.
diff --git a/scripts/scenarios/microphone-refresh-keeps-newer-device-list.e2e.ts b/scripts/scenarios/microphone-refresh-keeps-newer-device-list.e2e.ts
new file mode 100644
index 0000000000..71c5945438
--- /dev/null
+++ b/scripts/scenarios/microphone-refresh-keeps-newer-device-list.e2e.ts
@@ -0,0 +1,95 @@
+/// <reference lib="dom" />
+import { expect } from "e2e";
+
+import { test, WEB } from "./t3.ts";
+
+declare global {
+ interface Window {
+ microphoneEnumeration?: {
+ holdOldScan(): void;
+ readonly oldScanStarted: Promise<void>;
+ disconnectUsbMicrophone(): void;
+ releaseOldScan(): void;
+ };
+ }
+}
+
+test(
+ "A slow microphone scan cannot bring back a disconnected microphone",
+ WEB,
+ async ({ t3, app, browser, screen }) => {
+ await t3.project("demo");
+ await browser.addInitScript(() => {
+ const devices = navigator.mediaDevices;
+ const internalMic = {
+ kind: "audioinput",
+ deviceId: "internal",
+ label: "Internal test microphone",
+ };
+ const usbMic = { kind: "audioinput", deviceId: "usb", label: "USB test microphone" };
+ let connected = [internalMic, usbMic];
+ let holdNext = false;
+ const started = Promise.withResolvers<void>();
+ const release = Promise.withResolvers<void>();
+ // Emulate device snapshots when each enumeration starts and vary their delivery order.
+ Object.defineProperty(devices, "enumerateDevices", {
+ value: async () => {
+ const snapshot = connected;
+ if (holdNext) {
+ holdNext = false;
+ started.resolve();
+ await release.promise;
+ }
+ return snapshot;
+ },
+ });
+ window.microphoneEnumeration = {
+ holdOldScan: () => {
+ holdNext = true;
+ },
+ oldScanStarted: started.promise,
+ disconnectUsbMicrophone: () => {
+ connected = [internalMic];
+ devices.dispatchEvent(new Event("devicechange"));
+ },
+ releaseOldScan: release.resolve,
+ };
+ });
+
+ await t3.open("/settings/voice");
+ const moveUsbUp = screen.getByRole("button", "Move USB test microphone up", { exact: true });
+ await moveUsbUp.waitFor();
+ while (await moveUsbUp.isEnabled()) await moveUsbUp.tap();
+
+ const list = screen.getByRole("list", "Microphones, preferred first", { exact: true });
+ const usbRow = list.getByRole("listitem").filter({ hasText: "USB test microphone" });
+ await usbRow.getByText("In use", { exact: true }).waitFor();
+
+ await browser.evaluate(() => {
+ window.microphoneEnumeration!.holdOldScan();
+ return null;
+ });
+ await screen.getByRole("button", "Refresh microphones", { exact: true }).tap();
+ await browser.evaluate(async () => {
+ await window.microphoneEnumeration!.oldScanStarted;
+ window.microphoneEnumeration!.disconnectUsbMicrophone();
+ return null;
+ });
+ const disconnected = usbRow.getByText("Not connected", { exact: true });
+ await disconnected.waitFor();
+
+ await browser.evaluate(async () => {
+ window.microphoneEnumeration!.releaseOldScan();
+ // Sample after the delivered device list has had a chance to paint.
+ await new Promise<void>((resolve) =>
+ requestAnimationFrame(() => requestAnimationFrame(() => resolve())),
+ );
+ return null;
+ });
+ await app.screenshot("after-stale-microphone-scan");
+ expect(
+ await disconnected.isVisible(),
+ "The unplugged microphone remains marked Not connected",
+ ).toBe(true);
+ },
+);pnpm scenarios:prove scripts/scenarios/microphone-refresh-keeps-newer-device-list.e2e.ts --base mainWorkaround
No response
Metadata
Metadata
Assignees
Labels
vouch:trustedAuthor is trusted by repo permissions or the VOUCHED list.


Activity