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

add best effort extraction for ghostty pid

grohith32732ab04d7f6fc
diff --git a/Sources/Fluid/Services/TypingService.swift b/Sources/Fluid/Services/TypingService.swift
index c7c8342d..22e4a58c 100644
--- a/Sources/Fluid/Services/TypingService.swift
+++ b/Sources/Fluid/Services/TypingService.swift
@@ -225,9 +225,9 @@ final class TypingService {
return Self.isCurrentlyFocusedElement(element, expectedPID: pid)
}
- private func isGhosttyTarget(preferredTargetPID: pid_t?) -> Bool {
- guard let preferredTargetPID, preferredTargetPID > 0,
- let app = NSRunningApplication(processIdentifier: preferredTargetPID)
+ private func isGhosttyApplication(pid: pid_t) -> Bool {
+ guard pid > 0,
+ let app = NSRunningApplication(processIdentifier: pid)
else {
return false
}
@@ -235,6 +235,26 @@ final class TypingService {
return app.bundleIdentifier == Self.ghosttyBundleIdentifier
}
+ private func ghosttyTargetPID(preferredTargetPID: pid_t?) -> pid_t? {
+ if let preferredTargetPID, preferredTargetPID > 0 {
+ return self.isGhosttyApplication(pid: preferredTargetPID) ? preferredTargetPID : nil
+ }
+
+ if let focusedPID = self.getSystemFocusedElementAndPID()?.pid,
+ self.isGhosttyApplication(pid: focusedPID)
+ {
+ return focusedPID
+ }
+
+ if let frontmostPID = NSWorkspace.shared.frontmostApplication?.processIdentifier,
+ self.isGhosttyApplication(pid: frontmostPID)
+ {
+ return frontmostPID
+ }
+
+ return nil
+ }
+
/// Best-effort: activates the app with the given PID, unless it's Fluid itself.
@discardableResult
static func activateApp(pid: pid_t) -> Bool {
@@ -352,9 +372,11 @@ final class TypingService {
self.log("[TypingService] insertTextInstantly called with \(text.count) characters")
self.log("[TypingService] Attempting to type text: \"\(text.prefix(50))\(text.count > 50 ? "..." : "")\"")
- if self.textInsertionMode == .standard, self.isGhosttyTarget(preferredTargetPID: preferredTargetPID) {
- self.log("[TypingService] Ghostty target detected in standard mode; forcing Reliable Paste path")
- if self.tryReliablePasteInsertion(text, preferredTargetPID: preferredTargetPID) {
+ if self.textInsertionMode == .standard,
+ let ghosttyTargetPID = self.ghosttyTargetPID(preferredTargetPID: preferredTargetPID)
+ {
+ self.log("[TypingService] Ghostty target detected in standard mode (PID \(ghosttyTargetPID)); forcing Reliable Paste path")
+ if self.tryReliablePasteInsertion(text, preferredTargetPID: ghosttyTargetPID) {
self.log("[TypingService] SUCCESS: Ghostty Reliable Paste path completed")
return
}