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
UI refactor and M1 crash fix - split views, removed deadlock NSLock
altic-deva909df4fabc8
diff --git a/Sources/Fluid/ContentView.swift b/Sources/Fluid/ContentView.swiftindex 6b42a057..756ed1d5 100644--- a/Sources/Fluid/ContentView.swift+++ b/Sources/Fluid/ContentView.swift@@ -19,6 +19,17 @@ import CoreGraphics// Import the talking animations from TalkingAnimations.swift// The TalkingAudioVisualizationView is now defined in TalkingAnimations.swift+// MARK: - Sidebar Item Enum++enum SidebarItem: Hashable {+ case welcome+ case recording+ case aiProcessing+ case settings+ case meetingTools+ case feedback+}+// MARK: - Listening Overlay View (using modular components)struct ListeningOverlayView: View{@@ -67,6 +78,7 @@ struct ContentView: View {@StateObject private var asr = ASRService()@StateObject private var mouseTracker = MousePositionTracker()@EnvironmentObject private var menuBarManager: MenuBarManager+ @Environment(\.theme) private var theme@State private var hotkeyManager: GlobalHotkeyManager? = nil@State private var hotkeyManagerInitialized: Bool = false@@ -216,6 +228,64 @@ struct ContentView: View {await preloadASRModel()}+ // Load saved provider ID first+ selectedProviderID = SettingsStore.shared.selectedProviderID++ // Establish provider context first+ updateCurrentProvider()++ enableAIProcessing = SettingsStore.shared.enableAIProcessing+ enableDebugLogs = SettingsStore.shared.enableDebugLogs+ availableModelsByProvider = SettingsStore.shared.availableModelsByProvider+ selectedModelByProvider = SettingsStore.shared.selectedModelByProvider+ providerAPIKeys = SettingsStore.shared.providerAPIKeys+ savedProviders = SettingsStore.shared.savedProviders++ // Migration & cleanup: normalize provider keys and drop legacy flat lists+ var normalized: [String: [String]] = [:]+ for (key, models) in availableModelsByProvider {+ let lower = key.lowercased()+ let newKey: String+ if lower == "openai" || lower == "groq" { newKey = lower }+ else { newKey = key.hasPrefix("custom:") ? key : "custom:\\(key)" }+ // Keep only unique, trimmed models+ let clean = Array(Set(models.map { $0.trimmingCharacters(in: .whitespacesAndNewlines) })).sorted()+ if !clean.isEmpty { normalized[newKey] = clean }+ }+ availableModelsByProvider = normalized+ SettingsStore.shared.availableModelsByProvider = normalized++ // Normalize selectedModelByProvider keys similarly and drop invalid selections+ var normalizedSel: [String: String] = [:]+ for (key, model) in selectedModelByProvider {+ let lower = key.lowercased()+ let newKey: String = (lower == "openai" || lower == "groq") ? lower : (key.hasPrefix("custom:") ? key : "custom:\\(key)")+ if let list = normalized[newKey], list.contains(model) { normalizedSel[newKey] = model }+ }+ selectedModelByProvider = normalizedSel+ SettingsStore.shared.selectedModelByProvider = normalizedSel++ // Determine initial model list without legacy flat-list fallback+ if let saved = savedProviders.first(where: { $0.id == selectedProviderID }) {+ // Use models from saved provider+ availableModels = saved.models+ openAIBaseURL = saved.baseURL+ providerAPIKeys[currentProvider] = saved.apiKey+ } else if let stored = availableModelsByProvider[currentProvider], !stored.isEmpty {+ // Use provider-specific stored list if present+ availableModels = stored+ } else {+ // Built-in defaults+ availableModels = defaultModels(for: providerKey(for: selectedProviderID))+ }++ // Restore previously selected model if valid+ if let sel = selectedModelByProvider[currentProvider], availableModels.contains(sel) {+ selectedModel = sel+ } else if let first = availableModels.first {+ selectedModel = first+ }+NSEvent.addLocalMonitorForEvents(matching: [.keyDown, .flagsChanged]) { event inlet eventModifiers = event.modifierFlags.intersection([.function, .command, .option, .control, .shift])let shortcutModifiers = hotkeyShortcut.modifierFlags.intersection([.function, .command, .option, .control, .shift])@@ -318,6 +388,20 @@ struct ContentView: View {hotkeyManager?.reinitialize()}}+ .onChange(of: enableAIProcessing) { newValue in+ SettingsStore.shared.enableAIProcessing = newValue+ // Sync to menu bar immediately+ menuBarManager.aiProcessingEnabled = newValue+ }+ .onChange(of: selectedModel) { newValue in+ if newValue != "__ADD_MODEL__" {+ selectedModelByProvider[currentProvider] = newValue+ SettingsStore.shared.selectedModelByProvider = selectedModelByProvider+ }+ }+ .onChange(of: selectedProviderID) { newValue in+ SettingsStore.shared.selectedProviderID = newValue+ }.onReceive(NotificationCenter.default.publisher(for: NSApplication.didBecomeActiveNotification)) { _ inlet trusted = AXIsProcessTrusted()if trusted != accessibilityEnabled {@@ -391,118 +475,54 @@ struct ContentView: View {Label("Welcome", systemImage: "house.fill").font(.system(size: 15, weight: .medium))}- .listRowBackground(sidebarRowBackground)NavigationLink(value: SidebarItem.recording) {Label("Recording", systemImage: "mic.fill").font(.system(size: 15, weight: .medium))}- .listRowBackground(sidebarRowBackground)-+NavigationLink(value: SidebarItem.aiProcessing) {Label("AI Processing", systemImage: "sparkles").font(.system(size: 15, weight: .medium))}- .listRowBackground(sidebarRowBackground)-- NavigationLink(value: SidebarItem.audio) {- Label("Audio", systemImage: "speaker.wave.2.fill")- .font(.system(size: 15, weight: .medium))- }- .listRowBackground(sidebarRowBackground)NavigationLink(value: SidebarItem.settings) {Label("Settings", systemImage: "gearshape.fill").font(.system(size: 15, weight: .medium))}- .listRowBackground(sidebarRowBackground)NavigationLink(value: SidebarItem.meetingTools) {Label("Meeting Tools", systemImage: "person.2.wave.2.fill").font(.system(size: 15, weight: .medium))}- .listRowBackground(sidebarRowBackground)NavigationLink(value: SidebarItem.feedback) {Label("Feedback", systemImage: "envelope.fill").font(.system(size: 15, weight: .medium))}- .listRowBackground(sidebarRowBackground)}.listStyle(.sidebar).navigationTitle("FluidVoice")- .background(sidebarBackground).scrollContentBackground(.hidden)- }-- private var sidebarRowBackground: some View {- RoundedRectangle(cornerRadius: 8)- .fill(.ultraThinMaterial.opacity(0.8))- .background(- RoundedRectangle(cornerRadius: 8)- .fill(- LinearGradient(- colors: [- Color(red: 0.10, green: 0.12, blue: 0.20).opacity(0.3), // Deep blue tint- Color(red: 0.06, green: 0.08, blue: 0.15).opacity(0.2), // Blue-charcoal- Color(red: 0.04, green: 0.05, blue: 0.10).opacity(0.1) // Dark blue- ],- startPoint: .top,- endPoint: .bottom- )- )- )- .overlay(- RoundedRectangle(cornerRadius: 8)- .stroke(Color.white.opacity(0.25), lineWidth: 0.5)- )- }-- private var sidebarBackground: some View {- LinearGradient(- colors: [- Color(red: 0.10, green: 0.12, blue: 0.22), // Deep blue-charcoal (more blue at top)- Color(red: 0.06, green: 0.08, blue: 0.16), // Rich blue-black- Color(red: 0.04, green: 0.05, blue: 0.10), // Ultra dark blue- Color(red: 0.02, green: 0.03, blue: 0.06) // Deepest blue- ],- startPoint: .top,- endPoint: .bottom- )+ .background {+ ZStack {+ theme.palette.sidebarBackground+ Rectangle().fill(theme.materials.sidebar)+ }+ .ignoresSafeArea()+ }+ .tint(theme.palette.accent)}private var detailView: some View {ZStack {- // Tech blue gradient background- ZStack {- // Base dark blue layer- Color(red: 0.04, green: 0.05, blue: 0.09)-- // Tech blue gradient overlay- LinearGradient(- colors: [- Color(red: 0.08, green: 0.10, blue: 0.18).opacity(0.8), // Deep tech blue (more blue)- Color(red: 0.05, green: 0.07, blue: 0.14).opacity(0.6), // Rich blue-black- Color(red: 0.06, green: 0.06, blue: 0.12).opacity(0.7), // Blue-charcoal- Color(red: 0.04, green: 0.05, blue: 0.10).opacity(0.5) // Base dark blue- ],- startPoint: .topLeading,- endPoint: .bottomTrailing- )-- // Subtle radial gradient for depth- RadialGradient(- colors: [- Color.clear,- Color(red: 0.02, green: 0.03, blue: 0.06).opacity(0.3)- ],- center: .center,- startRadius: 100,- endRadius: 400- )- }- .ignoresSafeArea()-+ theme.palette.windowBackground+ .ignoresSafeArea()++ Rectangle()+ .fill(theme.materials.window)+ .ignoresSafeArea()+Group {switch selectedSidebarItem ?? .welcome {case .welcome:@@ -511,8 +531,6 @@ struct ContentView: View {recordingViewcase .aiProcessing:aiProcessingView- case .audio:- audioViewcase .settings:settingsViewcase .meetingTools:@@ -521,839 +539,185 @@ struct ContentView: View {feedbackView}}+ .transition(.opacity)}}// MARK: - Welcome Guideprivate var welcomeView: some View {- ScrollView {- VStack(alignment: .leading, spacing: 20) {- // Header- VStack(alignment: .leading, spacing: 8) {- HStack {- Image(systemName: "book.fill")- .font(.system(size: 32))- .foregroundStyle(.blue)- VStack(alignment: .leading) {- Text("Welcome to FluidVoice")- .font(.system(size: 28, weight: .bold))- Text("Your AI-powered voice transcription assistant")- .font(.system(size: 16))- .foregroundStyle(.secondary)- }+ WelcomeView(+ asr: asr,+ selectedSidebarItem: $selectedSidebarItem,+ isTranscriptionFocused: $isTranscriptionFocused,+ accessibilityEnabled: accessibilityEnabled,+ providerAPIKeys: providerAPIKeys,+ currentProvider: currentProvider,+ openAIBaseURL: openAIBaseURL,+ availableModels: availableModels,+ selectedModel: selectedModel,+ playgroundUsed: playgroundUsed,+ stopAndProcessTranscription: { await stopAndProcessTranscription() },+ startRecording: startRecording,+ isLocalEndpoint: isLocalEndpoint+ )+ }++ // MARK: - Microphone Permission View (Kept inline for RecordingView)+ private var microphonePermissionView: some View {+ 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(labelFor(status: asr.micStatus))+ .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)}- Text("Follow this quick setup to start using FluidVoice.")- .font(.system(size: 14))- .foregroundStyle(.secondary)- .padding(.top, 4)}- .padding(.bottom, 8)-- // Quick Setup Checklist- HoverableGlossyCard {- VStack(alignment: .leading, spacing: 16) {- HStack {- Image(systemName: "checkmark.circle.fill")- .foregroundStyle(.blue)- Text("Quick Setup")- .font(.headline)- }-- VStack(alignment: .leading, spacing: 12) {- SetupStepView(- step: 1,- title: "Grant Microphone Permission",- description: "Allow FluidVoice to access your microphone for voice input",- status: asr.micStatus == .authorized ? .completed : .pending,- action: {- selectedSidebarItem = .recording- }- )-- SetupStepView(- step: 2,- title: "Enable Accessibility",- description: "Grant accessibility permission to type text into other apps",- status: accessibilityEnabled ? .completed : .pending,- action: {- selectedSidebarItem = .recording- }- )-- SetupStepView(- step: 3,- title: "Set Up AI Enhancement (Optional)",- description: "Configure API keys for AI-powered text enhancement",- status: {- let hasApiKey = providerAPIKeys[currentProvider]?.isEmpty == false- let isLocal = isLocalEndpoint(openAIBaseURL.trimmingCharacters(in: .whitespacesAndNewlines))- let hasModel = availableModels.contains(selectedModel)- return ((isLocal || hasApiKey) && hasModel) ? .completed : .pending- }(),- action: {- selectedSidebarItem = .aiProcessing- }- )-- SetupStepView(- step: 4,- title: "Test Your Setup below",- description: "Try the playground below to test your complete setup",- status: playgroundUsed ? .completed : .pending,- action: {- // No action needed - playground is right below- },- showConfigureButton: false- )- }+ Spacer()++ microphoneActionButton+ }++ // Step-by-step instructions when microphone is not authorized+ if asr.micStatus != .authorized {+ microphoneInstructionsView+ }+ }+ }++ private var microphoneActionButton: some View {+ Group {+ if asr.micStatus == .notDetermined {+ Button {+ asr.requestMicAccess()+ } label: {+ HStack(spacing: 6) {+ Image(systemName: "mic.fill")+ Text("Grant Access")+ .fontWeight(.medium)}- .padding(20)}+ .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()+ }+ }+ }++ private var microphoneInstructionsView: some View {+ 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 {+ instructionStep(number: "1", text: "Click **Grant Access** above")+ instructionStep(number: "2", text: "Choose **Allow** in the system dialog")+ } else if asr.micStatus == .denied {+ instructionStep(number: "1", text: "Click **Open Settings** above")+ instructionStep(number: "2", text: "Find **FluidVoice** in the microphone list")+ instructionStep(number: "3", text: "Toggle **FluidVoice ON** to allow access")+ }+ }+ .padding(.leading, 4)+ }+ .padding(12)+ .background(theme.palette.accent.opacity(0.12))+ .cornerRadius(8)+ }++ private func instructionStep(number: String, text: String) -> some View {+ HStack(spacing: 8) {+ Text(number + ".")+ .font(.caption2)+ .foregroundStyle(theme.palette.accent)+ .fontWeight(.semibold)+ .frame(width: 16)+ Text(text)+ .font(.caption)+ .foregroundStyle(.primary)+ }+ }- // Test Playground - Right after setup checklist- HoverableGlossyCard(excludeInteractiveElements: true) {- VStack(alignment: .leading, spacing: 16) {+ // MARK: - Settings View+ private var settingsView: some View {+ SettingsView(+ asr: asr,+ appear: $appear,+ showWhatsNewSheet: $showWhatsNewSheet,+ visualizerNoiseThreshold: $visualizerNoiseThreshold,+ selectedInputUID: $selectedInputUID,+ selectedOutputUID: $selectedOutputUID,+ inputDevices: $inputDevices,+ outputDevices: $outputDevices,+ startRecording: startRecording,+ refreshDevices: refreshDevices+ )+ }++ private var recordingView: some View {+ RecordingView(+ asr: asr,+ appear: $appear,+ accessibilityEnabled: $accessibilityEnabled,+ hotkeyShortcut: $hotkeyShortcut,+ isRecordingShortcut: $isRecordingShortcut,+ hotkeyManagerInitialized: $hotkeyManagerInitialized,+ pressAndHoldModeEnabled: $pressAndHoldModeEnabled,+ enableStreamingPreview: $enableStreamingPreview,+ copyToClipboard: $copyToClipboard,+ hotkeyManager: hotkeyManager,+ menuBarManager: menuBarManager,+ stopAndProcessTranscription: { await stopAndProcessTranscription() },+ startRecording: startRecording,+ downloadModels: { await downloadModels() },+ deleteModels: { await deleteModels() },+ openAccessibilitySettings: openAccessibilitySettings,+ restartApp: restartApp,+ revealAppInFinder: revealAppInFinder,+ openApplicationsFolder: openApplicationsFolder,+ getModelStatusText: getModelStatusText,+ labelFor: labelFor+ )+ }++ // MARK: - OLD Recording View (To Remove Later)+ private var _oldRecordingView: some View {+ ScrollView(.vertical, showsIndicators: false) {+ VStack(spacing: 24) {+ // Hero Header Card+ ThemedCard(style: .standard) {+ VStack(spacing: 16) {HStack {- Image(systemName: "text.bubble")- .font(.title2)- .foregroundStyle(.white)- Text("Test Playground")- .font(.title3)- .fontWeight(.semibold)-- Spacer()-- if !asr.finalText.isEmpty {- Button(action: {- NSPasteboard.general.clearContents()- NSPasteboard.general.setString(asr.finalText, forType: .string)- }) {- HStack {- Image(systemName: "doc.on.doc")- Text("Copy")- }- }- .buttonStyle(InlineButtonStyle())- .buttonHoverEffect()- }- }-- VStack(alignment: .leading, spacing: 12) {- HStack {- VStack(alignment: .leading, spacing: 4) {- Text("Test your voice transcription here!")- .font(.subheadline)- .fontWeight(.medium)- .foregroundStyle(.secondary)-- Text("• Click 'Start Recording' or use hotkey (Right Option/Alt)")- .font(.caption)- .foregroundStyle(.secondary)-- Text("• Speak naturally - words appear in real-time")- .font(.caption)- .foregroundStyle(.secondary)-- Text("• Click 'Stop Recording' when finished")- .font(.caption)- .foregroundStyle(.secondary)- }-- Spacer()-- VStack(alignment: .trailing, spacing: 4) {- if asr.isRunning {- HStack {- Image(systemName: "waveform")- .foregroundStyle(.red)- Text("Recording...")- .font(.caption)- .foregroundStyle(.red)- }- } else if !asr.finalText.isEmpty {- Text("\(asr.finalText.count) characters")- .font(.caption)- .foregroundStyle(.secondary)- }- }- }-- // Recording Controls- HStack(spacing: 16) {- if asr.isRunning {- Button(action: {- Task {- await stopAndProcessTranscription()- }- }) {- HStack(spacing: 8) {- Image(systemName: "stop.fill")- .foregroundStyle(.red)- Text("Stop Recording")- .fontWeight(.medium)- }- .padding(.horizontal, 16)- .padding(.vertical, 8)- .background(Color.red.opacity(0.1))- .clipShape(RoundedRectangle(cornerRadius: 8))- }- } else {- Button(action: {- startRecording()- }) {- HStack(spacing: 8) {- Image(systemName: "mic.fill")- .foregroundStyle(.green)- Text("Start Recording")- .fontWeight(.medium)- }- .padding(.horizontal, 16)- .padding(.vertical, 8)- .background(Color.green.opacity(0.1))- .clipShape(RoundedRectangle(cornerRadius: 8))- }- }-- if !asr.isRunning && !asr.finalText.isEmpty {- Button("Clear Results") {- asr.finalText = ""- }- .buttonStyle(.bordered)- .controlSize(.small)- }- }-- // TRANSCRIPTION TEXT AREA - ACTUAL TEXT FIELD- VStack(alignment: .leading, spacing: 12) {- HStack {- Text("Transcription Playground")- .font(.headline)- .fontWeight(.semibold)-- Spacer()-- if !asr.finalText.isEmpty {- Text("\(asr.finalText.count) characters")- .font(.caption)- .foregroundStyle(.secondary)- }- }-- // REAL TEXT EDITOR - Can receive focus and display transcription- TextEditor(text: $asr.finalText)- .font(.system(size: 16))- .focused($isTranscriptionFocused)- .frame(height: 200)- .padding(16)- .background(- RoundedRectangle(cornerRadius: 12)- .fill(asr.isRunning ? Color.blue.opacity(0.05) : Color.gray.opacity(0.05))- .overlay(- RoundedRectangle(cornerRadius: 12)- .stroke(asr.isRunning ? Color.blue.opacity(0.3) : Color.gray.opacity(0.2), lineWidth: asr.isRunning ? 2 : 1)- )- )- .overlay(- VStack {- if asr.isRunning {- VStack(spacing: 12) {- // Animated recording indicator overlay- HStack(spacing: 8) {- Image(systemName: "waveform")- .font(.system(size: 24))- .foregroundStyle(.blue)- .scaleEffect(1.0)- .animation(.easeInOut(duration: 0.8).repeatForever(), value: asr.isRunning)-- Image(systemName: "waveform")- .font(.system(size: 20))- .foregroundStyle(.blue.opacity(0.7))- .scaleEffect(1.0)- .animation(.easeInOut(duration: 0.6).repeatForever(), value: asr.isRunning)-- Image(systemName: "waveform")- .font(.system(size: 16))- .foregroundStyle(.blue.opacity(0.5))- .scaleEffect(1.0)- .animation(.easeInOut(duration: 0.4).repeatForever(), value: asr.isRunning)- }-- VStack(spacing: 4) {- Text("Listening... Speak now!")- .font(.title3)- .fontWeight(.semibold)- .foregroundStyle(.blue)-- Text("Your words will appear here in real-time")- .font(.subheadline)- .foregroundStyle(.blue.opacity(0.8))- }- }- } else if asr.finalText.isEmpty {- VStack(spacing: 12) {- Image(systemName: "text.bubble")- .font(.system(size: 32))- .foregroundStyle(.secondary.opacity(0.6))-- VStack(spacing: 4) {- Text("Ready to test!")- .font(.title3)- .fontWeight(.semibold)- .foregroundStyle(.primary)-- Text("Click 'Start Recording' or press your hotkey")- .font(.subheadline)- .foregroundStyle(.secondary)- }- }- }- }- .allowsHitTesting(false) // Don't block text editor interaction- )-- // Quick Action Buttons- if !asr.finalText.isEmpty {- HStack(spacing: 12) {- Button(action: {- NSPasteboard.general.clearContents()- NSPasteboard.general.setString(asr.finalText, forType: .string)- }) {- HStack(spacing: 6) {- Image(systemName: "doc.on.doc")- Text("Copy Text")- }- .padding(.horizontal, 16)- .padding(.vertical, 8)- .background(Color.blue.opacity(0.1))- .foregroundStyle(.blue)- .cornerRadius(8)- }-- Button("Clear & Test Again") {- asr.finalText = ""- }- .buttonStyle(.bordered)- .controlSize(.regular)-- Spacer()- }- .padding(.top, 8)- }- }- }- }- .padding(20)- }-- // How to Use- HoverableGlossyCard {- VStack(alignment: .leading, spacing: 16) {- HStack {- Image(systemName: "play.fill")- .foregroundStyle(.green)- Text("How to Use")- .font(.headline)- }-- VStack(alignment: .leading, spacing: 16) {- InstructionStep(- number: 1,- title: "Start Recording",- description: "Use your hotkey (default: Right Option/Alt) or click the record button in the main window"- )-- InstructionStep(- number: 2,- title: "Speak Clearly",- description: "Speak your text naturally. The app works best in quiet environments"- )-- InstructionStep(- number: 3,- title: "AI Enhancement",- description: "Your speech is transcribed, then enhanced by AI for better grammar and clarity"- )-- InstructionStep(- number: 4,- title: "Auto-Type Result",- description: "The enhanced text is automatically typed into your focused application"- )- }- }- .padding(20)- }-- // API Configuration Guide- HoverableGlossyCard {- VStack(alignment: .leading, spacing: 16) {- HStack {- Image(systemName: "key.fill")- .foregroundStyle(.purple)- Text("Get API Keys")- .font(.headline)- }-- VStack(alignment: .leading, spacing: 16) {- Text("Choose your AI provider:")- .font(.subheadline)- .foregroundStyle(.secondary)-- ProviderGuide(- name: "OpenAI",- url: "https://platform.openai.com/api-keys",- description: "Most popular choice with GPT-4.1 models",- baseURL: "https://api.openai.com/v1",- keyPrefix: "sk-"- )-- ProviderGuide(- name: "Groq",- url: "https://console.groq.com/keys",- description: "Fast inference with Llama and Mixtral models",- baseURL: "https://api.groq.com/openai/v1",- keyPrefix: "gsk_"- )--- // Local Models Coming Soon- HoverableGlossyCard(excludeInteractiveElements: true) {- VStack(alignment: .leading, spacing: 8) {- HStack {- Text("Local Models")- .font(.system(size: 14, weight: .semibold))- .foregroundStyle(.secondary)-- Spacer()-- Text("Coming Soon")- .font(.system(size: 12))- .foregroundStyle(.orange)- .padding(.horizontal, 8)- .padding(.vertical, 2)- .background(Color.orange.opacity(0.1))- .cornerRadius(8)- }-- Text("Run models locally for privacy and offline use")- .font(.system(size: 13))- .foregroundStyle(.secondary)- }- .padding(12)- }- }- }- .padding(20)- }--- }- .padding(20)- }- }-- // MARK: - Getting Started Helper Views-- private struct SetupStepView: View {- let step: Int- let title: String- let description: String- let status: SetupStatus- let action: () -> Void- var showConfigureButton: Bool = true-- enum SetupStatus {- case pending, completed, inProgress- }-- var body: some View {- HStack(alignment: .top, spacing: 12) {- ZStack {- Circle()- .fill(statusColor.opacity(0.2))- .frame(width: 32, height: 32)-- if status == .completed {- Image(systemName: "checkmark")- .foregroundStyle(statusColor)- .font(.system(size: 14, weight: .bold))- } else {- Text("\(step)")- .font(.system(size: 14, weight: .semibold))- .foregroundStyle(statusColor)- }- }-- VStack(alignment: .leading, spacing: 4) {- HStack {- Text(title)- .font(.system(size: 14, weight: .semibold))-- Spacer()-- if status != .completed && showConfigureButton {- Button("Configure") {- action()- }- .font(.system(size: 12))- .buttonStyle(.bordered)- .controlSize(.small)- }- }-- Text(description)- .font(.system(size: 13))- .foregroundStyle(.secondary)- }- }- .padding(.vertical, 8)- }-- private var statusColor: Color {- switch status {- case .completed: return .green- case .inProgress: return .blue- case .pending: return .secondary- }- }- }---- private struct InstructionStep: View {- let number: Int- let title: String- let description: String-- var body: some View {- HStack(alignment: .top, spacing: 12) {- ZStack {- Circle()- .fill(Color.blue.opacity(0.2))- .frame(width: 28, height: 28)-- Text("\(number)")- .font(.system(size: 14, weight: .semibold))- .foregroundStyle(.blue)- }-- VStack(alignment: .leading, spacing: 2) {- Text(title)- .font(.system(size: 14, weight: .semibold))-- Text(description)- .font(.system(size: 13))- .foregroundStyle(.secondary)- .lineLimit(2)- }- }- }- }-- private struct ProviderGuide: View {- let name: String- let url: String- let description: String- let baseURL: String- let keyPrefix: String-- var body: some View {- HoverableGlossyCard(excludeInteractiveElements: true) {- VStack(alignment: .leading, spacing: 8) {- HStack {- Text(name)- .font(.system(size: 14, weight: .semibold))-- Spacer()-- if !url.isEmpty {- Button("Get API Key") {- if let url = URL(string: url) {- NSWorkspace.shared.open(url)- }- }- .font(.system(size: 12))- .buttonStyle(.bordered)- .controlSize(.small)- }- }-- Text(description)- .font(.system(size: 13))- .foregroundStyle(.secondary)-- VStack(alignment: .leading, spacing: 4) {- HStack {- Text("Base URL:")- .font(.system(size: 12, weight: .medium))- .foregroundStyle(.secondary)- Text(baseURL)- .font(.system(size: 12, weight: .medium))- .foregroundStyle(.primary)- .textSelection(.enabled)- }-- HStack {- Text("Key Format:")- .font(.system(size: 12, weight: .medium))- .foregroundStyle(.secondary)- Text(keyPrefix == "not-needed" ? "Not required" : "Starts with: \(keyPrefix)")- .font(.system(size: 12, weight: .medium))- .foregroundStyle(.primary)- }- }- .padding(.top, 4)- }- .padding(12)- }- }- }---- private var microphonePermissionView: some View {- VStack(alignment: .leading, spacing: 12) {- HStack(spacing: 12) {- // Status indicator- Circle()- .fill(asr.micStatus == .authorized ? .green : .red)- .frame(width: 10, height: 10)-- VStack(alignment: .leading, spacing: 4) {- Text(labelFor(status: asr.micStatus))- .fontWeight(.medium)- .foregroundStyle(asr.micStatus == .authorized ? .primary : Color.red)-- if asr.micStatus != .authorized {- Text("Microphone access is required for voice recording")- .font(.caption)- .foregroundStyle(.secondary)- }- }- Spacer()-- microphoneActionButton- }-- // Step-by-step instructions when microphone is not authorized- if asr.micStatus != .authorized {- microphoneInstructionsView- }- }- }-- private var microphoneActionButton: some View {- 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()- }- }- }-- private var microphoneInstructionsView: some View {- VStack(alignment: .leading, spacing: 8) {- HStack(spacing: 8) {- Image(systemName: "info.circle.fill")- .foregroundStyle(.blue)- .font(.caption)- Text("How to enable microphone access:")- .font(.caption)- .fontWeight(.medium)- .foregroundStyle(.secondary)- }-- VStack(alignment: .leading, spacing: 4) {- if asr.micStatus == .notDetermined {- instructionStep(number: "1", text: "Click **Grant Access** above")- instructionStep(number: "2", text: "Choose **Allow** in the system dialog")- } else if asr.micStatus == .denied {- instructionStep(number: "1", text: "Click **Open Settings** above")- instructionStep(number: "2", text: "Find **FluidVoice** in the microphone list")- instructionStep(number: "3", text: "Toggle **FluidVoice ON** to allow access")- }- }- .padding(.leading, 4)- }- .padding(12)- .background(Color.blue.opacity(0.1))- .cornerRadius(8)- }-- private func instructionStep(number: String, text: String) -> some View {- HStack(spacing: 8) {- Text(number + ".")- .font(.caption2)- .foregroundStyle(.blue)- .fontWeight(.semibold)- .frame(width: 16)- Text(text)- .font(.caption)- .foregroundStyle(.primary)- }- }-- // MARK: - Settings View- private var settingsView: some View {- ScrollView(.vertical, showsIndicators: false) {- VStack(spacing: 24) {- // Header- HoverableGlossyCard {- 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)- }-- // Settings Card- HoverableGlossyCard {- VStack(alignment: .leading, spacing: 16) {- HStack {- Image(systemName: "power")- .font(.title2)- .foregroundStyle(.white)- Text("App Settings")- .font(.title3)- .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)- }- }- .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)- }- }- .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)- }- }- .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- Button(action: {- DispatchQueue.main.async {- showWhatsNewSheet = true- }- }) {- Text("What's New")- .font(.headline)- .foregroundColor(.white)- .frame(maxWidth: .infinity)- .padding(.vertical, 10)- .background(- LinearGradient(- colors: [Color.blue.opacity(0.8), Color.blue.opacity(0.6)],- startPoint: .leading,- endPoint: .trailing- )- )- .clipShape(RoundedRectangle(cornerRadius: 8))- }- .buttonStyle(.plain)- .padding(.top, 8)- }- }- .padding(24)- }- }- .padding(24)- }- }-- private var recordingView: some View {- ScrollView(.vertical, showsIndicators: false) {- VStack(spacing: 24) {- // Hero Header Card- HoverableGlossyCard {- VStack(spacing: 16) {- HStack {- Image(systemName: "waveform.circle.fill")- .font(.system(size: 32))+ Image(systemName: "waveform.circle.fill")+ .font(.system(size: 32)).foregroundStyle(.white)VStack(alignment: .leading, spacing: 4) {@@ -1410,7 +774,7 @@ struct ContentView: View {.modifier(CardAppearAnimation(delay: 0.1, appear: $appear))// Permissions Card- HoverableGlossyCard {+ ThemedCard(style: .standard) {VStack(alignment: .leading, spacing: 16) {HStack {Image(systemName: "shield.checkered")@@ -1428,7 +792,7 @@ struct ContentView: View {.modifier(CardAppearAnimation(delay: 0.2, appear: $appear))// Model Configuration Card (disable hover transforms to avoid AppKit constraint logs)- HoverableGlossyCard(excludeInteractiveElements: true) {+ ThemedCard(hoverEffect: false) {VStack(alignment: .leading, spacing: 16) {HStack {Image(systemName: "brain.head.profile")@@ -1497,7 +861,7 @@ struct ContentView: View {} else if asr.modelsExistOnDisk {HStack(spacing: 8) {Image(systemName: "doc.fill")- .foregroundStyle(.blue)+ .foregroundStyle(theme.palette.accent)Text("Models on Disk (Not Loaded)").font(.caption).foregroundStyle(.secondary)@@ -1532,7 +896,7 @@ struct ContentView: View {Text("Download")}.font(.caption)- .foregroundStyle(.blue)+ .foregroundStyle(theme.palette.accent)}.buttonStyle(.plain).help("Download ASR models (~500MB)")@@ -1570,7 +934,7 @@ struct ContentView: View {// Global Hotkey Card- HoverableGlossyCard {+ ThemedCard(style: .standard) {VStack(alignment: .leading, spacing: 16) {HStack {Image(systemName: "keyboard")@@ -1768,16 +1132,16 @@ struct ContentView: View {HStack(spacing: 12) {// Status indicatorCircle()- .fill(.red)+ .fill(theme.palette.warning).frame(width: 10, height: 10)VStack(alignment: .leading, spacing: 4) {HStack {Image(systemName: "exclamationmark.triangle.fill")- .foregroundStyle(.orange)+ .foregroundStyle(theme.palette.warning)Text("Accessibility permissions required").fontWeight(.medium)- .foregroundStyle(Color.red)+ .foregroundStyle(theme.palette.warning)}Text("Required for global hotkey functionality").font(.caption)@@ -1796,7 +1160,7 @@ struct ContentView: View {VStack(alignment: .leading, spacing: 12) {HStack(spacing: 8) {Image(systemName: "info.circle.fill")- .foregroundStyle(.blue)+ .foregroundStyle(theme.palette.accent).font(.caption)Text("Follow these steps to enable Accessibility:").font(.caption)@@ -1808,7 +1172,7 @@ struct ContentView: View {HStack(spacing: 8) {Text("1.").font(.caption2)- .foregroundStyle(.blue)+ .foregroundStyle(theme.palette.accent).fontWeight(.semibold).frame(width: 16)Text("Click **Open Accessibility Settings** above")@@ -1818,7 +1182,7 @@ struct ContentView: View {HStack(spacing: 8) {Text("2.").font(.caption2)- .foregroundStyle(.blue)+ .foregroundStyle(theme.palette.accent).fontWeight(.semibold).frame(width: 16)Text("In the Accessibility window, click the **+ button**")@@ -1828,7 +1192,7 @@ struct ContentView: View {HStack(spacing: 8) {Text("3.").font(.caption2)- .foregroundStyle(.blue)+ .foregroundStyle(theme.palette.accent).fontWeight(.semibold).frame(width: 16)Text("Navigate to Applications and select **FluidVoice**")@@ -1838,7 +1202,7 @@ struct ContentView: View {HStack(spacing: 8) {Text("4.").font(.caption2)- .foregroundStyle(.blue)+ .foregroundStyle(theme.palette.accent).fontWeight(.semibold).frame(width: 16)Text("Click **Open**, then toggle **FluidVoice ON** in the list")@@ -1864,7 +1228,7 @@ struct ContentView: View {}}.padding(12)- .background(Color.orange.opacity(0.1))+ .background(theme.palette.warning.opacity(0.12)).cornerRadius(8)}}@@ -1874,7 +1238,7 @@ struct ContentView: View {.modifier(CardAppearAnimation(delay: 0.5, appear: $appear))// Debug Settings Card- HoverableGlossyCard {+ ThemedCard(style: .prominent) {VStack(alignment: .leading, spacing: 16) {HStack {Image(systemName: "ladybug.fill")@@ -1918,12 +1282,20 @@ struct ContentView: View {// MARK: - AI Prompts Tabprivate var aiProcessingView: some View {VStack(alignment: .leading, spacing: 20) {- // Header Section- VStack(alignment: .leading, spacing: 8) {+ aiProcessingHeader+ aiConfigurationCard++ Spacer()+ }+ .padding(20)+ }++ private var aiProcessingHeader: some View {+ VStack(alignment: .leading, spacing: 8) {HStack {Image(systemName: "sparkles").font(.title2)- .foregroundStyle(.blue)+ .foregroundStyle(theme.palette.accent)Text("AI Post-Processing").font(.title2).fontWeight(.bold)@@ -1931,7 +1303,7 @@ struct ContentView: View {Button(action: { showHelp.toggle() }) {Image(systemName: "questionmark.circle").font(.title3)- .foregroundStyle(.blue.opacity(0.7))+ .foregroundStyle(theme.palette.accent.opacity(0.7))}.buttonStyle(.plain).buttonHoverEffect()@@ -2037,264 +1409,325 @@ struct ContentView: View {}}.padding(16)- .background(Color.blue.opacity(0.05))+ .background(theme.palette.accent.opacity(0.08)).cornerRadius(12).overlay(RoundedRectangle(cornerRadius: 12)- .stroke(Color.blue.opacity(0.2), lineWidth: 1)+ .stroke(theme.palette.accent.opacity(0.2), lineWidth: 1)).transition(.opacity)}}.padding(.bottom, 8)-- // Status Overview- HoverableGlossyCard {- VStack(alignment: .leading, spacing: 12) {+ }++ private var aiConfigurationCard: some View {+ ScrollView {+ VStack(spacing: 20) {+ // API Configuration Section+ ThemedCard(style: .prominent, hoverEffect: false) {+ VStack(alignment: .leading, spacing: 18) {HStack {- Image(systemName: "info.circle.fill")+ Image(systemName: "key.fill").font(.title3)- .foregroundStyle(.blue)- Text("Setup Status")+ .foregroundStyle(theme.palette.accent)+ Text("API Configuration").font(.headline).fontWeight(.semibold)}- // Status indicators- HStack(spacing: 16) {- // API Key status (or local endpoint indicator)- HStack(spacing: 4) {- let hasApiKey = !(providerAPIKeys[currentProvider] ?? "").isEmpty- let isLocal = isLocalEndpoint(openAIBaseURL.trimmingCharacters(in: .whitespacesAndNewlines))- let isConfigured = hasApiKey || isLocal-- Image(systemName: isConfigured ? "checkmark.circle.fill" : "xmark.circle.fill")- .foregroundStyle(isConfigured ? .green : .red)- .font(.caption)- Text(isLocal ? "Local" : "API Key")- .font(.caption)- .foregroundStyle(isConfigured ? .green : .red)+ Grid(alignment: .leading, horizontalSpacing: 16, verticalSpacing: 14) {+ GridRow(alignment: .center) {+ Text("Provider:")+ .frame(width: 72, alignment: .trailing)++ HStack(spacing: 8) {+ Picker("", selection: $selectedProviderID) {+ Text("OpenAI").tag("openai")+ Text("Groq").tag("groq")++ if !savedProviders.isEmpty {+ Divider()+ ForEach(savedProviders) { provider in+ Text(provider.name).tag(provider.id)+ }+ }+ }+ .pickerStyle(.menu)+ .labelsHidden()+ .frame(width: 190, alignment: .leading)+ .onChange(of: selectedProviderID) { newValue in+ switch newValue {+ case "openai":+ openAIBaseURL = "https://api.openai.com/v1"+ updateCurrentProvider()+ let key = "openai"+ if let stored = availableModelsByProvider[key], !stored.isEmpty { availableModels = stored }+ else { availableModels = defaultModels(for: key) }+ if let sel = selectedModelByProvider[key], availableModels.contains(sel) { selectedModel = sel }+ else { selectedModel = availableModels.first ?? selectedModel }+ case "groq":+ openAIBaseURL = "https://api.groq.com/openai/v1"+ updateCurrentProvider()+ let key = "groq"+ if let stored = availableModelsByProvider[key], !stored.isEmpty { availableModels = stored }+ else { availableModels = defaultModels(for: key) }+ if let sel = selectedModelByProvider[key], availableModels.contains(sel) { selectedModel = sel }+ else { selectedModel = availableModels.first ?? selectedModel }+ default:+ if let provider = savedProviders.first(where: { $0.id == newValue }) {+ openAIBaseURL = provider.baseURL+ updateCurrentProvider()+ providerAPIKeys[currentProvider] = provider.apiKey+ saveProviderAPIKeys()+ let key = providerKey(for: newValue)+ availableModels = provider.models.isEmpty ? (availableModelsByProvider[key] ?? defaultModels(for: key)) : provider.models+ if let sel = selectedModelByProvider[key], availableModels.contains(sel) { selectedModel = sel }+ else { selectedModel = availableModels.first ?? selectedModel }+ }+ }}- // Connection status- HStack(spacing: 4) {- Image(systemName: connectionStatus == .success ? "checkmark.circle.fill" : "circle")- .foregroundStyle(connectionStatus == .success ? .green : .secondary)- .font(.caption)- Text("Connection")- .font(.caption)- .foregroundStyle(connectionStatus == .success ? .green : .secondary)+ if !selectedProviderID.isEmpty && selectedProviderID != "openai" && selectedProviderID != "groq" {+ Button(action: {+ savedProviders.removeAll { $0.id == selectedProviderID }+ saveSavedProviders()+ let key = providerKey(for: selectedProviderID)+ availableModelsByProvider.removeValue(forKey: key)+ selectedModelByProvider.removeValue(forKey: key)+ providerAPIKeys.removeValue(forKey: key)+ saveProviderAPIKeys()+ SettingsStore.shared.availableModelsByProvider = availableModelsByProvider+ SettingsStore.shared.selectedModelByProvider = selectedModelByProvider+ selectedProviderID = "openai"+ openAIBaseURL = "https://api.openai.com/v1"+ updateCurrentProvider()+ availableModels = defaultModels(for: "openai")+ selectedModel = availableModels.first ?? selectedModel+ }) {+ Image(systemName: "trash")+ .foregroundStyle(.red)+ .font(.caption)+ }+ .buttonStyle(.plain)+ .help("Delete this provider")}+ }- // Model status- HStack(spacing: 4) {- Image(systemName: availableModels.contains(selectedModel) ? "checkmark.circle.fill" : "circle")- .foregroundStyle(availableModels.contains(selectedModel) ? .green : .secondary)+ Button("+ Add Provider") {+ showingSaveProvider = true+ newProviderName = ""+ newProviderBaseURL = ""+ newProviderApiKey = ""+ newProviderModels = ""+ }+ .buttonStyle(CompactButtonStyle())+ .buttonHoverEffect()+ }++ GridRow(alignment: .center) {+ Text("Model:")+ .frame(width: 72, alignment: .trailing)++ HStack(spacing: 8) {+ Menu {+ ForEach(availableModels, id: \.self) { model in+ Button(action: {+ selectedModel = model+ }) {+ HStack {+ Text(model)+ Spacer()+ if selectedModel == model {+ Image(systemName: "checkmark")+ .foregroundStyle(theme.palette.accent)+ }+ }+ }+ }++ Divider()++ Button("Add Model...") {+ showingAddModel = true+ newModelName = ""+ }+ } label: {+ HStack(spacing: 8) {+ Text(selectedModel)+ .lineLimit(1)+ Spacer(minLength: 4)+ Image(systemName: "chevron.down")+ .font(.caption)+ .foregroundStyle(.secondary)+ }+ .padding(.horizontal, 8)+ .padding(.vertical, 4)+ .background(.quaternary)+ .cornerRadius(6)+ }+ .menuStyle(.borderlessButton)+ .frame(width: 240)++ if availableModels.isEmpty {+ Image(systemName: "exclamationmark.triangle.fill")+ .foregroundStyle(.orange).font(.caption)- Text("Model")+ } else if availableModels.contains(selectedModel) {+ Image(systemName: "checkmark.circle.fill")+ .foregroundStyle(.green).font(.caption)- .foregroundStyle(availableModels.contains(selectedModel) ? .green : .secondary)}}++ EmptyView()}- .padding(16)- }- .modifier(CardAppearAnimation(delay: 0.05, appear: $appear))- // API Configuration Section- HoverableGlossyCard {- VStack(alignment: .leading, spacing: 16) {- HStack {- Image(systemName: "key.fill")- .font(.title3)- .foregroundStyle(.blue)- Text("API Configuration")- .font(.headline)- .fontWeight(.semibold)- }+ if !["openai", "groq"].contains(selectedProviderID) {+ GridRow(alignment: .center) {+ Text("Base URL:")+ .frame(width: 72, alignment: .trailing)- // Saved Providers Dropdown- // Provider Selection- HStack(spacing: 8) {- Text("Provider:")- Picker("Provider", selection: $selectedProviderID) {- // Built-in providers- Text("OpenAI").tag("openai")- Text("Groq").tag("groq")-- if !savedProviders.isEmpty {- Divider()- ForEach(savedProviders) { provider in- Text(provider.name).tag(provider.id)- }+ TextField("e.g., http://localhost:11434/v1", text: $openAIBaseURL)+ .textFieldStyle(.roundedBorder)+ .font(.system(.body, design: .monospaced))+ .frame(maxWidth: 380)+ .onChange(of: openAIBaseURL) { _ in+ updateCurrentProvider()+ }++ EmptyView()}}- .pickerStyle(.menu)- .frame(width: 180, alignment: .leading)- .layoutPriority(1)- .onChange(of: selectedProviderID) { newValue in- switch newValue {- case "openai":- openAIBaseURL = "https://api.openai.com/v1"- updateCurrentProvider()- let key = "openai"- if let stored = availableModelsByProvider[key], !stored.isEmpty { availableModels = stored }- else { availableModels = defaultModels(for: key) }- if let sel = selectedModelByProvider[key], availableModels.contains(sel) { selectedModel = sel }- else { selectedModel = availableModels.first ?? selectedModel }- case "groq":- openAIBaseURL = "https://api.groq.com/openai/v1"- updateCurrentProvider()- let key = "groq"- if let stored = availableModelsByProvider[key], !stored.isEmpty { availableModels = stored }- else { availableModels = defaultModels(for: key) }- if let sel = selectedModelByProvider[key], availableModels.contains(sel) { selectedModel = sel }- else { selectedModel = availableModels.first ?? selectedModel }- default:- if let provider = savedProviders.first(where: { $0.id == newValue }) {- openAIBaseURL = provider.baseURL- updateCurrentProvider()- // Load the saved API key for this provider- providerAPIKeys[currentProvider] = provider.apiKey- saveProviderAPIKeys()- // Load provider-specific models- let key = providerKey(for: newValue)- availableModels = provider.models.isEmpty ? (availableModelsByProvider[key] ?? defaultModels(for: key)) : provider.models- if let sel = selectedModelByProvider[key], availableModels.contains(sel) { selectedModel = sel }- else { selectedModel = availableModels.first ?? selectedModel }++ if showingAddModel {+ GridRow(alignment: .center) {+ Color.clear+ .frame(width: 72)++ HStack(spacing: 8) {+ TextField("Enter model name (e.g., gpt-4.1-nano)", text: $newModelName)+ .textFieldStyle(.roundedBorder)+ .frame(maxWidth: 320)++ Button("Add") {+ if !newModelName.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines).isEmpty {+ let modelName = newModelName.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)+ let key = providerKey(for: selectedProviderID)+ var list = availableModelsByProvider[key] ?? availableModels+ if !list.contains(modelName) { list.append(modelName) }+ availableModelsByProvider[key] = list+ SettingsStore.shared.availableModelsByProvider = availableModelsByProvider++ if let providerIndex = savedProviders.firstIndex(where: { $0.id == selectedProviderID }) {+ let updatedProvider = SettingsStore.SavedProvider(+ id: savedProviders[providerIndex].id,+ name: savedProviders[providerIndex].name,+ baseURL: savedProviders[providerIndex].baseURL,+ apiKey: savedProviders[providerIndex].apiKey,+ models: list+ )+ savedProviders[providerIndex] = updatedProvider+ saveSavedProviders()+ }++ availableModels = list+ selectedModel = modelName+ selectedModelByProvider[key] = modelName+ SettingsStore.shared.selectedModelByProvider = selectedModelByProvider+ showingAddModel = false+ newModelName = ""+ }+ }+ .buttonStyle(CompactButtonStyle())+ .buttonHoverEffect()+ .disabled(newModelName.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines).isEmpty)++ Button("Cancel") {+ showingAddModel = false+ newModelName = ""+ }+ .buttonStyle(CompactButtonStyle())+ .buttonHoverEffect()}- }- }-- Spacer()-- Button("+ Add Provider") {- showingSaveProvider = true- newProviderName = ""- newProviderBaseURL = ""- newProviderApiKey = ""- newProviderModels = ""- }- .buttonStyle(GlassButtonStyle())- .buttonHoverEffect()- }- // Delete button for custom providers - positioned near model catalogs- HStack(spacing: 8) {- // Delete button for custom providers- if !selectedProviderID.isEmpty && selectedProviderID != "openai" && selectedProviderID != "groq" {- Button(action: {- // Remove the provider- savedProviders.removeAll { $0.id == selectedProviderID }- saveSavedProviders()-- // Remove associated data- let key = providerKey(for: selectedProviderID)- availableModelsByProvider.removeValue(forKey: key)- selectedModelByProvider.removeValue(forKey: key)- providerAPIKeys.removeValue(forKey: key)- saveProviderAPIKeys()- SettingsStore.shared.availableModelsByProvider = availableModelsByProvider- SettingsStore.shared.selectedModelByProvider = selectedModelByProvider-- // Switch to OpenAI if we just deleted the current provider- selectedProviderID = "openai"- openAIBaseURL = "https://api.openai.com/v1"- updateCurrentProvider()- availableModels = defaultModels(for: "openai")- selectedModel = availableModels.first ?? selectedModel- }) {- Image(systemName: "trash")- .foregroundStyle(.red)- .font(.caption)+ EmptyView()}- .buttonStyle(.plain)- .help("Delete this provider")+ .transition(.opacity)}-- Spacer()}+ Divider()+ .padding(.vertical, 4)++ // API Key Management+ Button(action: {+ newProviderApiKey = providerAPIKeys[currentProvider] ?? ""+ showAPIKeyEditor = true+ }) {+ Label("Add or Modify API Key", systemImage: "key.fill")+ .labelStyle(.titleAndIcon)+ .font(.caption)+ }+ .buttonStyle(GlassButtonStyle())+ .buttonHoverEffect()+// Provider model catalogs quick linksHStack(spacing: 6) {Image(systemName: "link")- .font(.caption)- .foregroundStyle(.secondary)+ .font(.caption2)+ .foregroundStyle(.tertiary)Text("Model catalogs:")- .font(.caption)- .foregroundStyle(.secondary)+ .font(.caption2)+ .foregroundStyle(.tertiary)if selectedProviderID == "openai" {Link("OpenAI", destination: URL(string: "https://platform.openai.com/docs/models")!)- .font(.caption)- Text("·").font(.caption).foregroundStyle(.secondary)+ .font(.caption2)+ Text("·").font(.caption2).foregroundStyle(.tertiary)Link("Groq", destination: URL(string: "https://console.groq.com/docs/models")!)- .font(.caption)+ .font(.caption2).foregroundStyle(.secondary)} else if selectedProviderID == "groq" {Link("Groq", destination: URL(string: "https://console.groq.com/docs/models")!)- .font(.caption)- Text("·").font(.caption).foregroundStyle(.secondary)+ .font(.caption2)+ Text("·").font(.caption2).foregroundStyle(.tertiary)Link("OpenAI", destination: URL(string: "https://platform.openai.com/docs/models")!)- .font(.caption)+ .font(.caption2).foregroundStyle(.secondary)} else {Link("OpenAI", destination: URL(string: "https://platform.openai.com/docs/models")!)- .font(.caption)- Text("·").font(.caption).foregroundStyle(.secondary)+ .font(.caption2)+ Text("·").font(.caption2).foregroundStyle(.tertiary)Link("Groq", destination: URL(string: "https://console.groq.com/docs/models")!)- .font(.caption)+ .font(.caption2)}}- .padding(.top, 2)-- HStack(spacing: 8) {- Button(action: {- newProviderApiKey = providerAPIKeys[currentProvider] ?? ""- showAPIKeyEditor = true- }) {- Label("Add or Modify API Key", systemImage: "key.fill")- .labelStyle(.titleAndIcon)- .font(.caption)- }- .buttonStyle(GlassButtonStyle())- .buttonHoverEffect()-+ // Connection Test+ HStack(spacing: 12) {+ Label("Verify connection", systemImage: "network")+ .font(.caption)+ .foregroundStyle(.secondary)- Spacer(minLength: 8)+ Spacer(minLength: 12)- // Connection Test ButtonButton(action: {DebugLogger.shared.info("=== TEST CONNECTION BUTTON PRESSED ===", source: "ContentView")Task { await testAPIConnection() }}) {- HStack(spacing: 4) {- if isTestingConnection {- ProgressView()- .frame(width: 12, height: 12)- } else {- Image(systemName: "network")- .font(.caption)- }- Text(isTestingConnection ? "Testing..." : "Test")- .font(.caption)- }- .foregroundStyle(.blue)- .padding(.horizontal, 8)- .padding(.vertical, 4)- .background(Color.blue.opacity(0.1))- .clipShape(RoundedRectangle(cornerRadius: 6))+ Text(isTestingConnection ? "Verifying..." : "Verify")+ .font(.caption)+ .fontWeight(.semibold)+ .padding(.horizontal, 10)+ .padding(.vertical, 6)+ .frame(minWidth: 68)}- .buttonStyle(.plain)- .disabled(isTestingConnection ||- (!isLocalEndpoint(openAIBaseURL.trimmingCharacters(in: .whitespacesAndNewlines)) &&- (providerAPIKeys[currentProvider] ?? "").isEmpty))+ .buttonStyle(CompactButtonStyle()).buttonHoverEffect()-- Text("(\(currentProvider.capitalized))")- .font(.caption)- .foregroundColor(.secondary)+ .disabled(isTestingConnection ||+ (!isLocalEndpoint(openAIBaseURL.trimmingCharacters(in: .whitespacesAndNewlines)) &&+ (providerAPIKeys[currentProvider] ?? "").isEmpty))}.sheet(isPresented: $showAPIKeyEditor) {@@ -2332,70 +1765,55 @@ struct ContentView: View {.frame(minWidth: 350, minHeight: 150)}- // Connection Status Display- HStack(spacing: 8) {- // Real-time validation indicator- // Only show API key warning for non-local endpoints- if (providerAPIKeys[currentProvider] ?? "").isEmpty &&- !isLocalEndpoint(openAIBaseURL.trimmingCharacters(in: .whitespacesAndNewlines)) {- Image(systemName: "exclamationmark.triangle.fill")- .foregroundStyle(.orange)- .font(.caption)- Text("API key required")- .font(.caption)- .foregroundStyle(.orange)- } else if connectionStatus == .success {- Image(systemName: "checkmark.circle.fill")- .foregroundStyle(.green)- .font(.caption)- Text("Ready to test")- .font(.caption)- .foregroundStyle(.green)- } else if connectionStatus == .failed {- Image(systemName: "exclamationmark.circle.fill")- .foregroundStyle(.red)- .font(.caption)- VStack(alignment: .leading, spacing: 2) {- Text("Connection failed")+ // Connection Status Display (only shown when there's something to show)+ if (providerAPIKeys[currentProvider] ?? "").isEmpty &&+ !isLocalEndpoint(openAIBaseURL.trimmingCharacters(in: .whitespacesAndNewlines)) ||+ connectionStatus == .success ||+ connectionStatus == .failed ||+ connectionStatus == .testing {+ HStack(spacing: 8) {+ // Only show API key warning for non-local endpoints+ if (providerAPIKeys[currentProvider] ?? "").isEmpty &&+ !isLocalEndpoint(openAIBaseURL.trimmingCharacters(in: .whitespacesAndNewlines)) {+ Image(systemName: "exclamationmark.triangle.fill")+ .foregroundStyle(.orange)+ .font(.caption)+ Text("API key required")+ .font(.caption)+ .foregroundStyle(.orange)+ } else if connectionStatus == .success {+ Image(systemName: "checkmark.circle.fill")+ .foregroundStyle(.green).font(.caption)+ Text("Connection verified")+ .font(.caption)+ .foregroundStyle(.green)+ } else if connectionStatus == .failed {+ Image(systemName: "exclamationmark.circle.fill").foregroundStyle(.red)- if !connectionErrorMessage.isEmpty {- Text(connectionErrorMessage)- .font(.caption2)- .foregroundStyle(.red.opacity(0.8))- .lineLimit(1)+ .font(.caption)+ VStack(alignment: .leading, spacing: 2) {+ Text("Connection failed")+ .font(.caption)+ .foregroundStyle(.red)+ if !connectionErrorMessage.isEmpty {+ Text(connectionErrorMessage)+ .font(.caption2)+ .foregroundStyle(.red.opacity(0.8))+ .lineLimit(1)+ }}+ } else if connectionStatus == .testing {+ ProgressView()+ .frame(width: 16, height: 16)+ Text("Verifying...")+ .font(.caption)+ .foregroundStyle(theme.palette.accent)}- } else if connectionStatus == .testing {- ProgressView()- .frame(width: 16, height: 16)- Text("Testing...")- .font(.caption)- .foregroundStyle(.blue)- } else {- Image(systemName: "network")- .foregroundStyle(.secondary)- .font(.caption)- Text("Test connection to verify setup")- .font(.caption)- .foregroundStyle(.secondary)- }-- Spacer()- }- .padding(.top, 6)- // Show Base URL only for custom providers (not built-in ones)- if !["openai", "groq"].contains(selectedProviderID) {- HStack(spacing: 8) {- TextField("Base URL (e.g., http://localhost:11434/v1)", text: $openAIBaseURL)- .textFieldStyle(.roundedBorder)- .frame(width: 350)- .layoutPriority(1)- .onChange(of: openAIBaseURL) { _ in- updateCurrentProvider()- }+ Spacer()}+ .padding(.top, 6)}// Add Provider Modal@@ -2479,292 +1897,26 @@ struct ContentView: View {// Name and URL are always required// API key is only required for non-local endpoints- return nameEmpty || urlEmpty || (!isLocal && apiKeyEmpty)- }())-- Button("Cancel") {- showingSaveProvider = false- newProviderName = ""; newProviderBaseURL = ""; newProviderApiKey = ""; newProviderModels = ""- }- .buttonStyle(GlassButtonStyle())- .buttonHoverEffect()- }- }- .transition(.opacity)- }-- }- .padding(20)- }- .modifier(CardAppearAnimation(delay: 0.1, appear: $appear))-- // Model Configuration Section- HoverableGlossyCard {- VStack(alignment: .leading, spacing: 16) {- HStack {- Image(systemName: "brain.head.profile")- .font(.title3)- .foregroundStyle(.purple)- Text("Model Configuration")- .font(.headline)- .fontWeight(.semibold)- }-- // Model Selection with Validation- HStack(spacing: 8) {- HStack(spacing: 4) {- Text("Model:")- if availableModels.isEmpty {- Image(systemName: "exclamationmark.triangle.fill")- .foregroundStyle(.orange)- .font(.caption)- } else if !availableModels.isEmpty && availableModels.contains(selectedModel) {- Image(systemName: "checkmark.circle.fill")- .foregroundStyle(.green)- .font(.caption)- }- }- Menu {- ForEach(availableModels, id: \.self) { model in- Button(action: {- selectedModel = model- }) {- HStack {- Text(model)- Spacer()- if selectedModel == model {- Image(systemName: "checkmark")- .foregroundStyle(.blue)- }- }- }- }-- Divider()-- Button("Add Model...") {- showingAddModel = true- newModelName = ""- }- } label: {- HStack {- Text(selectedModel)- Spacer()- Image(systemName: "chevron.down")- .font(.caption)- .foregroundStyle(.secondary)- }- .padding(.horizontal, 8)- .padding(.vertical, 4)- .background(.quaternary)- .cornerRadius(6)- }- .frame(width: 220, alignment: .leading)- .layoutPriority(1)- }-- // Add Model Input (shown when plus button is clicked)- if showingAddModel {- HStack(spacing: 8) {- TextField("Enter model name (e.g., gpt-4.1-nano)", text: $newModelName)- .textFieldStyle(.roundedBorder)- .frame(width: 250)- .layoutPriority(1)-- Button("Add") {- if !newModelName.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines).isEmpty {- let modelName = newModelName.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)- // Append to current provider's list only- let key = providerKey(for: selectedProviderID)- var list = availableModelsByProvider[key] ?? availableModels- if !list.contains(modelName) { list.append(modelName) }- availableModelsByProvider[key] = list- SettingsStore.shared.availableModelsByProvider = availableModelsByProvider-- // If this is a saved custom provider, update its models array too- if let providerIndex = savedProviders.firstIndex(where: { $0.id == selectedProviderID }) {- let updatedProvider = SettingsStore.SavedProvider(- id: savedProviders[providerIndex].id,- name: savedProviders[providerIndex].name,- baseURL: savedProviders[providerIndex].baseURL,- apiKey: savedProviders[providerIndex].apiKey,- models: list- )- savedProviders[providerIndex] = updatedProvider- saveSavedProviders()- }-- // Reflect in UI list- availableModels = list- selectedModel = modelName- selectedModelByProvider[key] = modelName- SettingsStore.shared.selectedModelByProvider = selectedModelByProvider- showingAddModel = false- newModelName = ""- }- }- .buttonStyle(GlassButtonStyle())- .buttonHoverEffect()- .buttonHoverEffect()- .disabled(newModelName.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines).isEmpty)-- Button("Cancel") {- showingAddModel = false- newModelName = ""- }- .buttonStyle(GlassButtonStyle())- .buttonHoverEffect()- .buttonHoverEffect()- }- .transition(.opacity)- }-- // Manage Models List- VStack(alignment: .leading, spacing: 8) {- Text("Models for this provider")- .font(.caption)- .foregroundStyle(.secondary)-- ForEach(availableModels, id: \.self) { model in- HStack {- Text(model)- Spacer()- if isCustomModel(model) {- Button(action: { removeModel(model) }) {- Image(systemName: "xmark.circle.fill")- .foregroundStyle(.red)- }- .buttonStyle(.plain)- } else {- Image(systemName: "lock.fill")- .foregroundStyle(.secondary)- }- }- .padding(.vertical, 4)- }-- HStack {- Button("Reset to defaults") {- // Clear stored list for this provider and show defaults- availableModelsByProvider[currentProvider] = []- SettingsStore.shared.availableModelsByProvider = availableModelsByProvider- availableModels = defaultModels(for: providerKey(for: selectedProviderID))- selectedModel = availableModels.first ?? selectedModel- selectedModelByProvider[currentProvider] = selectedModel- SettingsStore.shared.selectedModelByProvider = selectedModelByProvider-- // If this is a saved custom provider, reset its models array too- if let providerIndex = savedProviders.firstIndex(where: { $0.id == selectedProviderID }) {- let updatedProvider = SettingsStore.SavedProvider(- id: savedProviders[providerIndex].id,- name: savedProviders[providerIndex].name,- baseURL: savedProviders[providerIndex].baseURL,- apiKey: savedProviders[providerIndex].apiKey,- models: availableModels- )- savedProviders[providerIndex] = updatedProvider- saveSavedProviders()- }- }- .buttonStyle(GlassButtonStyle())- .buttonHoverEffect()- }- }-- }- .padding(20)- }- .modifier(CardAppearAnimation(delay: 0.2, appear: $appear))---- Spacer()- }- .padding(20)- .onAppear {- // Load saved provider ID first- selectedProviderID = SettingsStore.shared.selectedProviderID-- // Establish provider context first- updateCurrentProvider()-- enableAIProcessing = SettingsStore.shared.enableAIProcessing- enableDebugLogs = SettingsStore.shared.enableDebugLogs- availableModelsByProvider = SettingsStore.shared.availableModelsByProvider- selectedModelByProvider = SettingsStore.shared.selectedModelByProvider- providerAPIKeys = SettingsStore.shared.providerAPIKeys- savedProviders = SettingsStore.shared.savedProviders-- // Migration & cleanup: normalize provider keys and drop legacy flat lists- var normalized: [String: [String]] = [:]- for (key, models) in availableModelsByProvider {- let lower = key.lowercased()- let newKey: String- if lower == "openai" || lower == "groq" { newKey = lower }- else { newKey = key.hasPrefix("custom:") ? key : "custom:\\(key)" }- // Keep only unique, trimmed models- let clean = Array(Set(models.map { $0.trimmingCharacters(in: .whitespacesAndNewlines) })).sorted()- if !clean.isEmpty { normalized[newKey] = clean }- }- availableModelsByProvider = normalized- SettingsStore.shared.availableModelsByProvider = normalized-- // Normalize selectedModelByProvider keys similarly and drop invalid selections- var normalizedSel: [String: String] = [:]- for (key, model) in selectedModelByProvider {- let lower = key.lowercased()- let newKey: String = (lower == "openai" || lower == "groq") ? lower : (key.hasPrefix("custom:") ? key : "custom:\\(key)")- if let list = normalized[newKey], list.contains(model) { normalizedSel[newKey] = model }- }- selectedModelByProvider = normalizedSel- SettingsStore.shared.selectedModelByProvider = normalizedSel-- // Determine initial model list without legacy flat-list fallback- if let saved = savedProviders.first(where: { $0.id == selectedProviderID }) {- // Use models from saved provider- availableModels = saved.models- openAIBaseURL = saved.baseURL- providerAPIKeys[currentProvider] = saved.apiKey- } else if let stored = availableModelsByProvider[currentProvider], !stored.isEmpty {- // Use provider-specific stored list if present- availableModels = stored- } else {- // Built-in defaults- availableModels = defaultModels(for: providerKey(for: selectedProviderID))- }+ return nameEmpty || urlEmpty || (!isLocal && apiKeyEmpty)+ }())- // Restore previously selected model if valid- if let sel = selectedModelByProvider[currentProvider], availableModels.contains(sel) {- selectedModel = sel- } else if let first = availableModels.first {- selectedModel = first- }- }- .onChange(of: asr.isRunning) { newValue in- // Mark playground as used when user starts recording- if newValue && !playgroundUsed {- playgroundUsed = true+ Button("Cancel") {+ showingSaveProvider = false+ newProviderName = ""; newProviderBaseURL = ""; newProviderApiKey = ""; newProviderModels = ""+ }+ .buttonStyle(GlassButtonStyle())+ .buttonHoverEffect()+ }+ }+ .transition(.opacity)}- }- .onChange(of: asr.finalText) { newValue in- // Also mark as used when text appears in playground- if !newValue.isEmpty && !playgroundUsed {- playgroundUsed = true++ }+ .padding(20)}- }- .onChange(of: enableAIProcessing) { newValue in- SettingsStore.shared.enableAIProcessing = newValue- // Sync to menu bar immediately- menuBarManager.aiProcessingEnabled = newValue- }- .onChange(of: selectedModel) { newValue in- if newValue != "__ADD_MODEL__" {- selectedModelByProvider[currentProvider] = newValue- SettingsStore.shared.selectedModelByProvider = selectedModelByProvider+ .modifier(CardAppearAnimation(delay: 0.1, appear: $appear))}- }- .onChange(of: selectedProviderID) { newValue in- SettingsStore.shared.selectedProviderID = newValue+ .padding()}}@@ -2783,7 +1935,7 @@ struct ContentView: View {HStack {Image(systemName: "envelope.fill").font(.system(size: 32))- .foregroundStyle(.blue)+ .foregroundStyle(theme.palette.accent)VStack(alignment: .leading) {Text("Send Feedback").font(.system(size: 28, weight: .bold))@@ -2796,7 +1948,7 @@ struct ContentView: View {.padding(.bottom, 8)// Feedback Form- HoverableGlossyCard {+ ThemedCard(style: .standard, hoverEffect: false) {VStack(alignment: .leading, spacing: 16) {VStack(alignment: .leading, spacing: 12) {Text("Email")@@ -2818,10 +1970,10 @@ struct ContentView: View {.padding(12).background(RoundedRectangle(cornerRadius: 8)- .fill(Color.gray.opacity(0.1))+ .fill(theme.palette.cardBackground.opacity(0.6)).overlay(RoundedRectangle(cornerRadius: 8)- .stroke(Color.gray.opacity(0.3), lineWidth: 1)+ .stroke(theme.palette.cardBorder.opacity(0.35), lineWidth: 1))).overlay(@@ -2882,110 +2034,7 @@ struct ContentView: View {}}- // MARK: - Audio Tab- private var audioView: some View- {- VStack(alignment: .leading, spacing: 16) {- HStack {- Text("Input Device")- Spacer()- Picker("Input Device", selection: $selectedInputUID) {- ForEach(inputDevices, id: \.uid) { dev in- Text(dev.name).tag(dev.uid)- }- }- .frame(width: 280)- .onChange(of: selectedInputUID) { newUID in- SettingsStore.shared.preferredInputDeviceUID = newUID- _ = AudioDevice.setDefaultInputDevice(uid: newUID)- if asr.isRunning {- asr.stopWithoutTranscription()- startRecording()- }- }- }-- HStack {- Text("Output Device")- Spacer()- Picker("Output Device", selection: $selectedOutputUID) {- ForEach(outputDevices, id: \.uid) { dev in- Text(dev.name).tag(dev.uid)- }- }- .frame(width: 280)- .onChange(of: selectedOutputUID) { newUID in- SettingsStore.shared.preferredOutputDeviceUID = newUID- _ = AudioDevice.setDefaultOutputDevice(uid: newUID)- }- }-- HStack(spacing: 12) {- Button {- refreshDevices()- } label: {- Label("Refresh", systemImage: "arrow.clockwise")- }-- if let defIn = AudioDevice.getDefaultInputDevice()?.name, let defOut = AudioDevice.getDefaultOutputDevice()?.name {- Text("Default In: \(defIn) · Default Out: \(defOut)")- .font(.caption)- .foregroundColor(.secondary)- }- }-- // Visualization Sensitivity Section- VStack(alignment: .leading, spacing: 16) {- HStack {- VStack(alignment: .leading, spacing: 4) {- Text("Visualization Sensitivity")- .font(.system(size: 16, weight: .semibold))- Text("Control how sensitive the audio visualizer is to sound input")- .font(.system(size: 13))- .foregroundColor(.secondary)- }-- Spacer()-- Button("Reset") {- visualizerNoiseThreshold = 0.4- SettingsStore.shared.visualizerNoiseThreshold = visualizerNoiseThreshold- }- .font(.system(size: 12))- }-- HStack(spacing: 12) {- Text("More Sensitive")- .font(.system(size: 12, weight: .medium))- .foregroundColor(.secondary)- .frame(width: 70)-- Slider(value: $visualizerNoiseThreshold, in: 0.01...0.8, step: 0.01)- .controlSize(.regular)-- Text("Less Sensitive")- .font(.system(size: 12, weight: .medium))- .foregroundColor(.secondary)- .frame(width: 70)-- Text(String(format: "%.2f", visualizerNoiseThreshold))- .font(.system(size: 12, weight: .medium, design: .monospaced))- .foregroundColor(.primary)- .frame(width: 40)- }- }- .padding(20)-- // Removed Debug Settings section-- Spacer()- }- .padding(20)- .onAppear { refreshDevices() }- .onChange(of: visualizerNoiseThreshold) { newValue in- SettingsStore.shared.visualizerNoiseThreshold = newValue- }- }+ // Audio settings merged into SettingsViewprivate func refreshDevices(){@@ -3860,486 +2909,9 @@ struct ContentView: View {// Deprecated: hotkey persistence is handled via SettingsStore}-private enum SidebarItem: Hashable {- case welcome- case recording- case aiProcessing- case audio- case settings- case meetingTools- case feedback-}--// MARK: - Embedded CoreAudio Device Manager-enum AudioDevice-{- struct Device: Identifiable, Hashable- {- let id: AudioObjectID- let uid: String- let name: String- let hasInput: Bool- let hasOutput: Bool- }-- static func listAllDevices() -> [Device]- {- var address = AudioObjectPropertyAddress(- mSelector: kAudioHardwarePropertyDevices,- mScope: kAudioObjectPropertyScopeGlobal,- mElement: kAudioObjectPropertyElementMain- )-- var dataSize: UInt32 = 0- var status = AudioObjectGetPropertyDataSize(AudioObjectID(kAudioObjectSystemObject), &address, 0, nil, &dataSize)- if status != noErr || dataSize == 0- {- return []- }-- let count = Int(dataSize) / MemoryLayout<AudioObjectID>.size- var deviceIDs = [AudioObjectID](repeating: 0, count: count)- status = AudioObjectGetPropertyData(AudioObjectID(kAudioObjectSystemObject), &address, 0, nil, &dataSize, &deviceIDs)- if status != noErr- {- return []- }-- var devices: [Device] = []- devices.reserveCapacity(deviceIDs.count)-- for devId in deviceIDs- {- let name = getStringProperty(devId, selector: kAudioObjectPropertyName, scope: kAudioObjectPropertyScopeGlobal) ?? "Unknown"- let uid = getStringProperty(devId, selector: kAudioDevicePropertyDeviceUID, scope: kAudioObjectPropertyScopeGlobal) ?? ""- let hasIn = hasChannels(devId, scope: kAudioObjectPropertyScopeInput)- let hasOut = hasChannels(devId, scope: kAudioObjectPropertyScopeOutput)- devices.append(Device(id: devId, uid: uid, name: name, hasInput: hasIn, hasOutput: hasOut))- }-- return devices.sorted { $0.name.localizedCaseInsensitiveCompare($1.name) == .orderedAscending }- }-- static func listInputDevices() -> [Device]- {- return listAllDevices().filter { $0.hasInput }- }-- static func listOutputDevices() -> [Device]- {- return listAllDevices().filter { $0.hasOutput }- }-- static func getDefaultInputDevice() -> Device?- {- guard let devId: AudioObjectID = getDefaultDeviceId(selector: kAudioHardwarePropertyDefaultInputDevice) else { return nil }- return listAllDevices().first { $0.id == devId }- }-- static func getDefaultOutputDevice() -> Device?- {- guard let devId: AudioObjectID = getDefaultDeviceId(selector: kAudioHardwarePropertyDefaultOutputDevice) else { return nil }- return listAllDevices().first { $0.id == devId }- }-- @discardableResult- static func setDefaultInputDevice(uid: String) -> Bool- {- guard let device = listInputDevices().first(where: { $0.uid == uid }) else { return false }- return setDefaultDeviceId(device.id, selector: kAudioHardwarePropertyDefaultInputDevice)- }-- @discardableResult- static func setDefaultOutputDevice(uid: String) -> Bool- {- guard let device = listOutputDevices().first(where: { $0.uid == uid }) else { return false }- return setDefaultDeviceId(device.id, selector: kAudioHardwarePropertyDefaultOutputDevice)- }-- private static func getDefaultDeviceId(selector: AudioObjectPropertySelector) -> AudioObjectID?- {- var address = AudioObjectPropertyAddress(- mSelector: selector,- mScope: kAudioObjectPropertyScopeGlobal,- mElement: kAudioObjectPropertyElementMain- )- var devId = AudioObjectID(0)- var size = UInt32(MemoryLayout<AudioObjectID>.size)- let status = AudioObjectGetPropertyData(AudioObjectID(kAudioObjectSystemObject), &address, 0, nil, &size, &devId)- return status == noErr ? devId : nil- }-- private static func setDefaultDeviceId(_ devId: AudioObjectID, selector: AudioObjectPropertySelector) -> Bool- {- var address = AudioObjectPropertyAddress(- mSelector: selector,- mScope: kAudioObjectPropertyScopeGlobal,- mElement: kAudioObjectPropertyElementMain- )- var mutableDevId = devId- let size = UInt32(MemoryLayout<AudioObjectID>.size)- let status = AudioObjectSetPropertyData(AudioObjectID(kAudioObjectSystemObject), &address, 0, nil, size, &mutableDevId)- return status == noErr- }-- private static func getStringProperty(_ devId: AudioObjectID, selector: AudioObjectPropertySelector, scope: AudioObjectPropertyScope) -> String?- {- var address = AudioObjectPropertyAddress(- mSelector: selector,- mScope: scope,- mElement: kAudioObjectPropertyElementMain- )-- var dataSize: UInt32 = 0- var status = AudioObjectGetPropertyDataSize(devId, &address, 0, nil, &dataSize)- if status != noErr || dataSize == 0- {- return nil- }-- let rawPtr = UnsafeMutableRawPointer.allocate(byteCount: Int(dataSize), alignment: MemoryLayout<Int8>.alignment)- defer { rawPtr.deallocate() }-- status = AudioObjectGetPropertyData(devId, &address, 0, nil, &dataSize, rawPtr)- if status != noErr- {- return nil- }-- let cfStr = rawPtr.load(as: CFString.self)- return cfStr as String- }-- private static func hasChannels(_ devId: AudioObjectID, scope: AudioObjectPropertyScope) -> Bool- {- var address = AudioObjectPropertyAddress(- mSelector: kAudioDevicePropertyStreamConfiguration,- mScope: scope,- mElement: kAudioObjectPropertyElementMain- )-- var dataSize: UInt32 = 0- var status = AudioObjectGetPropertyDataSize(devId, &address, 0, nil, &dataSize)- if status != noErr || dataSize == 0- {- return false- }-- let rawPtr = UnsafeMutableRawPointer.allocate(byteCount: Int(dataSize), alignment: MemoryLayout<Int8>.alignment)- defer { rawPtr.deallocate() }-- status = AudioObjectGetPropertyData(devId, &address, 0, nil, &dataSize, rawPtr)- if status != noErr- {- return false- }-- let ablPtr = rawPtr.bindMemory(to: AudioBufferList.self, capacity: 1)- let buffers = UnsafeMutableAudioBufferListPointer(ablPtr)- var channelCount = 0- for buffer in buffers- {- channelCount += Int(buffer.mNumberChannels)- }- return channelCount > 0- }-}--// MARK: - Low-overhead CoreAudio hardware observer-final class AudioHardwareObserver: ObservableObject-{- private let subject = PassthroughSubject<Void, Never>()- var changePublisher: AnyPublisher<Void, Never> { subject.eraseToAnyPublisher() }-- private var installed: Bool = false-- init()- {- register()- }-- deinit- {- unregister()- }-- private func register()- {- guard installed == false else { return }- var addrDevices = AudioObjectPropertyAddress(- mSelector: kAudioHardwarePropertyDevices,- mScope: kAudioObjectPropertyScopeGlobal,- mElement: kAudioObjectPropertyElementMain- )- var addrDefaultIn = AudioObjectPropertyAddress(- mSelector: kAudioHardwarePropertyDefaultInputDevice,- mScope: kAudioObjectPropertyScopeGlobal,- mElement: kAudioObjectPropertyElementMain- )- var addrDefaultOut = AudioObjectPropertyAddress(- mSelector: kAudioHardwarePropertyDefaultOutputDevice,- mScope: kAudioObjectPropertyScopeGlobal,- mElement: kAudioObjectPropertyElementMain- )-- let queue = DispatchQueue.main- let sys = AudioObjectID(kAudioObjectSystemObject)-- _ = AudioObjectAddPropertyListenerBlock(sys, &addrDevices, queue) { [weak self] _, _ in- self?.subject.send(())- }- _ = AudioObjectAddPropertyListenerBlock(sys, &addrDefaultIn, queue) { [weak self] _, _ in- self?.subject.send(())- }- _ = AudioObjectAddPropertyListenerBlock(sys, &addrDefaultOut, queue) { [weak self] _, _ in- self?.subject.send(())- }-- installed = true- }-- private func unregister()- {- guard installed else { return }- // Intentionally omitted: removing blocks is optional; listeners end with object lifetime.- installed = false- }-}--// MARK: - Custom Styles for Premium UI--struct GlassButtonStyle: ButtonStyle {- func makeBody(configuration: Configuration) -> some View {- configuration.label- .fontWeight(.semibold)- .padding(.horizontal, 20)- .padding(.vertical, 12)- .background(- RoundedRectangle(cornerRadius: 10)- .fill(.regularMaterial) // Less transparent for better contrast- .background(- RoundedRectangle(cornerRadius: 10)- .fill(- LinearGradient(- colors: [- .white.opacity(0.08),- Color(red: 0.2, green: 0.3, blue: 0.5).opacity(0.05),- .black.opacity(0.02),- .white.opacity(0.04)- ],- startPoint: .topLeading,- endPoint: .bottomTrailing- )- )- )- .overlay(- RoundedRectangle(cornerRadius: 10)- .stroke(.white.opacity(0.25), lineWidth: 1.0) // Less harsh border- )- .overlay(- RoundedRectangle(cornerRadius: 10)- .stroke(- LinearGradient(- colors: [.white.opacity(0.6), .clear, .clear, .white.opacity(0.2)],- startPoint: .topLeading,- endPoint: .bottomTrailing- ),- lineWidth: 1- )- )- .shadow(color: .black.opacity(0.3), radius: 8, x: 0, y: 4)- .shadow(color: .white.opacity(0.1), radius: 1, x: 0, y: 1)- )- .scaleEffect(configuration.isPressed ? 0.96 : 1.0)- .animation(.spring(response: 0.2, dampingFraction: 0.8), value: configuration.isPressed)- }-}--struct PremiumButtonStyle: ButtonStyle {- let isRecording: Bool- let height: CGFloat-- init(isRecording: Bool = false, height: CGFloat = 44) {- self.isRecording = isRecording- self.height = height- }-- func makeBody(configuration: Configuration) -> some View {- configuration.label- .fontWeight(.semibold)- .frame(maxWidth: .infinity)- .frame(height: height)- .foregroundColor(isRecording ? .white : .black)- .background(- RoundedRectangle(cornerRadius: 14)- .fill(- isRecording ?- LinearGradient(colors: [.red.opacity(0.8), .red.opacity(0.6)], startPoint: .topLeading, endPoint: .bottomTrailing) :- LinearGradient(colors: [Color.white.opacity(0.8), Color(red: 0.6, green: 0.7, blue: 0.9)], startPoint: .topLeading, endPoint: .bottomTrailing)- )- .overlay(- RoundedRectangle(cornerRadius: 14)- .stroke(.white.opacity(0.2), lineWidth: 1)- )- .shadow(color: (isRecording ? Color.red : Color.black).opacity(0.3), radius: 8, x: 0, y: 4)- )- .scaleEffect(configuration.isPressed ? 0.97 : 1.0)- .animation(.spring(response: 0.2, dampingFraction: 0.8), value: configuration.isPressed)- }-}--struct SecondaryButtonStyle: ButtonStyle {- func makeBody(configuration: Configuration) -> some View {- configuration.label- .fontWeight(.semibold)- .frame(maxWidth: .infinity)- .frame(height: 44)- .foregroundColor(.primary)- .background(- RoundedRectangle(cornerRadius: 14)- .fill(.ultraThinMaterial)- .overlay(- RoundedRectangle(cornerRadius: 14)- .stroke(.white.opacity(0.3), lineWidth: 1)- )- .shadow(color: .black.opacity(0.2), radius: 6, x: 0, y: 3)- )- .scaleEffect(configuration.isPressed ? 0.97 : 1.0)- .animation(.spring(response: 0.2, dampingFraction: 0.8), value: configuration.isPressed)- }-}--struct CompactButtonStyle: ButtonStyle {- let isReady: Bool-- init(isReady: Bool = false) {- self.isReady = isReady- }-- func makeBody(configuration: Configuration) -> some View {- configuration.label- .fontWeight(.medium)- .frame(maxWidth: .infinity)- .frame(height: 36)- .foregroundColor(.primary)- .background(- RoundedRectangle(cornerRadius: 8)- .fill(- isReady ?- LinearGradient(colors: [Color(red: 0.4, green: 0.5, blue: 0.7).opacity(0.3), Color(red: 0.2, green: 0.3, blue: 0.5).opacity(0.1)], startPoint: .top, endPoint: .bottom) :- LinearGradient(colors: [Color(red: 0.2, green: 0.3, blue: 0.5).opacity(0.1), Color(red: 0.1, green: 0.15, blue: 0.3).opacity(0.05)], startPoint: .top, endPoint: .bottom)- )- .overlay(- RoundedRectangle(cornerRadius: 8)- .stroke(isReady ? .white.opacity(0.3) : Color(red: 0.4, green: 0.5, blue: 0.7).opacity(0.3), lineWidth: 1)- )- .shadow(color: .black.opacity(0.2), radius: 4, x: 0, y: 2)- )- .scaleEffect(configuration.isPressed ? 0.97 : 1.0)- .animation(.spring(response: 0.2, dampingFraction: 0.8), value: configuration.isPressed)- }-}--struct InlineButtonStyle: ButtonStyle {- func makeBody(configuration: Configuration) -> some View {- configuration.label- .font(.caption)- .fontWeight(.medium)- .padding(.horizontal, 8)- .padding(.vertical, 4)- .foregroundColor(.white)- .background(- RoundedRectangle(cornerRadius: 6)- .fill(Color(red: 0.3, green: 0.4, blue: 0.6).opacity(0.2))- .overlay(- RoundedRectangle(cornerRadius: 6)- .stroke(.white.opacity(0.2), lineWidth: 0.5)- )- .shadow(color: .black.opacity(0.1), radius: 2, x: 0, y: 1)- )- .scaleEffect(configuration.isPressed ? 0.95 : 1.0)- .animation(.easeInOut(duration: 0.1), value: configuration.isPressed)- }-}--struct GlassToggleStyle: ToggleStyle {- func makeBody(configuration: Configuration) -> some View {- HStack {- configuration.label- .foregroundStyle(.primary)-- Spacer()-- ZStack {- RoundedRectangle(cornerRadius: 14)- .fill(configuration.isOn ?- AnyShapeStyle(LinearGradient(colors: [Color.white.opacity(0.9), Color(red: 0.6, green: 0.7, blue: 0.9)], startPoint: .leading, endPoint: .trailing)) :- AnyShapeStyle(.quaternary))- .frame(width: 44, height: 24)- .shadow(color: .black.opacity(0.2), radius: 4, x: 0, y: 2)-- Circle()- .fill(configuration.isOn ? .black : .white)- .shadow(color: .black.opacity(0.3), radius: 3, x: 0, y: 2)- .frame(width: 20, height: 20)- .offset(x: configuration.isOn ? 10 : -10)- .animation(.spring(response: 0.3, dampingFraction: 0.7), value: configuration.isOn)- }- .onTapGesture {- configuration.isOn.toggle()- }- }- }-}+// SidebarItem enum moved to top of file-// MARK: - Glossy Card Style-struct GlossyCardBackground: View {- let cornerRadius: CGFloat- let isElevated: Bool-- init(cornerRadius: CGFloat = 20, isElevated: Bool = false) {- self.cornerRadius = cornerRadius- self.isElevated = isElevated- }-- var body: some View {- RoundedRectangle(cornerRadius: cornerRadius)- .fill(.ultraThinMaterial)- .background(- RoundedRectangle(cornerRadius: cornerRadius)- .fill(- LinearGradient(- colors: [- .white.opacity(0.15),- .white.opacity(0.05),- .black.opacity(0.02),- .white.opacity(0.08)- ],- startPoint: .topLeading,- endPoint: .bottomTrailing- )- )- )- .overlay(- RoundedRectangle(cornerRadius: cornerRadius)- .stroke(.white.opacity(isElevated ? 0.7 : 0.5), lineWidth: isElevated ? 2 : 1.5)- )- .overlay(- RoundedRectangle(cornerRadius: cornerRadius)- .stroke(- LinearGradient(- colors: [.white.opacity(0.7), .clear, .clear, .white.opacity(0.3)],- startPoint: .topLeading,- endPoint: .bottomTrailing- ),- lineWidth: 1- )- )- .shadow(color: .black.opacity(isElevated ? 0.6 : 0.4), radius: isElevated ? 35 : 25, x: 0, y: isElevated ? 18 : 12)- .shadow(color: .black.opacity(isElevated ? 0.3 : 0.2), radius: isElevated ? 12 : 8, x: 0, y: isElevated ? 6 : 4)- .shadow(color: .white.opacity(isElevated ? 0.25 : 0.15), radius: isElevated ? 3 : 2, x: 0, y: 1)- }-}+// AudioDevice and AudioHardwareObserver moved to Services/AudioDeviceService.swift// MARK: - Card Animation Modifierstruct CardAppearAnimation: ViewModifier {diff --git a/Sources/Fluid/Services/ASRService.swift b/Sources/Fluid/Services/ASRService.swiftindex b66c10d0..bdb76265 100644--- a/Sources/Fluid/Services/ASRService.swift+++ b/Sources/Fluid/Services/ASRService.swift@@ -85,8 +85,7 @@ final class ASRService: ObservableObjectprivate var isProcessingChunk: Bool = falseprivate var skipNextChunk: Bool = falseprivate var previousFullTranscription: String = ""- private let processingLock = NSLock() // Prevent concurrent CoreML access- private let transcriptionExecutor = TranscriptionExecutor()+ private let transcriptionExecutor = TranscriptionExecutor() // Serializes all CoreML accessprivate var audioLevelSubject = PassthroughSubject<CGFloat, Never>()var audioLevelPublisher: AnyPublisher<CGFloat, Never> { audioLevelSubject.eraseToAnyPublisher() }@@ -229,11 +228,7 @@ final class ASRService: ObservableObject{guard isRunning else { return "" }- // CRITICAL: Wait for any in-flight transcription to complete- DebugLogger.shared.debug("stop(): waiting for processing lock", source: "ASRService")- processingLock.lock()- processingLock.unlock()- DebugLogger.shared.debug("stop(): processing lock cleared", source: "ASRService")+ DebugLogger.shared.debug("stop(): cancelling streaming and preparing final transcription", source: "ASRService")stopStreamingTimer()removeEngineTap()@@ -286,10 +281,6 @@ final class ASRService: ObservableObject{guard isRunning else { return }- // CRITICAL: Wait for any in-flight transcription to complete- processingLock.lock()- processingLock.unlock()-stopStreamingTimer()removeEngineTap()engine.stop()@@ -736,19 +727,7 @@ final class ASRService: ObservableObjectprivate func processStreamingChunk() async {guard isRunning else { return }- // Use lock to prevent race conditions with CoreML- guard processingLock.try() else {- DebugLogger.shared.debug("⚠️ Skipping chunk - lock held by previous transcription", source: "ASRService")- skipNextChunk = true- return- }-- defer {- DebugLogger.shared.debug("Streaming chunk releasing processing lock", source: "ASRService")- processingLock.unlock()- }-- // Double-check processing flag+ // Skip if already processing to prevent queue buildupguard !isProcessingChunk else {DebugLogger.shared.debug("⚠️ Skipping chunk - previous transcription still in progress", source: "ASRService")skipNextChunk = true@@ -771,6 +750,8 @@ final class ASRService: ObservableObjectlet chunk = Array(recordedPCM[0..<currentSampleCount])isProcessingChunk = true+ defer { isProcessingChunk = false }+let startTime = Date()do {@@ -804,8 +785,6 @@ final class ASRService: ObservableObjectDebugLogger.shared.error("❌ Streaming failed: \(error)", source: "ASRService")skipNextChunk = true}-- isProcessingChunk = false}/// Smart diff to prevent text from jumping arounddiff --git a/Sources/Fluid/Services/AudioDeviceService.swift b/Sources/Fluid/Services/AudioDeviceService.swiftnew file mode 100644index 00000000..03b43851--- /dev/null+++ b/Sources/Fluid/Services/AudioDeviceService.swift@@ -0,0 +1,226 @@+//+// AudioDeviceService.swift+// fluid+//+// CoreAudio device management and monitoring+//++import Foundation+import CoreAudio+import Combine++// MARK: - Audio Device Manager++enum AudioDevice {+ struct Device: Identifiable, Hashable {+ let id: AudioObjectID+ let uid: String+ let name: String+ let hasInput: Bool+ let hasOutput: Bool+ }++ static func listAllDevices() -> [Device] {+ var address = AudioObjectPropertyAddress(+ mSelector: kAudioHardwarePropertyDevices,+ mScope: kAudioObjectPropertyScopeGlobal,+ mElement: kAudioObjectPropertyElementMain+ )++ var dataSize: UInt32 = 0+ var status = AudioObjectGetPropertyDataSize(AudioObjectID(kAudioObjectSystemObject), &address, 0, nil, &dataSize)+ if status != noErr || dataSize == 0 {+ return []+ }++ let count = Int(dataSize) / MemoryLayout<AudioObjectID>.size+ var deviceIDs = [AudioObjectID](repeating: 0, count: count)+ status = AudioObjectGetPropertyData(AudioObjectID(kAudioObjectSystemObject), &address, 0, nil, &dataSize, &deviceIDs)+ if status != noErr {+ return []+ }++ var devices: [Device] = []+ devices.reserveCapacity(deviceIDs.count)++ for devId in deviceIDs {+ let name = getStringProperty(devId, selector: kAudioObjectPropertyName, scope: kAudioObjectPropertyScopeGlobal) ?? "Unknown"+ let uid = getStringProperty(devId, selector: kAudioDevicePropertyDeviceUID, scope: kAudioObjectPropertyScopeGlobal) ?? ""+ let hasIn = hasChannels(devId, scope: kAudioObjectPropertyScopeInput)+ let hasOut = hasChannels(devId, scope: kAudioObjectPropertyScopeOutput)+ devices.append(Device(id: devId, uid: uid, name: name, hasInput: hasIn, hasOutput: hasOut))+ }++ return devices.sorted { $0.name.localizedCaseInsensitiveCompare($1.name) == .orderedAscending }+ }++ static func listInputDevices() -> [Device] {+ return listAllDevices().filter { $0.hasInput }+ }++ static func listOutputDevices() -> [Device] {+ return listAllDevices().filter { $0.hasOutput }+ }++ static func getDefaultInputDevice() -> Device? {+ guard let devId: AudioObjectID = getDefaultDeviceId(selector: kAudioHardwarePropertyDefaultInputDevice) else { return nil }+ return listAllDevices().first { $0.id == devId }+ }++ static func getDefaultOutputDevice() -> Device? {+ guard let devId: AudioObjectID = getDefaultDeviceId(selector: kAudioHardwarePropertyDefaultOutputDevice) else { return nil }+ return listAllDevices().first { $0.id == devId }+ }++ @discardableResult+ static func setDefaultInputDevice(uid: String) -> Bool {+ guard let device = listInputDevices().first(where: { $0.uid == uid }) else { return false }+ return setDefaultDeviceId(device.id, selector: kAudioHardwarePropertyDefaultInputDevice)+ }++ @discardableResult+ static func setDefaultOutputDevice(uid: String) -> Bool {+ guard let device = listOutputDevices().first(where: { $0.uid == uid }) else { return false }+ return setDefaultDeviceId(device.id, selector: kAudioHardwarePropertyDefaultOutputDevice)+ }++ private static func getDefaultDeviceId(selector: AudioObjectPropertySelector) -> AudioObjectID? {+ var address = AudioObjectPropertyAddress(+ mSelector: selector,+ mScope: kAudioObjectPropertyScopeGlobal,+ mElement: kAudioObjectPropertyElementMain+ )+ var devId = AudioObjectID(0)+ var size = UInt32(MemoryLayout<AudioObjectID>.size)+ let status = AudioObjectGetPropertyData(AudioObjectID(kAudioObjectSystemObject), &address, 0, nil, &size, &devId)+ return status == noErr ? devId : nil+ }++ private static func setDefaultDeviceId(_ devId: AudioObjectID, selector: AudioObjectPropertySelector) -> Bool {+ var address = AudioObjectPropertyAddress(+ mSelector: selector,+ mScope: kAudioObjectPropertyScopeGlobal,+ mElement: kAudioObjectPropertyElementMain+ )+ var mutableDevId = devId+ let size = UInt32(MemoryLayout<AudioObjectID>.size)+ let status = AudioObjectSetPropertyData(AudioObjectID(kAudioObjectSystemObject), &address, 0, nil, size, &mutableDevId)+ return status == noErr+ }++ private static func getStringProperty(_ devId: AudioObjectID, selector: AudioObjectPropertySelector, scope: AudioObjectPropertyScope) -> String? {+ var address = AudioObjectPropertyAddress(+ mSelector: selector,+ mScope: scope,+ mElement: kAudioObjectPropertyElementMain+ )++ var dataSize: UInt32 = 0+ var status = AudioObjectGetPropertyDataSize(devId, &address, 0, nil, &dataSize)+ if status != noErr || dataSize == 0 {+ return nil+ }++ let rawPtr = UnsafeMutableRawPointer.allocate(byteCount: Int(dataSize), alignment: MemoryLayout<Int8>.alignment)+ defer { rawPtr.deallocate() }++ status = AudioObjectGetPropertyData(devId, &address, 0, nil, &dataSize, rawPtr)+ if status != noErr {+ return nil+ }++ let cfStr = rawPtr.load(as: CFString.self)+ return cfStr as String+ }++ private static func hasChannels(_ devId: AudioObjectID, scope: AudioObjectPropertyScope) -> Bool {+ var address = AudioObjectPropertyAddress(+ mSelector: kAudioDevicePropertyStreamConfiguration,+ mScope: scope,+ mElement: kAudioObjectPropertyElementMain+ )++ var dataSize: UInt32 = 0+ var status = AudioObjectGetPropertyDataSize(devId, &address, 0, nil, &dataSize)+ if status != noErr || dataSize == 0 {+ return false+ }++ let rawPtr = UnsafeMutableRawPointer.allocate(byteCount: Int(dataSize), alignment: MemoryLayout<Int8>.alignment)+ defer { rawPtr.deallocate() }++ status = AudioObjectGetPropertyData(devId, &address, 0, nil, &dataSize, rawPtr)+ if status != noErr {+ return false+ }++ let ablPtr = rawPtr.bindMemory(to: AudioBufferList.self, capacity: 1)+ let buffers = UnsafeMutableAudioBufferListPointer(ablPtr)+ var channelCount = 0+ for buffer in buffers {+ channelCount += Int(buffer.mNumberChannels)+ }+ return channelCount > 0+ }+}++// MARK: - Audio Hardware Observer++final class AudioHardwareObserver: ObservableObject {+ private let subject = PassthroughSubject<Void, Never>()+ var changePublisher: AnyPublisher<Void, Never> { subject.eraseToAnyPublisher() }++ private var installed: Bool = false++ init() {+ register()+ }++ deinit {+ unregister()+ }++ private func register() {+ guard installed == false else { return }+ var addrDevices = AudioObjectPropertyAddress(+ mSelector: kAudioHardwarePropertyDevices,+ mScope: kAudioObjectPropertyScopeGlobal,+ mElement: kAudioObjectPropertyElementMain+ )+ var addrDefaultIn = AudioObjectPropertyAddress(+ mSelector: kAudioHardwarePropertyDefaultInputDevice,+ mScope: kAudioObjectPropertyScopeGlobal,+ mElement: kAudioObjectPropertyElementMain+ )+ var addrDefaultOut = AudioObjectPropertyAddress(+ mSelector: kAudioHardwarePropertyDefaultOutputDevice,+ mScope: kAudioObjectPropertyScopeGlobal,+ mElement: kAudioObjectPropertyElementMain+ )++ let queue = DispatchQueue.main+ let sys = AudioObjectID(kAudioObjectSystemObject)++ _ = AudioObjectAddPropertyListenerBlock(sys, &addrDevices, queue) { [weak self] _, _ in+ self?.subject.send(())+ }+ _ = AudioObjectAddPropertyListenerBlock(sys, &addrDefaultIn, queue) { [weak self] _, _ in+ self?.subject.send(())+ }+ _ = AudioObjectAddPropertyListenerBlock(sys, &addrDefaultOut, queue) { [weak self] _, _ in+ self?.subject.send(())+ }++ installed = true+ }++ private func unregister() {+ guard installed else { return }+ // Intentionally omitted: removing blocks is optional; listeners end with object lifetime.+ installed = false+ }+}++++diff --git a/Sources/Fluid/Theme/AppTheme.swift b/Sources/Fluid/Theme/AppTheme.swiftnew file mode 100644index 00000000..d333a12d--- /dev/null+++ b/Sources/Fluid/Theme/AppTheme.swift@@ -0,0 +1,121 @@+import SwiftUI++/// Central theme definition for the Fluid app. All colors, spacings and materials+/// should be defined here to keep styling consistent and easy to evolve.+struct AppTheme {+ struct Palette {+ let windowBackground: Color+ let contentBackground: Color+ let sidebarBackground: Color+ let cardBackground: Color+ let elevatedCardBackground: Color+ let toolbarBackground: Color+ let cardBorder: Color+ let separator: Color+ let primaryText: Color+ let secondaryText: Color+ let tertiaryText: Color+ let accent: Color+ let warning: Color+ let success: Color+ }++ struct Metrics {+ struct Spacing {+ let xs: CGFloat+ let sm: CGFloat+ let md: CGFloat+ let lg: CGFloat+ let xl: CGFloat+ let xxl: CGFloat++ static let standard = Spacing(+ xs: 4,+ sm: 8,+ md: 12,+ lg: 16,+ xl: 20,+ xxl: 28+ )+ }++ struct CornerRadius {+ let sm: CGFloat+ let md: CGFloat+ let lg: CGFloat+ let pill: CGFloat++ static let standard = CornerRadius(+ sm: 6,+ md: 10,+ lg: 16,+ pill: 999+ )+ }++ struct Shadow {+ let color: Color+ let radius: CGFloat+ let x: CGFloat+ let y: CGFloat+ let opacity: Double++ static func subtle(color: Color, opacity: Double = 0.45) -> Shadow {+ Shadow(color: color, radius: 12, x: 0, y: 6, opacity: opacity)+ }+ }++ let spacing: Spacing+ let corners: CornerRadius+ let cardShadow: Shadow+ let elevatedCardShadow: Shadow+ }++ struct Materials {+ let window: Material+ let sidebar: Material+ let card: Material+ let elevatedCard: Material+ let toolbar: Material+ }++ let palette: Palette+ let metrics: Metrics+ let materials: Materials++ /// Default dark-forward theme tuned for macOS Sonoma / Sequoia aesthetics.+ static let dark = AppTheme(+ palette: Palette(+ windowBackground: Color(red: 0.08, green: 0.08, blue: 0.08),+ contentBackground: Color(red: 0.10, green: 0.10, blue: 0.10),+ sidebarBackground: Color(red: 0.06, green: 0.06, blue: 0.06),+ cardBackground: Color(red: 0.12, green: 0.12, blue: 0.12),+ elevatedCardBackground: Color(red: 0.14, green: 0.14, blue: 0.14),+ toolbarBackground: Color(red: 0.09, green: 0.09, blue: 0.09),+ cardBorder: Color(nsColor: .separatorColor).opacity(0.25),+ separator: Color(nsColor: .separatorColor).opacity(0.4),+ primaryText: Color(nsColor: .labelColor),+ secondaryText: Color(nsColor: .secondaryLabelColor),+ tertiaryText: Color(nsColor: .tertiaryLabelColor),+ accent: Color(red: 0.20, green: 0.85, blue: 0.50),+ warning: Color(nsColor: .systemOrange),+ success: Color(nsColor: .systemGreen)+ ),+ metrics: Metrics(+ spacing: .standard,+ corners: .standard,+ cardShadow: .subtle(color: .black, opacity: 0.70),+ elevatedCardShadow: .subtle(color: .black, opacity: 0.80)+ ),+ materials: Materials(+ window: .thinMaterial,+ sidebar: .ultraThinMaterial,+ card: .thinMaterial,+ elevatedCard: .regularMaterial,+ toolbar: .ultraThinMaterial+ )+ )+}++// MARK: - Helpers+diff --git a/Sources/Fluid/Theme/Components/SetupComponents.swift b/Sources/Fluid/Theme/Components/SetupComponents.swiftnew file mode 100644index 00000000..e91eaf02--- /dev/null+++ b/Sources/Fluid/Theme/Components/SetupComponents.swift@@ -0,0 +1,173 @@+//+// SetupComponents.swift+// fluid+//+// Helper components for setup and onboarding UI+//++import SwiftUI+import AppKit++// MARK: - Setup Step View++struct SetupStepView: View {+ let step: Int+ let title: String+ let description: String+ let status: SetupStatus+ let action: () -> Void+ var showConfigureButton: Bool = true++ enum SetupStatus {+ case pending, completed, inProgress+ }++ var body: some View {+ HStack(alignment: .top, spacing: 12) {+ ZStack {+ Circle()+ .fill(statusColor.opacity(0.2))+ .frame(width: 32, height: 32)++ if status == .completed {+ Image(systemName: "checkmark")+ .foregroundStyle(statusColor)+ .font(.system(size: 14, weight: .bold))+ } else {+ Text("\(step)")+ .font(.system(size: 14, weight: .semibold))+ .foregroundStyle(statusColor)+ }+ }++ VStack(alignment: .leading, spacing: 4) {+ HStack {+ Text(title)+ .font(.system(size: 14, weight: .semibold))++ Spacer()++ if status != .completed && showConfigureButton {+ Button("Configure") {+ action()+ }+ .font(.system(size: 12))+ .buttonStyle(.bordered)+ .controlSize(.small)+ }+ }++ Text(description)+ .font(.system(size: 13))+ .foregroundStyle(.secondary)+ }+ }+ .padding(.vertical, 8)+ }++ private var statusColor: Color {+ switch status {+ case .completed: return .green+ case .inProgress: return .blue+ case .pending: return .secondary+ }+ }+}++// MARK: - Instruction Step++struct InstructionStep: View {+ @Environment(\.theme) private var theme+ let number: Int+ let title: String+ let description: String++ var body: some View {+ HStack(alignment: .top, spacing: 12) {+ ZStack {+ Circle()+ .fill(theme.palette.accent.opacity(0.2))+ .frame(width: 28, height: 28)++ Text("\(number)")+ .font(.system(size: 14, weight: .semibold))+ .foregroundStyle(theme.palette.accent)+ }++ VStack(alignment: .leading, spacing: 2) {+ Text(title)+ .font(.system(size: 14, weight: .semibold))++ Text(description)+ .font(.system(size: 13))+ .foregroundStyle(.secondary)+ .lineLimit(2)+ }+ }+ }+}++// MARK: - Provider Guide++struct ProviderGuide: View {+ let name: String+ let url: String+ let description: String+ let baseURL: String+ let keyPrefix: String++ var body: some View {+ ThemedCard(hoverEffect: false) {+ VStack(alignment: .leading, spacing: 8) {+ HStack {+ Text(name)+ .font(.system(size: 14, weight: .semibold))++ Spacer()++ if !url.isEmpty {+ Button("Get API Key") {+ if let url = URL(string: url) {+ NSWorkspace.shared.open(url)+ }+ }+ .font(.system(size: 12))+ .buttonStyle(.bordered)+ .controlSize(.small)+ }+ }++ Text(description)+ .font(.system(size: 13))+ .foregroundStyle(.secondary)++ VStack(alignment: .leading, spacing: 4) {+ HStack {+ Text("Base URL:")+ .font(.system(size: 12, weight: .medium))+ .foregroundStyle(.secondary)+ Text(baseURL)+ .font(.system(size: 12, weight: .medium))+ .foregroundStyle(.primary)+ .textSelection(.enabled)+ }++ HStack {+ Text("Key Format:")+ .font(.system(size: 12, weight: .medium))+ .foregroundStyle(.secondary)+ Text(keyPrefix == "not-needed" ? "Not required" : "Starts with: \(keyPrefix)")+ .font(.system(size: 12, weight: .medium))+ .foregroundStyle(.primary)+ }+ }+ .padding(.top, 4)+ }+ .padding(12)+ }+ }+}++++diff --git a/Sources/Fluid/Theme/Components/ThemedCard.swift b/Sources/Fluid/Theme/Components/ThemedCard.swiftnew file mode 100644index 00000000..4d4cbe1e--- /dev/null+++ b/Sources/Fluid/Theme/Components/ThemedCard.swift@@ -0,0 +1,115 @@+import SwiftUI++enum ThemedCardStyle {+ case standard+ case prominent+ case subtle+}++struct ThemedCard<Content: View>: View {+ @Environment(\.theme) private var theme+ @State private var isHovered = false++ private let style: ThemedCardStyle+ private let hoverEffect: Bool+ private let padding: CGFloat?+ private let content: Content++ init(+ style: ThemedCardStyle = .standard,+ padding: CGFloat? = nil,+ hoverEffect: Bool = false,+ @ViewBuilder content: () -> Content+ ) {+ self.style = style+ self.padding = padding+ self.hoverEffect = hoverEffect+ self.content = content()+ }++ var body: some View {+ let configuration = CardConfiguration(style: style, theme: theme)+ let shape = RoundedRectangle(cornerRadius: configuration.cornerRadius, style: .continuous)++ content+ .padding(padding ?? theme.metrics.spacing.lg)+ .background(configuration.material, in: shape)+ .background(+ shape+ .fill(configuration.background)+ .overlay(+ shape.stroke(+ configuration.border.opacity(+ isHovered && hoverEffect ? configuration.hoverBorderOpacity : configuration.borderOpacity+ ),+ lineWidth: configuration.borderWidth+ )+ )+ .shadow(+ color: configuration.shadow.color.opacity(+ isHovered && hoverEffect ? min(configuration.shadow.opacity + configuration.hoverShadowBoost, 1.0) : configuration.shadow.opacity+ ),+ radius: configuration.shadow.radius,+ x: configuration.shadow.x,+ y: isHovered && hoverEffect ? configuration.shadow.y + 1 : configuration.shadow.y+ )+ )+ .scaleEffect(isHovered && hoverEffect ? 1.01 : 1.0)+ .onHover { hovering in+ guard hoverEffect else { return }+ isHovered = hovering+ }+ .animation(.easeOut(duration: 0.18), value: isHovered)+ }+}++// MARK: - Configuration+private extension ThemedCard {+ struct CardConfiguration {+ let background: Color+ let border: Color+ let borderOpacity: Double+ let hoverBorderOpacity: Double+ let borderWidth: CGFloat+ let material: Material+ let cornerRadius: CGFloat+ let shadow: AppTheme.Metrics.Shadow+ let hoverShadowBoost: Double++ init(style: ThemedCardStyle, theme: AppTheme) {+ switch style {+ case .standard:+ background = theme.palette.cardBackground+ border = theme.palette.cardBorder+ borderOpacity = 0.28+ hoverBorderOpacity = 0.5+ borderWidth = 1+ material = theme.materials.card+ cornerRadius = theme.metrics.corners.lg+ shadow = theme.metrics.cardShadow+ hoverShadowBoost = 0.12+ case .prominent:+ background = theme.palette.elevatedCardBackground+ border = theme.palette.accent+ borderOpacity = 0.25+ hoverBorderOpacity = 0.55+ borderWidth = 1.2+ material = theme.materials.elevatedCard+ cornerRadius = theme.metrics.corners.lg+ shadow = theme.metrics.elevatedCardShadow+ hoverShadowBoost = 0.15+ case .subtle:+ background = theme.palette.contentBackground+ border = theme.palette.cardBorder+ borderOpacity = 0.18+ hoverBorderOpacity = 0.32+ borderWidth = 0.8+ material = theme.materials.card+ cornerRadius = theme.metrics.corners.md+ shadow = theme.metrics.cardShadow+ hoverShadowBoost = 0.08+ }+ }+ }+}+diff --git a/Sources/Fluid/Theme/Components/ThemedGroupBox.swift b/Sources/Fluid/Theme/Components/ThemedGroupBox.swiftnew file mode 100644index 00000000..be845950--- /dev/null+++ b/Sources/Fluid/Theme/Components/ThemedGroupBox.swift@@ -0,0 +1,48 @@+import SwiftUI++struct ThemedGroupBox<Label: View, Content: View>: View {+ @Environment(\.theme) private var theme++ private let style: ThemedCardStyle+ private let hoverEffect: Bool+ private let label: Label+ private let content: Content++ init(+ style: ThemedCardStyle = .standard,+ hoverEffect: Bool = false,+ @ViewBuilder label: () -> Label,+ @ViewBuilder content: () -> Content+ ) {+ self.style = style+ self.hoverEffect = hoverEffect+ self.label = label()+ self.content = content()+ }++ var body: some View {+ ThemedCard(style: style, padding: 0, hoverEffect: hoverEffect) {+ VStack(alignment: .leading, spacing: theme.metrics.spacing.md) {+ label+ .font(.headline)+ .foregroundStyle(theme.palette.secondaryText)+ .padding(.top, theme.metrics.spacing.md)+ .padding(.horizontal, theme.metrics.spacing.md)++ Divider()+ .background(theme.palette.separator)+ .opacity(0.6)+ .padding(.horizontal, theme.metrics.spacing.md)++ content+ .padding(.bottom, theme.metrics.spacing.md)+ .padding(.horizontal, theme.metrics.spacing.md)+ }+ .frame(maxWidth: .infinity, alignment: .leading)+ }+ }+}++++diff --git a/Sources/Fluid/Theme/NativeButtonStyles.swift b/Sources/Fluid/Theme/NativeButtonStyles.swiftnew file mode 100644index 00000000..ff79bd45--- /dev/null+++ b/Sources/Fluid/Theme/NativeButtonStyles.swift@@ -0,0 +1,321 @@+import SwiftUI++// MARK: - Primary (Prominent) Button+struct GlassButtonStyle: ButtonStyle {+ func makeBody(configuration: Configuration) -> some View {+ GlassButton(configuration: configuration)+ }++ private struct GlassButton: View {+ @Environment(\.theme) private var theme+ @State private var isHovered = false+ let configuration: ButtonStyle.Configuration++ private var shape: RoundedRectangle {+ RoundedRectangle(cornerRadius: theme.metrics.corners.md, style: .continuous)+ }++ var body: some View {+ configuration.label+ .fontWeight(.semibold)+ .padding(.horizontal, theme.metrics.spacing.lg)+ .padding(.vertical, theme.metrics.spacing.md)+ .frame(minHeight: 36)+ .foregroundStyle(theme.palette.primaryText)+ .background(theme.materials.card, in: shape)+ .background(+ shape+ .fill(theme.palette.cardBackground)+ .overlay(+ shape.stroke(+ theme.palette.cardBorder.opacity(isHovered ? 0.45 : 0.25),+ lineWidth: 1+ )+ )+ )+ .overlay(+ shape+ .stroke(theme.palette.accent.opacity(isHovered ? 0.25 : 0.1), lineWidth: 1)+ .blendMode(.plusLighter)+ )+ .shadow(+ color: theme.palette.cardBorder.opacity(isHovered ? 0.45 : 0.22),+ radius: isHovered ? theme.metrics.cardShadow.radius : max(theme.metrics.cardShadow.radius - 3, 2),+ x: 0,+ y: isHovered ? theme.metrics.cardShadow.y : theme.metrics.cardShadow.y - 2+ )+ .scaleEffect(configuration.isPressed ? 0.97 : (isHovered ? 1.01 : 1.0))+ .animation(.spring(response: 0.18, dampingFraction: 0.78), value: isHovered)+ .animation(.spring(response: 0.2, dampingFraction: 0.8), value: configuration.isPressed)+ .onHover { isHovered = $0 }+ }+ }+}++// MARK: - Primary Accent Button+struct PremiumButtonStyle: ButtonStyle {+ var isRecording: Bool = false+ var height: CGFloat = 44++ func makeBody(configuration: Configuration) -> some View {+ PrimaryButton(configuration: configuration, isRecording: isRecording, height: height)+ }++ private struct PrimaryButton: View {+ @Environment(\.theme) private var theme+ @State private var isHovered = false+ let configuration: ButtonStyle.Configuration+ let isRecording: Bool+ let height: CGFloat++ private var shape: RoundedRectangle {+ RoundedRectangle(cornerRadius: theme.metrics.corners.lg, style: .continuous)+ }++ private var baseGradient: LinearGradient {+ if isRecording {+ return LinearGradient(+ colors: [+ Color(nsColor: .systemRed),+ Color(nsColor: .systemRed).opacity(0.8)+ ],+ startPoint: .topLeading,+ endPoint: .bottomTrailing+ )+ }++ return LinearGradient(+ colors: [+ theme.palette.accent.opacity(0.95),+ theme.palette.accent.opacity(0.75)+ ],+ startPoint: .topLeading,+ endPoint: .bottomTrailing+ )+ }++ var body: some View {+ configuration.label+ .fontWeight(.semibold)+ .frame(maxWidth: .infinity)+ .frame(height: height)+ .foregroundStyle(isRecording ? Color.white : theme.palette.primaryText)+ .background(+ shape+ .fill(baseGradient)+ .overlay(+ shape.stroke(+ Color.white.opacity(isHovered ? 0.35 : 0.2),+ lineWidth: 1+ )+ )+ )+ .shadow(+ color: (isRecording ? Color(nsColor: .systemRed) : theme.palette.accent)+ .opacity(isHovered ? 0.45 : 0.25),+ radius: isHovered ? theme.metrics.elevatedCardShadow.radius : max(theme.metrics.cardShadow.radius - 2, 2),+ x: 0,+ y: isHovered ? theme.metrics.elevatedCardShadow.y : theme.metrics.cardShadow.y+ )+ .scaleEffect(configuration.isPressed ? 0.98 : (isHovered ? 1.01 : 1.0))+ .animation(.spring(response: 0.18, dampingFraction: 0.75), value: isHovered)+ .animation(.spring(response: 0.18, dampingFraction: 0.75), value: configuration.isPressed)+ .onHover { isHovered = $0 }+ }+ }+}++// MARK: - Secondary Button+struct SecondaryButtonStyle: ButtonStyle {+ func makeBody(configuration: Configuration) -> some View {+ SecondaryButton(configuration: configuration)+ }++ private struct SecondaryButton: View {+ @Environment(\.theme) private var theme+ @State private var isHovered = false+ let configuration: ButtonStyle.Configuration++ private var shape: RoundedRectangle {+ RoundedRectangle(cornerRadius: theme.metrics.corners.lg, style: .continuous)+ }++ var body: some View {+ configuration.label+ .fontWeight(.semibold)+ .frame(maxWidth: .infinity)+ .frame(height: 42)+ .foregroundStyle(theme.palette.primaryText)+ .background(theme.materials.card, in: shape)+ .background(+ shape+ .fill(theme.palette.cardBackground)+ .overlay(+ shape.stroke(+ theme.palette.cardBorder.opacity(isHovered ? 0.45 : 0.25),+ lineWidth: 1+ )+ )+ )+ .shadow(+ color: theme.palette.cardBorder.opacity(isHovered ? 0.35 : 0.15),+ radius: isHovered ? theme.metrics.cardShadow.radius : max(theme.metrics.cardShadow.radius - 4, 1),+ x: 0,+ y: isHovered ? theme.metrics.cardShadow.y : theme.metrics.cardShadow.y - 2+ )+ .scaleEffect(configuration.isPressed ? 0.98 : (isHovered ? 1.01 : 1.0))+ .animation(.spring(response: 0.18, dampingFraction: 0.78), value: isHovered)+ .animation(.spring(response: 0.2, dampingFraction: 0.8), value: configuration.isPressed)+ .onHover { isHovered = $0 }+ }+ }+}++// MARK: - Compact Button+struct CompactButtonStyle: ButtonStyle {+ var isReady: Bool = false++ func makeBody(configuration: Configuration) -> some View {+ CompactButton(configuration: configuration, isReady: isReady)+ }++ private struct CompactButton: View {+ @Environment(\.theme) private var theme+ @State private var isHovered = false+ let configuration: ButtonStyle.Configuration+ let isReady: Bool++ private var shape: RoundedRectangle {+ RoundedRectangle(cornerRadius: theme.metrics.corners.sm, style: .continuous)+ }++ var body: some View {+ configuration.label+ .fontWeight(.medium)+ .frame(maxWidth: .infinity)+ .frame(height: 34)+ .foregroundStyle(theme.palette.primaryText)+ .background(theme.materials.card, in: shape)+ .background(+ shape+ .fill(theme.palette.cardBackground)+ .overlay(+ shape.stroke(+ (isReady ? theme.palette.accent : theme.palette.cardBorder)+ .opacity(isHovered ? 0.45 : 0.25),+ lineWidth: 1+ )+ )+ )+ .shadow(+ color: (isReady ? theme.palette.accent : theme.palette.cardBorder)+ .opacity(isHovered ? 0.3 : 0.12),+ radius: isHovered ? theme.metrics.cardShadow.radius - 2 : 2,+ x: 0,+ y: isHovered ? theme.metrics.cardShadow.y - 1 : 1+ )+ .scaleEffect(configuration.isPressed ? 0.97 : (isHovered ? 1.01 : 1.0))+ .animation(.spring(response: 0.18, dampingFraction: 0.78), value: isHovered)+ .animation(.spring(response: 0.2, dampingFraction: 0.8), value: configuration.isPressed)+ .onHover { isHovered = $0 }+ }+ }+}++// MARK: - Inline Button+struct InlineButtonStyle: ButtonStyle {+ func makeBody(configuration: Configuration) -> some View {+ InlineButton(configuration: configuration)+ }++ private struct InlineButton: View {+ @Environment(\.theme) private var theme+ @State private var isHovered = false+ let configuration: ButtonStyle.Configuration++ private var shape: Capsule {+ Capsule()+ }++ var body: some View {+ configuration.label+ .font(.caption)+ .fontWeight(.medium)+ .padding(.horizontal, theme.metrics.spacing.md)+ .padding(.vertical, theme.metrics.spacing.xs)+ .foregroundStyle(Color.white)+ .background(+ shape+ .fill(theme.palette.accent.opacity(isHovered ? 0.9 : 0.8))+ )+ .shadow(+ color: theme.palette.accent.opacity(isHovered ? 0.45 : 0.25),+ radius: isHovered ? 6 : 3,+ x: 0,+ y: isHovered ? 3 : 1+ )+ .scaleEffect(configuration.isPressed ? 0.96 : (isHovered ? 1.03 : 1.0))+ .animation(.easeOut(duration: 0.15), value: isHovered)+ .animation(.easeOut(duration: 0.15), value: configuration.isPressed)+ .onHover { isHovered = $0 }+ }+ }+}++// MARK: - Glass Toggle Style+struct GlassToggleStyle: ToggleStyle {+ func makeBody(configuration: Configuration) -> some View {+ ToggleBody(configuration: configuration)+ }++ private struct ToggleBody: View {+ @Environment(\.theme) private var theme+ let configuration: ToggleStyle.Configuration+ @State private var isHovered = false++ var body: some View {+ HStack {+ configuration.label+ .foregroundStyle(theme.palette.primaryText)++ Spacer()++ ZStack {+ Capsule()+ .fill(configuration.isOn ? theme.palette.accent.opacity(0.6) : theme.palette.cardBackground)+ .overlay(+ Capsule()+ .stroke(theme.palette.cardBorder.opacity(isHovered ? 0.4 : 0.25), lineWidth: 1)+ )+ .frame(width: 46, height: 26)+ .background(theme.materials.card, in: Capsule())+ .shadow(+ color: theme.palette.cardBorder.opacity(isHovered ? 0.35 : 0.18),+ radius: isHovered ? 8 : 4,+ x: 0,+ y: isHovered ? 3 : 1+ )++ Circle()+ .fill(Color.white)+ .frame(width: 22, height: 22)+ .shadow(color: Color.black.opacity(0.2), radius: 2, x: 0, y: 1)+ .overlay(+ Circle()+ .stroke(theme.palette.cardBorder.opacity(0.3), lineWidth: 0.5)+ )+ .offset(x: configuration.isOn ? 9 : -9)+ .animation(.spring(response: 0.28, dampingFraction: 0.75), value: configuration.isOn)+ }+ .onTapGesture {+ configuration.isOn.toggle()+ }+ .onHover { isHovered = $0 }+ }+ }+ }+}++++diff --git a/Sources/Fluid/Theme/ThemeEnvironment.swift b/Sources/Fluid/Theme/ThemeEnvironment.swiftnew file mode 100644index 00000000..a4319bf5--- /dev/null+++ b/Sources/Fluid/Theme/ThemeEnvironment.swift@@ -0,0 +1,23 @@+import SwiftUI++private struct ThemeKey: EnvironmentKey {+ static var defaultValue: AppTheme = .dark+}++extension EnvironmentValues {+ var theme: AppTheme {+ get { self[ThemeKey.self] }+ set { self[ThemeKey.self] = newValue }+ }+}++extension View {+ /// Applies an app theme to the view hierarchy.+ func appTheme(_ theme: AppTheme) -> some View {+ environment(\.theme, theme)+ }+}++++diff --git a/Sources/Fluid/UI/GlossyEffects.swift b/Sources/Fluid/UI/GlossyEffects.swiftindex 81458293..eb221a06 100644--- a/Sources/Fluid/UI/GlossyEffects.swift+++ b/Sources/Fluid/UI/GlossyEffects.swift@@ -1,118 +1,47 @@import SwiftUI-// MARK: - 3D Hoverable Card Component+// MARK: - Hoverable Glossy Card Componentstruct HoverableGlossyCard<Content: View>: View {+ @Environment(\.theme) private var theme@State private var isHovered = false- let content: Content- let excludeInteractiveElements: Bool-++ private let content: Content+ private let excludeInteractiveElements: Bool+init(excludeInteractiveElements: Bool = false, @ViewBuilder content: () -> Content) {self.content = content()self.excludeInteractiveElements = excludeInteractiveElements}-- var body: some View {- content- .background(- RoundedRectangle(cornerRadius: 20)- .fill(Color(red: 0.10, green: 0.12, blue: 0.20).opacity(0.85))- .background(- RoundedRectangle(cornerRadius: 20)- .fill(- LinearGradient(- colors: [- Color(red: 0.10, green: 0.12, blue: 0.20).opacity(0.4),- Color(red: 0.06, green: 0.08, blue: 0.14).opacity(0.25)- ],- startPoint: .topLeading,- endPoint: .bottomTrailing- )- )- )- .overlay(- RoundedRectangle(cornerRadius: 20)- .stroke(Color.white.opacity(isHovered ? 0.35 : 0.18), lineWidth: isHovered ? 1.5 : 1)- )- .shadow(color: Color.black.opacity(isHovered ? 0.45 : 0.28), radius: isHovered ? 24 : 18, x: 0, y: isHovered ? 12 : 8)- )- .brightness(isHovered && !excludeInteractiveElements ? 0.02 : 0.0)- .onHover { hovering in- isHovered = hovering- }- .animation(.easeInOut(duration: 0.15), value: isHovered)- }-}-// MARK: - Enhanced Button with Hover Effects-struct HoverableButton<Content: View>: View {- @State private var isHovered = false- let action: () -> Void- let isDisabled: Bool- let content: Content-- init(action: @escaping () -> Void, isDisabled: Bool = false, @ViewBuilder content: () -> Content) {- self.action = action- self.isDisabled = isDisabled- self.content = content()- }-var body: some View {- Button(action: action) {- content- .scaleEffect(isHovered && !isDisabled ? 1.05 : 1.0)- .brightness(isHovered && !isDisabled ? 0.1 : 0.0)- .shadow(- color: .white.opacity(isHovered && !isDisabled ? 0.3 : 0.1),- radius: isHovered && !isDisabled ? 8 : 2- )- }- .disabled(isDisabled)- .onHover { hovering in- if !isDisabled {- isHovered = hovering- }- }- .animation(.spring(response: 0.2, dampingFraction: 0.7), value: isHovered)- }-}+ let shape = RoundedRectangle(cornerRadius: theme.metrics.corners.lg, style: .continuous)+ let cardShadow = theme.metrics.cardShadow-// MARK: - Enhanced Button Styles with Hover Effects-struct EnhancedGlassButtonStyle: ButtonStyle {- @State private var isHovered = false-- func makeBody(configuration: Configuration) -> some View {- configuration.label- .fontWeight(.semibold)- .padding(.horizontal, 20)- .padding(.vertical, 12)- .background(- RoundedRectangle(cornerRadius: 10)- .fill(Color(red: 0.12, green: 0.14, blue: 0.24).opacity(0.9))- .background(- RoundedRectangle(cornerRadius: 10)- .fill(- LinearGradient(- colors: [- Color(red: 0.12, green: 0.14, blue: 0.24).opacity(isHovered ? 0.45 : 0.3),- Color(red: 0.07, green: 0.09, blue: 0.16).opacity(isHovered ? 0.25 : 0.15)- ],- startPoint: .topLeading,- endPoint: .bottomTrailing- )+ return content+ .background(theme.materials.card, in: shape)+ .background {+ shape+ .fill(theme.palette.cardBackground)+ .overlay(+ shape+ .stroke(+ theme.palette.cardBorder.opacity(isHovered ? 0.5 : 0.25),+ lineWidth: isHovered ? 1.2 : 1))- .overlay(- RoundedRectangle(cornerRadius: 10)- .stroke(Color.white.opacity(isHovered ? 0.35 : 0.22), lineWidth: isHovered ? 1.5 : 1)+ .shadow(+ color: cardShadow.color.opacity(isHovered ? min(cardShadow.opacity + 0.1, 1.0) : cardShadow.opacity),+ radius: isHovered ? cardShadow.radius + 2 : cardShadow.radius,+ x: cardShadow.x,+ y: isHovered ? cardShadow.y + 1 : cardShadow.y)- .shadow(color: Color.black.opacity(isHovered ? 0.5 : 0.3), radius: isHovered ? 14 : 10, x: 0, y: isHovered ? 7 : 5)- )- .scaleEffect(configuration.isPressed ? 0.96 : (isHovered ? 1.05 : 1.0))- .brightness(isHovered ? 0.05 : 0.0)- .onHover { hovering in isHovered = hovering }- .animation(.spring(response: 0.2, dampingFraction: 0.8), value: configuration.isPressed)- .animation(.spring(response: 0.2, dampingFraction: 0.7), value: isHovered)+ }+ .scaleEffect(isHovered && !excludeInteractiveElements ? 1.02 : 1.0)+ .onHover { hovering in+ isHovered = hovering+ }+ .animation(.easeOut(duration: 0.18), value: isHovered)}}@@ -124,13 +53,18 @@ extension View {}struct ButtonHoverModifier: ViewModifier {+ @Environment(\.theme) private var theme@State private var isHovered = falsefunc body(content: Content) -> some View {content.scaleEffect(isHovered ? 1.05 : 1.0)- .brightness(isHovered ? 0.1 : 0.0)- .shadow(color: .white.opacity(isHovered ? 0.3 : 0.0), radius: isHovered ? 6 : 0)+ .shadow(+ color: theme.palette.accent.opacity(isHovered ? 0.35 : 0.0),+ radius: isHovered ? 8 : 0,+ x: 0,+ y: isHovered ? 3 : 0+ ).onHover { hovering inisHovered = hovering}diff --git a/Sources/Fluid/UI/RecordingView.swift b/Sources/Fluid/UI/RecordingView.swiftnew file mode 100644index 00000000..aa7fb7ce--- /dev/null+++ b/Sources/Fluid/UI/RecordingView.swift@@ -0,0 +1,787 @@+//+// RecordingView.swift+// fluid+//+// Recording controls and configuration view+//++import SwiftUI+import AVFoundation++struct RecordingView: View {+ @ObservedObject var asr: ASRService+ @Environment(\.theme) private var theme+ @Binding var appear: Bool+ @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: MenuBarManager+ let stopAndProcessTranscription: () async -> Void+ let startRecording: () -> Void+ let downloadModels: () async -> Void+ let deleteModels: () async -> Void+ let openAccessibilitySettings: () -> Void+ let restartApp: () -> Void+ let revealAppInFinder: () -> Void+ let openApplicationsFolder: () -> Void+ let getModelStatusText: () -> String+ let labelFor: (AVAuthorizationStatus) -> String++ var body: some View {+ ScrollView(.vertical, showsIndicators: false) {+ VStack(spacing: 24) {+ // Hero Header Card+ ThemedCard(style: .standard) {+ VStack(spacing: 16) {+ HStack {+ Image(systemName: "waveform.circle.fill")+ .font(.system(size: 32))+ .foregroundStyle(.white)++ VStack(alignment: .leading, spacing: 4) {+ Text("Voice Dictation")+ .font(.title2)+ .fontWeight(.bold)+ Text("AI-powered speech recognition")+ .font(.subheadline)+ .foregroundStyle(.secondary)+ }++ Spacer()+ }++ // Status and Recording Control+ VStack(spacing: 12) {+ // Status indicator+ HStack {+ Circle()+ .fill(asr.isRunning ? .red : asr.isAsrReady ? .green : .secondary)+ .frame(width: 8, height: 8)++ Text(asr.isRunning ? "Recording..." : asr.isAsrReady ? "Ready to record" : "Model not ready")+ .font(.subheadline)+ .foregroundStyle(asr.isRunning ? .red : asr.isAsrReady ? .green : .secondary)+ }++ // Recording Control (Single Toggle Button)+ Button(action: {+ if asr.isRunning {+ Task {+ await stopAndProcessTranscription()+ }+ } else {+ startRecording()+ }+ }) {+ HStack {+ Image(systemName: asr.isRunning ? "stop.fill" : "mic.fill")+ .font(.system(size: 16, weight: .semibold))+ Text(asr.isRunning ? "Stop Recording" : "Start Recording")+ }+ .frame(maxWidth: .infinity)+ }+ .buttonStyle(PremiumButtonStyle(isRecording: asr.isRunning))+ .buttonHoverEffect()+ .scaleEffect(asr.isRunning ? 1.05 : 1.0)+ .animation(.spring(response: 0.3), value: asr.isRunning)+ .disabled(!asr.isAsrReady && !asr.isRunning)+ }+ }+ .padding(24)+ }+ .modifier(CardAppearAnimation(delay: 0.1, appear: $appear))++ // Permissions Card+ ThemedCard(style: .standard) {+ VStack(alignment: .leading, spacing: 16) {+ HStack {+ Image(systemName: "shield.checkered")+ .font(.title2)+ .foregroundStyle(.white)+ Text("Permissions")+ .font(.title3)+ .fontWeight(.semibold)+ }++ MicrophonePermissionView(+ asr: asr,+ labelFor: labelFor+ )+ }+ .padding(24)+ }+ .modifier(CardAppearAnimation(delay: 0.2, appear: $appear))++ // Model Configuration Card+ ThemedCard(hoverEffect: false) {+ ModelConfigurationCard(+ asr: asr,+ getModelStatusText: getModelStatusText,+ deleteModels: deleteModels,+ downloadModels: downloadModels+ )+ }+ .modifier(CardAppearAnimation(delay: 0.3, appear: $appear))++ // Global Hotkey Card+ ThemedCard(style: .standard) {+ GlobalHotkeyCard(+ accessibilityEnabled: accessibilityEnabled,+ hotkeyShortcut: $hotkeyShortcut,+ isRecordingShortcut: $isRecordingShortcut,+ hotkeyManagerInitialized: hotkeyManagerInitialized,+ pressAndHoldModeEnabled: $pressAndHoldModeEnabled,+ enableStreamingPreview: $enableStreamingPreview,+ copyToClipboard: $copyToClipboard,+ hotkeyManager: hotkeyManager,+ menuBarManager: menuBarManager,+ openAccessibilitySettings: openAccessibilitySettings,+ restartApp: restartApp,+ revealAppInFinder: revealAppInFinder,+ openApplicationsFolder: openApplicationsFolder+ )+ }+ .modifier(CardAppearAnimation(delay: 0.5, appear: $appear))++ // Debug Settings Card+ ThemedCard(style: .prominent) {+ 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: "RecordingView")+ }+ } 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)+ .modifier(CardAppearAnimation(delay: 0.6, appear: $appear))+ }+ .padding(24)+ }+ }+}++// MARK: - Microphone Permission View++private struct MicrophonePermissionView: View {+ @ObservedObject var asr: ASRService+ @Environment(\.theme) private var theme+ let labelFor: (AVAuthorizationStatus) -> String++ var body: some View {+ 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(labelFor(asr.micStatus))+ .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()++ microphoneActionButton+ }++ // Step-by-step instructions when microphone is not authorized+ if asr.micStatus != .authorized {+ microphoneInstructionsView+ }+ }+ }++ private var microphoneActionButton: some View {+ 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()+ }+ }+ }++ private var microphoneInstructionsView: some View {+ 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 {+ instructionStep(number: "1", text: "Click **Grant Access** above")+ instructionStep(number: "2", text: "Choose **Allow** in the system dialog")+ } else if asr.micStatus == .denied {+ instructionStep(number: "1", text: "Click **Open Settings** above")+ instructionStep(number: "2", text: "Find **FluidVoice** in the microphone list")+ instructionStep(number: "3", text: "Toggle **FluidVoice ON** to allow access")+ }+ }+ .padding(.leading, 4)+ }+ .padding(12)+ .background(theme.palette.accent.opacity(0.12))+ .cornerRadius(8)+ }++ private func instructionStep(number: String, text: String) -> some View {+ HStack(spacing: 8) {+ Text(number + ".")+ .font(.caption2)+ .foregroundStyle(theme.palette.accent)+ .fontWeight(.semibold)+ .frame(width: 16)+ Text(text)+ .font(.caption)+ .foregroundStyle(.primary)+ }+ }+}++// MARK: - Model Configuration Card++private struct ModelConfigurationCard: View {+ @ObservedObject var asr: ASRService+ @Environment(\.theme) private var theme+ let getModelStatusText: () -> String+ let deleteModels: () async -> Void+ let downloadModels: () async -> Void++ var body: some View {+ VStack(alignment: .leading, spacing: 16) {+ HStack {+ Image(systemName: "brain.head.profile")+ .font(.title2)+ .foregroundStyle(.white)+ Text("Voice to Text Model")+ .font(.title3)+ .fontWeight(.semibold)+ }++ VStack(alignment: .leading, spacing: 12) {+ HStack(spacing: 12) {+ Text("Model")+ .fontWeight(.medium)+ Spacer()+ Menu(asr.selectedModel.displayName) {+ ForEach(ASRService.ModelOption.allCases) { option in+ Button(option.displayName) { asr.selectedModel = option }+ }+ }+ .disabled(asr.isRunning)+ }++ Text(getModelStatusText())+ .font(.caption)+ .foregroundStyle(asr.isAsrReady ? .white : .secondary)+ .padding(.leading, 4)++ Text("Automatically detects and transcribes 25 European languages")+ .font(.caption)+ .foregroundStyle(.secondary)+ .padding(.leading, 4)++ // Model status indicator with action buttons+ HStack(spacing: 12) {+ if asr.isDownloadingModel {+ HStack(spacing: 8) {+ ProgressView()+ .controlSize(.small)+ Text("Downloading Model…")+ .font(.caption)+ .foregroundStyle(.secondary)+ }+ } else if asr.isAsrReady {+ HStack(spacing: 8) {+ Image(systemName: "checkmark.circle.fill")+ .foregroundStyle(.green)+ Text("Model Ready")+ .font(.caption)+ .fontWeight(.medium)+ .foregroundStyle(.white)+ }++ Button(action: {+ Task { await deleteModels() }+ }) {+ HStack(spacing: 4) {+ Image(systemName: "trash")+ Text("Delete")+ }+ .font(.caption)+ .foregroundStyle(.red)+ }+ .buttonStyle(.plain)+ .help("Delete downloaded models (~500MB)")+ } else if asr.modelsExistOnDisk {+ HStack(spacing: 8) {+ Image(systemName: "doc.fill")+ .foregroundStyle(theme.palette.accent)+ Text("Models on Disk (Not Loaded)")+ .font(.caption)+ .foregroundStyle(.secondary)+ }++ Button(action: {+ Task { await deleteModels() }+ }) {+ HStack(spacing: 4) {+ Image(systemName: "trash")+ Text("Delete")+ }+ .font(.caption)+ .foregroundStyle(.red)+ }+ .buttonStyle(.plain)+ .help("Delete downloaded models (~500MB)")+ } else {+ HStack(spacing: 8) {+ Image(systemName: "arrow.down.circle")+ .foregroundStyle(.orange)+ Text("Models Not Downloaded")+ .font(.caption)+ .foregroundStyle(.secondary)+ }++ Button(action: {+ Task { await downloadModels() }+ }) {+ HStack(spacing: 4) {+ Image(systemName: "arrow.down.circle.fill")+ Text("Download")+ }+ .font(.caption)+ .foregroundStyle(theme.palette.accent)+ }+ .buttonStyle(.plain)+ .help("Download ASR models (~500MB)")+ }+ }+ .padding(.horizontal, 12)+ .padding(.vertical, 8)+ .background(+ RoundedRectangle(cornerRadius: 8)+ .fill(.ultraThinMaterial.opacity(0.3))+ .overlay(+ RoundedRectangle(cornerRadius: 8)+ .stroke(.white.opacity(0.1), lineWidth: 1)+ )+ )++ // Helpful link: Supported languages+ HStack(alignment: .firstTextBaseline, spacing: 8) {+ Image(systemName: "link")+ .foregroundStyle(.secondary)+ Link(+ "Supported languages",+ destination: URL(string: "https://huggingface.co/nvidia/parakeet-tdt-0.6b-v3")!+ )+ }+ .font(.caption)+ .foregroundStyle(.secondary)+ }+ }+ .padding(24)+ }+}++// MARK: - Global Hotkey Card++private struct GlobalHotkeyCard: View {+ @Environment(\.theme) private var theme+ let accessibilityEnabled: Bool+ @Binding var hotkeyShortcut: HotkeyShortcut+ @Binding var isRecordingShortcut: Bool+ let hotkeyManagerInitialized: Bool+ @Binding var pressAndHoldModeEnabled: Bool+ @Binding var enableStreamingPreview: Bool+ @Binding var copyToClipboard: Bool+ let hotkeyManager: GlobalHotkeyManager?+ let menuBarManager: MenuBarManager+ let openAccessibilitySettings: () -> Void+ let restartApp: () -> Void+ let revealAppInFinder: () -> Void+ let openApplicationsFolder: () -> Void++ var body: some View {+ VStack(alignment: .leading, spacing: 16) {+ HStack {+ Image(systemName: "keyboard")+ .font(.title2)+ .foregroundStyle(.white)+ Text("Global Hotkey")+ .font(.title3)+ .fontWeight(.semibold)+ }++ if accessibilityEnabled {+ hotkeyEnabledView+ } else {+ hotkeyDisabledView+ }+ }+ .padding(24)+ }++ // Content when accessibility is enabled+ private var hotkeyEnabledView: some View {+ 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: "RecordingView")+ 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: "RecordingView")+ 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+ }+ }+ }++ // Content when accessibility is disabled+ private var hotkeyDisabledView: some View {+ 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)+ }+ }+}++++diff --git a/Sources/Fluid/UI/SettingsView.swift b/Sources/Fluid/UI/SettingsView.swiftnew file mode 100644index 00000000..18c6ee9e--- /dev/null+++ b/Sources/Fluid/UI/SettingsView.swift@@ -0,0 +1,279 @@+//+// SettingsView.swift+// fluid+//+// App preferences and audio device settings+//++import SwiftUI++struct SettingsView: View {+ @ObservedObject var asr: ASRService+ @Environment(\.theme) private var theme+ @Binding var appear: Bool+ @Binding var showWhatsNewSheet: Bool+ @Binding var visualizerNoiseThreshold: Double+ @Binding var selectedInputUID: String+ @Binding var selectedOutputUID: String+ @Binding var inputDevices: [AudioDevice.Device]+ @Binding var outputDevices: [AudioDevice.Device]++ let startRecording: () -> Void+ let refreshDevices: () -> Void++ var 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 Card+ ThemedCard(style: .standard) {+ VStack(alignment: .leading, spacing: 16) {+ HStack {+ Image(systemName: "power")+ .font(.title2)+ .foregroundStyle(.white)+ Text("App Settings")+ .font(.title3)+ .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)+ }+ }+ .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)+ }+ }+ .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)+ }+ }+ .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+ Button("What's New") {+ DispatchQueue.main.async {+ showWhatsNewSheet = true+ }+ }+ .buttonStyle(PremiumButtonStyle(height: 40))+ .buttonHoverEffect()+ .padding(.top, 8)+ }+ }+ .padding(24)+ }++ // Audio Devices Card+ ThemedCard(style: .standard) {+ VStack(alignment: .leading, spacing: 16) {+ HStack {+ Image(systemName: "speaker.wave.2.fill")+ .font(.title2)+ .foregroundStyle(.white)+ Text("Audio Devices")+ .font(.title3)+ .fontWeight(.semibold)+ }++ VStack(alignment: .leading, spacing: 16) {+ HStack {+ Text("Input Device")+ .fontWeight(.medium)+ Spacer()+ Picker("Input Device", selection: $selectedInputUID) {+ ForEach(inputDevices, id: \.uid) { dev in+ Text(dev.name).tag(dev.uid)+ }+ }+ .frame(width: 280)+ .onChange(of: selectedInputUID) { newUID in+ SettingsStore.shared.preferredInputDeviceUID = newUID+ _ = AudioDevice.setDefaultInputDevice(uid: newUID)+ if asr.isRunning {+ asr.stopWithoutTranscription()+ startRecording()+ }+ }+ }++ HStack {+ Text("Output Device")+ .fontWeight(.medium)+ Spacer()+ Picker("Output Device", selection: $selectedOutputUID) {+ ForEach(outputDevices, id: \.uid) { dev in+ Text(dev.name).tag(dev.uid)+ }+ }+ .frame(width: 280)+ .onChange(of: selectedOutputUID) { newUID in+ SettingsStore.shared.preferredOutputDeviceUID = newUID+ _ = AudioDevice.setDefaultOutputDevice(uid: newUID)+ }+ }++ HStack(spacing: 12) {+ Button {+ refreshDevices()+ } label: {+ Label("Refresh", systemImage: "arrow.clockwise")+ }+ .buttonStyle(GlassButtonStyle())+ .buttonHoverEffect()++ Spacer()++ if let defIn = AudioDevice.getDefaultInputDevice()?.name,+ let defOut = AudioDevice.getDefaultOutputDevice()?.name {+ Text("Default In: \(defIn) · Default Out: \(defOut)")+ .font(.caption)+ .foregroundColor(.secondary)+ }+ }+ }+ }+ .padding(24)+ }++ // Visualization Sensitivity Card+ ThemedCard(style: .standard) {+ VStack(alignment: .leading, spacing: 16) {+ HStack {+ Image(systemName: "waveform")+ .font(.title2)+ .foregroundStyle(.white)+ Text("Visualization")+ .font(.title3)+ .fontWeight(.semibold)+ }++ VStack(alignment: .leading, spacing: 16) {+ HStack {+ VStack(alignment: .leading, spacing: 4) {+ Text("Visualization Sensitivity")+ .font(.system(size: 16, weight: .semibold))+ Text("Control how sensitive the audio visualizer is to sound input")+ .font(.system(size: 13))+ .foregroundColor(.secondary)+ }++ Spacer()++ Button("Reset") {+ visualizerNoiseThreshold = 0.4+ SettingsStore.shared.visualizerNoiseThreshold = visualizerNoiseThreshold+ }+ .font(.system(size: 12))+ .buttonStyle(GlassButtonStyle())+ .buttonHoverEffect()+ }++ HStack(spacing: 12) {+ Text("More Sensitive")+ .font(.system(size: 12, weight: .medium))+ .foregroundColor(.secondary)+ .frame(width: 90)++ Slider(value: $visualizerNoiseThreshold, in: 0.01...0.8, step: 0.01)+ .controlSize(.regular)++ Text("Less Sensitive")+ .font(.system(size: 12, weight: .medium))+ .foregroundColor(.secondary)+ .frame(width: 90)++ Text(String(format: "%.2f", visualizerNoiseThreshold))+ .font(.system(size: 12, weight: .medium, design: .monospaced))+ .foregroundColor(.primary)+ .frame(width: 40)+ }+ }+ }+ .padding(24)+ }+ }+ .padding(24)+ }+ .onAppear {+ refreshDevices()+ }+ .onChange(of: visualizerNoiseThreshold) { newValue in+ SettingsStore.shared.visualizerNoiseThreshold = newValue+ }+ }+}++++diff --git a/Sources/Fluid/UI/WelcomeView.swift b/Sources/Fluid/UI/WelcomeView.swiftnew file mode 100644index 00000000..ffd42b2e--- /dev/null+++ b/Sources/Fluid/UI/WelcomeView.swift@@ -0,0 +1,459 @@+//+// WelcomeView.swift+// fluid+//+// Welcome and setup guide view+//++import SwiftUI+import AppKit+import AVFoundation++struct WelcomeView: View {+ @ObservedObject var asr: ASRService+ @Binding var selectedSidebarItem: SidebarItem?+ var isTranscriptionFocused: FocusState<Bool>.Binding+ @Environment(\.theme) private var theme++ let accessibilityEnabled: Bool+ let providerAPIKeys: [String: String]+ let currentProvider: String+ let openAIBaseURL: String+ let availableModels: [String]+ let selectedModel: String+ let playgroundUsed: Bool++ let stopAndProcessTranscription: () async -> Void+ let startRecording: () -> Void+ let isLocalEndpoint: (String) -> Bool++ var body: some View {+ ScrollView {+ VStack(alignment: .leading, spacing: 20) {+ // Header+ VStack(alignment: .leading, spacing: 8) {+ HStack {+ Image(systemName: "book.fill")+ .font(.system(size: 32))+ .foregroundStyle(theme.palette.accent)+ VStack(alignment: .leading) {+ Text("Welcome to FluidVoice")+ .font(.system(size: 28, weight: .bold))+ Text("Your AI-powered voice transcription assistant")+ .font(.system(size: 16))+ .foregroundStyle(.secondary)+ }+ }+ Text("Follow this quick setup to start using FluidVoice.")+ .font(.system(size: 14))+ .foregroundStyle(.secondary)+ .padding(.top, 4)+ }+ .padding(.bottom, 8)++ // Quick Setup Checklist+ ThemedCard(style: .prominent) {+ VStack(alignment: .leading, spacing: 16) {+ HStack {+ Image(systemName: "checkmark.circle.fill")+ .foregroundStyle(theme.palette.accent)+ Text("Quick Setup")+ .font(.headline)+ }++ VStack(alignment: .leading, spacing: 12) {+ SetupStepView(+ step: 1,+ title: "Grant Microphone Permission",+ description: "Allow FluidVoice to access your microphone for voice input",+ status: asr.micStatus == .authorized ? .completed : .pending,+ action: {+ selectedSidebarItem = .recording+ }+ )++ SetupStepView(+ step: 2,+ title: "Enable Accessibility",+ description: "Grant accessibility permission to type text into other apps",+ status: accessibilityEnabled ? .completed : .pending,+ action: {+ selectedSidebarItem = .recording+ }+ )++ SetupStepView(+ step: 3,+ title: "Set Up AI Enhancement (Optional)",+ description: "Configure API keys for AI-powered text enhancement",+ status: {+ let hasApiKey = providerAPIKeys[currentProvider]?.isEmpty == false+ let isLocal = isLocalEndpoint(openAIBaseURL.trimmingCharacters(in: .whitespacesAndNewlines))+ let hasModel = availableModels.contains(selectedModel)+ return ((isLocal || hasApiKey) && hasModel) ? .completed : .pending+ }(),+ action: {+ selectedSidebarItem = .aiProcessing+ }+ )++ SetupStepView(+ step: 4,+ title: "Test Your Setup below",+ description: "Try the playground below to test your complete setup",+ status: playgroundUsed ? .completed : .pending,+ action: {+ // No action needed - playground is right below+ },+ showConfigureButton: false+ )+ }+ }+ .padding(20)+ }++ // Test Playground - Right after setup checklist+ ThemedCard(hoverEffect: false) {+ VStack(alignment: .leading, spacing: 16) {+ HStack {+ Image(systemName: "text.bubble")+ .font(.title2)+ .foregroundStyle(.white)+ Text("Test Playground")+ .font(.title3)+ .fontWeight(.semibold)++ Spacer()++ if !asr.finalText.isEmpty {+ Button(action: {+ NSPasteboard.general.clearContents()+ NSPasteboard.general.setString(asr.finalText, forType: .string)+ }) {+ HStack {+ Image(systemName: "doc.on.doc")+ Text("Copy")+ }+ }+ .buttonStyle(InlineButtonStyle())+ .buttonHoverEffect()+ }+ }++ VStack(alignment: .leading, spacing: 12) {+ HStack {+ VStack(alignment: .leading, spacing: 4) {+ Text("Test your voice transcription here!")+ .font(.subheadline)+ .fontWeight(.medium)+ .foregroundStyle(.secondary)++ Text("• Click 'Start Recording' or use hotkey (Right Option/Alt)")+ .font(.caption)+ .foregroundStyle(.secondary)++ Text("• Speak naturally - words appear in real-time")+ .font(.caption)+ .foregroundStyle(.secondary)++ Text("• Click 'Stop Recording' when finished")+ .font(.caption)+ .foregroundStyle(.secondary)+ }++ Spacer()++ VStack(alignment: .trailing, spacing: 4) {+ if asr.isRunning {+ HStack {+ Image(systemName: "waveform")+ .foregroundStyle(.red)+ Text("Recording...")+ .font(.caption)+ .foregroundStyle(.red)+ }+ } else if !asr.finalText.isEmpty {+ Text("\(asr.finalText.count) characters")+ .font(.caption)+ .foregroundStyle(.secondary)+ }+ }+ }++ // Recording Controls+ HStack(spacing: 16) {+ if asr.isRunning {+ Button(action: {+ Task {+ await stopAndProcessTranscription()+ }+ }) {+ HStack(spacing: 8) {+ Image(systemName: "stop.fill")+ .foregroundStyle(.red)+ Text("Stop Recording")+ .fontWeight(.medium)+ }+ .padding(.horizontal, 16)+ .padding(.vertical, 8)+ .background(theme.palette.warning.opacity(0.12))+ .clipShape(RoundedRectangle(cornerRadius: 8))+ }+ } else {+ Button(action: {+ startRecording()+ }) {+ HStack(spacing: 8) {+ Image(systemName: "mic.fill")+ .foregroundStyle(.green)+ Text("Start Recording")+ .fontWeight(.medium)+ }+ .padding(.horizontal, 16)+ .padding(.vertical, 8)+ .background(theme.palette.success.opacity(0.12))+ .clipShape(RoundedRectangle(cornerRadius: 8))+ }+ }++ if !asr.isRunning && !asr.finalText.isEmpty {+ Button("Clear Results") {+ asr.finalText = ""+ }+ .buttonStyle(.bordered)+ .controlSize(.small)+ }+ }++ // TRANSCRIPTION TEXT AREA - ACTUAL TEXT FIELD+ VStack(alignment: .leading, spacing: 12) {+ HStack {+ Text("Transcription Playground")+ .font(.headline)+ .fontWeight(.semibold)++ Spacer()++ if !asr.finalText.isEmpty {+ Text("\(asr.finalText.count) characters")+ .font(.caption)+ .foregroundStyle(.secondary)+ }+ }++ // REAL TEXT EDITOR - Can receive focus and display transcription+ TextEditor(text: $asr.finalText)+ .font(.system(size: 16))+ .focused(isTranscriptionFocused)+ .frame(height: 200)+ .padding(16)+ .background(+ RoundedRectangle(cornerRadius: 12)+ .fill(+ asr.isRunning ? theme.palette.accent.opacity(0.12) : theme.palette.cardBackground.opacity(0.85)+ )+ .overlay(+ RoundedRectangle(cornerRadius: 12)+ .stroke(+ asr.isRunning ? theme.palette.accent.opacity(0.4) : theme.palette.cardBorder.opacity(0.35),+ lineWidth: asr.isRunning ? 2 : 1+ )+ )+ )+ .overlay(+ VStack {+ if asr.isRunning {+ VStack(spacing: 12) {+ // Animated recording indicator overlay+ HStack(spacing: 8) {+ Image(systemName: "waveform")+ .font(.system(size: 24))+ .foregroundStyle(theme.palette.accent)+ .scaleEffect(1.0)+ .animation(.easeInOut(duration: 0.8).repeatForever(), value: asr.isRunning)++ Image(systemName: "waveform")+ .font(.system(size: 20))+ .foregroundStyle(theme.palette.accent.opacity(0.7))+ .scaleEffect(1.0)+ .animation(.easeInOut(duration: 0.6).repeatForever(), value: asr.isRunning)++ Image(systemName: "waveform")+ .font(.system(size: 16))+ .foregroundStyle(theme.palette.accent.opacity(0.5))+ .scaleEffect(1.0)+ .animation(.easeInOut(duration: 0.4).repeatForever(), value: asr.isRunning)+ }++ VStack(spacing: 4) {+ Text("Listening... Speak now!")+ .font(.title3)+ .fontWeight(.semibold)+ .foregroundStyle(theme.palette.accent)++ Text("Your words will appear here in real-time")+ .font(.subheadline)+ .foregroundStyle(theme.palette.accent.opacity(0.8))+ }+ }+ } else if asr.finalText.isEmpty {+ VStack(spacing: 12) {+ Image(systemName: "text.bubble")+ .font(.system(size: 32))+ .foregroundStyle(.secondary.opacity(0.6))++ VStack(spacing: 4) {+ Text("Ready to test!")+ .font(.title3)+ .fontWeight(.semibold)+ .foregroundStyle(.primary)++ Text("Click 'Start Recording' or press your hotkey")+ .font(.subheadline)+ .foregroundStyle(.secondary)+ }+ }+ }+ }+ .allowsHitTesting(false) // Don't block text editor interaction+ )++ // Quick Action Buttons+ if !asr.finalText.isEmpty {+ HStack(spacing: 12) {+ Button(action: {+ NSPasteboard.general.clearContents()+ NSPasteboard.general.setString(asr.finalText, forType: .string)+ }) {+ HStack(spacing: 6) {+ Image(systemName: "doc.on.doc")+ Text("Copy Text")+ }+ .padding(.horizontal, 16)+ .padding(.vertical, 8)+ .background(theme.palette.accent.opacity(0.12))+ .foregroundStyle(theme.palette.accent)+ .cornerRadius(8)+ }++ Button("Clear & Test Again") {+ asr.finalText = ""+ }+ .buttonStyle(.bordered)+ .controlSize(.regular)++ Spacer()+ }+ .padding(.top, 8)+ }+ }+ }+ }+ .padding(20)+ }++ // How to Use+ ThemedCard(style: .standard) {+ VStack(alignment: .leading, spacing: 16) {+ HStack {+ Image(systemName: "play.fill")+ .foregroundStyle(.green)+ Text("How to Use")+ .font(.headline)+ }++ VStack(alignment: .leading, spacing: 16) {+ InstructionStep(+ number: 1,+ title: "Start Recording",+ description: "Use your hotkey (default: Right Option/Alt) or click the record button in the main window"+ )++ InstructionStep(+ number: 2,+ title: "Speak Clearly",+ description: "Speak your text naturally. The app works best in quiet environments"+ )++ InstructionStep(+ number: 3,+ title: "AI Enhancement",+ description: "Your speech is transcribed, then enhanced by AI for better grammar and clarity"+ )++ InstructionStep(+ number: 4,+ title: "Auto-Type Result",+ description: "The enhanced text is automatically typed into your focused application"+ )+ }+ }+ .padding(20)+ }++ // API Configuration Guide+ ThemedCard(style: .prominent) {+ VStack(alignment: .leading, spacing: 16) {+ HStack {+ Image(systemName: "key.fill")+ .foregroundStyle(.purple)+ Text("Get API Keys")+ .font(.headline)+ }++ VStack(alignment: .leading, spacing: 16) {+ Text("Choose your AI provider:")+ .font(.subheadline)+ .foregroundStyle(.secondary)++ ProviderGuide(+ name: "OpenAI",+ url: "https://platform.openai.com/api-keys",+ description: "Most popular choice with GPT-4.1 models",+ baseURL: "https://api.openai.com/v1",+ keyPrefix: "sk-"+ )++ ProviderGuide(+ name: "Groq",+ url: "https://console.groq.com/keys",+ description: "Fast inference with Llama and Mixtral models",+ baseURL: "https://api.groq.com/openai/v1",+ keyPrefix: "gsk_"+ )++ // Local Models Coming Soon+ ThemedCard(hoverEffect: false) {+ VStack(alignment: .leading, spacing: 8) {+ HStack {+ Text("Local Models")+ .font(.system(size: 14, weight: .semibold))+ .foregroundStyle(.secondary)++ Spacer()++ Text("Coming Soon")+ .font(.system(size: 12))+ .foregroundStyle(theme.palette.warning)+ .padding(.horizontal, 8)+ .padding(.vertical, 2)+ .background(theme.palette.warning.opacity(0.12))+ .cornerRadius(8)+ }++ Text("Run models locally for privacy and offline use")+ .font(.system(size: 13))+ .foregroundStyle(.secondary)+ }+ .padding(12)+ }+ }+ }+ .padding(20)+ }+ }+ .padding(20)+ }+ }+}+diff --git a/Sources/Fluid/UI/WhatsNewView.swift b/Sources/Fluid/UI/WhatsNewView.swiftindex be46d86d..49553862 100644--- a/Sources/Fluid/UI/WhatsNewView.swift+++ b/Sources/Fluid/UI/WhatsNewView.swift@@ -2,6 +2,7 @@ import SwiftUIstruct WhatsNewView: View {@Environment(\.dismiss) private var dismiss+ @Environment(\.theme) private var theme@State private var showContent = false@State private var features: [WhatsNewFeature] = []@State private var isLoading = true@@ -24,95 +25,74 @@ struct WhatsNewView: View {var body: some View {ZStack {- // Background- Color.black- .opacity(0.95)+ theme.palette.windowBackground.ignoresSafeArea()-- VStack(spacing: 0) {- // Header- VStack(spacing: 12) {- // App Icon or Logo- Image(nsImage: NSApp.applicationIconImage)- .resizable()- .frame(width: 80, height: 80)- .clipShape(RoundedRectangle(cornerRadius: 16))- .shadow(color: .blue.opacity(0.3), radius: 20, x: 0, y: 10)- .scaleEffect(showContent ? 1 : 0.5)- .opacity(showContent ? 1 : 0)-- Text("What's New in v\(version)")- .font(.system(size: 28, weight: .bold, design: .rounded))- .foregroundStyle(- LinearGradient(- colors: [.white, .white.opacity(0.8)],- startPoint: .top,- endPoint: .bottom- )- )- .opacity(showContent ? 1 : 0)- .offset(y: showContent ? 0 : -20)++ Rectangle()+ .fill(theme.materials.window)+ .ignoresSafeArea()++ ThemedCard(style: .prominent, padding: 0, hoverEffect: false) {+ VStack(spacing: 0) {+ // Header+ VStack(spacing: theme.metrics.spacing.md) {+ // App Icon or Logo+ Image(nsImage: NSApp.applicationIconImage)+ .resizable()+ .frame(width: 80, height: 80)+ .clipShape(RoundedRectangle(cornerRadius: theme.metrics.corners.lg))+ .shadow(color: theme.palette.accent.opacity(0.3), radius: 18, x: 0, y: 8)+ .scaleEffect(showContent ? 1 : 0.5)+ .opacity(showContent ? 1 : 0)++ Text("What's New in v\(version)")+ .font(.system(size: 28, weight: .bold, design: .rounded))+ .foregroundStyle(theme.palette.primaryText)+ .opacity(showContent ? 1 : 0)+ .offset(y: showContent ? 0 : -20)++ Text("FluidVoice keeps getting better")+ .font(.system(size: 14, weight: .medium))+ .foregroundStyle(theme.palette.secondaryText)+ .opacity(showContent ? 1 : 0)+ .offset(y: showContent ? 0 : -20)+ }+ .padding(.top, theme.metrics.spacing.xl)+ .padding(.bottom, theme.metrics.spacing.lg)- Text("FluidVoice keeps getting better")- .font(.system(size: 14, weight: .medium))- .foregroundColor(.white.opacity(0.6))- .opacity(showContent ? 1 : 0)- .offset(y: showContent ? 0 : -20)- }- .padding(.top, 40)- .padding(.bottom, 30)-- // Features List- ScrollView {- VStack(spacing: 20) {- ForEach(Array(features.enumerated()), id: \.offset) { index, feature in- FeatureRow(feature: feature)- .opacity(showContent ? 1 : 0)- .offset(y: showContent ? 0 : 30)- .animation(- .spring(response: 0.6, dampingFraction: 0.8)- .delay(Double(index) * 0.1),- value: showContent- )+ // Features List+ ScrollView {+ VStack(spacing: theme.metrics.spacing.lg) {+ ForEach(Array(features.enumerated()), id: \.offset) { index, feature in+ FeatureRow(feature: feature)+ .opacity(showContent ? 1 : 0)+ .offset(y: showContent ? 0 : 24)+ .animation(+ .spring(response: 0.6, dampingFraction: 0.8)+ .delay(Double(index) * 0.1),+ value: showContent+ )+ }}+ .padding(.horizontal, theme.metrics.spacing.xl)+ .padding(.vertical, theme.metrics.spacing.md)}- .padding(.horizontal, 40)- .padding(.vertical, 20)- }-- // Continue Button- Button(action: {- withAnimation(.spring(response: 0.3, dampingFraction: 0.7)) {- SettingsStore.shared.markWhatsNewAsSeen()- dismiss()++ // Continue Button+ Button("Continue") {+ withAnimation(.spring(response: 0.3, dampingFraction: 0.7)) {+ SettingsStore.shared.markWhatsNewAsSeen()+ dismiss()+ }}- }) {- Text("Continue")- .font(.system(size: 16, weight: .semibold))- .foregroundColor(.white)- .frame(maxWidth: .infinity)- .frame(height: 50)- .background(- LinearGradient(- colors: [Color.blue, Color.blue.opacity(0.8)],- startPoint: .leading,- endPoint: .trailing- )- )- .clipShape(RoundedRectangle(cornerRadius: 12))- .shadow(color: .blue.opacity(0.3), radius: 10, x: 0, y: 5)+ .buttonStyle(PremiumButtonStyle(height: 48))+ .buttonHoverEffect()+ .padding(.horizontal, theme.metrics.spacing.xl)+ .padding(.vertical, theme.metrics.spacing.lg)+ .opacity(showContent ? 1 : 0)}- .buttonStyle(.plain)- .padding(.horizontal, 40)- .padding(.vertical, 30)- .opacity(showContent ? 1 : 0)}- .frame(width: 500, height: 600)- .background(- RoundedRectangle(cornerRadius: 20)- .fill(Color(NSColor.windowBackgroundColor).opacity(0.95))- .shadow(color: .black.opacity(0.5), radius: 30, x: 0, y: 15)- )+ .frame(width: 520, height: 620)}.onAppear {withAnimation(.spring(response: 0.6, dampingFraction: 0.8).delay(0.1)) {@@ -255,52 +235,39 @@ struct WhatsNewView: View {struct FeatureRow: View {let feature: WhatsNewFeature+ @Environment(\.theme) private var themevar body: some View {- HStack(alignment: .top, spacing: 16) {- // Icon- ZStack {- Circle()- .fill(- LinearGradient(- colors: [- Color.blue.opacity(0.2),- Color.blue.opacity(0.1)- ],- startPoint: .topLeading,- endPoint: .bottomTrailing+ ThemedCard(style: .subtle, hoverEffect: false) {+ HStack(alignment: .top, spacing: theme.metrics.spacing.md) {+ ZStack {+ Circle()+ .fill(theme.palette.accent.opacity(0.12))+ .frame(width: 46, height: 46)+ .overlay(+ Circle()+ .stroke(theme.palette.accent.opacity(0.2), lineWidth: 1))- )- .frame(width: 50, height: 50)++ Image(systemName: feature.icon)+ .font(.system(size: 21, weight: .medium))+ .foregroundStyle(theme.palette.accent)+ }- Image(systemName: feature.icon)- .font(.system(size: 22, weight: .medium))- .foregroundColor(.blue)- }-- // Text- VStack(alignment: .leading, spacing: 6) {- Text(feature.title)- .font(.system(size: 16, weight: .semibold))- .foregroundColor(.white)+ VStack(alignment: .leading, spacing: theme.metrics.spacing.xs) {+ Text(feature.title)+ .font(.system(size: 16, weight: .semibold))+ .foregroundStyle(theme.palette.primaryText)++ Text(feature.description)+ .font(.system(size: 14, weight: .regular))+ .foregroundStyle(theme.palette.secondaryText)+ .fixedSize(horizontal: false, vertical: true)+ }- Text(feature.description)- .font(.system(size: 14, weight: .regular))- .foregroundColor(.white.opacity(0.7))- .fixedSize(horizontal: false, vertical: true)+ Spacer()}-- Spacer()}- .padding(16)- .background(- RoundedRectangle(cornerRadius: 12)- .fill(Color.white.opacity(0.05))- )- .overlay(- RoundedRectangle(cornerRadius: 12)- .stroke(Color.white.opacity(0.1), lineWidth: 1)- )}}diff --git a/Sources/Fluid/fluidApp.swift b/Sources/Fluid/fluidApp.swiftindex 1873b6da..297e39b2 100644--- a/Sources/Fluid/fluidApp.swift+++ b/Sources/Fluid/fluidApp.swift@@ -14,20 +14,17 @@ struct fluidApp: App {@StateObject private var menuBarManager = MenuBarManager()@NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate@State private var showWhatsNew = false+ @State private var theme = AppTheme.dark- init() {- // Note: App UI is designed with dark color scheme in mind- // All gradients and effects are optimized for dark mode- // AppDelegate handles initialization and permissions- }-var body: some Scene {WindowGroup {ContentView().environmentObject(menuBarManager)- .preferredColorScheme(.dark) // Force dark mode to prevent UI issues+ .appTheme(theme)+ .preferredColorScheme(.dark).sheet(isPresented: $showWhatsNew) {WhatsNewView()+ .appTheme(theme)}.onAppear {// Check if we should show what's new after a short delay@@ -39,5 +36,7 @@ struct fluidApp: App {showWhatsNew = true}}+ .defaultSize(width: 1000, height: 700)+ .windowResizability(.contentSize)}}