Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
fix: match renamed Bluetooth mics in main-window state like the backend
Richie McIlroyf92291252497
diff --git a/apps/desktop/src/routes/(window-chrome)/new-main/index.tsx b/apps/desktop/src/routes/(window-chrome)/new-main/index.tsxindex 1eb23c221..3beeea4d6 100644--- a/apps/desktop/src/routes/(window-chrome)/new-main/index.tsx+++ b/apps/desktop/src/routes/(window-chrome)/new-main/index.tsx@@ -142,6 +142,19 @@ const findCamera = (cameras: CameraWithDetails[], id: DeviceOrModelID) => {});};+// Must stay in sync with find_mic_by_label_or_fuzzy in src-tauri: Bluetooth+// mics can reappear under a slightly different name (profile switch), and the+// backend accepts case-insensitive containment in either direction.+const findMicrophone = (microphones: MicrophoneWithDetails[], name: string) => {+ const exact = microphones.find((m) => m.name === name);+ if (exact) return exact;+ const nameLower = name.toLowerCase();+ return microphones.find((m) => {+ const deviceLower = m.name.toLowerCase();+ return deviceLower.includes(nameLower) || nameLower.includes(deviceLower);+ });+};+type WindowListItem = Pick<CaptureWindow,"id" | "owner_name" | "name" | "bounds" | "refresh_rate"@@ -2652,7 +2665,7 @@ function Page() {createEffect(() => {if (!microphoneMenuOpen() || !openMicrophoneSettingsWhenReady()) return;const mic = rawOptions.micName- ? devices.microphones.find((m) => m.name === rawOptions.micName)+ ? findMicrophone(devices.microphones, rawOptions.micName): undefined;if (!mic) return;setMicrophoneInitialSettings(mic);@@ -2690,7 +2703,9 @@ function Page() {return findCamera(devices.cameras, rawOptions.cameraID);},micName: () =>- devices.microphones.find((m) => m.name === rawOptions.micName),+ rawOptions.micName != null+ ? findMicrophone(devices.microphones, rawOptions.micName)+ : undefined,// Selected-but-unplugged devices (e.g. undocked laptop): the selection is// remembered, the row shows "Not connected", and the effects below// re-apply the device when it reappears.@@ -2701,7 +2716,7 @@ function Page() {micDisconnected: () =>rawOptions.micName != null &&!devices.isPending &&- !devices.microphones.some((m) => m.name === rawOptions.micName),+ !findMicrophone(devices.microphones, rawOptions.micName),target: (): ScreenCaptureTarget | undefined => {switch (rawOptions.captureTarget.variant) {case "display": {@@ -2739,15 +2754,25 @@ function Page() {micPresence = undefined;return;}- const present = devices.microphones.some((m) => m.name === name);+ const matched = findMicrophone(devices.microphones, name);// Mid-recording device changes are the backend watcher's job; keep the// last idle observation so the reclaim runs once the recording ends.if (isRecording()) return;const previous = micPresence;- micPresence = { name, present };- if (present && previous?.present === false && previous.name === name) {+ micPresence = { name, present: !!matched };+ const reappeared = previous?.present === false && previous.name === name;+ if (matched && (reappeared || matched.name !== name)) {+ // The feed rejects non-exact labels, so a fuzzy match (Bluetooth+ // rename) must be applied under the connected device's name. The+ // stored selection converges only after the backend accepts it,+ // keeping a failed call from retriggering this effect.+ const matchedName = matched.name;commands- .setMicInput(name)+ .setMicInput(matchedName)+ .then(() => {+ if (rawOptions.micName === name && matchedName !== name)+ setOptions("micName", matchedName);+ }).catch((error) =>console.error("Failed to restore reconnected microphone:", error),);