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

reduce snapshot restore time

grohith32756504289d8bc
diff --git a/Sources/Fluid/Services/PasteDeliveryCoordinator.swift b/Sources/Fluid/Services/PasteDeliveryCoordinator.swift
index 338eada1..2f0680d2 100644
--- a/Sources/Fluid/Services/PasteDeliveryCoordinator.swift
+++ b/Sources/Fluid/Services/PasteDeliveryCoordinator.swift
@@ -434,19 +434,14 @@ final class SystemPasteboardManager: PasteboardManaging {
@MainActor
final class SystemPasteCommandPoster: PasteCommandPosting {
- private static let commandKeyCode: CGKeyCode = 0x37
private static let vKeyCode: CGKeyCode = 0x09
- private nonisolated static let eventDelayNanoseconds: UInt64 = 10_000_000
+ nonisolated static let clipboardSettleDelayNanoseconds: UInt64 = 50_000_000
func postGlobalPasteCommand() async -> Bool {
guard AXIsProcessTrusted() else { return false }
- let source = CGEventSource(stateID: .privateState)
- guard let commandDown = CGEvent(
- keyboardEventSource: source,
- virtualKey: Self.commandKeyCode,
- keyDown: true
- ), let vDown = CGEvent(
+ let source = CGEventSource(stateID: .combinedSessionState)
+ guard let vDown = CGEvent(
keyboardEventSource: source,
virtualKey: Self.vKeyCode,
keyDown: true
@@ -454,38 +449,25 @@ final class SystemPasteCommandPoster: PasteCommandPosting {
keyboardEventSource: source,
virtualKey: Self.vKeyCode,
keyDown: false
- ), let commandUp = CGEvent(
- keyboardEventSource: source,
- virtualKey: Self.commandKeyCode,
- keyDown: false
) else {
return false
}
- commandDown.flags = .maskCommand
vDown.flags = .maskCommand
vUp.flags = .maskCommand
- commandDown.post(tap: .cghidEventTap)
- await self.pauseBetweenEvents()
+ // Match Muesli's publication delay and two-event Command+V sequence.
+ try? await Task.sleep(nanoseconds: Self.clipboardSettleDelayNanoseconds)
vDown.post(tap: .cghidEventTap)
- await self.pauseBetweenEvents()
vUp.post(tap: .cghidEventTap)
- await self.pauseBetweenEvents()
- commandUp.post(tap: .cghidEventTap)
return true
}
-
- private func pauseBetweenEvents() async {
- // Always finish posting the key-up events, even if the calling task was cancelled.
- try? await Task.sleep(nanoseconds: Self.eventDelayNanoseconds)
- }
}
@MainActor
final class PasteDeliveryCoordinator {
static let shared = PasteDeliveryCoordinator()
- nonisolated static let defaultSettlementDelayNanoseconds: UInt64 = 1_500_000_000
+ nonisolated static let defaultSettlementDelayNanoseconds: UInt64 = 500_000_000
private struct ClipboardLease {
let originalSnapshot: PasteboardSnapshot
diff --git a/Sources/Fluid/fluidApp.swift b/Sources/Fluid/fluidApp.swift
index 4d94cbfc..3d31c006 100644
--- a/Sources/Fluid/fluidApp.swift
+++ b/Sources/Fluid/fluidApp.swift
@@ -23,10 +23,14 @@ struct FluidApp: App {
var body: some Scene {
WindowGroup(id: "main") {
- AdaptiveAppTheme(accent: self.settings.accentColor) {
- ContentView()
- .environmentObject(self.menuBarManager)
- .environmentObject(self.appServices)
+ if let benchmarkConfiguration = InsertionLatencyBenchmarkConfiguration.current {
+ InsertionLatencyBenchmarkView(configuration: benchmarkConfiguration)
+ } else {
+ AdaptiveAppTheme(accent: self.settings.accentColor) {
+ ContentView()
+ .environmentObject(self.menuBarManager)
+ .environmentObject(self.appServices)
+ }
}
}
.defaultSize(width: 1000, height: 700)