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(rewrite): restore the source field before Replace Original

altic-dev28db74b8a290
diff --git a/Sources/Fluid/Services/RewriteModeService.swift b/Sources/Fluid/Services/RewriteModeService.swift
index 6e025f57..41139075 100644
--- a/Sources/Fluid/Services/RewriteModeService.swift
+++ b/Sources/Fluid/Services/RewriteModeService.swift
@@ -150,8 +150,19 @@ final class RewriteModeService: ObservableObject {
func acceptRewrite(_ text: String) async {
// The panel may clear its state before this queued action starts.
guard !text.isEmpty else { return }
- NSApp.hide(nil) // Restore focus to the previous app
- _ = await self.typingService.typeTextInstantly(text)
+ NSApp.hide(nil)
+ // Hiding alone races the paste: the focused element can still be our
+ // panel when the editability check runs. Put focus back on the field
+ // the rewrite was recorded from, and fall back to a short settle.
+ var targetPID: pid_t?
+ if let context = NotchContentState.shared.recordingTargetContext {
+ let preparation = await TypingService.prepareTargetForDelivery(context)
+ targetPID = context.pid
+ self.appendDiagnosticLog("acceptRewrite focus=\(preparation.rawValue) pid=\(context.pid)")
+ } else {
+ try? await Task.sleep(nanoseconds: 80_000_000)
+ }
+ _ = await self.typingService.typeTextInstantly(text, preferredTargetPID: targetPID)
}
func clearState() {