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
Prepare reliable text insertion branch for review
altic-dev7ab3cbe153eb
diff --git a/.github/pull_request_template.md b/.github/pull_request_template.mdindex 8f64baca..981830fc 100644--- a/.github/pull_request_template.md+++ b/.github/pull_request_template.md@@ -1,21 +1,24 @@## Description-Brief description of what this PR does.+Adds a new text insertion mode setting near Copy to Clipboard and makes Reliable Paste the default for more dependable dictation insertion across browsers and desktop apps. Also preserves an Experimental Direct Typing path for users who want to try to avoid clipboard changes.## Type of Change-- [ ] 🐞 Bug fix (non-breaking change which fixes an issue)-- [ ] ✨ New feature (non-breaking change which adds functionality)+- [x] 🐞 Bug fix (non-breaking change which fixes an issue)+- [x] ✨ New feature (non-breaking change which adds functionality)- [ ] 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)- [ ] 📝 Documentation update## Related Issues-Closes #(issue number)+- Closes #174+- Closes #125+- Related to #74## Testing-- [ ] Tested on Intel/Apple Silicon Mac-- [ ] Tested on Apple Silicon Mac+- [ ] Tested on Intel Mac+- [x] Tested on Apple Silicon Mac- [ ] Tested on macOS [version]-- [ ] Ran linter locally: `brew install swiftlint && swiftlint --strict --config .swiftlint.yml`-- [ ] Ran formatter locally: `brew install swiftformat && swiftformat --config .swiftformat Sources`+- [x] Ran linter locally: `swiftlint --strict --config .swiftlint.yml Sources`+- [x] Ran formatter locally: `swiftformat --config .swiftformat Sources`+- [x] Built locally: `sh build_incremental.sh`## Screenshots / Video-Add screenshots or Video recording of the app after you have made your changes\ No newline at end of file+Add screenshots or Video recording of the app after you have made your changesdiff --git a/Sources/Fluid/Persistence/SettingsStore.swift b/Sources/Fluid/Persistence/SettingsStore.swiftindex 7947b4c5..df5ab3c0 100644--- a/Sources/Fluid/Persistence/SettingsStore.swift+++ b/Sources/Fluid/Persistence/SettingsStore.swift@@ -77,31 +77,6 @@ final class SettingsStore: ObservableObject {}}- enum TextInsertionMode: String, CaseIterable, Identifiable, Codable {- case standard- case reliablePaste-- var id: String { self.rawValue }-- var displayName: String {- switch self {- case .standard:- return "Experimental Direct Typing"- case .reliablePaste:- return "Reliable Paste"- }- }-- var description: String {- switch self {- case .standard:- return "Avoids changing your clipboard history by typing directly when possible. May fail or behave inconsistently in some apps."- case .reliablePaste:- return "Works best across browsers and desktop apps. Uses a temporary clipboard paste, so clipboard history apps may briefly record dictated text."- }- }- }-struct DictationPromptProfile: Codable, Identifiable, Hashable {let id: Stringvar name: String@@ -851,20 +826,6 @@ final class SettingsStore: ObservableObject {set { self.defaults.set(newValue, forKey: Keys.copyTranscriptionToClipboard) }}- var textInsertionMode: TextInsertionMode {- get {- guard let raw = self.defaults.string(forKey: Keys.textInsertionMode),- let mode = TextInsertionMode(rawValue: raw) else {- return .reliablePaste- }- return mode- }- set {- objectWillChange.send()- self.defaults.set(newValue.rawValue, forKey: Keys.textInsertionMode)- }- }-var preferredInputDeviceUID: String? {get { self.defaults.string(forKey: Keys.preferredInputDeviceUID) }set { self.defaults.set(newValue, forKey: Keys.preferredInputDeviceUID) }@@ -2657,6 +2618,46 @@ private extension SettingsStore {}extension SettingsStore {+ enum TextInsertionMode: String, CaseIterable, Identifiable, Codable {+ case standard+ case reliablePaste++ var id: String { self.rawValue }++ var displayName: String {+ switch self {+ case .standard:+ return "Experimental Direct Typing"+ case .reliablePaste:+ return "Reliable Paste"+ }+ }++ var description: String {+ switch self {+ case .standard:+ return "Tries to avoid clipboard changes by typing directly when possible. May fail or behave inconsistently in some apps."+ case .reliablePaste:+ return "Works best across browsers and desktop apps. Uses a temporary clipboard paste, so clipboard history apps may briefly record dictated text."+ }+ }+ }++ var textInsertionMode: TextInsertionMode {+ get {+ guard let raw = self.defaults.string(forKey: Keys.textInsertionMode),+ let mode = TextInsertionMode(rawValue: raw)+ else {+ return .reliablePaste+ }+ return mode+ }+ set {+ objectWillChange.send()+ self.defaults.set(newValue.rawValue, forKey: Keys.textInsertionMode)+ }+ }+/// Available Whisper model sizesenum WhisperModelSize: String, CaseIterable, Identifiable {case tiny = "ggml-tiny.bin"diff --git a/Sources/Fluid/Services/TypingService.swift b/Sources/Fluid/Services/TypingService.swiftindex 1c527f3f..9267471b 100644--- a/Sources/Fluid/Services/TypingService.swift+++ b/Sources/Fluid/Services/TypingService.swift@@ -45,7 +45,7 @@ final class TypingService {static func captureSystemFocusedPID() -> pid_t? {// Accessibility is required to query system-focused AX element.guard AXIsProcessTrusted() else {- Self.storeFocusSnapshot(nil)+ self.storeFocusSnapshot(nil)return nil}@@ -84,7 +84,7 @@ final class TypingService {@discardableResultstatic func restoreCapturedFocus(in pid: pid_t) -> Bool {guard AXIsProcessTrusted() else { return false }- guard let snapshot = Self.loadFocusSnapshot(),+ guard let snapshot = loadFocusSnapshot(),snapshot.pid == pid else { return false }Self.logFocusState("[TypingService] Before restoreCapturedFocus")@@ -316,13 +316,13 @@ final class TypingService {private static let cgEventUnicodeLimit = 200private static func storeFocusSnapshot(_ snapshot: FocusSnapshot?) {- Self.focusSnapshotQueue.sync {+ self.focusSnapshotQueue.sync {Self.focusSnapshot = snapshot}}private static func loadFocusSnapshot() -> FocusSnapshot? {- Self.focusSnapshotQueue.sync { Self.focusSnapshot }+ self.focusSnapshotQueue.sync { Self.focusSnapshot }}private static func copyAXElementAttribute(from element: AXUIElement, attribute: CFString) -> AXUIElement? {@@ -366,8 +366,8 @@ final class TypingService {}private static func logFocusState(_ prefix: String) {- guard Self.isLoggingEnabled else { return }- DebugLogger.shared.debug("\(prefix) | \(Self.currentFocusDebugDescription())", source: "TypingService")+ guard self.isLoggingEnabled else { return }+ DebugLogger.shared.debug("\(prefix) | \(self.currentFocusDebugDescription())", source: "TypingService")}private static func isCurrentlyFocusedElement(_ expectedElement: AXUIElement, expectedPID: pid_t) -> Bool {