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
style(ai): split provider and prompt settings
altic-dev84d8eb2807bb
diff --git a/Sources/Fluid/Services/PrivateAIProvider.swift b/Sources/Fluid/Services/PrivateAIProvider.swiftindex 17d02eb6..2aa6bcaa 100644--- a/Sources/Fluid/Services/PrivateAIProvider.swift+++ b/Sources/Fluid/Services/PrivateAIProvider.swift@@ -14,10 +14,44 @@ struct PrivateAIModelDownloadProgress: Sendable, Equatable {var totalBytesWritten: Int64var totalBytesExpected: Int64?+ init(bytesWritten: Int64, totalBytesWritten: Int64, totalBytesExpected: Int64?) {+ self.bytesWritten = bytesWritten+ self.totalBytesWritten = totalBytesWritten+ self.totalBytesExpected = totalBytesExpected+ }++ init(initialExpectedBytes: Int64?) {+ self.init(+ bytesWritten: 0,+ totalBytesWritten: 0,+ totalBytesExpected: initialExpectedBytes.flatMap { $0 > 0 ? $0 : nil }+ )+ }++ var hasWrittenBytes: Bool {+ self.totalBytesWritten > 0+ }+var fractionCompleted: Double? {+ guard self.hasWrittenBytes else { return nil }guard let totalBytesExpected, totalBytesExpected > 0 else { return nil }return min(1, max(0, Double(self.totalBytesWritten) / Double(totalBytesExpected)))}++ func withFallbackExpectedBytes(_ byteCount: Int64?) -> PrivateAIModelDownloadProgress {+ guard self.totalBytesExpected == nil,+ let byteCount,+ byteCount > 0+ else {+ return self+ }++ return PrivateAIModelDownloadProgress(+ bytesWritten: self.bytesWritten,+ totalBytesWritten: self.totalBytesWritten,+ totalBytesExpected: byteCount+ )+ }}enum PrivateAIModelDownloadProgressText {@@ -30,6 +64,9 @@ enum PrivateAIModelDownloadProgressText {guard let progress else {return "Starting download. This can take a few minutes."}+ guard progress.hasWrittenBytes else {+ return "Downloading. This can take a few minutes."+ }guard let fraction = progress.fractionCompleted else {return "Downloading. This can take a few minutes."}@@ -39,6 +76,11 @@ enum PrivateAIModelDownloadProgressText {static func byteText(for progress: PrivateAIModelDownloadProgress?) -> String? {guard let progress else { return nil }+ guard progress.hasWrittenBytes else {+ guard let expected = progress.totalBytesExpected, expected > 0 else { return nil }+ return "\(Self.byteCountText(expected)) download"+ }+let written = Self.byteCountText(progress.totalBytesWritten)guard let expected = progress.totalBytesExpected, expected > 0 else {return "\(written) downloaded"@@ -50,6 +92,7 @@ enum PrivateAIModelDownloadProgressText {static func detailText(for progress: PrivateAIModelDownloadProgress?) -> String {guard let progress else { return "Starting download..." }guard let byteText = Self.byteText(for: progress) else { return "Downloading..." }+ guard progress.hasWrittenBytes else { return byteText }guard let fraction = progress.fractionCompleted else { return byteText }return "\(byteText) (\(Int(fraction * 100))%)"}diff --git a/Sources/Fluid/UI/AISettings/AIEnhancementSettingsView.swift b/Sources/Fluid/UI/AISettings/AIEnhancementSettingsView.swiftindex f1a46bfc..3317270d 100644--- a/Sources/Fluid/UI/AISettings/AIEnhancementSettingsView.swift+++ b/Sources/Fluid/UI/AISettings/AIEnhancementSettingsView.swift@@ -1,5 +1,30 @@import SwiftUI+enum AIEnhancementConfigurationSection: String, CaseIterable, Identifiable {+ case providers+ case advancedPrompts++ var id: String { self.rawValue }++ var title: String {+ switch self {+ case .providers:+ return "AI Providers"+ case .advancedPrompts:+ return "Advanced Prompts"+ }+ }++ var systemImage: String {+ switch self {+ case .providers:+ return "cpu"+ case .advancedPrompts:+ return "slider.horizontal.3"+ }+ }+}+enum PrivateAIModelLoadState: Equatable {case idlecase downloading(modelID: String, progress: PrivateAIModelDownloadProgress?)@@ -53,10 +78,11 @@ struct AIEnhancementSettingsView: View {@State var providerSearchText: String = ""@State var privateAISelectedModelID: String = PrivateAIIntegrationService.configuredModelID@State var privateAILoadState: PrivateAIModelLoadState = .idle+ @State var selectedConfigurationSection: AIEnhancementConfigurationSection = .providers+ @State var hoveredConfigurationSection: AIEnhancementConfigurationSection?@State var hoveredPromptCardKey: String? = nil@State var selectedPromptMode: SettingsStore.PromptMode = .dictate@State var hoveredPromptModeKey: String? = nil- @State var hoveredCleanupControlKey: String? = nil@State var hoveredPromptScopeKey: String? = nilvar body: some View {diff --git a/Sources/Fluid/UI/AISettingsView+AIConfiguration.swift b/Sources/Fluid/UI/AISettingsView+AIConfiguration.swiftindex a894240b..318ea531 100644--- a/Sources/Fluid/UI/AISettingsView+AIConfiguration.swift+++ b/Sources/Fluid/UI/AISettingsView+AIConfiguration.swift@@ -51,50 +51,18 @@ extension AIEnhancementSettingsView {ThemedCard(style: .prominent, hoverEffect: false) {VStack(alignment: .leading, spacing: 16) {self.aiSetupHeader- self.aiSetupSummaryBar-- HStack(spacing: 12) {- VStack(alignment: .leading, spacing: 2) {- Text("Providers")- .font(.system(size: 14, weight: .semibold))- Text("Configure your AI provider")- .font(.caption)- .foregroundStyle(.secondary)+ self.aiConfigurationSectionPicker++ Group {+ switch self.selectedConfigurationSection {+ case .providers:+ self.providerConfigurationContent+ case .advancedPrompts:+ self.promptsStepContent}-- Spacer()-- Button(action: { self.viewModel.showHelp.toggle() }) {- HStack(spacing: 5) {- Image(systemName: self.viewModel.showHelp ? "questionmark.circle.fill" : "questionmark.circle")- .font(.system(size: 14))- Text("Help")- .font(.caption)- .fontWeight(.medium)- }- .foregroundStyle(self.viewModel.showHelp ? self.theme.palette.accent : .secondary)- .padding(.horizontal, 10)- .padding(.vertical, 6)- .background(- Capsule()- .fill(self.viewModel.showHelp ? self.theme.palette.accent.opacity(0.12) : self.theme.palette.cardBackground.opacity(0.8))- .overlay(- Capsule()- .stroke(self.viewModel.showHelp ? self.theme.palette.accent.opacity(0.3) : self.theme.palette.cardBorder.opacity(0.4), lineWidth: 1)- )- )- }- .buttonStyle(.plain)}-- if self.viewModel.showHelp { self.helpSectionView }-- self.providerStepContent-- Divider()- .background(self.theme.palette.separator.opacity(0.5))-- self.promptsStepContent+ .transition(.opacity)+ .animation(.easeOut(duration: 0.12), value: self.selectedConfigurationSection)}.padding(16)}@@ -130,7 +98,7 @@ extension AIEnhancementSettingsView {.font(.title3).fontWeight(.semibold).foregroundStyle(self.theme.palette.primaryText)- Text("Choose the model used for AI Enhancement.")+ Text("Set up providers and prompt behavior separately.").font(.caption).foregroundStyle(self.theme.palette.secondaryText)}@@ -139,6 +107,107 @@ extension AIEnhancementSettingsView {}}+ private var aiConfigurationSectionPicker: some View {+ HStack(spacing: 3) {+ ForEach(AIEnhancementConfigurationSection.allCases) { section in+ self.aiConfigurationSectionButton(section)+ }+ }+ .padding(4)+ .background(+ Capsule(style: .continuous)+ .fill(self.theme.palette.contentBackground.opacity(0.78))+ .overlay(+ Capsule(style: .continuous)+ .stroke(self.theme.palette.cardBorder.opacity(0.24), lineWidth: 1)+ )+ )+ .frame(maxWidth: .infinity, alignment: .center)+ .accessibilityElement(children: .contain)+ }++ private func aiConfigurationSectionButton(_ section: AIEnhancementConfigurationSection) -> some View {+ let isSelected = self.selectedConfigurationSection == section+ let isHovering = self.hoveredConfigurationSection == section+ let tone = self.theme.palette.accent+ let shape = Capsule(style: .continuous)++ return Button {+ self.selectedConfigurationSection = section+ } label: {+ HStack(spacing: 8) {+ Image(systemName: section.systemImage)+ .font(.system(size: 12, weight: .semibold))+ Text(section.title)+ .font(.system(size: 13, weight: .semibold))+ }+ .foregroundStyle(isSelected ? tone : (isHovering ? self.theme.palette.primaryText : self.theme.palette.secondaryText))+ .frame(width: 176, height: 36)+ .contentShape(shape)+ .background(+ shape+ .fill(isSelected ? tone.opacity(0.13) : (isHovering ? self.theme.palette.cardBackground.opacity(0.66) : .clear))+ .overlay(+ shape+ .stroke(isSelected ? tone.opacity(0.46) : (isHovering ? self.theme.palette.cardBorder.opacity(0.36) : .clear), lineWidth: 1)+ )+ .shadow(color: isSelected ? tone.opacity(0.18) : .clear, radius: 8, x: 0, y: 2)+ )+ }+ .buttonStyle(.plain)+ .accessibilityLabel(section.title)+ .accessibilityAddTraits(isSelected ? .isSelected : [])+ .onHover { hovering in+ self.hoveredConfigurationSection = hovering ? section : nil+ }+ .animation(.easeOut(duration: 0.12), value: isHovering)+ .animation(.easeOut(duration: 0.12), value: isSelected)+ }++ private var providerConfigurationContent: some View {+ VStack(alignment: .leading, spacing: 16) {+ self.aiSetupSummaryBar++ HStack(spacing: 12) {+ VStack(alignment: .leading, spacing: 2) {+ Text("Providers")+ .font(.system(size: 14, weight: .semibold))+ Text("Configure local models and API providers.")+ .font(.caption)+ .foregroundStyle(.secondary)+ }++ Spacer()++ Button(action: { self.viewModel.showHelp.toggle() }) {+ HStack(spacing: 5) {+ Image(systemName: self.viewModel.showHelp ? "questionmark.circle.fill" : "questionmark.circle")+ .font(.system(size: 14))+ Text("Help")+ .font(.caption)+ .fontWeight(.medium)+ }+ .foregroundStyle(self.viewModel.showHelp ? self.theme.palette.accent : .secondary)+ .padding(.horizontal, 10)+ .padding(.vertical, 6)+ .background(+ Capsule()+ .fill(self.viewModel.showHelp ? self.theme.palette.accent.opacity(0.12) : self.theme.palette.cardBackground.opacity(0.8))+ .overlay(+ Capsule()+ .stroke(self.viewModel.showHelp ? self.theme.palette.accent.opacity(0.3) : self.theme.palette.cardBorder.opacity(0.4), lineWidth: 1)+ )+ )+ }+ .buttonStyle(.plain)+ }++ if self.viewModel.showHelp { self.helpSectionView }++ self.providerStepContent+ }+ }+private var aiSetupSummaryBar: some View {ViewThatFits(in: .horizontal) {HStack(spacing: 12) {@@ -146,13 +215,13 @@ extension AIEnhancementSettingsView {self.aiSetupSummaryDividerself.aiSetupSummaryItem(icon: "cloud", text: "Cloud models use provider APIs")self.aiSetupSummaryDivider- self.aiSetupSummaryItem(icon: "slider.horizontal.3", text: "AI Enhancement enables dictation prompts")+ self.aiSetupSummaryItem(icon: "keyboard", text: "Shortcuts choose when prompts run")}VStack(alignment: .leading, spacing: 7) {self.aiSetupSummaryItem(icon: "cpu", text: "Local models run on Mac")self.aiSetupSummaryItem(icon: "cloud", text: "Cloud models use provider APIs")- self.aiSetupSummaryItem(icon: "slider.horizontal.3", text: "AI Enhancement enables dictation prompts")+ self.aiSetupSummaryItem(icon: "keyboard", text: "Shortcuts choose when prompts run")}}.padding(.horizontal, 2)@@ -756,7 +825,10 @@ extension AIEnhancementSettingsView {guard !self.privateAILoadState.isDownloading(model.id) else { return }- self.privateAILoadState = .downloading(modelID: model.id, progress: nil)+ self.privateAILoadState = .downloading(+ modelID: model.id,+ progress: PrivateAIModelDownloadProgress(initialExpectedBytes: model.artifact.byteCount)+ )Task { @MainActor indo {DebugLogger.shared.info(@@ -768,7 +840,7 @@ extension AIEnhancementSettingsView {guard self.privateAISelectedModelID == model.id else { return }self.privateAILoadState = .downloading(modelID: model.id,- progress: progress+ progress: progress.withFallbackExpectedBytes(model.artifact.byteCount))}}@@ -1706,7 +1778,7 @@ extension AIEnhancementSettingsView {.font(.system(size: 12, weight: .medium)).foregroundStyle(self.theme.palette.accent)HStack(alignment: .firstTextBaseline, spacing: 0) {- Text("Prompts & Advanced")+ Text("Advanced Prompts").font(.system(size: 14, weight: .semibold))Text(" - Choose how to process your speech — email, code, terminal, and more").font(.caption)diff --git a/Sources/Fluid/UI/AISettingsView+AdvancedSettings.swift b/Sources/Fluid/UI/AISettingsView+AdvancedSettings.swiftindex a054f64b..69bbe74c 100644--- a/Sources/Fluid/UI/AISettingsView+AdvancedSettings.swift+++ b/Sources/Fluid/UI/AISettingsView+AdvancedSettings.swift@@ -179,8 +179,6 @@ extension AIEnhancementSettingsView {.frame(minWidth: AISettingsLayout.actionMinWidth, minHeight: AISettingsLayout.controlHeight)Spacer(minLength: 8)-- self.promptProcessingControl}self.promptModeTabSelector@@ -188,36 +186,6 @@ extension AIEnhancementSettingsView {.frame(maxWidth: .infinity)}- private var promptProcessingControl: some View {- let mode = self.selectedPromptMode.normalized- let isPrivateAILocked = mode == .dictate && self.viewModel.isPrivateAIModelSelected()- let isOff = self.viewModel.isPromptSelectionOff(for: mode)- let helpText: String = {- if isOff {- switch mode {- case .dictate:- return "Off: dictation types the raw transcript. Prompts and app overrides are paused."- case .edit, .write, .rewrite:- return "Off: Edit Text uses the built-in prompt. Custom prompts and app overrides are paused."- }- }- if isPrivateAILocked {- return "On: \(PrivateAIProviderFeature.displayName) uses the \(PrivateAIProviderFeature.displayName) prompt."- }- return mode == .dictate ? "On: dictation follows the selected prompt scope." : "On: Edit Text follows the selected prompt scope."- }()-- return HStack(alignment: .center, spacing: 7) {- Text("AI Enhancement")- .font(.system(size: 12, weight: .semibold))- .foregroundStyle(self.theme.palette.secondaryText)- .lineLimit(1)-- self.cleanupSegmentedControl(isOff: isOff, mode: mode)- }- .help(helpText)- }-private var promptModeTabSelector: some View {HStack(spacing: 2) {ForEach(SettingsStore.PromptMode.visiblePromptModes) { mode in@@ -416,76 +384,6 @@ extension AIEnhancementSettingsView {.padding(.horizontal, 4)}- private func cleanupSegmentedControl(isOff: Bool, mode: SettingsStore.PromptMode) -> some View {- let tone = self.modeAccentColor(mode)-- return- HStack(spacing: 4) {- self.cleanupSegmentButton(- title: "Off",- key: "off",- isSelected: isOff,- tone: tone,- action: { self.viewModel.setPromptSelectionOff(true, for: mode) }- )-- self.cleanupSegmentButton(- title: "On",- key: "on",- isSelected: !isOff,- tone: tone,- action: {- if mode.normalized == .dictate, self.viewModel.isPrivateAIModelSelected() {- self.viewModel.selectPrivateAIPromptIfAvailable()- } else {- self.viewModel.setSelectedPromptID(nil, for: mode)- }- }- )- }- .font(.system(size: 12, weight: .semibold))- .padding(3)- .background(- RoundedRectangle(cornerRadius: 12, style: .continuous)- .fill(self.theme.palette.contentBackground.opacity(0.78))- .overlay(- RoundedRectangle(cornerRadius: 12, style: .continuous)- .stroke(self.theme.palette.cardBorder.opacity(0.22), lineWidth: 1)- )- )- }-- private func cleanupSegmentButton(- title: String,- key: String,- isSelected: Bool,- tone: Color,- action: @escaping () -> Void- ) -> some View {- let isHovering = self.hoveredCleanupControlKey == key- let cornerRadius: CGFloat = 9-- return Button {- action()- } label: {- Text(title)- }- .buttonStyle(.plain)- .padding(.horizontal, 12)- .frame(height: 26)- .contentShape(RoundedRectangle(cornerRadius: cornerRadius, style: .continuous))- .fluidControlSurface(- isSelected: isSelected,- isHovered: isHovering,- tone: tone,- cornerRadius: cornerRadius- )- .foregroundStyle(isSelected ? tone : (isHovering ? self.theme.palette.primaryText : self.theme.palette.secondaryText))- .onHover { hovering in- self.hoveredCleanupControlKey = hovering ? key : nil- }- }-private func promptRoutingScopeRow(mode: SettingsStore.PromptMode) -> some View {HStack(alignment: .center, spacing: 10) {Text(mode.normalized == .dictate ? "Use AI" : "Use prompts")diff --git a/Sources/Fluid/UI/OnboardingAIEnhancementStepView.swift b/Sources/Fluid/UI/OnboardingAIEnhancementStepView.swiftindex 037d3f10..9eb070b6 100644--- a/Sources/Fluid/UI/OnboardingAIEnhancementStepView.swift+++ b/Sources/Fluid/UI/OnboardingAIEnhancementStepView.swift@@ -146,7 +146,7 @@ struct OnboardingAIEnhancementStepView: View {private var primaryPrivateAIButtonTitle: String {if self.isDownloadingPrivateAI {- return "Downloading"+ return PrivateAIModelDownloadProgressText.buttonTitle(for: self.privateAISetupProgress)}if self.isLoadingPrivateAI {return "Loading..."@@ -886,8 +886,10 @@ struct OnboardingAIEnhancementStepView: View {.frame(height: 4)} else {ProgressView()+ .progressViewStyle(.linear).controlSize(.small).tint(FluidOnboardingLandingColors.blue)+ .frame(height: 4)}}.padding(.top, 2)@@ -1175,7 +1177,7 @@ struct OnboardingAIEnhancementStepView: View {let model = self.privateAIModellet actionID = self.beginPrivateAIAction()self.privateAISetupErrorMessage = nil- self.privateAISetupProgress = nil+ self.privateAISetupProgress = PrivateAIModelDownloadProgress(initialExpectedBytes: model.artifact.byteCount)self.isDownloadingPrivateAI = trueself.privateAIActionTask = Task { @MainActor in@@ -1183,7 +1185,7 @@ struct OnboardingAIEnhancementStepView: View {_ = try await PrivateAIIntegrationService.prepareModel(model) { progress inawait MainActor.run {guard self.privateAIActionID == actionID else { return }- self.privateAISetupProgress = progress+ self.privateAISetupProgress = progress.withFallbackExpectedBytes(model.artifact.byteCount)}}guard self.privateAIActionID == actionID, !Task.isCancelled else { return }