Skip to content

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(accessibility): bound AX round-trips to 2 seconds

altic-deva35dba9cdf63
diff --git a/Sources/Fluid/AppDelegate.swift b/Sources/Fluid/AppDelegate.swift
index f869252d..c209b39a 100644
--- a/Sources/Fluid/AppDelegate.swift
+++ b/Sources/Fluid/AppDelegate.swift
@@ -46,6 +46,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
}
func applicationDidFinishLaunching(_ notification: Notification) {
+ AccessibilityMessagingTimeout.configure()
// Bring up file logging + crash handlers immediately during launch.
_ = FileLogger.shared
TypingService.startKeyboardLayoutTracking()
diff --git a/Sources/Fluid/Services/AccessibilityMessagingTimeout.swift b/Sources/Fluid/Services/AccessibilityMessagingTimeout.swift
new file mode 100644
index 00000000..93bc0552
--- /dev/null
+++ b/Sources/Fluid/Services/AccessibilityMessagingTimeout.swift
@@ -0,0 +1,12 @@
+import ApplicationServices
+
+/// Bounds every Accessibility round-trip this process makes. The system
+/// default is about six seconds; a busy target app would otherwise block the
+/// main thread, and with it the keyboard event tap, for that long.
+enum AccessibilityMessagingTimeout {
+ static let seconds: Float = 2
+
+ static func configure() {
+ AXUIElementSetMessagingTimeout(AXUIElementCreateSystemWide(), self.seconds)
+ }
+}
diff --git a/Tests/FluidDictationIntegrationTests/PasteDeliveryCoordinatorTests.swift b/Tests/FluidDictationIntegrationTests/PasteDeliveryCoordinatorTests.swift
index 28eeabd2..90e12410 100644
--- a/Tests/FluidDictationIntegrationTests/PasteDeliveryCoordinatorTests.swift
+++ b/Tests/FluidDictationIntegrationTests/PasteDeliveryCoordinatorTests.swift
@@ -399,6 +399,13 @@ final class PasteDeliveryCoordinatorTests: XCTestCase {
XCTAssertEqual(state.textDeliveryFailureTranscript, "retained output")
}
+ func testAccessibilityMessagingTimeoutIsBounded() {
+ // Well under the ~6 s system default so a hung target app cannot
+ // stall the main thread and the keyboard tap for that long.
+ XCTAssertEqual(AccessibilityMessagingTimeout.seconds, 2)
+ XCTAssertLessThan(AccessibilityMessagingTimeout.seconds, 6)
+ }
+
func testRecoveryActivationNeverRequestsAllWindows() {
XCTAssertTrue(TypingService.recoveryActivationOptions.contains(.activateIgnoringOtherApps))
XCTAssertFalse(TypingService.recoveryActivationOptions.contains(.activateAllWindows))