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

lint and format

altic-devc82e75872c4d
diff --git a/Sources/Fluid/Services/DebugLogger.swift b/Sources/Fluid/Services/DebugLogger.swift
index 77cfb618..bcf4fd99 100644
--- a/Sources/Fluid/Services/DebugLogger.swift
+++ b/Sources/Fluid/Services/DebugLogger.swift
@@ -74,16 +74,16 @@ class DebugLogger: ObservableObject {
func log(_ message: String, level: LogLevel = .info, source: String = "App") {
let loggingEnabled = self.loggingEnabled
-
+
// If logging is disabled, we drop all logs except errors which are always printed to console
- if !loggingEnabled && level != .error {
+ if !loggingEnabled, level != .error {
return
}
self.queue.async {
let timestamp = Date()
let timestampString = Self.logFormatter.string(from: timestamp)
-
+
let formattedLine = self.formatLogLine(timestamp: timestampString, level: level, source: source, message: message)
// Always write to FileLogger and Console if we reach this point (either logging is enabled OR it's an error)
@@ -92,7 +92,7 @@ class DebugLogger: ObservableObject {
// Only update the UI logs if logging is enabled (don't show errors in UI if debug is off)
guard loggingEnabled else { return }
-
+
let entry = LogEntry(
timestamp: timestamp,
level: level,
diff --git a/Sources/Fluid/Services/GlobalHotkeyManager.swift b/Sources/Fluid/Services/GlobalHotkeyManager.swift
index 83dd8587..5d1626c2 100644
--- a/Sources/Fluid/Services/GlobalHotkeyManager.swift
+++ b/Sources/Fluid/Services/GlobalHotkeyManager.swift
@@ -589,7 +589,7 @@ final class GlobalHotkeyManager: NSObject {
await MainActor.run {
if !self.validateEventTapHealth() {
DebugLogger.shared.warning("Health check failed, attempting to recover", source: "GlobalHotkeyManager")
-
+
if self.setupGlobalHotkey() {
self.isInitialized = true
DebugLogger.shared.info("Health check recovery successful", source: "GlobalHotkeyManager")
@@ -607,7 +607,7 @@ final class GlobalHotkeyManager: NSObject {
initializationTask?.cancel()
healthCheckTask?.cancel()
cleanupEventTap()
-
+
DebugLogger.shared.info("Deinitialized and cleaned up", source: "GlobalHotkeyManager")
}
}
diff --git a/Sources/Fluid/Services/LLMClient.swift b/Sources/Fluid/Services/LLMClient.swift
index 6d8e64c3..d2ea85f1 100644
--- a/Sources/Fluid/Services/LLMClient.swift
+++ b/Sources/Fluid/Services/LLMClient.swift
@@ -325,16 +325,17 @@ final class LLMClient {
// DEBUG LOG: Show full delta to see all fields (e.g., 'reasoning', 'thought', 'delta_reasoning', etc.)
if let deltaData = try? JSONSerialization.data(withJSONObject: delta, options: [.fragmentsAllowed]),
- let deltaString = String(data: deltaData, encoding: .utf8) {
+ let deltaString = String(data: deltaData, encoding: .utf8)
+ {
DebugLogger.shared.debug("LLMClient: Full Delta: \(deltaString)", source: "LLMClient")
}
-
+
// Handle separate reasoning fields (OpenAI 'reasoning', 'reasoning_content', DeepSeek, etc.)
- let reasoningField = delta["reasoning_content"] as? String ??
- delta["reasoning"] as? String ??
- delta["thought"] as? String ??
- delta["thinking"] as? String
-
+ let reasoningField = delta["reasoning_content"] as? String ??
+ delta["reasoning"] as? String ??
+ delta["thought"] as? String ??
+ delta["thinking"] as? String
+
if let reasoning = reasoningField {
if state == .initial {
state = .inThinking
@@ -346,15 +347,15 @@ final class LLMClient {
// Handle content with potential <think> tags
if let content = delta["content"] as? String {
- // If we were in thinking mode via a separate field (not tag-based),
+ // If we were in thinking mode via a separate field (not tag-based),
// receiving "content" usually means the thinking phase is over.
if state == .inThinking && reasoningField == nil && tagDetectionBuffer.isEmpty {
// This is a subtle heuristic: if we were thinking, didn't just get a reasoning field chunk,
- // and have no partial tags buffered, we should check if this content chunk
+ // and have no partial tags buffered, we should check if this content chunk
// is the start of the final answer.
// For safety with tag-based parsers, we let the parser decide unless it's a known separate-field model.
}
-
+
// Debug: Log first few chunks and any chunk containing think tags
let containsThinkTag = content.contains("<think") || content.contains("</think") || content.contains("<thinking") || content.contains("</thinking")
if thinkingBuffer.count + contentBuffer.count < 8 || containsThinkTag {
@@ -483,11 +484,11 @@ final class LLMClient {
let (thinking, cleanedContent) = self.stripThinkingTags(rawContent)
// Also check for multiple reasoning field variants
- let reasoningContent = message["reasoning_content"] as? String ??
- message["reasoning"] as? String ??
- message["thought"] as? String ??
- message["thinking"] as? String
-
+ let reasoningContent = message["reasoning_content"] as? String ??
+ message["reasoning"] as? String ??
+ message["thought"] as? String ??
+ message["thinking"] as? String
+
let finalThinking = [thinking, reasoningContent].compactMap { $0 }.filter { !$0.isEmpty }.joined(separator: "\n")
return Response(
@@ -612,20 +613,19 @@ final class LLMClient {
private func logRequest(_ request: URLRequest) {
guard let url = request.url, let method = request.httpMethod else { return }
-
+
var bodyString = ""
if let body = request.httpBody {
bodyString = String(data: body, encoding: .utf8) ?? ""
}
-
+
var curl = "curl -X \(method) \"\(url.absoluteString)\" \\\n"
for (key, value) in request.allHTTPHeaderFields ?? [:] {
let maskedValue = key.lowercased().contains("auth") ? "Bearer [REDACTED]" : value
curl += " -H \"\(key): \(maskedValue)\" \\\n"
}
curl += " -d '\(bodyString)'"
-
+
DebugLogger.shared.info("LLMClient: Full Request as cURL:\n\(curl)", source: "LLMClient")
}
}
-
diff --git a/Sources/Fluid/Services/SimpleUpdater.swift b/Sources/Fluid/Services/SimpleUpdater.swift
index b5ece0ea..16d200ba 100644
--- a/Sources/Fluid/Services/SimpleUpdater.swift
+++ b/Sources/Fluid/Services/SimpleUpdater.swift
@@ -312,7 +312,7 @@ final class SimpleUpdater {
// we need to replace the old app and use the new name
let installedAppName = installedAppURL.lastPathComponent
let downloadedAppName = downloadedAppURL.lastPathComponent
-
+
DebugLogger.shared.info("SimpleUpdater: Installing app - Current: \(installedAppName), New: \(downloadedAppName)", source: "SimpleUpdater")
let finalAppURL: URL
diff --git a/Sources/Fluid/Services/ThinkingParsers.swift b/Sources/Fluid/Services/ThinkingParsers.swift
index 2858f04d..5cff3cac 100644
--- a/Sources/Fluid/Services/ThinkingParsers.swift
+++ b/Sources/Fluid/Services/ThinkingParsers.swift
@@ -62,8 +62,9 @@ enum ThinkingParserFactory {
}
// OpenAI reasoning models (o1, o3, gpt-5): use SeparateFieldThinkingParser
- if SettingsStore.shared.isReasoningModel(model) &&
- (modelLower.contains("gpt-5") || modelLower.contains("o1") || modelLower.contains("o3") || modelLower.contains("gpt-oss")) {
+ if SettingsStore.shared.isReasoningModel(model) &&
+ (modelLower.contains("gpt-5") || modelLower.contains("o1") || modelLower.contains("o3") || modelLower.contains("gpt-oss"))
+ {
DebugLogger.shared.debug("ThinkingParser: Using SeparateFieldParser for reasoning model '\(model)'", source: "LLMClient")
return SeparateFieldThinkingParser()
}
@@ -303,7 +304,7 @@ struct SeparateFieldThinkingParser: ThinkingParser {
currentState: ThinkingParserState,
tagBuffer: inout String
) -> (ThinkingParserState, String, String) {
- // For separate-field models, receiving any "content" chunk means
+ // For separate-field models, receiving any "content" chunk means
// we are definitively in the content phase.
return (.inContent, "", chunk)
}
@@ -313,4 +314,3 @@ struct SeparateFieldThinkingParser: ThinkingParser {
return (thinkingBuffer.joined(), contentBuffer.joined().trimmingCharacters(in: .whitespacesAndNewlines))
}
}
-
diff --git a/Sources/Fluid/UI/SettingsView.swift b/Sources/Fluid/UI/SettingsView.swift
index 526150d1..f63a1a49 100644
--- a/Sources/Fluid/UI/SettingsView.swift
+++ b/Sources/Fluid/UI/SettingsView.swift
@@ -474,10 +474,12 @@ struct SettingsView: View {
let currentValid = newDevices.contains { $0.uid == self.selectedInputUID }
if !currentValid {
if let prefUID = SettingsStore.shared.preferredInputDeviceUID,
- newDevices.contains(where: { $0.uid == prefUID }) {
+ newDevices.contains(where: { $0.uid == prefUID })
+ {
self.selectedInputUID = prefUID
} else if let defaultUID = AudioDevice.getDefaultInputDevice()?.uid,
- newDevices.contains(where: { $0.uid == defaultUID }) {
+ newDevices.contains(where: { $0.uid == defaultUID })
+ {
self.selectedInputUID = defaultUID
} else {
self.selectedInputUID = newDevices.first?.uid ?? ""
@@ -514,10 +516,12 @@ struct SettingsView: View {
let currentValid = newDevices.contains { $0.uid == self.selectedOutputUID }
if !currentValid {
if let prefUID = SettingsStore.shared.preferredOutputDeviceUID,
- newDevices.contains(where: { $0.uid == prefUID }) {
+ newDevices.contains(where: { $0.uid == prefUID })
+ {
self.selectedOutputUID = prefUID
} else if let defaultUID = AudioDevice.getDefaultOutputDevice()?.uid,
- newDevices.contains(where: { $0.uid == defaultUID }) {
+ newDevices.contains(where: { $0.uid == defaultUID })
+ {
self.selectedOutputUID = defaultUID
} else {
self.selectedOutputUID = newDevices.first?.uid ?? ""
@@ -622,9 +626,9 @@ struct SettingsView: View {
set: { SettingsStore.shared.enableDebugLogs = $0 }
)
)
-
+
Divider().padding(.vertical, 8)
-
+
Button {
let url = FileLogger.shared.currentLogFileURL()
if FileManager.default.fileExists(atPath: url.path) {
@@ -655,39 +659,43 @@ struct SettingsView: View {
await AudioStartupGate.shared.waitUntilOpen()
self.refreshDevices()
-
+
// Sync input device selection after refresh
if !self.inputDevices.isEmpty {
let inputValid = self.inputDevices.contains { $0.uid == self.selectedInputUID }
if !inputValid || self.selectedInputUID.isEmpty {
if let prefUID = SettingsStore.shared.preferredInputDeviceUID,
- self.inputDevices.contains(where: { $0.uid == prefUID }) {
+ self.inputDevices.contains(where: { $0.uid == prefUID })
+ {
self.selectedInputUID = prefUID
} else if let defaultUID = AudioDevice.getDefaultInputDevice()?.uid,
- self.inputDevices.contains(where: { $0.uid == defaultUID }) {
+ self.inputDevices.contains(where: { $0.uid == defaultUID })
+ {
self.selectedInputUID = defaultUID
} else {
self.selectedInputUID = self.inputDevices.first?.uid ?? ""
}
}
}
-
+
// Sync output device selection after refresh
if !self.outputDevices.isEmpty {
let outputValid = self.outputDevices.contains { $0.uid == self.selectedOutputUID }
if !outputValid || self.selectedOutputUID.isEmpty {
if let prefUID = SettingsStore.shared.preferredOutputDeviceUID,
- self.outputDevices.contains(where: { $0.uid == prefUID }) {
+ self.outputDevices.contains(where: { $0.uid == prefUID })
+ {
self.selectedOutputUID = prefUID
} else if let defaultUID = AudioDevice.getDefaultOutputDevice()?.uid,
- self.outputDevices.contains(where: { $0.uid == defaultUID }) {
+ self.outputDevices.contains(where: { $0.uid == defaultUID })
+ {
self.selectedOutputUID = defaultUID
} else {
self.selectedOutputUID = self.outputDevices.first?.uid ?? ""
}
}
}
-
+
// CRITICAL FIX: Populate cached default device names after onAppear, not during view body evaluation.
// This avoids the CoreAudio/SwiftUI AttributeGraph race condition that causes EXC_BAD_ACCESS.
self.cachedDefaultInputName = AudioDevice.getDefaultInputDevice()?.name ?? ""