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

Allow dictation in Muse (#1261)

ALTICea94c8a6736d
diff --git a/Sources/Fluid/Services/DeliveryTargetAssessment.swift b/Sources/Fluid/Services/DeliveryTargetAssessment.swift
index 03270de7..4b60cb94 100644
--- a/Sources/Fluid/Services/DeliveryTargetAssessment.swift
+++ b/Sources/Fluid/Services/DeliveryTargetAssessment.swift
@@ -1,3 +1,4 @@
+import AppKit
import ApplicationServices
import Foundation
@@ -59,9 +60,30 @@ enum DeliveryTargetAssessment: Equatable {
var valueSettable = DarwinBoolean(false)
let settableResult = AXUIElementIsAttributeSettable(element, kAXValueAttribute as CFString, &valueSettable)
+ if role == "AXButton", settableResult != .success || !valueSettable.boolValue {
+ var pid: pid_t = 0
+ if AXUIElementGetPid(element, &pid) == .success,
+ NSRunningApplication(processIdentifier: pid)?.bundleIdentifier == "com.meta.endo"
+ {
+ var titleRef: CFTypeRef?
+ var descriptionRef: CFTypeRef?
+ AXUIElementCopyAttributeValue(element, kAXTitleAttribute as CFString, &titleRef)
+ AXUIElementCopyAttributeValue(element, kAXDescriptionAttribute as CFString, &descriptionRef)
+ if self.isMuseComposer(bundleID: "com.meta.endo", role: role, title: titleRef as? String, description: descriptionRef as? String) {
+ return .unknown(reason: "muse_composer")
+ }
+ }
+ }
return self.classify(role: role, valueSettable: settableResult == .success && valueSettable.boolValue)
}
+ nonisolated static func isMuseComposer(bundleID: String?, role: String, title: String?, description: String?) -> Bool {
+ guard bundleID == "com.meta.endo", role == "AXButton" else { return false }
+ return [title, description].compactMap { $0 }.contains {
+ $0.split(whereSeparator: \.isWhitespace).joined(separator: " ") == "Message Attach file Send"
+ }
+ }
+
/// Pure role decision, kept separate from the AX queries so it can be tested.
nonisolated static func classify(role: String, valueSettable: Bool) -> DeliveryTargetAssessment {
if self.editableRoles.contains(role) || valueSettable { return .editable(role: role) }
diff --git a/Tests/FluidDictationIntegrationTests/DeliveryTargetAssessmentTests.swift b/Tests/FluidDictationIntegrationTests/DeliveryTargetAssessmentTests.swift
index 1617ad69..b74c3a69 100644
--- a/Tests/FluidDictationIntegrationTests/DeliveryTargetAssessmentTests.swift
+++ b/Tests/FluidDictationIntegrationTests/DeliveryTargetAssessmentTests.swift
@@ -25,4 +25,14 @@ final class DeliveryTargetAssessmentTests: XCTestCase {
XCTAssertEqual(DeliveryTargetAssessment.classify(role: role, valueSettable: false), .unknown(reason: "role_\(role)"), role)
}
}
+
+ func testMuseComposerExceptionIsLimitedToItsComposer() {
+ let label = "Message Attach file\nSend"
+ XCTAssertTrue(DeliveryTargetAssessment.isMuseComposer(bundleID: "com.meta.endo", role: "AXButton", title: label, description: nil))
+ XCTAssertTrue(DeliveryTargetAssessment.isMuseComposer(bundleID: "com.meta.endo", role: "AXButton", title: nil, description: label))
+ XCTAssertFalse(DeliveryTargetAssessment.isMuseComposer(bundleID: "com.meta.endo", role: "AXButton", title: "Send", description: nil))
+ XCTAssertFalse(DeliveryTargetAssessment.isMuseComposer(bundleID: "another.app", role: "AXButton", title: label, description: nil))
+ XCTAssertFalse(DeliveryTargetAssessment.isMuseComposer(bundleID: "com.meta.endo", role: "AXMenuButton", title: label, description: nil))
+ XCTAssertFalse(DeliveryTargetAssessment.isMuseComposer(bundleID: "com.meta.endo", role: "AXButton", title: nil, description: nil))
+ }
}