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
refactor: streamline settings - remove redundancy and improve organization
altic-dev566347874d94
diff --git a/Sources/Fluid/Persistence/SettingsStore.swift b/Sources/Fluid/Persistence/SettingsStore.swiftindex c24f6298..bfad7160 100644--- a/Sources/Fluid/Persistence/SettingsStore.swift+++ b/Sources/Fluid/Persistence/SettingsStore.swift@@ -34,6 +34,7 @@ final class SettingsStorestatic let autoUpdateCheckEnabled = "AutoUpdateCheckEnabled"static let lastUpdateCheckDate = "LastUpdateCheckDate"static let lastSeenVersion = "LastSeenVersion"+ static let playgroundUsed = "PlaygroundUsed"}struct SavedProvider: Codable, Identifiable, Hashable@@ -267,6 +268,11 @@ final class SettingsStoreget { defaults.string(forKey: Keys.lastSeenVersion) }set { defaults.set(newValue, forKey: Keys.lastSeenVersion) }}++ var playgroundUsed: Bool {+ get { defaults.bool(forKey: Keys.playgroundUsed) }+ set { defaults.set(newValue, forKey: Keys.playgroundUsed) }+ }func shouldShowWhatsNew() -> Bool {let currentVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "1.0.0"diff --git a/Sources/Fluid/UI/SettingsView.swift b/Sources/Fluid/UI/SettingsView.swiftindex 18c6ee9e..3bd1c2a1 100644--- a/Sources/Fluid/UI/SettingsView.swift+++ b/Sources/Fluid/UI/SettingsView.swift@@ -6,6 +6,7 @@//import SwiftUI+import AVFoundationstruct SettingsView: View {@ObservedObject var asr: ASRService@@ -17,36 +18,26 @@ struct SettingsView: View {@Binding var selectedOutputUID: String@Binding var inputDevices: [AudioDevice.Device]@Binding var outputDevices: [AudioDevice.Device]+ @Binding var accessibilityEnabled: Bool+ @Binding var hotkeyShortcut: HotkeyShortcut+ @Binding var isRecordingShortcut: Bool+ @Binding var hotkeyManagerInitialized: Bool+ @Binding var pressAndHoldModeEnabled: Bool+ @Binding var enableStreamingPreview: Bool+ @Binding var copyToClipboard: Bool+ let hotkeyManager: GlobalHotkeyManager?+ let menuBarManager: MenuBarManagerlet startRecording: () -> Voidlet refreshDevices: () -> Void+ let openAccessibilitySettings: () -> Void+ let restartApp: () -> Void+ let revealAppInFinder: () -> Void+ let openApplicationsFolder: () -> Voidvar body: some View {ScrollView(.vertical, showsIndicators: false) {VStack(spacing: 24) {- // Header- ThemedCard(style: .standard) {- VStack(spacing: 16) {- HStack {- Image(systemName: "gear")- .font(.system(size: 32))- .foregroundStyle(.white)-- VStack(alignment: .leading, spacing: 4) {- Text("Settings")- .font(.title2)- .fontWeight(.bold)- Text("App behavior and preferences")- .font(.subheadline)- .foregroundStyle(.secondary)- }-- Spacer()- }- }- .padding(24)- }-// App Settings CardThemedCard(style: .standard) {VStack(alignment: .leading, spacing: 16) {@@ -59,65 +50,95 @@ struct SettingsView: View {.fontWeight(.semibold)}- VStack(spacing: 16) {- Toggle(isOn: Binding(- get: { SettingsStore.shared.launchAtStartup },- set: { SettingsStore.shared.launchAtStartup = $0 }- )) {- VStack(alignment: .leading, spacing: 4) {- Text("Launch at startup")- .font(.headline)- Text("Automatically start FluidVoice when you log in")- .font(.caption)- .foregroundStyle(.secondary)+ VStack(spacing: 20) {+ // Launch at startup+ VStack(alignment: .leading, spacing: 8) {+ HStack(alignment: .top, spacing: 16) {+ VStack(alignment: .leading, spacing: 4) {+ Text("Launch at startup")+ .font(.headline)+ Text("Automatically start FluidVoice when you log in")+ .font(.caption)+ .foregroundStyle(.secondary)+ }++ Spacer()++ Toggle("", isOn: Binding(+ get: { SettingsStore.shared.launchAtStartup },+ set: { SettingsStore.shared.launchAtStartup = $0 }+ ))+ .toggleStyle(.switch)+ .tint(.green)+ .labelsHidden()}++ Text("Note: Requires app to be signed for this to work.")+ .font(.caption2)+ .foregroundStyle(.secondary.opacity(0.7))+ .padding(.leading, 0)}- .toggleStyle(.switch)-- Text("Note: Requires app to be signed for this to work.")- .font(.caption2)- .foregroundStyle(.secondary.opacity(0.7))Divider()- Toggle(isOn: Binding(- get: { SettingsStore.shared.showInDock },- set: { SettingsStore.shared.showInDock = $0 }- )) {- VStack(alignment: .leading, spacing: 4) {- Text("Show in Dock")- .font(.headline)- Text("Display FluidVoice icon in the Dock")- .font(.caption)- .foregroundStyle(.secondary)+ // Show in Dock+ VStack(alignment: .leading, spacing: 8) {+ HStack(alignment: .top, spacing: 16) {+ VStack(alignment: .leading, spacing: 4) {+ Text("Show in Dock")+ .font(.headline)+ Text("Display FluidVoice icon in the Dock")+ .font(.caption)+ .foregroundStyle(.secondary)+ }++ Spacer()++ Toggle("", isOn: Binding(+ get: { SettingsStore.shared.showInDock },+ set: { SettingsStore.shared.showInDock = $0 }+ ))+ .toggleStyle(.switch)+ .tint(.green)+ .labelsHidden()}++ Text("Note: May require app restart to take effect.")+ .font(.caption2)+ .foregroundStyle(.secondary.opacity(0.7))+ .padding(.leading, 0)}- .toggleStyle(.switch)-- Text("Note: May require app restart to take effect.")- .font(.caption2)- .foregroundStyle(.secondary.opacity(0.7))Divider()- Toggle(isOn: Binding(- get: { SettingsStore.shared.autoUpdateCheckEnabled },- set: { SettingsStore.shared.autoUpdateCheckEnabled = $0 }- )) {- VStack(alignment: .leading, spacing: 4) {- Text("Automatic Updates")- .font(.headline)- Text("Check for updates automatically once per day")- .font(.caption)- .foregroundStyle(.secondary)+ // Automatic Updates+ VStack(alignment: .leading, spacing: 8) {+ HStack(alignment: .top, spacing: 16) {+ VStack(alignment: .leading, spacing: 4) {+ Text("Automatic Updates")+ .font(.headline)+ Text("Check for updates automatically once per day")+ .font(.caption)+ .foregroundStyle(.secondary)+ }++ Spacer()++ Toggle("", isOn: Binding(+ get: { SettingsStore.shared.autoUpdateCheckEnabled },+ set: { SettingsStore.shared.autoUpdateCheckEnabled = $0 }+ ))+ .toggleStyle(.switch)+ .tint(.green)+ .labelsHidden()+ }++ if let lastCheck = SettingsStore.shared.lastUpdateCheckDate {+ Text("Last checked: \(lastCheck.formatted(date: .abbreviated, time: .shortened))")+ .font(.caption2)+ .foregroundStyle(.secondary.opacity(0.7))+ .padding(.leading, 0)}- }- .toggleStyle(.switch)-- if let lastCheck = SettingsStore.shared.lastUpdateCheckDate {- Text("Last checked: \(lastCheck.formatted(date: .abbreviated, time: .shortened))")- .font(.caption2)- .foregroundStyle(.secondary.opacity(0.7))}// What's New Button@@ -128,7 +149,457 @@ struct SettingsView: View {}.buttonStyle(PremiumButtonStyle(height: 40)).buttonHoverEffect()- .padding(.top, 8)+ .padding(.top, 4)+ }+ }+ .padding(24)+ }++ // Microphone Permission Card+ ThemedCard(style: .standard) {+ VStack(alignment: .leading, spacing: 16) {+ HStack {+ Image(systemName: "mic.fill")+ .font(.title2)+ .foregroundStyle(.white)+ Text("Microphone Permission")+ .font(.title3)+ .fontWeight(.semibold)+ }++ VStack(alignment: .leading, spacing: 12) {+ HStack(spacing: 12) {+ // Status indicator+ Circle()+ .fill(asr.micStatus == .authorized ? theme.palette.success : theme.palette.warning)+ .frame(width: 10, height: 10)++ VStack(alignment: .leading, spacing: 4) {+ Text(asr.micStatus == .authorized ? "Microphone access granted" :+ asr.micStatus == .denied ? "Microphone access denied" :+ "Microphone access not determined")+ .fontWeight(.medium)+ .foregroundStyle(asr.micStatus == .authorized ? theme.palette.primaryText : theme.palette.warning)++ if asr.micStatus != .authorized {+ Text("Microphone access is required for voice recording")+ .font(.caption)+ .foregroundStyle(.secondary)+ }+ }+ Spacer()++ // Action button+ Group {+ if asr.micStatus == .notDetermined {+ Button {+ asr.requestMicAccess()+ } label: {+ HStack(spacing: 6) {+ Image(systemName: "mic.fill")+ Text("Grant Access")+ .fontWeight(.medium)+ }+ }+ .buttonStyle(GlassButtonStyle())+ .buttonHoverEffect()+ } else if asr.micStatus == .denied {+ Button {+ asr.openSystemSettingsForMic()+ } label: {+ HStack(spacing: 6) {+ Image(systemName: "gear")+ Text("Open Settings")+ .fontWeight(.medium)+ }+ }+ .buttonStyle(GlassButtonStyle())+ .buttonHoverEffect()+ }+ }+ }++ // Step-by-step instructions when microphone is not authorized+ if asr.micStatus != .authorized {+ VStack(alignment: .leading, spacing: 8) {+ HStack(spacing: 8) {+ Image(systemName: "info.circle.fill")+ .foregroundStyle(theme.palette.accent)+ .font(.caption)+ Text("How to enable microphone access:")+ .font(.caption)+ .fontWeight(.medium)+ .foregroundStyle(.secondary)+ }++ VStack(alignment: .leading, spacing: 4) {+ if asr.micStatus == .notDetermined {+ HStack(spacing: 8) {+ Text("1.")+ .font(.caption2)+ .foregroundStyle(theme.palette.accent)+ .fontWeight(.semibold)+ .frame(width: 16)+ Text("Click **Grant Access** above")+ .font(.caption)+ .foregroundStyle(.primary)+ }+ HStack(spacing: 8) {+ Text("2.")+ .font(.caption2)+ .foregroundStyle(theme.palette.accent)+ .fontWeight(.semibold)+ .frame(width: 16)+ Text("Choose **Allow** in the system dialog")+ .font(.caption)+ .foregroundStyle(.primary)+ }+ } else if asr.micStatus == .denied {+ HStack(spacing: 8) {+ Text("1.")+ .font(.caption2)+ .foregroundStyle(theme.palette.accent)+ .fontWeight(.semibold)+ .frame(width: 16)+ Text("Click **Open Settings** above")+ .font(.caption)+ .foregroundStyle(.primary)+ }+ HStack(spacing: 8) {+ Text("2.")+ .font(.caption2)+ .foregroundStyle(theme.palette.accent)+ .fontWeight(.semibold)+ .frame(width: 16)+ Text("Find **FluidVoice** in the microphone list")+ .font(.caption)+ .foregroundStyle(.primary)+ }+ HStack(spacing: 8) {+ Text("3.")+ .font(.caption2)+ .foregroundStyle(theme.palette.accent)+ .fontWeight(.semibold)+ .frame(width: 16)+ Text("Toggle **FluidVoice ON** to allow access")+ .font(.caption)+ .foregroundStyle(.primary)+ }+ }+ }+ .padding(.leading, 4)+ }+ .padding(12)+ .background(theme.palette.accent.opacity(0.12))+ .cornerRadius(8)+ }+ }+ }+ .padding(24)+ }++ // Global Hotkey Card+ ThemedCard(style: .standard) {+ VStack(alignment: .leading, spacing: 16) {+ HStack {+ Image(systemName: "keyboard")+ .font(.title2)+ .foregroundStyle(.white)+ Text("Global Hotkey")+ .font(.title3)+ .fontWeight(.semibold)+ }++ if accessibilityEnabled {+ // Hotkey is enabled+ VStack(alignment: .leading, spacing: 16) {+ // Current Hotkey Display+ VStack(alignment: .leading, spacing: 8) {+ Text("Current Hotkey")+ .font(.subheadline)+ .fontWeight(.medium)+ .foregroundStyle(.secondary)++ // Hotkey Display Row+ HStack(spacing: 16) {+ // Clean Hotkey Display+ HStack(spacing: 8) {+ Text(hotkeyShortcut.displayString)+ .font(.system(size: 16, weight: .semibold, design: .monospaced))+ .foregroundStyle(.primary)+ .padding(.horizontal, 12)+ .padding(.vertical, 6)+ .background(+ RoundedRectangle(cornerRadius: 8)+ .fill(.quaternary.opacity(0.5))+ .overlay(+ RoundedRectangle(cornerRadius: 8)+ .stroke(.primary.opacity(0.2), lineWidth: 1)+ )+ )+ }++ Spacer()++ // Enhanced Change Button+ Button {+ DebugLogger.shared.debug("Starting to record new shortcut", source: "SettingsView")+ isRecordingShortcut = true+ } label: {+ HStack(spacing: 8) {+ Image(systemName: "pencil")+ .font(.system(size: 13, weight: .semibold))+ Text("Change")+ .fontWeight(.semibold)+ }+ }+ .buttonStyle(GlassButtonStyle())+ .buttonHoverEffect()++ // Restart button for accessibility changes+ if !hotkeyManagerInitialized && accessibilityEnabled {+ Button {+ DebugLogger.shared.debug("User requested app restart for accessibility changes", source: "SettingsView")+ restartApp()+ } label: {+ HStack(spacing: 6) {+ Image(systemName: "arrow.clockwise.circle")+ .font(.system(size: 12, weight: .semibold))+ Text("Restart")+ .font(.system(size: 12, weight: .semibold))+ }+ }+ .buttonStyle(InlineButtonStyle())+ .buttonHoverEffect()+ }+ }+ }++ // Enhanced Status/Instruction Text+ HStack(spacing: 10) {+ if isRecordingShortcut {+ Image(systemName: "hand.point.up.left.fill")+ .foregroundStyle(.white)+ .font(.system(size: 16, weight: .medium))+ Text("Press your new hotkey combination now...")+ .font(.system(.subheadline, weight: .medium))+ .foregroundStyle(.white)+ } else if hotkeyManagerInitialized {+ Image(systemName: "checkmark.circle.fill")+ .foregroundStyle(.green)+ .font(.system(size: 16))+ VStack(alignment: .leading, spacing: 2) {+ Text("Global Shortcut Active")+ .font(.system(.caption, weight: .semibold))+ .foregroundStyle(.white)+ Text(pressAndHoldModeEnabled+ ? "Hold \(hotkeyShortcut.displayString) to record and release to stop"+ : "Press \(hotkeyShortcut.displayString) anywhere to start/stop recording")+ .font(.system(.caption))+ .foregroundStyle(.secondary)+ }+ } else {+ ProgressView()+ .scaleEffect(0.8)+ .frame(width: 16, height: 16)+ .foregroundStyle(.orange)+ VStack(alignment: .leading, spacing: 2) {+ Text("Hotkey Initializing...")+ .font(.system(.caption, weight: .semibold))+ .foregroundStyle(.orange)+ Text("Please wait while the global hotkey system starts up")+ .font(.system(.caption))+ .foregroundStyle(.secondary)+ }+ }+ }+ .padding(.horizontal, 12)+ .padding(.vertical, 8)+ .background(+ RoundedRectangle(cornerRadius: 8)+ .fill(.ultraThinMaterial.opacity(0.5))+ .overlay(+ RoundedRectangle(cornerRadius: 8)+ .stroke(.white.opacity(0.1), lineWidth: 1)+ )+ )++ // Press and hold toggle+ VStack(alignment: .leading, spacing: 12) {+ Toggle("Press and Hold Mode", isOn: $pressAndHoldModeEnabled)+ .toggleStyle(GlassToggleStyle())+ Text("When enabled, the shortcut only records while you hold it down, giving you quick push-to-talk style control.")+ .font(.caption)+ .foregroundStyle(.secondary)+ }+ .padding(.horizontal, 12)+ .padding(.vertical, 10)+ .background(+ RoundedRectangle(cornerRadius: 8)+ .fill(.ultraThinMaterial.opacity(0.5))+ .overlay(+ RoundedRectangle(cornerRadius: 8)+ .stroke(.white.opacity(0.08), lineWidth: 1)+ )+ )+ .onChange(of: pressAndHoldModeEnabled) { newValue in+ SettingsStore.shared.pressAndHoldMode = newValue+ hotkeyManager?.enablePressAndHoldMode(newValue)+ }++ // Streaming preview toggle+ VStack(alignment: .leading, spacing: 12) {+ Toggle("Show Live Preview", isOn: $enableStreamingPreview)+ .toggleStyle(GlassToggleStyle())+ Text("Display transcription text in real-time in the overlay as you speak. When disabled, only the animation is shown.")+ .font(.caption)+ .foregroundStyle(.secondary)+ }+ .padding(.horizontal, 12)+ .padding(.vertical, 10)+ .background(+ RoundedRectangle(cornerRadius: 8)+ .fill(.ultraThinMaterial.opacity(0.5))+ .overlay(+ RoundedRectangle(cornerRadius: 8)+ .stroke(.white.opacity(0.08), lineWidth: 1)+ )+ )+ .onChange(of: enableStreamingPreview) { newValue in+ SettingsStore.shared.enableStreamingPreview = newValue+ menuBarManager.updateOverlayPreviewSetting(newValue)+ if !newValue {+ menuBarManager.updateOverlayTranscription("")+ }+ }++ // Copy to clipboard toggle+ VStack(alignment: .leading, spacing: 12) {+ Toggle("Copy to Clipboard", isOn: $copyToClipboard)+ .toggleStyle(GlassToggleStyle())+ Text("Automatically copy transcribed text to clipboard as a backup, useful when no text field is selected.")+ .font(.caption)+ .foregroundStyle(.secondary)+ }+ .padding(.horizontal, 12)+ .padding(.vertical, 10)+ .background(+ RoundedRectangle(cornerRadius: 8)+ .fill(.ultraThinMaterial.opacity(0.5))+ .overlay(+ RoundedRectangle(cornerRadius: 8)+ .stroke(.white.opacity(0.08), lineWidth: 1)+ )+ )+ .onChange(of: copyToClipboard) { newValue in+ SettingsStore.shared.copyTranscriptionToClipboard = newValue+ }+ }+ } else {+ // Hotkey disabled - accessibility not enabled+ VStack(alignment: .leading, spacing: 16) {+ HStack(spacing: 12) {+ // Status indicator+ Circle()+ .fill(theme.palette.warning)+ .frame(width: 10, height: 10)++ VStack(alignment: .leading, spacing: 4) {+ HStack {+ Image(systemName: "exclamationmark.triangle.fill")+ .foregroundStyle(theme.palette.warning)+ Text("Accessibility permissions required")+ .fontWeight(.medium)+ .foregroundStyle(theme.palette.warning)+ }+ Text("Required for global hotkey functionality")+ .font(.caption)+ .foregroundStyle(.secondary)+ }+ Spacer()++ Button("Open Accessibility Settings") {+ openAccessibilitySettings()+ }+ .buttonStyle(GlassButtonStyle())+ .buttonHoverEffect()+ }++ // Prominent step-by-step instructions+ VStack(alignment: .leading, spacing: 12) {+ HStack(spacing: 8) {+ Image(systemName: "info.circle.fill")+ .foregroundStyle(theme.palette.accent)+ .font(.caption)+ Text("Follow these steps to enable Accessibility:")+ .font(.caption)+ .fontWeight(.medium)+ .foregroundStyle(.secondary)+ }++ VStack(alignment: .leading, spacing: 8) {+ HStack(spacing: 8) {+ Text("1.")+ .font(.caption2)+ .foregroundStyle(theme.palette.accent)+ .fontWeight(.semibold)+ .frame(width: 16)+ Text("Click **Open Accessibility Settings** above")+ .font(.caption)+ .foregroundStyle(.primary)+ }+ HStack(spacing: 8) {+ Text("2.")+ .font(.caption2)+ .foregroundStyle(theme.palette.accent)+ .fontWeight(.semibold)+ .frame(width: 16)+ Text("In the Accessibility window, click the **+ button**")+ .font(.caption)+ .foregroundStyle(.primary)+ }+ HStack(spacing: 8) {+ Text("3.")+ .font(.caption2)+ .foregroundStyle(theme.palette.accent)+ .fontWeight(.semibold)+ .frame(width: 16)+ Text("Navigate to Applications and select **FluidVoice**")+ .font(.caption)+ .foregroundStyle(.primary)+ }+ HStack(spacing: 8) {+ Text("4.")+ .font(.caption2)+ .foregroundStyle(theme.palette.accent)+ .fontWeight(.semibold)+ .frame(width: 16)+ Text("Click **Open**, then toggle **FluidVoice ON** in the list")+ .font(.caption)+ .foregroundStyle(.primary)+ }+ }+ .padding(.leading, 4)++ // Helper buttons+ HStack(spacing: 12) {+ Button("Reveal FluidVoice in Finder") {+ revealAppInFinder()+ }+ .buttonStyle(InlineButtonStyle())+ .buttonHoverEffect()++ Button("Open Applications Folder") {+ openApplicationsFolder()+ }+ .buttonStyle(InlineButtonStyle())+ .buttonHoverEffect()+ }+ }+ .padding(12)+ .background(theme.palette.warning.opacity(0.12))+ .cornerRadius(8)+ }}}.padding(24)@@ -262,6 +733,42 @@ struct SettingsView: View {}.padding(24)}++ // Debug Settings Card+ ThemedCard(style: .standard) {+ VStack(alignment: .leading, spacing: 16) {+ HStack {+ Image(systemName: "ladybug.fill")+ .font(.title2)+ .foregroundStyle(.white)+ Text("Debug Settings")+ .font(.title3)+ .fontWeight(.semibold)+ }++ VStack(alignment: .leading, spacing: 12) {+ Button {+ let url = FileLogger.shared.currentLogFileURL()+ if FileManager.default.fileExists(atPath: url.path) {+ NSWorkspace.shared.activateFileViewerSelecting([url])+ } else {+ DebugLogger.shared.info("Log file not found at \(url.path)", source: "SettingsView")+ }+ } label: {+ Label("Reveal Log File", systemImage: "doc.richtext")+ .labelStyle(.titleAndIcon)+ }+ .buttonStyle(GlassButtonStyle())+ .buttonHoverEffect()++ Text("Click to reveal the debug log file. This file contains detailed information about app operations and can help with troubleshooting issues.")+ .font(.caption)+ .foregroundStyle(.secondary)+ .padding(.leading, 4)+ }+ }+ .padding(24)+ }}.padding(24)}