Fastest and only macOS Dictation app with on-device STT and custom trained AI enhancement model. Windows, iOS testflight! Android, Linux waitlist open! A local Wispr Flow alternative. Follow https://x.com/fluidvoiceapp for more
fix isolate microphone availability updates
altic-dev3e04401a16c0
diff --git a/Sources/Fluid/ContentView.swift b/Sources/Fluid/ContentView.swiftindex b2383181..a3cacb21 100644--- a/Sources/Fluid/ContentView.swift+++ b/Sources/Fluid/ContentView.swift@@ -389,6 +389,9 @@ struct ContentView: View {self.selectedOutputUID = sysOut}}+ .onChange(of: self.audioObserver.inputAvailabilityTick) { _, _ in+ self.refreshInputDevices()+ }.onDisappear {Task { await self.asr.stopWithoutTranscription() }self.cancelPrewarmDictationIfNeeded()@@ -1537,6 +1540,24 @@ struct ContentView: View {}}+ private func refreshInputDevices() {+ DispatchQueue.global(qos: .userInitiated).async {+ let inputs = AudioDevice.listInputDevicesRefreshingLiveness()+ let defaultInputUID = AudioDevice.getDefaultInputDevice()?.uid+ DispatchQueue.main.async {+ self.inputDevices = inputs+ if let selectedInput = self.appServices.microphonePreferenceCoordinator+ .reconcileMicrophoneSelection(+ availableInputs: inputs,+ defaultInputUID: defaultInputUID+ )+ {+ self.selectedInputUID = selectedInput.uid+ }+ }+ }+ }+// MARK: - Model Management Functionsprivate func saveModels() {diff --git a/Sources/Fluid/Services/AudioDeviceService.swift b/Sources/Fluid/Services/AudioDeviceService.swiftindex b2d50d5e..4cd86152 100644--- a/Sources/Fluid/Services/AudioDeviceService.swift+++ b/Sources/Fluid/Services/AudioDeviceService.swift@@ -400,6 +400,7 @@ final class AudioHardwareObserver: ObservableObject {/// Using a simple `@Published` value avoids putting `AnyPublisher`/`SubscriptionView` generics into/// SwiftUI's root view type, which can trigger AttributeGraph metadata-instantiation crashes at launch.@Published private(set) var changeTick: UInt64 = 0+ @Published private(set) var inputAvailabilityTick: UInt64 = 0private var installed: Bool = falseprivate var devicesListenerToken: AudioObjectPropertyListenerBlock?@@ -427,7 +428,7 @@ final class AudioHardwareObserver: ObservableObject {@MainActorfunc signalInputAvailabilityChanged() {- self.changeTick &+= 1+ self.inputAvailabilityTick &+= 1}func restartObservingAfterAudioServiceReset() {@@ -484,7 +485,7 @@ final class AudioHardwareObserver: ObservableObject {self?.refreshInputAvailabilityListeners()}let defaultInToken: AudioObjectPropertyListenerBlock = { [weak self] _, _ in- self?.changeTick &+= 1+ self?.inputAvailabilityTick &+= 1}let defaultOutToken: AudioObjectPropertyListenerBlock = { [weak self] _, _ inself?.changeTick &+= 1@@ -594,7 +595,7 @@ final class AudioHardwareObserver: ObservableObject {_ = AudioDevice.listInputDevicesRefreshingLiveness()DispatchQueue.main.async { [weak self] inguard let self else { return }- self.changeTick &+= 1+ self.inputAvailabilityTick &+= 1NotificationCenter.default.post(name: .inputDeviceAvailabilityDidChange,object: self,@@ -706,7 +707,7 @@ final class AudioHardwareObserver: ObservableObject {let isClosed = ClamshellState.isClosedguard isClosed != self.lastClamshellClosed else { return }self.lastClamshellClosed = isClosed- self.changeTick &+= 1+ self.inputAvailabilityTick &+= 1DebugLogger.shared.info("MacBook clamshell state changed (closed=\(isClosed))",source: "AudioHardwareObserver"diff --git a/Tests/FluidDictationIntegrationTests/HotkeyShortcutTests.swift b/Tests/FluidDictationIntegrationTests/HotkeyShortcutTests.swiftindex b23ab78c..00e56455 100644--- a/Tests/FluidDictationIntegrationTests/HotkeyShortcutTests.swift+++ b/Tests/FluidDictationIntegrationTests/HotkeyShortcutTests.swift@@ -993,6 +993,16 @@ final class HotkeyShortcutTests: XCTestCase {XCTAssertFalse(AudioDevice.isInputDeviceAlive(unavailable))}+ @MainActor+ func testInputAvailabilitySignalDoesNotEmitGenericHardwareChange() {+ let observer = AudioHardwareObserver()++ observer.signalInputAvailabilityChanged()++ XCTAssertEqual(observer.inputAvailabilityTick, 1)+ XCTAssertEqual(observer.changeTick, 0)+ }+@MainActorfunc testClamshellSkipsEnumeratedUnusableBuiltInMicrophone() throws {try self.withRestoredDefaults(keys: [