Skip to content

Fastest and only macOS Dictation app with on-device STT and custom trained AI enhancement model. Windows, iOS testflight! Android, Linux waitlist open! A local Wispr Flow alternative. Follow https://x.com/fluidvoiceapp for more

feat(onboarding): add AI enhancement step with Fluid Intelligence tryout

altic-dev6a5fb51dd496
diff --git a/.gitignore b/.gitignore
index 41ba4c0d..23ef9225 100644
--- a/.gitignore
+++ b/.gitignore
@@ -212,6 +212,9 @@ assets/
.swiftpm/
scripts/
+# Benchmark / eval reports (local-only)
+benchmark_reports/
+
**.profraw
icon_work/
sample/
diff --git a/Sources/Fluid/ContentView.swift b/Sources/Fluid/ContentView.swift
index 7690a555..8d4f86f9 100644
--- a/Sources/Fluid/ContentView.swift
+++ b/Sources/Fluid/ContentView.swift
@@ -1064,6 +1064,12 @@ struct ContentView: View {
finishOnboarding: {
self.completeOnboardingIfPossible()
},
+ finishOnboardingAtGettingStarted: {
+ self.completeOnboardingIfPossible(selecting: .welcome)
+ },
+ openAIEnhancementSettingsFromOnboarding: {
+ self.completeOnboardingForAIProviderSetup()
+ },
openAccessibilitySettings: self.openAccessibilitySettings,
restartApp: self.restartApp,
menuBarManager: self.menuBarManager,
@@ -2163,8 +2169,10 @@ struct ContentView: View {
private var isOnboardingPlaygroundStepActive: Bool {
let onboardingPlaygroundStep = 4
+ let onboardingAIEnhancementStep = 5
return !self.settings.onboardingCompleted &&
- self.settings.onboardingCurrentStep == onboardingPlaygroundStep
+ (self.settings.onboardingCurrentStep == onboardingPlaygroundStep ||
+ self.settings.onboardingCurrentStep == onboardingAIEnhancementStep)
}
private func currentDictationOutputRouteForHotkeyStop() -> DictationOutputRoute {
@@ -3117,6 +3125,7 @@ extension ContentView {
if self.isOnboardingPlaygroundStepActive {
self.asr.finalText = ""
self.settings.onboardingPlaygroundValidated = false
+ self.settings.onboardingPlaygroundSkipped = false
self.settings.playgroundUsed = false
self.playgroundUsed = false
}
@@ -3198,15 +3207,7 @@ extension ContentView {
}
private var onboardingPlaygroundReady: Bool {
- self.settings.onboardingPlaygroundValidated
- }
-
- private var canCompleteOnboarding: Bool {
- self.onboardingVoiceModelReady &&
- self.onboardingMicrophoneReady &&
- self.onboardingAccessibilityReady &&
- self.onboardingAIReady &&
- self.onboardingPlaygroundReady
+ self.settings.onboardingPlaygroundValidated || self.settings.onboardingPlaygroundSkipped
}
@MainActor
@@ -3223,13 +3224,64 @@ extension ContentView {
// MARK: - ContentView Accessibility & Lifecycle Helpers
extension ContentView {
- func completeOnboardingIfPossible() {
- guard self.canCompleteOnboarding else { return }
+ func completeOnboardingIfPossible(selecting target: SidebarItem? = nil) {
+ let missingRequirements = self.missingOnboardingCompletionRequirements()
+ guard missingRequirements.isEmpty else {
+ self.presentOnboardingCompletionBlocked(missingRequirements)
+ return
+ }
+
+ self.completeOnboarding(selecting: target)
+ }
+
+ func completeOnboardingForAIProviderSetup() {
+ let missingRequirements = self.missingOnboardingCompletionRequirements(allowsAIConfiguration: true)
+ guard missingRequirements.isEmpty else {
+ self.presentOnboardingCompletionBlocked(missingRequirements)
+ return
+ }
+
+ self.completeOnboarding(selecting: .aiEnhancements)
+ }
+ private func completeOnboarding(selecting target: SidebarItem? = nil) {
self.settings.onboardingCompleted = true
let isOnboarded = self.asr.isAsrReady || self.asr.modelsExistOnDisk
- self.selectedSidebarItem = isOnboarded ? .preferences : .welcome
+ self.selectedSidebarItem = target ?? (isOnboarded ? .preferences : .welcome)
+ }
+
+ private func missingOnboardingCompletionRequirements(allowsAIConfiguration: Bool = false) -> [String] {
+ var missing: [String] = []
+
+ if !self.onboardingVoiceModelReady {
+ missing.append("voice model")
+ }
+ if !self.onboardingMicrophoneReady {
+ missing.append("microphone access")
+ }
+ if !self.onboardingAccessibilityReady {
+ missing.append("Accessibility access")
+ }
+ if !allowsAIConfiguration, !self.onboardingAIReady {
+ missing.append("AI choice")
+ }
+ if !self.onboardingPlaygroundReady {
+ missing.append("test or skip")
+ }
+
+ return missing
+ }
+
+ private func presentOnboardingCompletionBlocked(_ missingRequirements: [String]) {
+ let missingText = missingRequirements.joined(separator: ", ")
+ DebugLogger.shared.warning(
+ "Onboarding completion blocked; missing=\(missingText)",
+ source: "ContentView"
+ )
+ self.asr.errorTitle = "Setup Isn't Complete"
+ self.asr.errorMessage = "Finish \(missingText) to continue."
+ self.asr.showError = true
}
func labelFor(status: AVAuthorizationStatus) -> String {
diff --git a/Sources/Fluid/Persistence/SettingsStore.swift b/Sources/Fluid/Persistence/SettingsStore.swift
index bdac26b1..0922376c 100644
--- a/Sources/Fluid/Persistence/SettingsStore.swift
+++ b/Sources/Fluid/Persistence/SettingsStore.swift
@@ -1978,6 +1978,14 @@ final class SettingsStore: ObservableObject {
}
}
+ var onboardingPlaygroundSkipped: Bool {
+ get { self.defaults.bool(forKey: Keys.onboardingPlaygroundSkipped) }
+ set {
+ objectWillChange.send()
+ self.defaults.set(newValue, forKey: Keys.onboardingPlaygroundSkipped)
+ }
+ }
+
var onboardingSelectedLanguageID: String {
get {
let stored = self.defaults.string(forKey: Keys.onboardingSelectedLanguageID)?
@@ -2037,12 +2045,14 @@ final class SettingsStore: ObservableObject {
self.defaults.set(0, forKey: Keys.onboardingCurrentStep)
self.defaults.set(false, forKey: Keys.onboardingAISkipped)
self.defaults.set(false, forKey: Keys.onboardingPlaygroundValidated)
+ self.defaults.set(false, forKey: Keys.onboardingPlaygroundSkipped)
self.defaults.set("en", forKey: Keys.onboardingSelectedLanguageID)
} else {
self.defaults.set(true, forKey: Keys.onboardingCompleted)
self.defaults.set(0, forKey: Keys.onboardingCurrentStep)
self.defaults.set(false, forKey: Keys.onboardingAISkipped)
self.defaults.set(false, forKey: Keys.onboardingPlaygroundValidated)
+ self.defaults.set(false, forKey: Keys.onboardingPlaygroundSkipped)
self.defaults.set("en", forKey: Keys.onboardingSelectedLanguageID)
}
}
@@ -2053,6 +2063,7 @@ final class SettingsStore: ObservableObject {
self.defaults.set(0, forKey: Keys.onboardingCurrentStep)
self.defaults.set(false, forKey: Keys.onboardingAISkipped)
self.defaults.set(false, forKey: Keys.onboardingPlaygroundValidated)
+ self.defaults.set(false, forKey: Keys.onboardingPlaygroundSkipped)
self.defaults.set("en", forKey: Keys.onboardingSelectedLanguageID)
self.defaults.set(false, forKey: Keys.playgroundUsed)
}
@@ -2956,7 +2967,10 @@ final class SettingsStore: ObservableObject {
}
private func verifiedProviderIDsForCurrentConfiguration() -> [String] {
- let providerIDs = ModelRepository.builtInProviderIDs + self.savedProviders.map(\.id)
+ var providerIDs = ModelRepository.builtInProviderIDs + self.savedProviders.map(\.id)
+ if PrivateFeatures.privateAIProvider {
+ providerIDs.append(PrivateAIProviderFeature.shared.providerID)
+ }
return providerIDs.filter { self.isVerifiedProviderForCurrentConfiguration($0) }
}
@@ -3061,6 +3075,11 @@ final class SettingsStore: ObservableObject {
guard !trimmed.isEmpty else { return "" }
let providerID = trimmed
if ModelRepository.shared.isBuiltIn(providerID) { return providerID }
+ if PrivateFeatures.privateAIProvider,
+ providerID == PrivateAIProviderFeature.shared.providerID
+ {
+ return providerID
+ }
let savedProviderID = providerID.hasPrefix("custom:") ?
String(providerID.dropFirst("custom:".count)) : providerID
@@ -3973,6 +3992,7 @@ private extension SettingsStore {
static let onboardingCurrentStep = "OnboardingCurrentStep"
static let onboardingAISkipped = "OnboardingAISkipped"
static let onboardingPlaygroundValidated = "OnboardingPlaygroundValidated"
+ static let onboardingPlaygroundSkipped = "OnboardingPlaygroundSkipped"
static let onboardingSelectedLanguageID = "OnboardingSelectedLanguageID"
// Command Mode Keys
diff --git a/Sources/Fluid/Services/PrivateAIIntegrationService.swift b/Sources/Fluid/Services/PrivateAIIntegrationService.swift
index fa933d38..28c64764 100644
--- a/Sources/Fluid/Services/PrivateAIIntegrationService.swift
+++ b/Sources/Fluid/Services/PrivateAIIntegrationService.swift
@@ -76,6 +76,43 @@ actor PrivateAIIntegrationService {
self.provider.isModelInstalled(model)
}
+ nonisolated static func canRemoveInstalledModel(_ model: PrivateAIRegisteredModel) -> Bool {
+ guard let path = self.provider.localModelPath(for: model) else {
+ return false
+ }
+
+ let targetURL = URL(fileURLWithPath: path).standardizedFileURL
+ let modelDirectoryURL = self.modelDirectoryURL.standardizedFileURL
+ let expectedURL = self.expectedLocalModelURL(for: model).standardizedFileURL
+ let targetPath = targetURL.path
+ let modelDirectoryPath = modelDirectoryURL.path
+
+ return targetPath == expectedURL.path || targetPath.hasPrefix(modelDirectoryPath + "/")
+ }
+
+ nonisolated static func removeInstalledModel(_ model: PrivateAIRegisteredModel) throws {
+ guard let path = self.provider.localModelPath(for: model) else {
+ return
+ }
+
+ let targetURL = URL(fileURLWithPath: path).standardizedFileURL
+ let modelDirectoryURL = self.modelDirectoryURL.standardizedFileURL
+ let expectedURL = self.expectedLocalModelURL(for: model).standardizedFileURL
+ let targetPath = targetURL.path
+ let modelDirectoryPath = modelDirectoryURL.path
+
+ guard targetPath == expectedURL.path || targetPath.hasPrefix(modelDirectoryPath + "/") else {
+ throw PrivateAIModelRemovalError(message: "This model is not in FluidVoice's model folder.")
+ }
+
+ try FileManager.default.removeItem(at: targetURL)
+ }
+
+ func unloadAndRemoveInstalledModel(_ model: PrivateAIRegisteredModel, reason: String) async throws {
+ await self.unloadCachedRuntime(reason: reason)
+ try Self.removeInstalledModel(model)
+ }
+
nonisolated static func prepareModel(
_ model: PrivateAIRegisteredModel,
progressHandler: PrivateAIModelDownloadProgressHandler? = nil
@@ -120,6 +157,14 @@ actor PrivateAIIntegrationService {
}
}
+private struct PrivateAIModelRemovalError: LocalizedError {
+ let message: String
+
+ var errorDescription: String? {
+ self.message
+ }
+}
+
private struct UnavailableAIIntegrationShim: PrivateAIIntegrationProviding {
static let shared = UnavailableAIIntegrationShim()
diff --git a/Sources/Fluid/Services/PrivateAIProvider.swift b/Sources/Fluid/Services/PrivateAIProvider.swift
index 6eead894..91c701fc 100644
--- a/Sources/Fluid/Services/PrivateAIProvider.swift
+++ b/Sources/Fluid/Services/PrivateAIProvider.swift
@@ -20,6 +20,45 @@ struct PrivateAIModelDownloadProgress: Sendable, Equatable {
}
}
+enum PrivateAIModelDownloadProgressText {
+ static func buttonTitle(for progress: PrivateAIModelDownloadProgress?) -> String {
+ guard let fraction = progress?.fractionCompleted else { return "Downloading" }
+ return "Downloading \(Int(fraction * 100))%"
+ }
+
+ static func statusText(for progress: PrivateAIModelDownloadProgress?) -> String {
+ guard let progress else {
+ return "Starting download. This can take a few minutes."
+ }
+ guard let fraction = progress.fractionCompleted else {
+ return "Downloading. This can take a few minutes."
+ }
+ return "Downloading \(Int(fraction * 100))%. This can take a few minutes."
+ }
+
+ static func byteText(for progress: PrivateAIModelDownloadProgress?) -> String? {
+ guard let progress else { return nil }
+
+ let written = Self.byteCountText(progress.totalBytesWritten)
+ guard let expected = progress.totalBytesExpected, expected > 0 else {
+ return "\(written) downloaded"
+ }
+
+ return "\(written) of \(Self.byteCountText(expected))"
+ }
+
+ 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 let fraction = progress.fractionCompleted else { return byteText }
+ return "\(byteText) (\(Int(fraction * 100))%)"
+ }
+
+ private static func byteCountText(_ bytes: Int64) -> String {
+ ByteCountFormatter.string(fromByteCount: bytes, countStyle: .file)
+ }
+}
+
typealias PrivateAIModelDownloadProgressHandler = @Sendable (PrivateAIModelDownloadProgress) async -> Void
struct PrivateAIRegisteredModel: Sendable, Codable, Hashable, Identifiable {
diff --git a/Sources/Fluid/UI/AISettingsView+AIConfiguration.swift b/Sources/Fluid/UI/AISettingsView+AIConfiguration.swift
index a15c3560..a894240b 100644
--- a/Sources/Fluid/UI/AISettingsView+AIConfiguration.swift
+++ b/Sources/Fluid/UI/AISettingsView+AIConfiguration.swift
@@ -960,26 +960,11 @@ extension AIEnhancementSettingsView {
}
private static func downloadButtonText(progress: PrivateAIModelDownloadProgress?) -> String {
- guard let fraction = progress?.fractionCompleted else { return "Downloading..." }
- return "Downloading \(Int(fraction * 100))%"
+ PrivateAIModelDownloadProgressText.buttonTitle(for: progress)
}
private static func downloadProgressText(_ progress: PrivateAIModelDownloadProgress?) -> String {
- guard let progress else { return "Downloading..." }
- let written = Self.byteCountText(progress.totalBytesWritten)
- guard let expected = progress.totalBytesExpected, expected > 0 else {
- return "\(written) downloaded"
- }
-
- let expectedText = Self.byteCountText(expected)
- if let fraction = progress.fractionCompleted {
- return "\(written) of \(expectedText) (\(Int(fraction * 100))%)"
- }
- return "\(written) of \(expectedText)"
- }
-
- private static func byteCountText(_ bytes: Int64) -> String {
- ByteCountFormatter.string(fromByteCount: bytes, countStyle: .file)
+ PrivateAIModelDownloadProgressText.detailText(for: progress)
}
private static func elapsedMilliseconds(since start: ContinuousClock.Instant) -> Int {
diff --git a/Sources/Fluid/UI/OnboardingAIEnhancementStepView.swift b/Sources/Fluid/UI/OnboardingAIEnhancementStepView.swift
new file mode 100644
index 00000000..feb99e20
--- /dev/null
+++ b/Sources/Fluid/UI/OnboardingAIEnhancementStepView.swift
@@ -0,0 +1,1296 @@
+import Foundation
+import SwiftUI
+
+struct OnboardingAIEnhancementStepView: View {
+ @Binding var finalText: String
+
+ let progressValue: Double
+ let glowCenter: UnitPoint
+ let language: VoiceEngineLanguage
+ let shortcutDisplay: String
+ let isTestReady: Bool
+ let isRunning: Bool
+ let isRecordingShortcut: Bool
+ let shortcutRecordingMessage: String?
+ let onGlowMove: (CGPoint, CGSize) -> Void
+ let onGlowExit: () -> Void
+ let onBack: () -> Void
+ let onSkip: () -> Void
+ let onUseAIProvider: () -> Void
+ let onFinishSetup: () -> Void
+
+ @Environment(\.accessibilityReduceMotion) private var reduceMotion
+ @ObservedObject private var settings = SettingsStore.shared
+
+ @State private var hoveredButtonID: String?
+ @State private var isDownloadingPrivateAI = false
+ @State private var isLoadingPrivateAI = false
+ @State private var isDeletingPrivateAI = false
+ @State private var privateAISetupProgress: PrivateAIModelDownloadProgress?
+ @State private var privateAISetupErrorMessage: String?
+ @State private var privateAIActionTask: Task<Void, Never>?
+ @State private var privateAIActionID = UUID()
+ @State private var shouldShowTryout = false
+ @State private var hasPreparedExistingPrivateAI = false
+ @State private var selectedExampleID = Self.examples[0].id
+ @State private var activeRecordingExampleID: String?
+ @State private var playgroundOutputs: [String: String] = [:]
+ @Namespace private var exampleMorphNamespace
+
+ private enum ScrollTarget {
+ static let top = "fluid-intelligence-top"
+ }
+
+ private struct EnhancementExample: Identifiable {
+ let id: String
+ let raw: String
+ let polished: String
+ }
+
+ private enum ButtonTone {
+ case primary
+ case secondary
+ case destructive
+ }
+
+ private struct PillButtonConfiguration {
+ let id: String
+ let title: String
+ let systemImage: String?
+ let tone: ButtonTone
+ let width: CGFloat
+ let height: CGFloat
+ let fontSize: CGFloat
+ let isEnabled: Bool
+ }
+
+ private enum ExampleGridMetrics {
+ static let widthInset: CGFloat = 88
+ static let maxWidth: CGFloat = 900
+ static let headerLeadingInset: CGFloat = 50
+ static let columnSpacing: CGFloat = 12
+ static let rowSpacing: CGFloat = 8
+ static let rowHeight: CGFloat = 102
+ static let innerTextHeight: CGFloat = 86
+ static let iconSize: CGFloat = 40
+ static let arrowSize: CGFloat = 32
+ static let rawCornerRadius: CGFloat = 14
+ static let innerCornerRadius: CGFloat = 10
+ static let heroHeight: CGFloat = 154
+ }
+
+ private static let examples = [
+ EnhancementExample(
+ id: "message-format",
+ raw: "Hey John, Newline, how are you doing today? Next paragraph Best Newline, thanks.",
+ polished: "Hey John,\nHow are you doing today?\n\nBest,\nthanks."
+ ),
+ EnhancementExample(
+ id: "correction",
+ raw: "Hey, can we meet at five thirty tomorrow morning? Sorry, can you make it three thirty p.m. today?",
+ polished: "Hey, can we meet at 3:30 PM today?"
+ ),
+ EnhancementExample(
+ id: "list",
+ raw: "Make a grocery list. First one is banana, second one is apple, third one is orange.",
+ polished: "Grocery list:\n- banana\n- apple\n- orange"
+ ),
+ ]
+
+ private var privateAIModel: PrivateAIRegisteredModel {
+ PrivateAIModelRegistry.defaultModel
+ }
+
+ private var fluidIntelligenceName: String {
+ let displayName = PrivateAIProviderFeature.displayName.trimmingCharacters(in: .whitespacesAndNewlines)
+ if displayName.isEmpty || displayName == "Private AI Provider" {
+ return "Fluid Intelligence"
+ }
+ return displayName
+ }
+
+ private var privateAIModelDisplayName: String {
+ let displayName = self.privateAIModel.displayName.trimmingCharacters(in: .whitespacesAndNewlines)
+ return displayName.isEmpty ? "Fluid-1" : displayName
+ }
+
+ private var privateAIModelSizeText: String {
+ guard let byteCount = self.privateAIModel.artifact.byteCount, byteCount > 0 else {
+ return "Size shown before download"
+ }
+ return "~\(ByteCountFormatter.string(fromByteCount: byteCount, countStyle: .file))"
+ }
+
+ private var isPrivateAIInstalled: Bool {
+ PrivateAIIntegrationService.isModelInstalled(self.privateAIModel)
+ }
+
+ private var isPrivateAIAvailable: Bool {
+ PrivateAIProviderPromptFormat.isAvailable(settings: self.settings)
+ }
+
+ private var isPrivateAIBusy: Bool {
+ self.isDownloadingPrivateAI || self.isLoadingPrivateAI || self.isDeletingPrivateAI
+ }
+
+ private var canNavigateOrMutate: Bool {
+ !self.isPrivateAIBusy && !self.isRunning && !self.isRecordingShortcut
+ }
+
+ private var canDeletePrivateAIModel: Bool {
+ self.isPrivateAIInstalled && PrivateAIIntegrationService.canRemoveInstalledModel(self.privateAIModel)
+ }
+
+ private var primaryPrivateAIButtonTitle: String {
+ if self.isDownloadingPrivateAI {
+ return "Downloading"
+ }
+ if self.isLoadingPrivateAI {
+ return "Loading..."
+ }
+ if self.isDeletingPrivateAI {
+ return "Deleting..."
+ }
+ if !self.isPrivateAIInstalled {
+ return "Download"
+ }
+ if self.isPrivateAIAvailable, !self.shouldShowTryout {
+ return "Test FluidVoice"
+ }
+ if self.isPrivateAIAvailable, self.shouldShowTryout {
+ return "Using"
+ }
+ return "Use"
+ }
+
+ private var primaryPrivateAIButtonIcon: String? {
+ if self.isPrivateAIBusy {
+ return nil
+ }
+ if !self.isPrivateAIInstalled {
+ return "arrow.down.circle.fill"
+ }
+ if self.isPrivateAIAvailable, !self.shouldShowTryout {
+ return "sparkles"
+ }
+ if self.isPrivateAIAvailable, self.shouldShowTryout {
+ return "checkmark.circle.fill"
+ }
+ return "bolt.fill"
+ }
+
+ private var isPrimaryPrivateAIButtonEnabled: Bool {
+ self.canNavigateOrMutate && !(self.isPrivateAIAvailable && self.shouldShowTryout)
+ }
+
+ private var canFinishSetup: Bool {
+ self.shouldShowTryout &&
+ self.isTestReady &&
+ !self.isRunning &&
+ !self.isRecordingShortcut &&
+ !self.isPrivateAIBusy
+ }
+
+ private var privateAISetupStatusText: String? {
+ guard self.isDownloadingPrivateAI else { return nil }
+ return PrivateAIModelDownloadProgressText.statusText(for: self.privateAISetupProgress)
+ }
+
+ private var privateAIDownloadByteText: String? {
+ PrivateAIModelDownloadProgressText.byteText(for: self.privateAISetupProgress)
+ }
+
+ private var trimmedFinalText: String {
+ self.finalText.trimmingCharacters(in: .whitespacesAndNewlines)
+ }
+
+ private var sectionTransition: AnyTransition {
+ if self.reduceMotion {
+ return .opacity
+ }
+ return .asymmetric(
+ insertion: .opacity.combined(with: .scale(scale: 0.992, anchor: .center)),
+ removal: .opacity.combined(with: .scale(scale: 1.006, anchor: .center))
+ )
+ }
+
+ var body: some View {
+ GeometryReader { proxy in
+ ZStack {
+ FluidOnboardingLandingBackdrop(glowCenter: self.glowCenter)
+
+ ScrollViewReader { scrollProxy in
+ VStack(spacing: 0) {
+ FluidOnboardingCompactProgress(value: self.progressValue)
+ .padding(.top, 28)
+
+ ScrollView(.vertical, showsIndicators: true) {
+ VStack(spacing: 0) {
+ Color.clear
+ .frame(height: 22)
+ .id(Self.ScrollTarget.top)
+
+ self.introSection(scrollProxy: scrollProxy, containerWidth: proxy.size.width)
+ }
+ .frame(maxWidth: .infinity)
+ }
+
+ self.footer
+ }
+ .frame(width: proxy.size.width, height: proxy.size.height)
+ .onAppear {
+ self.prepareExistingPrivateAIStateIfNeeded()
+ }
+ .onDisappear {
+ self.cancelPrivateAIAction()
+ }
+ .onChange(of: self.finalText) { _, newValue in
+ self.captureCurrentExampleOutput(newValue)
+ }
+ .onChange(of: self.isRunning) { _, isRunning in
+ if isRunning {
+ self.activeRecordingExampleID = self.selectedExampleID
+ }
+ }
+ }
+
+ FluidOnboardingLandingHoverTracker(
+ onMove: self.onGlowMove,
+ onExit: self.onGlowExit
+ )
+ .frame(width: proxy.size.width, height: proxy.size.height)
+ .accessibilityHidden(true)
+ }
+ }
+ }
+
+ private func introSection(scrollProxy: ScrollViewProxy, containerWidth: CGFloat) -> some View {
+ Group {
+ if self.shouldShowTryout {
+ self.playgroundSection(containerWidth: containerWidth)
+ .transition(self.sectionTransition)
+ } else {
+ self.setupSection(scrollProxy: scrollProxy, containerWidth: containerWidth)
+ .transition(self.sectionTransition)
+ }
+ }
+ .animation(self.reduceMotion ? nil : .easeInOut(duration: 0.28), value: self.shouldShowTryout)
+ .frame(maxWidth: .infinity)
+ }
+
+ private func setupSection(scrollProxy: ScrollViewProxy, containerWidth: CGFloat) -> some View {
+ VStack(spacing: 0) {
+ VStack(spacing: 0) {
+ FluidOnboardingCompactAppIconMark(size: 52)
+ .padding(.bottom, 18)
+
+ Text("One more thing...")
+ .font(.system(size: 32, weight: .semibold))
+ .foregroundStyle(.white)
+ .multilineTextAlignment(.center)
+ .lineLimit(1)
+ .minimumScaleFactor(0.74)
+ .padding(.horizontal, 32)
+ .padding(.bottom, 10)
+
+ Text("FluidVoice can polish your raw dictation unlike other apps out there, locally, for free.")
+ .font(.system(size: 15, weight: .medium))
+ .foregroundStyle(Color.white.opacity(0.64))
+ .multilineTextAlignment(.center)
+ .lineLimit(2)
+ .minimumScaleFactor(0.82)
+ .frame(maxWidth: 700)
+ .padding(.horizontal, 32)
+ }
+ .frame(height: ExampleGridMetrics.heroHeight, alignment: .top)
+ .padding(.bottom, 20)
+
+ self.examplesPanel
+ .frame(width: self.exampleGridWidth(containerWidth: containerWidth))
+ .padding(.bottom, 18)
+
+ Text("Want FluidVoice to polish your dictation?")
+ .font(.system(size: 17, weight: .semibold))
+ .foregroundStyle(.white.opacity(0.92))
+ .padding(.bottom, 12)
+
+ self.fluidIntelligenceCard(scrollProxy: scrollProxy)
+ .frame(width: min(containerWidth - 92, 840))
+ .padding(.bottom, 12)
+
+ Text(self.shouldShowTryout ? "Try it below before finishing setup." : "You can change this later in AI Enhancement settings.")
+ .font(.system(size: 12, weight: .medium))
+ .foregroundStyle(Color.white.opacity(0.46))
+ }
+ .frame(maxWidth: .infinity)
+ }
+
+ private func playgroundSection(containerWidth: CGFloat) -> some View {
+ VStack(spacing: 0) {
+ VStack(spacing: 0) {
+ FluidOnboardingCompactAppIconMark(size: 52)
+ .padding(.bottom, 18)
+
+ VStack(spacing: 8) {
+ Text("Let's polish your text.")
+ .font(.system(size: 32, weight: .semibold))
+ .foregroundStyle(.white)
+ .multilineTextAlignment(.center)
+ .lineLimit(1)
+ .minimumScaleFactor(0.74)
+
+ Text("Choose an example, press \(self.shortcutDisplay), then dictate it naturally.")
+ .font(.system(size: 15, weight: .medium))
+ .foregroundStyle(Color.white.opacity(0.62))
+ .multilineTextAlignment(.center)
+ .lineLimit(2)
+ .minimumScaleFactor(0.82)
+ }
+ .padding(.horizontal, 32)
+ }
+ .frame(height: ExampleGridMetrics.heroHeight, alignment: .top)
+ .padding(.bottom, 22)
+
+ self.playgroundExamplesPanel
+ .frame(width: self.exampleGridWidth(containerWidth: containerWidth))
+ .padding(.bottom, 12)
+
+ Text(self.isTestReady ? "Looks good. Finish setup when you're ready." : "The polished result will appear on the selected row.")
+ .font(.system(size: 12, weight: .medium))
+ .foregroundStyle(Color.white.opacity(0.46))
+ .multilineTextAlignment(.center)
+ .lineLimit(1)
+ .minimumScaleFactor(0.82)
+ }
+ .frame(maxWidth: .infinity)
+ }
+
+ private func exampleGridWidth(containerWidth: CGFloat) -> CGFloat {
+ min(max(containerWidth - ExampleGridMetrics.widthInset, 360), ExampleGridMetrics.maxWidth)
+ }
+
+ private func exampleGridHeader(leftTitle: String, rightTitle: String) -> some View {
+ HStack(spacing: ExampleGridMetrics.columnSpacing) {
+ Text(leftTitle)
+ .font(.system(size: 11, weight: .semibold))
+ .foregroundStyle(Color.white.opacity(0.48))
+ .frame(maxWidth: .infinity, alignment: .center)
+
+ Color.clear
+ .frame(width: ExampleGridMetrics.arrowSize, height: 1)
+
+ Text(rightTitle)
+ .font(.system(size: 11, weight: .semibold))
+ .foregroundStyle(FluidOnboardingLandingColors.blue.opacity(0.84))
+ .frame(maxWidth: .infinity, alignment: .center)
+ }
+ .padding(.leading, ExampleGridMetrics.headerLeadingInset)
+ }
+
+ private var examplesPanel: some View {
+ VStack(spacing: ExampleGridMetrics.rowSpacing) {
+ self.exampleGridHeader(leftTitle: "Raw dictation (before)", rightTitle: "Polished (after)")
+
+ ForEach(Self.examples) { example in
+ self.exampleRow(example)
+ }
+ }
+ }
+
+ private func exampleRow(_ example: EnhancementExample) -> some View {
+ HStack(alignment: .center, spacing: ExampleGridMetrics.columnSpacing) {
+ HStack(spacing: ExampleGridMetrics.columnSpacing) {
+ Image(systemName: "mic.fill")
+ .font(.system(size: 14, weight: .semibold))
+ .foregroundStyle(FluidOnboardingLandingColors.blue)
+ .frame(width: ExampleGridMetrics.iconSize, height: ExampleGridMetrics.iconSize)
+ .background(
+ Circle()
+ .fill(FluidOnboardingLandingColors.blue.opacity(0.12))
+ .overlay(
+ Circle()
+ .stroke(FluidOnboardingLandingColors.blue.opacity(0.22), lineWidth: 1)
+ )
+ )
+
+ Text(example.raw)
+ .font(.system(size: 12, weight: .medium))
+ .foregroundStyle(Color.white.opacity(0.52))
+ .lineLimit(4)
+ .minimumScaleFactor(0.80)
+ .frame(maxWidth: .infinity, alignment: .leading)
+ .padding(.horizontal, 13)
+ .padding(.vertical, 10)
+ .frame(height: ExampleGridMetrics.innerTextHeight, alignment: .center)
+ .background(
+ RoundedRectangle(cornerRadius: ExampleGridMetrics.innerCornerRadius, style: .continuous)
+ .fill(Color.white.opacity(0.040))
+ )
+ }
+ .padding(.horizontal, 9)
+ .padding(.vertical, 7)
+ .frame(height: ExampleGridMetrics.rowHeight)
+ .frame(maxWidth: .infinity)
+ .background(
+ RoundedRectangle(cornerRadius: ExampleGridMetrics.rawCornerRadius, style: .continuous)
+ .fill(Color.white.opacity(0.038))
+ .overlay(
+ RoundedRectangle(cornerRadius: ExampleGridMetrics.rawCornerRadius, style: .continuous)
+ .stroke(Color.white.opacity(0.070), lineWidth: 1)
+ )
+ )
+ .matchedGeometryEffect(
+ id: "example-raw-\(example.id)",
+ in: self.exampleMorphNamespace,
+ properties: .frame,
+ isSource: !self.shouldShowTryout
+ )
+
+ Image(systemName: "arrow.right")
+ .font(.system(size: 13, weight: .bold))
+ .foregroundStyle(.white.opacity(0.80))
+ .frame(width: ExampleGridMetrics.arrowSize, height: ExampleGridMetrics.arrowSize)
+ .background(
+ Circle()
+ .fill(Color.white.opacity(0.065))
+ .overlay(
+ Circle()
+ .stroke(Color.white.opacity(0.10), lineWidth: 1)
+ )
+ )
+ .matchedGeometryEffect(
+ id: "example-arrow-\(example.id)",
+ in: self.exampleMorphNamespace,
+ properties: .frame,
+ isSource: !self.shouldShowTryout
+ )
+
+ self.polishedExampleSurface(example)
+ .matchedGeometryEffect(
+ id: "example-output-\(example.id)",
+ in: self.exampleMorphNamespace,
+ properties: .frame,
+ isSource: !self.shouldShowTryout
+ )
+ }
+ }
+
+ private var playgroundExamplesPanel: some View {
+ VStack(spacing: ExampleGridMetrics.rowSpacing) {
+ self.exampleGridHeader(leftTitle: "Try saying this", rightTitle: "Fluid Intelligence output")
+
+ ForEach(Self.examples) { example in
+ self.playgroundExampleRow(example)
+ }
+ }
+ }
+
+ private func polishedExampleSurface(_ example: EnhancementExample) -> some View {
+ let shape = RoundedRectangle(cornerRadius: ExampleGridMetrics.rawCornerRadius, style: .continuous)
+
+ return ZStack(alignment: .topLeading) {
+ Text(example.polished)
+ .font(.system(size: 12, weight: .semibold))
+ .foregroundStyle(Color.white.opacity(0.84))
+ .lineLimit(5)
+ .minimumScaleFactor(0.80)
+ .padding(.horizontal, 16)
+ .padding(.vertical, 12)
+ }
+ .frame(height: ExampleGridMetrics.rowHeight, alignment: .topLeading)
+ .frame(maxWidth: .infinity, alignment: .topLeading)
+ .background(
+ shape
+ .fill(FluidOnboardingLandingColors.blue.opacity(0.060))
+ .overlay(
+ shape.stroke(FluidOnboardingLandingColors.blue.opacity(0.42), lineWidth: 1.2)
+ )
+ )
+ }
+
+ private func playgroundExampleRow(_ example: EnhancementExample) -> some View {
+ let isSelected = example.id == self.selectedExampleID
+ let outputText = self.playgroundOutputs[example.id] ?? ""
+ let hasOutput = !outputText.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty
+ let isListening = self.activeRecordingExampleID == example.id && self.isRunning
+ let rawShape = RoundedRectangle(cornerRadius: 14, style: .continuous)
+ let outputShape = RoundedRectangle(cornerRadius: 14, style: .continuous)
+
+ return HStack(alignment: .center, spacing: ExampleGridMetrics.columnSpacing) {
+ Button {
+ self.selectExample(example)
+ } label: {
+ HStack(spacing: ExampleGridMetrics.columnSpacing) {
+ Image(systemName: isSelected ? "mic.circle.fill" : "mic.fill")
+ .font(.system(size: 17, weight: .semibold))
+ .foregroundStyle(FluidOnboardingLandingColors.blue)
+ .frame(width: ExampleGridMetrics.iconSize, height: ExampleGridMetrics.iconSize)
+ .background(
+ Circle()
+ .fill(FluidOnboardingLandingColors.blue.opacity(isSelected ? 0.22 : 0.12))
+ .overlay(
+ Circle()
+ .stroke(FluidOnboardingLandingColors.blue.opacity(isSelected ? 0.48 : 0.22), lineWidth: 1)
+ )
+ )
+
+ Text(example.raw)
+ .font(.system(size: 12, weight: .medium))
+ .foregroundStyle(Color.white.opacity(isSelected ? 0.76 : 0.52))
+ .lineLimit(4)
+ .minimumScaleFactor(0.80)
+ .frame(maxWidth: .infinity, alignment: .leading)
+ .padding(.horizontal, 13)
+ .padding(.vertical, 10)
+ .frame(height: ExampleGridMetrics.innerTextHeight, alignment: .center)
+ .background(
+ RoundedRectangle(cornerRadius: ExampleGridMetrics.innerCornerRadius, style: .continuous)
+ .fill(Color.white.opacity(isSelected ? 0.062 : 0.040))
+ )
+ }
+ .padding(.horizontal, 9)
+ .padding(.vertical, 7)
+ .frame(height: ExampleGridMetrics.rowHeight)
+ .frame(maxWidth: .infinity)
+ .background(
+ rawShape
+ .fill(Color.white.opacity(isSelected ? 0.054 : 0.038))
+ .overlay(
+ rawShape
+ .stroke(isSelected ? FluidOnboardingLandingColors.blue.opacity(0.48) : Color.white.opacity(0.070), lineWidth: isSelected ? 1.2 : 1)
+ )
+ .shadow(color: FluidOnboardingLandingColors.blue.opacity(isSelected ? 0.13 : 0), radius: 13, x: 0, y: 4)
+ )
+ .contentShape(rawShape)
+ }
+ .matchedGeometryEffect(
+ id: "example-raw-\(example.id)",
+ in: self.exampleMorphNamespace,
+ properties: .frame,
+ isSource: self.shouldShowTryout
+ )
+ .buttonStyle(.plain)
+ .focusable(false)
+ .contentShape(rawShape)
+ .disabled(self.isPrivateAIBusy)
+
+ Image(systemName: isSelected && self.isRunning ? "waveform" : "arrow.right")
+ .font(.system(size: 13, weight: .bold))
+ .foregroundStyle(.white.opacity(0.80))
+ .frame(width: ExampleGridMetrics.arrowSize, height: ExampleGridMetrics.arrowSize)
+ .background(
+ Circle()
+ .fill(isListening ? FluidOnboardingLandingColors.blue.opacity(0.22) : Color.white.opacity(isSelected ? 0.10 : 0.065))
+ .overlay(
+ Circle()
+ .stroke(isSelected ? FluidOnboardingLandingColors.blue.opacity(0.28) : Color.white.opacity(0.10), lineWidth: 1)
+ )
+ .shadow(color: FluidOnboardingLandingColors.blue.opacity(isListening ? 0.30 : 0), radius: 12, x: 0, y: 0)
+ )
+ .matchedGeometryEffect(
+ id: "example-arrow-\(example.id)",
+ in: self.exampleMorphNamespace,
+ properties: .frame,
+ isSource: self.shouldShowTryout
+ )
+
+ ZStack(alignment: .topLeading) {
+ if hasOutput {
+ Text(outputText)
+ .font(.system(size: 12, weight: .semibold))
+ .foregroundStyle(Color.white.opacity(0.86))
+ .lineLimit(5)
+ .minimumScaleFactor(0.80)
+ .padding(.leading, 16)
+ .padding(.trailing, 42)
+ .padding(.vertical, 12)
+ } else if isListening {
+ HStack(spacing: 8) {
+ Image(systemName: "waveform")
+ .font(.system(size: 12, weight: .bold))
+ .foregroundStyle(FluidOnboardingLandingColors.blue)
+
+ Text("Listening...")
+ .font(.system(size: 12, weight: .semibold))
+ .foregroundStyle(Color.white.opacity(0.74))
+ }
+ .padding(.horizontal, 16)
+ .padding(.vertical, 14)
+ } else if isSelected {
+ VStack(alignment: .leading, spacing: 4) {
+ Text("Dictate here.")
+ .font(.system(size: 12, weight: .semibold))
+ .foregroundStyle(Color.white.opacity(0.36))
+ .lineLimit(1)
+ .minimumScaleFactor(0.82)
+
+ Text("Press \(self.shortcutDisplay) and speak this example.")
+ .font(.system(size: 10, weight: .medium))
+ .foregroundStyle(Color.white.opacity(0.28))
+ .lineLimit(1)
+ .minimumScaleFactor(0.78)
+ }
+ .padding(.horizontal, 16)
+ .padding(.vertical, 12)
+ }
+
+ if hasOutput {
+ Button {
+ self.clearExampleOutput(example)
+ } label: {
+ Image(systemName: "xmark.circle.fill")
+ .font(.system(size: 14, weight: .semibold))
+ .foregroundStyle(Color.white.opacity(0.42))
+ .frame(width: 28, height: 28)
+ }
+ .buttonStyle(.plain)
+ .focusable(false)
+ .contentShape(Circle())
+ .padding(.top, 5)
+ .padding(.trailing, 6)
+ .frame(maxWidth: .infinity, alignment: .topTrailing)
+ }
+ }
+ .frame(height: ExampleGridMetrics.rowHeight, alignment: .topLeading)
+ .frame(maxWidth: .infinity, alignment: .topLeading)
+ .background(
+ outputShape
+ .fill(FluidOnboardingLandingColors.blue.opacity(isListening ? 0.105 : (isSelected ? 0.072 : 0.040)))
+ .overlay(
+ outputShape
+ .stroke(FluidOnboardingLandingColors.blue.opacity(isListening ? 0.72 : (isSelected ? 0.54 : 0.22)), lineWidth: isSelected ? 1.3 : 1)
+ )
+ .shadow(color: FluidOnboardingLandingColors.blue.opacity(isListening ? 0.24 : (isSelected ? 0.16 : 0.04)), radius: isSelected ? 14 : 8, x: 0, y: 5)
+ )
+ .contentShape(outputShape)
+ .onTapGesture {
+ self.selectExample(example)
+ }
+ .matchedGeometryEffect(
+ id: "example-output-\(example.id)",
+ in: self.exampleMorphNamespace,
+ properties: .frame,
+ isSource: self.shouldShowTryout
+ )
+ }
+ .accessibilityElement(children: .combine)
+ .accessibilityLabel("Try example. \(example.raw)")
+ }
+
+ private func fluidIntelligenceCard(scrollProxy: ScrollViewProxy) -> some View {
+ let shape = RoundedRectangle(cornerRadius: 18, style: .continuous)
+ let isHovered = self.hoveredButtonID == "fluid-intelligence" && self.canNavigateOrMutate
+
+ return VStack(alignment: .leading, spacing: 12) {
+ HStack(alignment: .top, spacing: 18) {
+ VStack(alignment: .leading, spacing: 10) {
+ HStack(spacing: 8) {
+ Text(self.fluidIntelligenceName)
+ .font(.system(size: 22, weight: .semibold))
+ .foregroundStyle(.white)
+ .lineLimit(1)
+ .minimumScaleFactor(0.78)
+
+ Text("Experimental")
+ .font(.system(size: 10, weight: .bold))
+ .foregroundStyle(Color(red: 1.0, green: 0.72, blue: 0.26))
+ .padding(.horizontal, 8)
+ .padding(.vertical, 3)
+ .background(
+ Capsule()
+ .fill(Color(red: 1.0, green: 0.72, blue: 0.26).opacity(0.14))
+ )
+ }
+
+ Text("Powered by \(self.privateAIModelDisplayName)")
+ .font(.system(size: 11, weight: .semibold))
+ .foregroundStyle(Color.white.opacity(0.42))
+ .lineLimit(1)
+
+ Label("Trained on 100K+ dictation data points to polish your words.", systemImage: "sparkles")
+ .font(.system(size: 12, weight: .semibold))
+ .foregroundStyle(Color.white.opacity(0.74))
+ .lineLimit(1)
+ .minimumScaleFactor(0.78)
+ }
+
+ Spacer(minLength: 12)
+
+ HStack(spacing: 10) {
+ if self.isPrimaryPrivateAIButtonEnabled {
+ self.primaryPrivateAIButton(scrollProxy: scrollProxy)
+ .keyboardShortcut(.defaultAction)
+ } else {
+ self.primaryPrivateAIButton(scrollProxy: scrollProxy)
+ }
+
+ if self.canDeletePrivateAIModel {
+ self.pillButton(
+ PillButtonConfiguration(
+ id: "fluid-intelligence-delete",
+ title: "Delete",
+ systemImage: "trash.fill",
+ tone: .destructive,
+ width: 112,
+ height: 40,
+ fontSize: 13,
+ isEnabled: self.canNavigateOrMutate
+ ),
+ action: self.deletePrivateAIModel
+ )
+ }
+ }
+ }
+
+ HStack(spacing: 13) {
+ self.modelFact("lock.fill", "Runs locally. No API key.")
+ self.modelFact("internaldrive", "Download size \(self.privateAIModelSizeText)")
+ self.modelFact("timer", "May be slower on older Macs.")
+ }
+
+ if self.isDownloadingPrivateAI {
+ self.privateAIDownloadProgressView
+ }
+
+ if let message = self.privateAISetupErrorMessage {
+ Text(message)
+ .font(.system(size: 11, weight: .semibold))
+ .foregroundStyle(Color.red.opacity(0.82))
+ .lineLimit(1)
+ .minimumScaleFactor(0.74)
+ }
+ }
+ .padding(.horizontal, 18)
+ .padding(.vertical, 16)
+ .background(
+ shape
+ .fill(Color.white.opacity(isHovered ? 0.070 : 0.052))
+ .overlay(shape.stroke(FluidOnboardingLandingColors.blue.opacity(isHovered ? 0.42 : 0.26), lineWidth: 1))
+ .shadow(color: FluidOnboardingLandingColors.blue.opacity(isHovered ? 0.18 : 0.08), radius: isHovered ? 18 : 10, x: 0, y: 5)
+ )
+ .onHover { isHovered in
+ self.setHoveredButton(isHovered ? "fluid-intelligence" : nil)
+ }
+ }
+
+ private var privateAIDownloadProgressView: some View {
+ VStack(alignment: .leading, spacing: 7) {
+ HStack(spacing: 8) {
+ Text(self.privateAISetupStatusText ?? "Downloading. This can take a few minutes.")
+ .font(.system(size: 11, weight: .semibold))
+ .foregroundStyle(Color.white.opacity(0.66))
+ .lineLimit(1)
+ .minimumScaleFactor(0.78)
+
+ Spacer(minLength: 8)
+
+ if let byteText = self.privateAIDownloadByteText {
+ Text(byteText)
+ .font(.system(size: 10, weight: .semibold))
+ .foregroundStyle(Color.white.opacity(0.42))
+ .lineLimit(1)
+ .minimumScaleFactor(0.74)
+ }
+ }
+
+ if let fraction = self.privateAISetupProgress?.fractionCompleted {
+ ProgressView(value: fraction)
+ .progressViewStyle(.linear)
+ .tint(FluidOnboardingLandingColors.blue)
+ .frame(height: 4)
+ } else {
+ ProgressView()
+ .controlSize(.small)
+ .tint(FluidOnboardingLandingColors.blue)
+ }
+ }
+ .padding(.top, 2)
+ .transition(self.reduceMotion ? .opacity : .opacity.combined(with: .move(edge: .top)))
+ }
+
+ private func primaryPrivateAIButton(scrollProxy: ScrollViewProxy) -> some View {
+ self.pillButton(
+ PillButtonConfiguration(
+ id: "fluid-intelligence",
+ title: self.primaryPrivateAIButtonTitle,
+ systemImage: self.primaryPrivateAIButtonIcon,
+ tone: .primary,
+ width: 150,
+ height: 40,
+ fontSize: 13,
+ isEnabled: self.isPrimaryPrivateAIButtonEnabled
+ ),
+ action: {
+ self.handlePrivateAIPrimaryAction(scrollProxy: scrollProxy)
+ }
+ )
+ }
+
+ private func modelFact(_ systemImage: String, _ text: String) -> some View {
+ HStack(spacing: 6) {
+ Image(systemName: systemImage)
+ .font(.system(size: 11, weight: .bold))
+ .foregroundStyle(FluidOnboardingLandingColors.blue.opacity(0.86))
+
+ Text(text)
+ .font(.system(size: 12, weight: .medium))
+ .foregroundStyle(Color.white.opacity(0.58))
+ .lineLimit(1)
+ .minimumScaleFactor(0.76)
+ }
+ }
+
+ private var footer: some View {
+ HStack {
+ self.pillButton(
+ PillButtonConfiguration(
+ id: "back",
+ title: "Back",
+ systemImage: nil,
+ tone: .secondary,
+ width: 132,
+ height: 48,
+ fontSize: 16,
+ isEnabled: self.canNavigateOrMutate
+ ),
+ action: {
+ self.cancelPrivateAIAction()
+ self.onBack()
+ }
+ )
+ .keyboardShortcut(.cancelAction)
+
+ Spacer()
+
+ if self.shouldShowTryout {
+ self.finishButton
+ .keyboardShortcut(.defaultAction)
+ } else {
+ HStack(spacing: 12) {
+ self.providerChoiceButton
+
+ self.skipButton
+ }
+ }
+ }
+ .padding(.horizontal, 30)
+ .padding(.bottom, 24)
+ }
+
+ private var providerChoiceButton: some View {
+ self.pillButton(
+ PillButtonConfiguration(
+ id: "ai-provider",
+ title: "Use my own AI provider",
+ systemImage: "arrow.up.right",
+ tone: .secondary,
+ width: 280,
+ height: 48,
+ fontSize: 15,
+ isEnabled: self.canNavigateOrMutate
+ ),
+ action: {
+ self.cancelPrivateAIAction()
+ self.onUseAIProvider()
+ }
+ )
+ }
+
+ private var skipButton: some View {
+ self.pillButton(
+ PillButtonConfiguration(
+ id: "ai-skip",
+ title: "Skip for now",
+ systemImage: nil,
+ tone: .secondary,
+ width: 132,
+ height: 48,
+ fontSize: 16,
+ isEnabled: self.canNavigateOrMutate
+ ),
+ action: {
+ self.cancelPrivateAIAction()
+ self.onSkip()
+ }
+ )
+ }
+
+ private var finishButton: some View {
+ self.pillButton(
+ PillButtonConfiguration(
+ id: "ai-finish",
+ title: "Finish setup",
+ systemImage: "checkmark",
+ tone: .primary,
+ width: 164,
+ height: 48,
+ fontSize: 16,
+ isEnabled: self.canFinishSetup
+ ),
+ action: {
+ self.cancelPrivateAIAction()
+ self.onFinishSetup()
+ }
+ )
+ }
+
+ private func pillButton(
+ _ configuration: PillButtonConfiguration,
+ action: @escaping () -> Void
+ ) -> some View {
+ let isDisabled = !configuration.isEnabled
+ let isHovered = self.hoveredButtonID == configuration.id && !isDisabled
+ let shape = Capsule()
+ let accentColor = configuration.tone == .destructive ? Color.red : FluidOnboardingLandingColors.blue
+ let isPrimary = configuration.tone == .primary
+ let isDestructive = configuration.tone == .destructive
+ let fillColor: Color = {
+ if isPrimary {
+ return accentColor.opacity(isDisabled ? 0.34 : 1)
+ }
+ if isDestructive {
+ return Color.red.opacity(isDisabled ? 0.045 : (isHovered ? 0.24 : 0.16))
+ }
+ return Color.white.opacity(isDisabled ? 0.045 : (isHovered ? 0.11 : 0.07))
+ }()
+ let borderColor: Color = {
+ if isPrimary {
+ return Color.white.opacity(isHovered ? 0.30 : 0)
+ }
+ if isDestructive {
+ return Color.red.opacity(isHovered ? 0.48 : 0.24)
+ }
+ return isHovered ? accentColor.opacity(0.30) : Color.white.opacity(0.07)
+ }()
+ let foregroundOpacity = isDisabled ? 0.42 : (isPrimary ? 1.0 : (isHovered ? 0.94 : 0.78))
+ let shadowOpacity = isDisabled ? 0 : (isPrimary ? (isHovered ? 0.56 : 0.26) : (isHovered ? 0.12 : 0))
+
+ return Button(action: action) {
+ HStack(spacing: configuration.systemImage == nil ? 0 : 8) {
+ if let systemImage = configuration.systemImage {
+ Image(systemName: systemImage)
+ .font(.system(size: 12, weight: .bold))
+ }
+
+ Text(configuration.title)
+ .font(.system(size: configuration.fontSize, weight: .semibold))
+ .lineLimit(1)
+ .minimumScaleFactor(0.72)
+ }
+ .foregroundStyle(.white.opacity(foregroundOpacity))
+ .frame(width: configuration.width, height: configuration.height)
+ .background(
+ shape
+ .fill(fillColor)
+ .overlay(shape.fill(Color.white.opacity(isPrimary && isHovered ? 0.10 : 0)))
+ .overlay(shape.stroke(borderColor, lineWidth: isHovered ? 1.2 : 1))
+ .overlay(
+ shape
+ .stroke(accentColor.opacity(isHovered ? 0.50 : 0), lineWidth: isHovered ? 1.4 : 1)
+ .padding(-2)
+ )
+ .shadow(color: accentColor.opacity(shadowOpacity), radius: isHovered ? 16 : 9, x: 0, y: isHovered ? 6 : 3)
+ )
+ .contentShape(shape)
+ }
+ .buttonStyle(.plain)
+ .focusable(false)
+ .contentShape(shape)
+ .disabled(isDisabled)
+ .onHover { isHovered in
+ self.setHoveredButton(isHovered && !isDisabled ? configuration.id : nil)
+ }
+ }
+
+ private func setHoveredButton(_ buttonID: String?) {
+ guard self.hoveredButtonID != buttonID else { return }
+ if self.reduceMotion {
+ self.hoveredButtonID = buttonID
+ } else {
+ withAnimation(.easeOut(duration: 0.14)) {
+ self.hoveredButtonID = buttonID
+ }
+ }
+ }
+
+ private func selectExample(_ example: EnhancementExample) {
+ guard !self.isRunning else { return }
+ guard self.selectedExampleID != example.id else { return }
+ self.selectedExampleID = example.id
+ }
+
+ private func captureCurrentExampleOutput(_ text: String) {
+ guard self.shouldShowTryout else { return }
+
+ let trimmedText = text.trimmingCharacters(in: .whitespacesAndNewlines)
+ guard !trimmedText.isEmpty else { return }
+
+ let targetExampleID = self.activeRecordingExampleID ?? self.selectedExampleID
+ self.playgroundOutputs[targetExampleID] = text
+ self.selectedExampleID = targetExampleID
+ self.activeRecordingExampleID = nil
+ self.settings.onboardingPlaygroundValidated = true
+ self.settings.playgroundUsed = true
+ }
+
+ private func clearExampleOutput(_ example: EnhancementExample) {
+ self.playgroundOutputs.removeValue(forKey: example.id)
+
+ if self.selectedExampleID == example.id {
+ self.finalText = ""
+ }
+
+ if !self.hasAnyPlaygroundOutput {
+ self.settings.onboardingPlaygroundValidated = false
+ self.settings.playgroundUsed = false
+ }
+ }
+
+ private var hasAnyPlaygroundOutput: Bool {
+ self.playgroundOutputs.values.contains { output in
+ !output.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty
+ }
+ }
+
+ private func handlePrivateAIPrimaryAction(scrollProxy: ScrollViewProxy) {
+ guard self.canNavigateOrMutate else { return }
+
+ guard PrivateFeatures.privateAIProvider,
+ !self.privateAIModel.id.isEmpty
+ else {
+ self.onUseAIProvider()
+ return
+ }
+
+ if self.isPrivateAIInstalled {
+ self.activatePrivateAI(scrollProxy: scrollProxy)
+ } else {
+ self.downloadPrivateAIModel()
+ }
+ }
+
+ private func prepareExistingPrivateAIStateIfNeeded() {
+ guard self.isPrivateAIAvailable else {
+ self.shouldShowTryout = false
+ return
+ }
+
+ guard !self.hasPreparedExistingPrivateAI else { return }
+ self.hasPreparedExistingPrivateAI = true
+ self.shouldShowTryout = false
+ }
+
+ private func downloadPrivateAIModel() {
+ guard self.canNavigateOrMutate else { return }
+ guard self.privateAIModel.canDownload else {
+ self.privateAISetupErrorMessage = "Download is not available for this build."
+ return
+ }
+
+ let model = self.privateAIModel
+ let actionID = self.beginPrivateAIAction()
+ self.privateAISetupErrorMessage = nil
+ self.privateAISetupProgress = nil
+ self.isDownloadingPrivateAI = true
+
+ self.privateAIActionTask = Task { @MainActor in
+ do {
+ _ = try await PrivateAIIntegrationService.prepareModel(model) { progress in
+ await MainActor.run {
+ guard self.privateAIActionID == actionID else { return }
+ self.privateAISetupProgress = progress
+ }
+ }
+ guard self.privateAIActionID == actionID, !Task.isCancelled else { return }
+
+ self.privateAISetupProgress = nil
+ self.isDownloadingPrivateAI = false
+ } catch is CancellationError {
+ guard self.privateAIActionID == actionID else { return }
+ self.privateAISetupProgress = nil
+ self.isDownloadingPrivateAI = false
+ } catch {
+ guard self.privateAIActionID == actionID else { return }
+ self.privateAISetupErrorMessage = Self.errorMessage(for: error)
+ self.privateAISetupProgress = nil
+ self.isDownloadingPrivateAI = false
+ }
+ if self.privateAIActionID == actionID {
+ self.privateAIActionTask = nil
+ }
+ }
+ }
+
+ private func activatePrivateAI(scrollProxy: ScrollViewProxy) {
+ guard self.canNavigateOrMutate else { return }
+
+ let model = self.privateAIModel
+ let actionID = self.beginPrivateAIAction()
+ self.privateAISetupErrorMessage = nil
+ self.privateAISetupProgress = nil
+ self.resetAITryoutDraft()
+ self.isLoadingPrivateAI = true
+
+ self.privateAIActionTask = Task { @MainActor in
+ do {
+ let status = try await PrivateAIIntegrationService.shared.loadModel(model)
+ guard self.privateAIActionID == actionID, !Task.isCancelled else { return }
+
+ guard status.state == .ready else {
+ throw PrivateAISetupError(message: status.message ?? "\(self.privateAIModelDisplayName) did not report ready.")
+ }
+
+ self.persistPrivateAIVerification(model)
+ self.shouldShowTryout = true
+ self.isLoadingPrivateAI = false
+ self.scrollToTop(using: scrollProxy)
+ } catch is CancellationError {
+ guard self.privateAIActionID == actionID else { return }
+ self.isLoadingPrivateAI = false
+ } catch {
+ guard self.privateAIActionID == actionID else { return }
+ self.privateAISetupErrorMessage = Self.errorMessage(for: error)
+ self.isLoadingPrivateAI = false
+ }
+ if self.privateAIActionID == actionID {
+ self.privateAIActionTask = nil
+ }
+ }
+ }
+
+ private func deletePrivateAIModel() {
+ guard self.canNavigateOrMutate, self.canDeletePrivateAIModel else { return }
+
+ let model = self.privateAIModel
+ let actionID = self.beginPrivateAIAction()
+ self.privateAISetupErrorMessage = nil
+ self.privateAISetupProgress = nil
+ self.isDeletingPrivateAI = true
+
+ self.privateAIActionTask = Task { @MainActor in
+ do {
+ try await PrivateAIIntegrationService.shared.unloadAndRemoveInstalledModel(model, reason: "onboarding-delete")
+ guard self.privateAIActionID == actionID, !Task.isCancelled else { return }
+
+ self.clearPrivateAIVerification()
+ self.resetAITryoutDraft()
+ self.shouldShowTryout = false
+ self.isDeletingPrivateAI = false
+ } catch is CancellationError {
+ guard self.privateAIActionID == actionID else { return }
+ self.isDeletingPrivateAI = false
+ } catch {
+ guard self.privateAIActionID == actionID else { return }
+ self.privateAISetupErrorMessage = Self.errorMessage(for: error)
+ self.isDeletingPrivateAI = false
+ }
+ if self.privateAIActionID == actionID {
+ self.privateAIActionTask = nil
+ }
+ }
+ }
+
+ private func persistPrivateAIVerification(_ model: PrivateAIRegisteredModel) {
+ let providerID = PrivateAIProviderFeature.shared.providerID
+ let providerKey = DictationAIPostProcessingGate.providerKey(for: providerID)
+ let modelIDs = PrivateAIModelRegistry.modelIDs()
+
+ var availableModelsByProvider = self.settings.availableModelsByProvider
+ availableModelsByProvider[providerKey] = modelIDs
+ self.settings.availableModelsByProvider = availableModelsByProvider
+
+ var selectedModelByProvider = self.settings.selectedModelByProvider
+ selectedModelByProvider[providerKey] = model.id
+ self.settings.selectedModelByProvider = selectedModelByProvider
+
+ var fingerprints = self.settings.verifiedProviderFingerprints
+ fingerprints[providerKey] = PrivateAIProviderFeature.verificationFingerprint(for: model.id)
+ self.settings.verifiedProviderFingerprints = fingerprints
+
+ self.settings.selectedProviderID = providerID
+ self.settings.setDictationPromptSelection(.privateAI)
+ self.settings.onboardingAISkipped = false
+ UserDefaults.standard.set(model.id, forKey: PrivateAIIntegrationService.selectedModelDefaultsKey)
+ }
+
+ private func clearPrivateAIVerification() {
+ let providerID = PrivateAIProviderFeature.shared.providerID
+ let providerKey = DictationAIPostProcessingGate.providerKey(for: providerID)
+
+ var fingerprints = self.settings.verifiedProviderFingerprints
+ fingerprints.removeValue(forKey: providerKey)
+ self.settings.verifiedProviderFingerprints = fingerprints
+
+ if self.settings.selectedProviderID == providerID {
+ self.settings.selectedProviderID = ""
+ }
+
+ if self.settings.dictationPromptSelection == .privateAI {
+ self.settings.setDictationPromptSelection(.default)
+ }
+
+ var availableModelsByProvider = self.settings.availableModelsByProvider
+ availableModelsByProvider.removeValue(forKey: providerKey)
+ self.settings.availableModelsByProvider = availableModelsByProvider
+
+ var selectedModelByProvider = self.settings.selectedModelByProvider
+ selectedModelByProvider.removeValue(forKey: providerKey)
+ self.settings.selectedModelByProvider = selectedModelByProvider
+
+ self.settings.onboardingAISkipped = false
+ UserDefaults.standard.removeObject(forKey: PrivateAIIntegrationService.selectedModelDefaultsKey)
+ UserDefaults.standard.removeObject(forKey: PrivateAIIntegrationService.localModelPathDefaultsKey)
+ }
+
+ private func resetAITryoutDraft() {
+ self.finalText = ""
+ self.activeRecordingExampleID = nil
+ self.playgroundOutputs.removeAll()
+ }
+
+ private func beginPrivateAIAction() -> UUID {
+ self.privateAIActionTask?.cancel()
+ let actionID = UUID()
+ self.privateAIActionID = actionID
+ return actionID
+ }
+
+ private func cancelPrivateAIAction() {
+ self.privateAIActionTask?.cancel()
+ self.privateAIActionTask = nil
+ self.privateAIActionID = UUID()
+ self.isDownloadingPrivateAI = false
+ self.isLoadingPrivateAI = false
+ self.isDeletingPrivateAI = false
+ self.privateAISetupProgress = nil
+ }
+
+ private func scrollToTop(using proxy: ScrollViewProxy) {
+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.08) {
+ if self.reduceMotion {
+ proxy.scrollTo(Self.ScrollTarget.top, anchor: .top)
+ } else {
+ withAnimation(.easeInOut(duration: 0.34)) {
+ proxy.scrollTo(Self.ScrollTarget.top, anchor: .top)
+ }
+ }
+ }
+ }
+
+ private struct PrivateAISetupError: LocalizedError {
+ let message: String
+
+ var errorDescription: String? {
+ self.message
+ }
+ }
+
+ private static func errorMessage(for error: Error) -> String {
+ if let localizedError = error as? LocalizedError,
+ let description = localizedError.errorDescription
+ {
+ return description
+ }
+ return String(describing: error)
+ }
+}
diff --git a/Sources/Fluid/UI/OnboardingTryoutStepView.swift b/Sources/Fluid/UI/OnboardingTryoutStepView.swift
index 62f19440..ee5f0166 100644
--- a/Sources/Fluid/UI/OnboardingTryoutStepView.swift
+++ b/Sources/Fluid/UI/OnboardingTryoutStepView.swift
@@ -9,6 +9,7 @@ struct OnboardingTryoutStepView: View {
let isRunning: Bool
let isRecordingShortcut: Bool
let shortcutRecordingMessage: String?
+ let footerHint: String?
let onToggleShortcut: () -> Void
@Environment(\.accessibilityReduceMotion) private var reduceMotion
@@ -19,6 +20,28 @@ struct OnboardingTryoutStepView: View {
@State private var isShortcutGlowActive = false
@State private var shortcutAnimationRevision = 0
+ init(
+ finalText: Binding<String>,
+ language: VoiceEngineLanguage,
+ shortcutDisplay: String,
+ isReady: Bool,
+ isRunning: Bool,
+ isRecordingShortcut: Bool,
+ shortcutRecordingMessage: String?,
+ footerHint: String? = nil,
+ onToggleShortcut: @escaping () -> Void
+ ) {
+ self._finalText = finalText
+ self.language = language
+ self.shortcutDisplay = shortcutDisplay
+ self.isReady = isReady
+ self.isRunning = isRunning
+ self.isRecordingShortcut = isRecordingShortcut
+ self.shortcutRecordingMessage = shortcutRecordingMessage
+ self.footerHint = footerHint
+ self.onToggleShortcut = onToggleShortcut
+ }
+
private static let languageExamples: [String: [String]] = [
"ar": [
"ذكرني أن أرسل الملاحظات قبل الخامسة.",
@@ -120,7 +143,7 @@ struct OnboardingTryoutStepView: View {
VStack(spacing: 12) {
self.keyboardCard
- Text("Feels slow or inaccurate? Go back and try another model for \(self.language.displayName).")
+ Text(self.footerHint ?? "Feels slow or inaccurate? Go back and try another model for \(self.language.displayName).")
.font(self.theme.typography.captionStrong)
.foregroundStyle(Color.white.opacity(0.44))
.multilineTextAlignment(.center)
@@ -241,7 +264,6 @@ struct OnboardingTryoutStepView: View {
}
private var editorPanel: some View {
- let shape = RoundedRectangle(cornerRadius: 14, style: .continuous)
let examples = Array(self.exampleTexts.prefix(1))
return VStack(alignment: .leading, spacing: 10) {
diff --git a/Sources/Fluid/UI/WelcomeView.swift b/Sources/Fluid/UI/WelcomeView.swift
index 55b286a5..da089030 100644
--- a/Sources/Fluid/UI/WelcomeView.swift
+++ b/Sources/Fluid/UI/WelcomeView.swift
@@ -584,6 +584,8 @@ struct OnboardingFlowView: View {
let accessibilitySetupInProgress: Bool
let markAISkipped: () -> Void
let finishOnboarding: () -> Void
+ let finishOnboardingAtGettingStarted: () -> Void
+ let openAIEnhancementSettingsFromOnboarding: () -> Void
let openAccessibilitySettings: () -> Void
let restartApp: () -> Void
let menuBarManager: MenuBarManager
@@ -611,6 +613,7 @@ struct OnboardingFlowView: View {
private enum OnboardingFooterButton {
case back
+ case skip
case next
}
@@ -687,15 +690,6 @@ struct OnboardingFlowView: View {
Double(self.step.rawValue + 1) / Double(Step.allCases.count)
}
- private var usesCinematicStep: Bool {
- switch self.step {
- case .landing, .language, .voiceModel, .permissions, .playground:
- return true
- case .aiEnhancement:
- return false
- }
- }
-
private var popularOnboardingLanguages: [VoiceEngineLanguage] {
VoiceEngineLanguageCatalog.popularLanguages()
}
@@ -816,7 +810,7 @@ struct OnboardingFlowView: View {
}
private var isPlaygroundReady: Bool {
- self.settings.onboardingPlaygroundValidated
+ self.settings.onboardingPlaygroundValidated || self.settings.onboardingPlaygroundSkipped
}
private var onboardingShortcutDisplay: String {
@@ -864,17 +858,8 @@ struct OnboardingFlowView: View {
var body: some View {
VStack(spacing: 0) {
- if self.usesCinematicStep {
- self.stepContent
- .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center)
- } else {
- self.header
- Divider()
- self.stepContent
- .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
- Divider()
- self.footer
- }
+ self.stepContent
+ .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center)
}
.background {
ZStack {
@@ -1334,7 +1319,10 @@ struct OnboardingFlowView: View {
private func cinematicFooter(
continueTitle: String,
canContinue: Bool,
- continueAction: @escaping () -> Void
+ continueAction: @escaping () -> Void,
+ skipTitle: String? = nil,
+ canSkip: Bool = false,
+ skipAction: (() -> Void)? = nil
) -> some View {
let canNavigateBack = !self.isModelPreparationInProgress && !self.asr.isRunning && !self.isRecordingAnyShortcut
@@ -1350,6 +1338,16 @@ struct OnboardingFlowView: View {
Spacer()
+ if let skipTitle, let skipAction {
+ self.cinematicFooterButton(
+ title: skipTitle,
+ kind: .skip,
+ isEnabled: canSkip
+ ) {
+ skipAction()
+ }
+ }
+
self.cinematicFooterButton(
title: continueTitle,
kind: .next,
@@ -1682,21 +1680,29 @@ struct OnboardingFlowView: View {
}
private var aiEnhancementStep: some View {
- VStack(alignment: .leading, spacing: 10) {
- HStack(spacing: 8) {
- Image(systemName: self.isAIReady ? "checkmark.circle.fill" : "sparkles")
- .foregroundStyle(self.isAIReady ? self.theme.palette.success : self.theme.palette.accent)
- Text(self.isAIReady
- ? "AI enhancement is ready (or skipped)"
- : "Configure AI enhancement or skip to continue")
- .font(self.theme.typography.bodySmallStrong)
- .foregroundStyle(self.isAIReady ? self.theme.palette.success : .secondary)
- }
- .padding(.horizontal, 24)
- .padding(.top, 16)
-
- AIEnhancementSettingsScreen(menuBarManager: self.menuBarManager, theme: self.theme)
- }
+ OnboardingAIEnhancementStepView(
+ finalText: Binding(
+ get: { self.asr.finalText },
+ set: { self.asr.finalText = $0 }
+ ),
+ progressValue: self.compactProgressValue,
+ glowCenter: self.landingGlowCenter,
+ language: self.selectedOnboardingLanguage,
+ shortcutDisplay: self.onboardingShortcutDisplay,
+ isTestReady: self.isPlaygroundReady,
+ isRunning: self.asr.isRunning,
+ isRecordingShortcut: self.activeShortcutRecordingTarget == .primaryDictation,
+ shortcutRecordingMessage: self.activeShortcutRecordingTarget == .primaryDictation ? self.shortcutRecordingMessage : nil,
+ onGlowMove: self.updateLandingGlow(location:in:),
+ onGlowExit: self.resetLandingGlow,
+ onBack: self.goBack,
+ onSkip: {
+ self.markAISkipped()
+ self.finishOnboardingAtGettingStarted()
+ },
+ onUseAIProvider: self.openAIEnhancementSettingsFromOnboarding,
+ onFinishSetup: self.finishOnboardingAtGettingStarted
+ )
}
private var playgroundStep: some View {
@@ -1749,10 +1755,17 @@ struct OnboardingFlowView: View {
self.cinematicFooter(
continueTitle: "Continue",
- canContinue: self.canContinue
- ) {
- self.handlePrimaryAction()
- }
+ canContinue: self.canContinue,
+ continueAction: {
+ self.handlePrimaryAction()
+ },
+ skipTitle: "Skip",
+ canSkip: !self.asr.isRunning && !self.isRecordingAnyShortcut,
+ skipAction: {
+ self.settings.onboardingPlaygroundSkipped = true
+ self.goNext()
+ }
+ )
}
.frame(width: proxy.size.width, height: proxy.size.height)
@@ -1770,37 +1783,6 @@ struct OnboardingFlowView: View {
}
}
- private var footer: some View {
- let canNavigateBack = !self.isModelPreparationInProgress
-
- return HStack(spacing: 10) {
- if self.step.rawValue > 0 {
- Button("Back") {
- self.goBack()
- }
- .fluidOnboardingSecondaryButton()
- .disabled(!canNavigateBack)
- }
-
- Spacer()
-
- if self.step == .aiEnhancement {
- Button("Skip this step") {
- self.markAISkipped()
- self.finishOnboarding()
- }
- .fluidOnboardingSecondaryButton()
- }
-
- Button(self.primaryButtonTitle) {
- self.handlePrimaryAction()
- }
- .fluidOnboardingProminentButton()
- .disabled(!self.canContinue)
- }
- .padding(20)
- }
-
private var microphoneActionButtonTitle: String {
switch self.asr.micStatus {
case .notDetermined:
@@ -2557,6 +2539,7 @@ struct OnboardingFlowView: View {
private func resetTryoutValidationForSetupChange() {
self.settings.onboardingPlaygroundValidated = false
+ self.settings.onboardingPlaygroundSkipped = false
self.settings.playgroundUsed = false
self.asr.finalText = ""
}