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: refine onboarding and unify dictation modes

altic-dev8e2497c23dd2
diff --git a/Sources/Fluid/ContentView.swift b/Sources/Fluid/ContentView.swift
index d5981ad4..5254350a 100644
--- a/Sources/Fluid/ContentView.swift
+++ b/Sources/Fluid/ContentView.swift
@@ -3497,7 +3497,12 @@ struct ContentView: View {
private func currentDictationOutputRouteForHotkeyStop() -> DictationOutputRoute {
let isDictationMode = self.activeRecordingMode == .dictate || self.activeRecordingMode == .promptMode
- if self.isOnboardingSandboxRouteActive && isDictationMode {
+ if OnboardingDictationOutputPolicy.usesSandbox(
+ onboardingPracticeActive: self.isOnboardingSandboxRouteActive,
+ isDictation: isDictationMode,
+ targetProcessID: NotchContentState.shared.recordingTargetPID,
+ fluidVoiceProcessID: ProcessInfo.processInfo.processIdentifier
+ ) {
return .onboardingSandbox
}
return .normal
diff --git a/Sources/Fluid/Persistence/SettingsStore.swift b/Sources/Fluid/Persistence/SettingsStore.swift
index 8de7aac4..e5c41cc0 100644
--- a/Sources/Fluid/Persistence/SettingsStore.swift
+++ b/Sources/Fluid/Persistence/SettingsStore.swift
@@ -749,25 +749,25 @@ final class SettingsStore: ObservableObject {
func dictationPromptDisplayName(for slot: DictationShortcutSlot, appBundleID: String?) -> String {
switch self.dictationPromptSelection(for: slot) {
case .off:
- return "Off"
+ return "Basic"
case .default:
if let profile = self.resolvedDictationPromptProfile(for: slot, appBundleID: appBundleID) {
let name = profile.name.trimmingCharacters(in: .whitespacesAndNewlines)
return name.isEmpty ? "Untitled" : name
}
- return "Default"
+ return "Smart"
case .privateAI:
if self.isAppDictationPromptBindingActive(for: slot, appBundleID: appBundleID) {
if let profile = self.resolvedDictationPromptProfile(for: slot, appBundleID: appBundleID) {
let name = profile.name.trimmingCharacters(in: .whitespacesAndNewlines)
return name.isEmpty ? "Untitled" : name
}
- return "Default"
+ return "Smart"
}
- return PrivateAIProviderFeature.displayName
+ return "Smart"
case let .profile(promptID):
guard let profile = self.dictationPromptProfiles.first(where: { $0.id == promptID && $0.mode.normalized == .dictate }) else {
- return "Default"
+ return "Smart"
}
let name = profile.name.trimmingCharacters(in: .whitespacesAndNewlines)
return name.isEmpty ? "Untitled" : name
diff --git a/Sources/Fluid/Services/NotchOverlayManager.swift b/Sources/Fluid/Services/NotchOverlayManager.swift
index 740edfee..acbfe099 100644
--- a/Sources/Fluid/Services/NotchOverlayManager.swift
+++ b/Sources/Fluid/Services/NotchOverlayManager.swift
@@ -49,6 +49,23 @@ final class NotchOverlayManager {
EmptyView
>?
private var currentMode: OverlayMode = .dictation
+ private var onboardingOverlayOwner: UUID?
+
+ /// Shows the real controls without starting microphone capture.
+ func beginOnboardingOverlay(owner: UUID) {
+ guard self.onboardingOverlayOwner != owner else { return }
+ self.hideImmediately()
+ self.onboardingOverlayOwner = owner
+ self.show(audioLevelPublisher: Empty<CGFloat, Never>().eraseToAnyPublisher(), mode: .dictation)
+ NotchContentState.shared.showsOnboardingModeHint = true
+ }
+
+ func endOnboardingOverlay(owner: UUID) {
+ guard self.onboardingOverlayOwner == owner else { return }
+ self.onboardingOverlayOwner = nil
+ NotchContentState.shared.showsOnboardingModeHint = false
+ self.hideImmediately()
+ }
/// Store last audio publisher for re-showing during processing
private var lastAudioPublisher: AnyPublisher<CGFloat, Never>?
@@ -150,6 +167,7 @@ final class NotchOverlayManager {
}
func show(audioLevelPublisher: AnyPublisher<CGFloat, Never>, mode: OverlayMode) {
+ NotchContentState.shared.showsOnboardingModeHint = false
self.refreshNotchPresentationPolicy()
Self.overlayBench("show_called mode=\(mode.rawValue) state=\(self.state) commandExpanded=\(self.isCommandOutputExpanded)")
self.cancelInFlightHideForNewPresentation()
@@ -186,7 +204,7 @@ final class NotchOverlayManager {
let targetScreen = OverlayScreenResolver.screenForCurrentPointer()
// Route to bottom overlay if user preference is set
- if SettingsStore.shared.overlayPosition == .bottom {
+ if self.onboardingOverlayOwner != nil || SettingsStore.shared.overlayPosition == .bottom {
Self.overlayBench("show_internal_route target=bottom")
self.showBottomOverlay(audioLevelPublisher: audioLevelPublisher, mode: mode)
return
diff --git a/Sources/Fluid/Services/OnboardingAISetupController+Live.swift b/Sources/Fluid/Services/OnboardingAISetupController+Live.swift
new file mode 100644
index 00000000..b68145ff
--- /dev/null
+++ b/Sources/Fluid/Services/OnboardingAISetupController+Live.swift
@@ -0,0 +1,43 @@
+import Foundation
+
+extension OnboardingAISetupController {
+ static var live: OnboardingAISetupController {
+ OnboardingAISetupController(dependencies: Dependencies(
+ recommend: {
+ guard PrivateFeatures.privateAIProvider else { throw PrivateAIUnavailableError() }
+ let recommendation = await PrivateAIHardwareRecommendation.current()
+ guard let model = PrivateAIModelRegistry.model(id: recommendation.model.rawValue), model.isEnabled else {
+ throw PrivateAIUnavailableError()
+ }
+ let installed = await Task.detached(priority: .utility) {
+ PrivateAIIntegrationService.isModelInstalled(model)
+ }.value
+ guard installed || model.canDownload else { throw PrivateAIUnavailableError() }
+ return Model(id: model.id, name: model.displayName, byteCount: model.artifact.byteCount, installed: installed)
+ },
+ prepare: { model, report in
+ guard let registered = PrivateAIModelRegistry.model(id: model.id) else { throw PrivateAIUnavailableError() }
+ _ = try await PrivateAIIntegrationService.prepareModel(registered) { progress in
+ let progress = progress.withFallbackExpectedBytes(model.byteCount)
+ await report(Progress(
+ fraction: progress.fractionCompleted,
+ status: PrivateAIModelDownloadProgressText.statusText(for: progress),
+ bytes: PrivateAIModelDownloadProgressText.byteText(for: progress)
+ ))
+ }
+ },
+ load: { model in
+ guard let registered = PrivateAIModelRegistry.model(id: model.id) else { throw PrivateAIUnavailableError() }
+ let status = try await PrivateAIIntegrationService.shared.loadModel(registered)
+ guard status.state == .ready else {
+ throw SetupError(message: status.message ?? "The model could not be prepared. Please try again.")
+ }
+ }
+ ))
+ }
+
+ private struct SetupError: LocalizedError {
+ let message: String
+ var errorDescription: String? { self.message }
+ }
+}
diff --git a/Sources/Fluid/Services/OnboardingAISetupController.swift b/Sources/Fluid/Services/OnboardingAISetupController.swift
new file mode 100644
index 00000000..f8234ec2
--- /dev/null
+++ b/Sources/Fluid/Services/OnboardingAISetupController.swift
@@ -0,0 +1,112 @@
+import Combine
+import Foundation
+
+/// Owns one explicit setup attempt. Reads and cancelled work never commit a model selection.
+@MainActor
+final class OnboardingAISetupController: ObservableObject {
+ struct Model: Equatable, Sendable {
+ let id: String
+ let name: String
+ let byteCount: Int64?
+ let installed: Bool
+ }
+
+ struct Progress: Equatable, Sendable {
+ let fraction: Double?
+ let status: String
+ let bytes: String?
+ }
+
+ enum Phase: Equatable {
+ case checking, offered, downloading, loading, cancelling, ready, unavailable
+ }
+
+ struct Dependencies {
+ var recommend: () async throws -> Model
+ var prepare: (Model, @escaping @Sendable (Progress) async -> Void) async throws -> Void
+ var load: (Model) async throws -> Void
+ }
+
+ @Published private(set) var model: Model?
+ @Published private(set) var phase: Phase = .checking
+ @Published private(set) var progress: Progress?
+ @Published private(set) var errorMessage: String?
+ private let dependencies: Dependencies
+ private var task: Task<Void, Never>?
+ private var operationID = UUID()
+
+ var isBusy: Bool { [.downloading, .loading, .cancelling].contains(self.phase) }
+
+ init(dependencies: Dependencies) {
+ self.dependencies = dependencies
+ }
+
+ func refresh() {
+ guard self.task == nil, self.phase != .ready else { return }
+ let operation = UUID()
+ self.operationID = operation
+ self.phase = .checking
+ self.errorMessage = nil
+ self.task = Task { @MainActor in
+ defer { if self.operationID == operation { self.task = nil } }
+ do {
+ let model = try await self.dependencies.recommend()
+ try Task.checkCancellation()
+ guard self.operationID == operation else { return }
+ self.model = model
+ self.phase = .offered
+ } catch {
+ guard self.operationID == operation else { return }
+ self.phase = .unavailable
+ if !Task.isCancelled { self.errorMessage = error.localizedDescription }
+ }
+ }
+ }
+
+ func enable(onReady: @escaping (Model) throws -> Void) {
+ guard self.task == nil, self.phase == .offered, let model else { return }
+ let operation = UUID()
+ self.operationID = operation
+ self.progress = nil
+ self.errorMessage = nil
+ self.phase = model.installed ? .loading : .downloading
+ self.task = Task { @MainActor in
+ defer { if self.operationID == operation { self.task = nil } }
+ do {
+ if !model.installed {
+ try await self.dependencies.prepare(model) { progress in
+ await MainActor.run {
+ guard self.operationID == operation, self.phase == .downloading else { return }
+ self.progress = progress
+ }
+ }
+ }
+ try Task.checkCancellation()
+ guard self.operationID == operation else { return }
+ self.phase = .loading
+ self.progress = nil
+ try await self.dependencies.load(model)
+ try Task.checkCancellation()
+ guard self.operationID == operation else { return }
+ // Persistence is performed only here, after readiness and cancellation checks.
+ try onReady(model)
+ self.phase = .ready
+ } catch {
+ guard self.operationID == operation else { return }
+ self.phase = .offered
+ self.progress = nil
+ if !Task.isCancelled, !(error is CancellationError) {
+ self.errorMessage = error.localizedDescription
+ }
+ }
+ }
+ }
+
+ func cancel() {
+ guard self.task != nil else { return }
+ self.task?.cancel()
+ self.progress = nil
+ self.errorMessage = nil
+ if self.isBusy { self.phase = .cancelling }
+ }
+}
diff --git a/Sources/Fluid/Services/OnboardingDictationOutputPolicy.swift b/Sources/Fluid/Services/OnboardingDictationOutputPolicy.swift
new file mode 100644
index 00000000..89377e88
--- /dev/null
+++ b/Sources/Fluid/Services/OnboardingDictationOutputPolicy.swift
@@ -0,0 +1,14 @@
+/// Onboarding previews only own recordings aimed at FluidVoice, never other apps.
+enum OnboardingDictationOutputPolicy {
+ static func usesSandbox(
+ onboardingPracticeActive: Bool,
+ isDictation: Bool,
+ targetProcessID: Int32?,
+ fluidVoiceProcessID: Int32
+ ) -> Bool {
+ guard onboardingPracticeActive, isDictation else { return false }
+ // An unknown target stays in the preview instead of writing to an arbitrary app.
+ guard let targetProcessID else { return true }
+ return targetProcessID == fluidVoiceProcessID
+ }
+}
diff --git a/Sources/Fluid/Services/OnboardingPolishPractice.swift b/Sources/Fluid/Services/OnboardingPolishPractice.swift
new file mode 100644
index 00000000..acf27914
--- /dev/null
+++ b/Sources/Fluid/Services/OnboardingPolishPractice.swift
@@ -0,0 +1,48 @@
+import Foundation
+
+/// Local practice progress; never writes dictation, provider, or persisted settings.
+struct OnboardingPolishPractice {
+ struct Example {
+ let spoken: String
+ let expected: String
+ }
+
+ static let examples = [
+ Example(spoken: "Hey John, Newline, how are you doing today?", expected: "Hey John,\nHow are you doing today?"),
+ Example(
+ spoken: "Hey, can we meet at five thirty tomorrow morning? Sorry, can you make it three thirty p.m. today?",
+ expected: "Hey, can we meet at 3:30 PM today?"
+ ),
+ Example(
+ spoken: "Make a grocery list. First one is banana, second one is apple, third one is orange.",
+ expected: "Grocery list:\n- banana\n- apple\n- orange"
+ ),
+ ]
+
+ private(set) var index = 0
+ private(set) var results: [Int: String] = [:]
+ private var awaitingOutput = false
+ var example: Example { Self.examples[self.index] }
+ var result: String? { self.results[self.index] }
+ var isLast: Bool { self.index == Self.examples.count - 1 }
+
+ mutating func beginAttempt() {
+ self.awaitingOutput = true
+ self.results[self.index] = nil
+ }
+
+ mutating func receive(_ text: String) {
+ let text = text.trimmingCharacters(in: .whitespacesAndNewlines)
+ guard self.awaitingOutput, !text.isEmpty else { return }
+ self.results[self.index] = text
+ self.awaitingOutput = false
+ }
+
+ @discardableResult
+ mutating func advance(isBusy: Bool) -> Bool {
+ guard !isBusy, self.result != nil, !self.isLast else { return false }
+ self.index += 1
+ self.awaitingOutput = false
+ return true
+ }
+}
diff --git a/Sources/Fluid/Services/PrivateAIHardwareRecommendation.swift b/Sources/Fluid/Services/PrivateAIHardwareRecommendation.swift
new file mode 100644
index 00000000..34a90445
--- /dev/null
+++ b/Sources/Fluid/Services/PrivateAIHardwareRecommendation.swift
@@ -0,0 +1,110 @@
+import Darwin
+import Foundation
+import IOKit
+
+/// A hardware heuristic, not a latency guarantee. Does not alter settings or load models.
+enum PrivateAIHardwareRecommendation {
+ struct Hardware: Equatable, Sendable {
+ let chip: String
+ let memoryBytes: UInt64
+ let gpuCoreCount: Int?
+ }
+
+ enum Model: String, Sendable {
+ case pico = "fluid-1-pico-96k-dflash"
+ case mini = "fluid-1-mini-96k-dflash"
+ }
+
+ enum Reason: String, Sendable {
+ case sufficientHardware
+ case insufficientMemory
+ case entryLevelChip
+ case unknownHardware
+ }
+
+ struct Recommendation: Equatable, Sendable {
+ let model: Model
+ let reason: Reason
+ /// Published peak bandwidth; conservative lower variant when GPU identity is unavailable.
+ let bandwidthGBps: Double?
+ }
+
+ // A single bounded snapshot. Even the first caller on MainActor performs hardware IO off-main.
+ private static let hardwareTask = Task.detached(priority: .utility) {
+ Hardware(
+ chip: Self.readChip() ?? "unknown",
+ memoryBytes: ProcessInfo.processInfo.physicalMemory,
+ gpuCoreCount: Self.readGPUCoreCount()
+ )
+ }
+
+ static func currentHardware() async -> Hardware {
+ await self.hardwareTask.value
+ }
+
+ static func current() async -> Recommendation {
+ self.recommend(for: await self.currentHardware())
+ }
+
+ static func recommend(for hardware: Hardware) -> Recommendation {
+ let bandwidth = self.bandwidth(chip: hardware.chip, gpuCores: hardware.gpuCoreCount)
+ guard hardware.memoryBytes >= 18 * 1024 * 1024 * 1024 else {
+ return Recommendation(model: .pico, reason: .insufficientMemory, bandwidthGBps: bandwidth)
+ }
+ guard let bandwidth else {
+ return Recommendation(model: .pico, reason: .unknownHardware, bandwidthGBps: nil)
+ }
+ // Capacity and chip tier are independent gates. Generation alone is not a speed rating.
+ let tier = hardware.chip.split(whereSeparator: { $0.isWhitespace }).last?.lowercased()
+ let isPerformanceChip = ["pro", "max", "ultra"].contains(tier ?? "")
+ return Recommendation(
+ model: isPerformanceChip ? .mini : .pico,
+ reason: isPerformanceChip ? .sufficientHardware : .entryLevelChip,
+ bandwidthGBps: bandwidth
+ )
+ }
+
+ /// Apple published specifications, reviewed September 2026. Unknown generations do not inherit a tier.
+ /// M3/M4 Max: https://support.apple.com/117737 and https://support.apple.com/121554
+ /// M5 Pro/Max: https://support.apple.com/126319; Ultra: https://support.apple.com/122211
+ private static func bandwidth(chip: String, gpuCores: Int?) -> Double? {
+ let chip = chip.split(whereSeparator: { $0.isWhitespace }).joined(separator: " ").lowercased()
+ switch chip {
+ case "apple m1": return 68.3
+ case "apple m2", "apple m3": return 100
+ case "apple m4": return 120
+ case "apple m5": return 153
+ case "apple m1 pro", "apple m2 pro": return 200
+ case "apple m3 pro": return 150
+ case "apple m4 pro": return 273
+ case "apple m5 pro": return 307
+ case "apple m1 max", "apple m2 max": return 400
+ case "apple m3 max": return gpuCores == 40 ? 400 : 300
+ case "apple m4 max": return gpuCores == 40 ? 546 : 410
+ case "apple m5 max": return gpuCores == 40 ? 614 : 460
+ case "apple m1 ultra", "apple m2 ultra": return 800
+ case "apple m3 ultra": return 819
+ default: return nil
+ }
+ }
+
+ private static func readChip() -> String? {
+ var size = 0
+ guard sysctlbyname("machdep.cpu.brand_string", nil, &size, nil, 0) == 0,
+ size > 0, size <= 256 else { return nil }
+ var bytes = [CChar](repeating: 0, count: size)
+ guard sysctlbyname("machdep.cpu.brand_string", &bytes, &size, nil, 0) == 0 else { return nil }
+ return String(cString: bytes)
+ }
+
+ private static func readGPUCoreCount() -> Int? {
+ // Optional registry hint: fall back to the lower bandwidth variant when absent.
+ let service = IOServiceGetMatchingService(kIOMainPortDefault, IOServiceMatching("AGXAccelerator"))
+ guard service != 0 else { return nil }
+ defer { IOObjectRelease(service) }
+ guard let property = IORegistryEntryCreateCFProperty(service, "gpu-core-count" as CFString, kCFAllocatorDefault, 0),
+ let number = property.takeRetainedValue() as? NSNumber else { return nil }
+ let count = number.intValue
+ return (1...256).contains(count) ? count : nil
+ }
+}
diff --git a/Sources/Fluid/Theme/Components/OnboardingComponents.swift b/Sources/Fluid/Theme/Components/OnboardingComponents.swift
index 7bf98ddf..a656143a 100644
--- a/Sources/Fluid/Theme/Components/OnboardingComponents.swift
+++ b/Sources/Fluid/Theme/Components/OnboardingComponents.swift
@@ -1,6 +1,28 @@
import AppKit
import SwiftUI
+struct OnboardingModelInfoTooltip: View {
+ let text: String
+ let font: Font
+
+ var body: some View {
+ Text(self.text)
+ .font(self.font)
+ .foregroundStyle(.white.opacity(0.92))
+ .fixedSize(horizontal: false, vertical: true)
+ .padding(12)
+ .frame(width: 260, alignment: .leading)
+ .background(
+ RoundedRectangle(cornerRadius: 10)
+ .fill(Color(red: 0.075, green: 0.085, blue: 0.11))
+ .overlay(RoundedRectangle(cornerRadius: 10).stroke(Color.white.opacity(0.16), lineWidth: 1))
+ )
+ .shadow(color: .black.opacity(0.3), radius: 8, y: 4)
+ .allowsHitTesting(false)
+ .accessibilityHidden(true)
+ }
+}
+
struct FluidOnboardingLandingHero<Actions: View>: View {
@Environment(\.theme) private var theme
diff --git a/Sources/Fluid/Theme/Components/OnboardingFittedContent.swift b/Sources/Fluid/Theme/Components/OnboardingFittedContent.swift
new file mode 100644
index 00000000..340a932c
--- /dev/null
+++ b/Sources/Fluid/Theme/Components/OnboardingFittedContent.swift
@@ -0,0 +1,32 @@
+import SwiftUI
+
+/// Fits the page above its fixed navigation footer, without a page-level scroll view.
+struct OnboardingFittedContent<Content: View>: View {
+ let width: CGFloat
+ @ViewBuilder let content: () -> Content
+ @State private var measuredHeight: CGFloat = 1
+
+ var body: some View {
+ GeometryReader { geometry in
+ let scale = min(1, geometry.size.width / self.width, geometry.size.height / max(1, self.measuredHeight))
+ self.content()
+ .frame(width: self.width)
+ .fixedSize(horizontal: false, vertical: true)
+ .background {
+ GeometryReader { contentGeometry in
+ Color.clear.preference(key: OnboardingContentHeightKey.self, value: contentGeometry.size.height)
+ }
+ }
+ .onPreferenceChange(OnboardingContentHeightKey.self) { self.measuredHeight = $0 }
+ .scaleEffect(max(0, scale))
+ .frame(width: geometry.size.width, height: geometry.size.height)
+ }
+ }
+}
+
+private struct OnboardingContentHeightKey: PreferenceKey {
+ static let defaultValue: CGFloat = 1
+ static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) {
+ value = max(value, nextValue())
+ }
+}
diff --git a/Sources/Fluid/Theme/Components/OnboardingGlassSurface.swift b/Sources/Fluid/Theme/Components/OnboardingGlassSurface.swift
new file mode 100644
index 00000000..de4ac2c9
--- /dev/null
+++ b/Sources/Fluid/Theme/Components/OnboardingGlassSurface.swift
@@ -0,0 +1,53 @@
+import SwiftUI
+
+/// A bounded, static glass surface for onboarding, with an opaque accessibility fallback.
+struct OnboardingGlassSurface: ViewModifier {
+ let selected: Bool
+ @Environment(\.accessibilityReduceTransparency) private var reduceTransparency
+ @Environment(\.colorSchemeContrast) private var contrast
+
+ private var shape: RoundedRectangle {
+ RoundedRectangle(cornerRadius: AppTheme.Metrics.Showcase.cardRadius, style: .continuous)
+ }
+
+ func body(content: Content) -> some View {
+ self.material(content: content)
+ .overlay {
+ if !self.reduceTransparency {
+ self.shape.fill(LinearGradient(
+ colors: [.white.opacity(self.selected ? 0.08 : 0.025), .clear, FluidBrandColors.blue.opacity(self.selected ? 0.055 : 0.015)],
+ startPoint: .topLeading,
+ endPoint: .bottomTrailing
+ ))
+ .allowsHitTesting(false)
+ }
+ }
+ .overlay {
+ self.shape.strokeBorder(
+ LinearGradient(
+ colors: [.white.opacity(self.edgeOpacity), .white.opacity(0.06), .white.opacity(self.edgeOpacity * 0.55)],
+ startPoint: .topLeading,
+ endPoint: .bottomTrailing
+ ),
+ lineWidth: self.contrast == .increased ? 2 : 1
+ )
+ .allowsHitTesting(false)
+ }
+ .shadow(color: .black.opacity(self.selected ? 0.22 : 0.1), radius: self.selected ? 12 : 4, y: self.selected ? 8 : 2)
+ }
+
+ private var edgeOpacity: Double {
+ self.contrast == .increased ? 0.8 : (self.selected ? 0.30 : 0.10)
+ }
+
+ @ViewBuilder private func material(content: Content) -> some View {
+ if self.reduceTransparency {
+ content.background(self.shape.fill(Color(red: 0.065, green: 0.075, blue: 0.11)))
+ } else if #available(macOS 26, *) {
+ content
+ .glassEffect(.regular.tint(FluidBrandColors.blue.opacity(self.selected ? 0.08 : 0.025)), in: self.shape)
+ } else {
+ content.background(.ultraThinMaterial, in: self.shape)
+ }
+ }
+}
diff --git a/Sources/Fluid/UI/AISettings/AIEnhancementSettingsViewModel.swift b/Sources/Fluid/UI/AISettings/AIEnhancementSettingsViewModel.swift
index 0e36c38b..bc8b451a 100644
--- a/Sources/Fluid/UI/AISettings/AIEnhancementSettingsViewModel.swift
+++ b/Sources/Fluid/UI/AISettings/AIEnhancementSettingsViewModel.swift
@@ -1949,7 +1949,7 @@ final class AIEnhancementSettingsViewModel: ObservableObject {
$0.mode.normalized == mode.normalized
})
else {
- return "Built-in Default"
+ return mode.normalized == .dictate ? "Smart" : "Built-in Default"
}
let trimmed = profile.name.trimmingCharacters(in: .whitespacesAndNewlines)
diff --git a/Sources/Fluid/UI/AISettings/PrivateAISettingsController.swift b/Sources/Fluid/UI/AISettings/PrivateAISettingsController.swift
index 93cfe46c..66a30b01 100644
--- a/Sources/Fluid/UI/AISettings/PrivateAISettingsController.swift
+++ b/Sources/Fluid/UI/AISettings/PrivateAISettingsController.swift
@@ -80,10 +80,15 @@ final class PrivateAISettingsController: ObservableObject {
func usePreviewModel(isInstalled: Bool, onReady: @escaping () -> Void) {
guard !self.isBusy, let model = PrivateAIModelRegistry.model(id: self.previewModelID) else { return }
self.persistPrivateAIModelSelection(model.id, loadIfInstalled: false)
+ let activateSmartMode = { [weak self] in
+ guard let self else { return }
+ self.viewModel.selectPrivateAIPromptIfAvailable()
+ onReady()
+ }
if isInstalled {
- self.verifyPrivateAIConnection(model, onReady: onReady)
+ self.verifyPrivateAIConnection(model, onReady: activateSmartMode)
} else {
- self.downloadPrivateAIModel(model, onReady: onReady)
+ self.downloadPrivateAIModel(model, onReady: activateSmartMode)
}
}
diff --git a/Sources/Fluid/UI/AISettingsView+AdvancedSettings.swift b/Sources/Fluid/UI/AISettingsView+AdvancedSettings.swift
index fca11191..7398b8b2 100644
--- a/Sources/Fluid/UI/AISettingsView+AdvancedSettings.swift
+++ b/Sources/Fluid/UI/AISettingsView+AdvancedSettings.swift
@@ -1032,8 +1032,8 @@ extension AIEnhancementSettingsView {
let privateAISelection = SettingsStore.DictationPromptSelection.privateAI
self.promptProfileCard(
cardKey: "\(mode.normalized.rawValue)-\(PrivateAIProviderFeature.shared.providerID)",
- title: PrivateAIProviderFeature.displayName,
- subtitle: "",
+ title: "Smart",
+ subtitle: PrivateAIProviderFeature.displayName,
mode: mode,
isSelected: self.viewModel.isPrivateAIPromptSelected(),
assignments: self.promptAssignments(selection: privateAISelection, isPrivateAI: true),
@@ -1046,7 +1046,7 @@ extension AIEnhancementSettingsView {
let defaultSelection = SettingsStore.DictationPromptSelection.default
self.promptProfileCard(
cardKey: "\(mode.normalized.rawValue)-default",
- title: mode.normalized == .dictate ? "Built-in Default" : "Default \(self.friendlyModeName(mode))",
+ title: mode.normalized == .dictate ? "Smart" : "Default \(self.friendlyModeName(mode))",
subtitle: "",
mode: mode,
isSelected: self.viewModel.selectedPromptID(for: mode) == nil,
diff --git a/Sources/Fluid/UI/OnboardingAIEnhancementStepView.swift b/Sources/Fluid/UI/OnboardingAIEnhancementStepView.swift
index 79f32ac5..1578360c 100644
--- a/Sources/Fluid/UI/OnboardingAIEnhancementStepView.swift
+++ b/Sources/Fluid/UI/OnboardingAIEnhancementStepView.swift
@@ -3,55 +3,31 @@ 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 onToggleShortcut: () -> Void
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
+ @Environment(\.theme) private var theme
+ @Environment(\.accessibilityReduceTransparency) private var reduceTransparency
@ObservedObject private var settings = SettingsStore.shared
-
+ @StateObject private var setup = OnboardingAISetupController.live
+ @StateObject private var carouselAutoplay = OnboardingCarouselAutoplay()
@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 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 = "ai-enhancement-top"
- }
-
- private struct EnhancementExample: Identifiable {
- let id: String
- let raw: String
- let polished: String
- }
-
- private enum ButtonTone {
- case primary
- case secondary
- case destructive
- }
+ @State private var overlayOwner = UUID()
+ @State private var practice = OnboardingPolishPractice()
+ @ObservedObject private var contentState = NotchContentState.shared
+ private enum ButtonTone { case primary, secondary, destructive }
private struct PillButtonConfiguration {
let id: String
let title: String
@@ -63,986 +39,258 @@ struct OnboardingAIEnhancementStepView: View {
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?",
- polished: "Hey John,\nHow are you doing today?"
- ),
- 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 hasPrivateAIProvider: Bool {
- PrivateFeatures.privateAIProvider
- }
-
- private var privateAIProviderName: String {
- let displayName = PrivateAIProviderFeature.displayName.trimmingCharacters(in: .whitespacesAndNewlines)
- if displayName.isEmpty || displayName == "Private AI Provider" {
- return "Built-in AI"
- }
- return displayName
- }
-
- private var privateAIModelDisplayName: String {
- let displayName = self.privateAIModel.displayName.trimmingCharacters(in: .whitespacesAndNewlines)
- return displayName.isEmpty ? "AI model" : 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 canNavigate: Bool { !self.isRunning && !self.isRecordingShortcut && !self.contentState.isProcessing }
+ private var isReady: Bool { self.setup.phase == .ready }
+ private var sizeText: String? {
+ guard let count = self.setup.model?.byteCount, count > 0 else { return nil }
+ return ByteCountFormatter.string(fromByteCount: count, 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 PrivateAIModelDownloadProgressText.buttonTitle(for: self.privateAISetupProgress)
- }
- 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 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))
- )
+ private var enableTitle: String {
+ guard let model = self.setup.model else { return "Download & Enable" }
+ if model.installed { return "Enable Fluid Intelligence" }
+ return self.sizeText.map { "Download & Enable · \($0)" } ?? "Download & Enable"
}
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)
+ VStack(spacing: 0) {
+ FluidOnboardingCompactProgress(value: self.progressValue)
+ .padding(.top, 28)
+ OnboardingFittedContent(width: self.isReady ? 680 : 944) {
+ VStack(spacing: 0) {
+ self.hero
+ .padding(.bottom, 24)
+ if self.isReady {
+ self.tryout
+ } else {
+ self.offer
}
- .frame(maxWidth: .infinity)
+ Text(self.isReady
+ ? "These same controls appear whenever you dictate."
+ : "You can change this or turn it off later in Settings.")
+ .font(self.theme.typography.caption)
+ .foregroundStyle(.white.opacity(0.46))
+ .multilineTextAlignment(.center)
+ .padding(.top, 28)
}
-
- self.footer
- }
- .frame(width: proxy.size.width, height: proxy.size.height)
- .onDisappear {
- self.cancelPrivateAIAction()
- }
- .onChange(of: self.finalText) { _, newValue in
- self.captureCurrentExampleOutput(newValue)
+ .frame(maxWidth: self.isReady ? 600 : 880)
+ .frame(maxWidth: .infinity)
+ .padding(.horizontal, 32)
+ .padding(.top, 36)
+ .padding(.bottom, 24)
}
- .onChange(of: self.isRunning) { _, isRunning in
- if isRunning {
- self.activeRecordingExampleID = self.selectedExampleID
+ HStack {
+ self.action(id: "back", title: "Back", tone: .secondary, width: 132) {
+ self.setup.cancel()
+ self.onBack()
+ }
+ .keyboardShortcut(.cancelAction)
+ Spacer()
+ if self.isReady {
+ Button("Skip practice", action: self.onFinishSetup)
+ .buttonStyle(.plain)
+ .foregroundStyle(.white.opacity(0.58))
+ .disabled(!self.canNavigate)
+ self.action(id: "practice-next", title: self.practice.isLast ? "Finish setup" : "Next example", tone: .primary, width: 180) {
+ guard self.canNavigate, self.practice.result != nil else { return }
+ if self.practice.isLast {
+ self.onFinishSetup()
+ } else {
+ self.practice.advance(isBusy: !self.canNavigate)
+ }
+ }
+ .disabled(self.practice.result == nil)
+ } else {
+ self.offerNavigation
}
}
+ .padding(.horizontal, 30)
+ .padding(.bottom, 20)
+ .padding(.top, 12)
+ .fixedSize(horizontal: false, vertical: true)
}
-
- FluidOnboardingLandingHoverTracker(
- onMove: self.onGlowMove,
- onExit: self.onGlowExit
- )
- .frame(width: proxy.size.width, height: proxy.size.height)
- .accessibilityHidden(true)
+ 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)
+ .overlay {
+ if !self.isReady {
+ OnboardingCarouselInteractionTracker(autoplay: self.carouselAutoplay)
+ .allowsHitTesting(false)
+ .accessibilityHidden(true)
}
}
- .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(.fluidSystem(size: 32, weight: .semibold))
- .foregroundStyle(.white)
- .multilineTextAlignment(.center)
- .lineLimit(1)
- .minimumScaleFactor(0.74)
- .padding(.horizontal, 32)
- .padding(.bottom, 10)
-
- Text(self.setupSubtitleText)
- .font(.fluidSystem(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(self.setupQuestionText)
- .font(.fluidSystem(size: 17, weight: .semibold))
- .foregroundStyle(.white.opacity(0.92))
- .padding(.bottom, 12)
-
- self.setupChoiceCard(scrollProxy: scrollProxy)
- .frame(width: min(containerWidth - 92, 840))
- .padding(.bottom, 12)
-
- Text(self.setupFootnoteText)
- .font(.fluidSystem(size: 12, weight: .medium))
- .foregroundStyle(Color.white.opacity(0.46))
+ .task { self.setup.refresh() }
+ .onDisappear {
+ self.setup.cancel()
+ NotchOverlayManager.shared.endOnboardingOverlay(owner: self.overlayOwner)
}
- .frame(maxWidth: .infinity)
}
- private var setupSubtitleText: String {
- if self.hasPrivateAIProvider {
- return "FluidVoice can polish raw dictation locally with an optional built-in AI engine."
- }
- return "Optional: connect your own AI provider to polish dictation."
- }
-
- private var setupQuestionText: String {
- self.hasPrivateAIProvider ? "Want FluidVoice to polish your dictation?" : "Want AI polishing?"
- }
-
- private var setupFootnoteText: String {
- if self.shouldShowTryout {
- return "Try it below before finishing setup."
+ private var hero: some View {
+ VStack(spacing: 14) {
+ FluidOnboardingCompactAppIconMark(size: 52)
+ .padding(.bottom, 8)
+ (self.isReady ? Text("Try it right here.") : Text("Now, let's get a lil ")
+ + Text("fancy").italic().foregroundColor(FluidOnboardingLandingColors.blue) + Text("."))
+ .font(.fluidSystem(size: 32, weight: .semibold))
+ .foregroundStyle(.white)
+ .multilineTextAlignment(.center)
+ .lineLimit(2)
+ Text(self.isReady ? "Try three short examples with Smart mode." : "Fluid Intelligence can…")
+ .font(.fluidSystem(size: 15, weight: .medium))
+ .foregroundStyle(.white.opacity(0.64))
+ .multilineTextAlignment(.center)
}
- return "You can change this later in AI Providers."
}
- 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(.fluidSystem(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(.fluidSystem(size: 15, weight: .medium))
- .foregroundStyle(Color.white.opacity(0.62))
- .multilineTextAlignment(.center)
- .lineLimit(2)
- .minimumScaleFactor(0.82)
+ private var offer: some View {
+ VStack(spacing: 20) {
+ OnboardingCleanupExampleCarousel(autoplay: self.carouselAutoplay)
+ .padding(.bottom, 8)
+ if self.setup.phase == .checking {
+ ProgressView("Finding the right model for your Mac…")
+ .controlSize(.small)
+ } else if self.setup.isBusy {
+ self.preparationProgress
+ if self.setup.phase != .cancelling {
+ Button("Cancel") { self.setup.cancel() }
+ .buttonStyle(.plain)
+ .foregroundStyle(.white.opacity(0.8))
}
- .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(.fluidSystem(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(.fluidSystem(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(.fluidSystem(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)
+ if let error = self.setup.errorMessage {
+ Text(error)
+ .font(self.theme.typography.caption)
+ .foregroundStyle(self.theme.palette.warning)
+ .multilineTextAlignment(.center)
+ .fixedSize(horizontal: false, vertical: true)
}
- }
- }
-
- private func exampleRow(_ example: EnhancementExample) -> some View {
- HStack(alignment: .center, spacing: ExampleGridMetrics.columnSpacing) {
- HStack(spacing: ExampleGridMetrics.columnSpacing) {
- Image(systemName: "mic.fill")
- .font(.fluidSystem(size: 14, weight: .semibold))
+ if self.setup.phase == .unavailable {
+ Text("Fluid Intelligence isn't available right now. You can finish setup and try again later.")
+ .font(self.theme.typography.caption)
+ .foregroundStyle(.white.opacity(0.64))
+ .multilineTextAlignment(.center)
+ Button("Try again") { self.setup.refresh() }
+ .buttonStyle(.plain)
.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(.fluidSystem(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(.fluidSystem(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: "Polished output")
-
- ForEach(Self.examples) { example in
- self.playgroundExampleRow(example)
}
}
+ .frame(minHeight: 180)
}
- private func polishedExampleSurface(_ example: EnhancementExample) -> some View {
- let shape = RoundedRectangle(cornerRadius: ExampleGridMetrics.rawCornerRadius, style: .continuous)
-
- return ZStack(alignment: .topLeading) {
- Text(example.polished)
- .font(.fluidSystem(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 allowsDecorativeShadow = !self.reduceMotion
- let rawShadowRadius: CGFloat = allowsDecorativeShadow && isSelected ? 13 : 0
- let arrowShadowRadius: CGFloat = allowsDecorativeShadow && isListening ? 12 : 0
- let outputShadowRadius: CGFloat = allowsDecorativeShadow && (isSelected || isListening) ? (isSelected ? 14 : 8) : 0
- let outputShadowOpacity: Double = allowsDecorativeShadow ? (isListening ? 0.24 : (isSelected ? 0.16 : 0)) : 0
- 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(.fluidSystem(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(.fluidSystem(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(allowsDecorativeShadow && isSelected ? 0.13 : 0), radius: rawShadowRadius, x: 0, y: 4)
- )
- .contentShape(rawShape)
+ private var offerNavigation: some View {
+ HStack(spacing: 20) {
+ Button("I’ll set it up later") {
+ self.setup.cancel()
+ self.onSkip()
}
- .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(.fluidSystem(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(allowsDecorativeShadow && isListening ? 0.30 : 0), radius: arrowShadowRadius, 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(.fluidSystem(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(.fluidSystem(size: 12, weight: .bold))
- .foregroundStyle(FluidOnboardingLandingColors.blue)
-
- Text("Listening...")
- .font(.fluidSystem(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(.fluidSystem(size: 12, weight: .semibold))
- .foregroundStyle(Color.white.opacity(0.36))
- .lineLimit(1)
- .minimumScaleFactor(0.82)
-
- Text("Press \(self.shortcutDisplay) and speak this example.")
- .font(.fluidSystem(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(.fluidSystem(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(outputShadowOpacity), radius: outputShadowRadius, 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)")
- }
-
- @ViewBuilder
- private func setupChoiceCard(scrollProxy: ScrollViewProxy) -> some View {
- if self.hasPrivateAIProvider {
- self.privateAIProviderCard(scrollProxy: scrollProxy)
- } else {
- self.genericAIProviderCard
- }
- }
-
- private var genericAIProviderCard: some View {
- let shape = RoundedRectangle(cornerRadius: 18, style: .continuous)
- let isHovered = self.hoveredButtonID == "generic-ai-provider" && self.canNavigateOrMutate
-
- return HStack(alignment: .center, spacing: 18) {
- VStack(alignment: .leading, spacing: 10) {
- Text("AI provider")
- .font(.fluidSystem(size: 22, weight: .semibold))
- .foregroundStyle(.white)
- .lineLimit(1)
- .minimumScaleFactor(0.78)
-
- Label("Connect your own provider to polish dictation.", systemImage: "sparkles")
- .font(.fluidSystem(size: 12, weight: .semibold))
- .foregroundStyle(Color.white.opacity(0.74))
- .lineLimit(1)
- .minimumScaleFactor(0.78)
-
- HStack(spacing: 13) {
- self.modelFact("key.fill", "Uses your API key")
- self.modelFact("slider.horizontal.3", "Configurable later")
- self.modelFact("network", "Cloud or local")
- }
- }
-
- Spacer(minLength: 12)
-
- self.pillButton(
- PillButtonConfiguration(
- id: "generic-ai-provider",
- title: "Set up provider",
- systemImage: "arrow.up.right",
- tone: .primary,
- width: 168,
- height: 40,
- fontSize: 13,
- isEnabled: self.canNavigateOrMutate
- ),
- action: {
- self.cancelPrivateAIAction()
- self.onUseAIProvider()
- }
- )
- .keyboardShortcut(.defaultAction)
- }
- .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 ? "generic-ai-provider" : nil)
- }
- }
-
- private func privateAIProviderCard(scrollProxy: ScrollViewProxy) -> some View {
- let shape = RoundedRectangle(cornerRadius: 18, style: .continuous)
- let isHovered = self.hoveredButtonID == "private-ai-provider" && self.canNavigateOrMutate
-
- return VStack(alignment: .leading, spacing: 12) {
- HStack(alignment: .top, spacing: 18) {
- VStack(alignment: .leading, spacing: 10) {
- HStack(spacing: 8) {
- Text(self.privateAIProviderName)
- .font(.fluidSystem(size: 22, weight: .semibold))
- .foregroundStyle(.white)
- .lineLimit(1)
- .minimumScaleFactor(0.78)
-
- Text("Experimental")
- .font(.fluidSystem(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(.fluidSystem(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(.fluidSystem(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: "private-ai-provider-delete",
- title: "Delete",
- systemImage: "trash.fill",
- tone: .destructive,
- width: 112,
- height: 40,
- fontSize: 13,
- isEnabled: self.canNavigateOrMutate
- ),
- action: self.deletePrivateAIModel
- )
+ .font(.fluidSystem(size: 15, weight: .medium))
+ .foregroundStyle(.white.opacity(self.canNavigate ? 0.86 : 0.4))
+ .disabled(!self.canNavigate)
+
+ if self.setup.phase == .offered {
+ self.action(id: "enable", title: self.enableTitle, tone: .primary, width: 260) {
+ self.setup.enable { model in
+ guard self.canNavigate else {
+ throw SetupError(message: "Stop dictation, then enable cleanup again.")
+ }
+ guard let registered = PrivateAIModelRegistry.model(id: model.id) else {
+ throw PrivateAIUnavailableError()
+ }
+ self.persistPrivateAIVerification(registered)
+ self.finalText = ""
}
}
- }
-
- 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(.fluidSystem(size: 11, weight: .semibold))
- .foregroundStyle(Color.red.opacity(0.82))
- .lineLimit(1)
- .minimumScaleFactor(0.74)
+ .keyboardShortcut(.defaultAction)
}
}
- .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 ? "private-ai-provider" : 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(.fluidSystem(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(.fluidSystem(size: 10, weight: .semibold))
- .foregroundStyle(Color.white.opacity(0.42))
- .lineLimit(1)
- .minimumScaleFactor(0.74)
- }
- }
-
- if let fraction = self.privateAISetupProgress?.fractionCompleted {
+ private var preparationProgress: some View {
+ VStack(spacing: 10) {
+ if self.setup.phase == .downloading, let fraction = self.setup.progress?.fraction {
ProgressView(value: fraction)
- .progressViewStyle(.linear)
- .tint(FluidOnboardingLandingColors.blue)
- .frame(height: 4)
} else {
- ProgressView()
- .progressViewStyle(.linear)
- .controlSize(.small)
- .tint(FluidOnboardingLandingColors.blue)
- .frame(height: 4)
+ ProgressView().controlSize(.small)
}
- }
- .padding(.top, 2)
- .transition(self.reduceMotion ? .opacity : .opacity.combined(with: .move(edge: .top)))
- }
-
- private func primaryPrivateAIButton(scrollProxy: ScrollViewProxy) -> some View {
- self.pillButton(
- PillButtonConfiguration(
- id: "private-ai-provider",
- title: self.primaryPrivateAIButtonTitle,
- systemImage: self.primaryPrivateAIButtonIcon,
- tone: .primary,
- width: 150,
- height: 40,
- fontSize: 13,
- isEnabled: self.isPrimaryPrivateAIButtonEnabled
- ),
- action: {
- self.handlePrivateAIPrimaryAction(scrollProxy: scrollProxy)
+ Text(self.preparationStatus)
+ .font(self.theme.typography.captionStrong)
+ .foregroundStyle(self.theme.palette.warning)
+ .multilineTextAlignment(.center)
+ if let bytes = self.setup.progress?.bytes {
+ Text(bytes)
+ .font(self.theme.typography.caption)
+ .foregroundStyle(.white.opacity(0.5))
}
- )
- }
-
- private func modelFact(_ systemImage: String, _ text: String) -> some View {
- HStack(spacing: 6) {
- Image(systemName: systemImage)
- .font(.fluidSystem(size: 11, weight: .bold))
- .foregroundStyle(FluidOnboardingLandingColors.blue.opacity(0.86))
-
- Text(text)
- .font(.fluidSystem(size: 12, weight: .medium))
- .foregroundStyle(Color.white.opacity(0.58))
- .lineLimit(1)
- .minimumScaleFactor(0.76)
}
+ .tint(FluidOnboardingLandingColors.blue)
+ .frame(maxWidth: 340)
}
- 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 {
- HStack(spacing: 12) {
- self.skipTryoutButton
-
- self.finishButton
- .keyboardShortcut(.defaultAction)
- }
- } else {
- HStack(spacing: 12) {
- self.providerChoiceButton
-
- self.skipButton
- }
- }
+ private var preparationStatus: String {
+ switch self.setup.phase {
+ case .loading: "Preparing the model for your Mac. This can take a little while."
+ case .cancelling: "Cancelling setup… You can go back or set this up later."
+ default: self.setup.progress?.status ?? "Starting download…"
}
- .padding(.horizontal, 30)
- .padding(.bottom, 24)
}
- private var providerChoiceButton: some View {
- self.pillButton(
- PillButtonConfiguration(
- id: "ai-provider",
- title: self.hasPrivateAIProvider ? "Use my own AI provider" : "Set up AI provider",
- systemImage: "arrow.up.right",
- tone: .secondary,
- width: 280,
- height: 48,
- fontSize: 15,
- isEnabled: self.canNavigateOrMutate
- ),
- action: {
- self.cancelPrivateAIAction()
- self.onUseAIProvider()
- }
+ private var tryout: some View {
+ OnboardingPolishPracticeView(
+ practice: self.practice,
+ isRunning: self.isRunning,
+ isProcessing: self.contentState.isProcessing,
+ isRecordingShortcut: self.isRecordingShortcut,
+ shortcutDisplay: self.shortcutDisplay,
+ shortcutRecordingMessage: self.shortcutRecordingMessage,
+ onToggleShortcut: self.onToggleShortcut
)
+ .onAppear { NotchOverlayManager.shared.beginOnboardingOverlay(owner: self.overlayOwner) }
+ .onDisappear { NotchOverlayManager.shared.endOnboardingOverlay(owner: self.overlayOwner) }
+ .onChange(of: self.isRunning) { _, running in
+ if running { self.practice.beginAttempt() }
+ }
+ .onChange(of: self.finalText) { _, text in
+ self.practice.receive(text)
+ }
}
- 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()
+ @ViewBuilder
+ private func action(id: String, title: String, tone: ButtonTone, width: CGFloat, action: @escaping () -> Void) -> some View {
+ if #available(macOS 26, *), !self.reduceTransparency {
+ Button(action: action) {
+ Text(title)
+ .font(.fluidSystem(size: 16, weight: .semibold))
+ .foregroundStyle(.white)
+ .frame(width: width - 32, height: 40)
}
- )
- }
-
- private var skipTryoutButton: some View {
- self.pillButton(
- PillButtonConfiguration(
- id: "ai-skip-tryout",
- title: "Skip",
+ .fluidGlassAction(prominent: tone == .primary)
+ .font(.fluidSystem(size: 17, weight: .semibold))
+ .tint(tone == .primary ? Color(red: 0.20, green: 0.43, blue: 0.88) : nil)
+ .disabled(!self.canNavigate)
+ } else {
+ self.pillButton(PillButtonConfiguration(
+ id: id,
+ title: title,
systemImage: nil,
- tone: .secondary,
- width: 132,
+ tone: tone,
+ width: width,
height: 48,
fontSize: 16,
- isEnabled: self.canNavigateOrMutate
- ),
- action: {
- self.cancelPrivateAIAction()
- self.onFinishSetup()
- }
- )
+ isEnabled: self.canNavigate
+ ), action: action)
+ }
}
- 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 struct SetupError: LocalizedError {
+ let message: String
+ var errorDescription: String? { self.message }
}
private func pillButton(
@@ -1124,159 +372,6 @@ struct OnboardingAIEnhancementStepView: View {
}
}
- 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
- }
-
- private func clearExampleOutput(_ example: EnhancementExample) {
- self.playgroundOutputs.removeValue(forKey: example.id)
-
- if self.selectedExampleID == example.id {
- self.finalText = ""
- }
- }
-
- 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 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 = PrivateAIModelDownloadProgress(initialExpectedBytes: model.artifact.byteCount)
- 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.withFallbackExpectedBytes(model.artifact.byteCount)
- }
- }
- 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)
@@ -1301,86 +396,4 @@ struct OnboardingAIEnhancementStepView: View {
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
- self.settings.verifiedPrivateAIModelFingerprints = [:]
-
- 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/OnboardingCarouselAutoplay.swift b/Sources/Fluid/UI/OnboardingCarouselAutoplay.swift
new file mode 100644
index 00000000..fe2a2d45
--- /dev/null
+++ b/Sources/Fluid/UI/OnboardingCarouselAutoplay.swift
@@ -0,0 +1,124 @@
+import AppKit
+import Combine
+import SwiftUI
+
+/// One pending wakeup; pointer movement only extends the deadline, without redrawing SwiftUI.
+final class OnboardingCarouselAutoplay: ObservableObject {
+ private static let interval: TimeInterval = 10
+ let advance = PassthroughSubject<Void, Never>()
+ private var timer: Timer?
+ private var deadline: TimeInterval = 0
+ private var isRunning = false
+
+ func start() {
+ guard !self.isRunning else { return }
+ self.isRunning = true
+ self.interact()
+ self.schedule(after: Self.interval)
+ }
+
+ func interact() {
+ self.deadline = ProcessInfo.processInfo.systemUptime + Self.interval
+ }
+
+ func stop() {
+ self.isRunning = false
+ self.timer?.invalidate()
+ self.timer = nil
+ }
+
+ private func schedule(after delay: TimeInterval) {
+ let timer = Timer(timeInterval: delay, repeats: false) { [weak self] _ in
+ guard let self, self.isRunning else { return }
+ let remaining = self.deadline - ProcessInfo.processInfo.systemUptime
+ if remaining > 0 {
+ self.schedule(after: remaining)
+ } else {
+ self.interact()
+ self.advance.send()
+ if self.isRunning { self.schedule(after: Self.interval) }
+ }
+ }
+ timer.tolerance = 0.05
+ self.timer = timer
+ RunLoop.main.add(timer, forMode: .common)
+ }
+
+ deinit { self.timer?.invalidate() }
+}
+
+/// Observes only this page's events and always returns them unchanged to their controls.
+struct OnboardingCarouselInteractionTracker: NSViewRepresentable {
+ let autoplay: OnboardingCarouselAutoplay
+
+ func makeNSView(context: Context) -> TrackingView {
+ TrackingView(autoplay: self.autoplay)
+ }
+
+ func updateNSView(_ nsView: TrackingView, context: Context) {}
+
+ static func dismantleNSView(_ nsView: TrackingView, coordinator: ()) {
+ nsView.stopObserving()
+ }
+
+ final class TrackingView: NSView {
+ private let autoplay: OnboardingCarouselAutoplay
+ private var monitor: Any?
+ private var observers: [NSObjectProtocol] = []
+
+ init(autoplay: OnboardingCarouselAutoplay) {
+ self.autoplay = autoplay
+ super.init(frame: .zero)
+ }
+
+ required init?(coder: NSCoder) { nil }
+
+ override func hitTest(_ point: NSPoint) -> NSView? { nil }
+
+ override func viewDidMoveToWindow() {
+ super.viewDidMoveToWindow()
+ self.stopObserving()
+ guard let window else { return }
+ self.monitor = NSEvent.addLocalMonitorForEvents(matching: [
+ .leftMouseDown, .leftMouseUp, .rightMouseDown, .rightMouseUp,
+ .otherMouseDown, .otherMouseUp, .mouseMoved, .leftMouseDragged,
+ .rightMouseDragged, .otherMouseDragged, .scrollWheel,
+ .keyDown, .keyUp, .flagsChanged, .magnify, .rotate, .swipe,
+ ]) { [weak self] event in
+ guard let self, event.window === self.window else { return event }
+ let isKeyboard = [.keyDown, .keyUp, .flagsChanged].contains(event.type)
+ if isKeyboard || self.bounds.contains(self.convert(event.locationInWindow, from: nil)) {
+ self.autoplay.interact()
+ }
+ return event
+ }
+ for name in [NSWindow.didBecomeKeyNotification, NSWindow.didResignKeyNotification] {
+ self.observers.append(NotificationCenter.default.addObserver(forName: name, object: window, queue: .main) { [weak self] _ in
+ self?.updateActivity()
+ })
+ }
+ self.updateActivity()
+ }
+
+ private func updateActivity() {
+ if self.window?.isKeyWindow == true {
+ self.autoplay.start()
+ } else {
+ self.autoplay.stop()
+ }
+ }
+
+ func stopObserving() {
+ self.autoplay.stop()
+ if let monitor { NSEvent.removeMonitor(monitor) }
+ self.monitor = nil
+ self.observers.forEach(NotificationCenter.default.removeObserver)
+ self.observers.removeAll()
+ }
+
+ deinit {
+ if let monitor { NSEvent.removeMonitor(monitor) }
+ self.observers.forEach(NotificationCenter.default.removeObserver)
+ }
+ }
+}
diff --git a/Sources/Fluid/UI/OnboardingCleanupExampleCarousel.swift b/Sources/Fluid/UI/OnboardingCleanupExampleCarousel.swift
new file mode 100644
index 00000000..764c686c
--- /dev/null
+++ b/Sources/Fluid/UI/OnboardingCleanupExampleCarousel.swift
@@ -0,0 +1,175 @@
+import SwiftUI
+
+/// Shared typography and layout for every spoken-text / cleanup comparison.
+struct OnboardingCleanupExampleCarousel: View {
+ @Environment(\.theme) private var theme
+ @Environment(\.accessibilityReduceMotion) private var reduceMotion
+ let autoplay: OnboardingCarouselAutoplay
+ @State private var selectedID = "correction"
+
+ private struct Example: Identifiable {
+ let id: String
+ let title: String
+ let spoken: String
+ let cleaned: String
+ }
+
+ private static let examples = [
+ Example(
+ id: "correction",
+ title: "Understand when you change your mind",
+ spoken: "I'm free at 7:30 tomorrow morning. Would you be available for a quick call? Sorry, I meant 9:30 am.",
+ cleaned: "I'm free at 9:30 am tomorrow morning. Would you be available for a quick call?"
+ ),
+ Example(
+ id: "list",
+ title: "Turn your rambling into lists",
+ spoken: "Grocery list. First one is apples, second one is milk, third one is egg.",
+ cleaned: "Grocery list\n\n1. Apples\n2. Milk\n3. Egg"
+ ),
+ Example(
+ id: "paragraphs",
+ title: "Start a new paragraph based on context",
+ spoken: "I think I'm gonna meet you tomorrow at 3 p.m. Let me know if the time works. If not, we can figure out some other time. Also, I think you need to fix the bug. Please let me know if you need some help there.",
+ cleaned: "I think I'm gonna meet you tomorrow at 3 p.m. Let me know if the time works. If not, we can figure out some other time.\n\nAlso, I think you need to fix the bug. Please let me know if you need some help there."
+ ),
+ Example(
+ id: "email",
+ title: "Format your words into an email",
+ spoken: "Hey Marcus, hope you're doing well. Please let me know if you have any updates on the work that we've been doing last week. Thanks.",
+ cleaned: "Hey Marcus,\n\nHope you're doing well. Please let me know if you have any updates on the work that we've been doing last week.\n\nThanks."
+ ),
+ ]
+ private var ids: [String] { Self.examples.map(\.id) }
+
+ var body: some View {
+ VStack(spacing: 16) {
+ GeometryReader { geometry in
+ let width = min(640, geometry.size.width * 0.76)
+ let sideWidth = max(48, (geometry.size.width - width - 48) / 2)
+ let stride = width / 2 + sideWidth / 2 + 16
+ FluidGlassControlGroup {
+ ZStack {
+ ForEach(Self.examples) { example in
+ let position = PrivateAIModelCarouselNavigation.position(of: example.id, in: self.ids, current: self.selectedID)
+ if abs(position) <= 1 {
+ self.card(example, compact: position != 0, contentWidth: width, visibleWidth: position == 0 ? width : sideWidth)
+ .opacity(position == 0 ? 1 : 0.65)
+ .scaleEffect(position == 0 ? 1 : 0.90)
+ .offset(x: CGFloat(position) * stride)
+ .zIndex(position == 0 ? 1 : 0)
+ .transition(.opacity)
+ }
+ }
+ }
+ .frame(width: geometry.size.width, height: geometry.size.height)
+ .clipped()
+ }
+ .simultaneousGesture(DragGesture(minimumDistance: 24).onEnded { value in
+ guard abs(value.translation.width) > abs(value.translation.height) else { return }
+ self.advance(forward: value.translation.width < 0)
+ })
+ }
+ .frame(height: 440)
+ FluidGlassControlGroup {
+ HStack(spacing: 24) {
+ self.arrow(forward: false)
+ HStack(spacing: 4) {
+ ForEach(Self.examples) { example in
+ Button { self.browse(example.id) } label: {
+ Circle()
+ .fill(self.selectedID == example.id ? FluidBrandColors.blue : self.theme.palette.secondaryText.opacity(0.4))
+ .frame(width: self.selectedID == example.id ? 10 : 7, height: self.selectedID == example.id ? 10 : 7)
+ .frame(width: 24, height: 24)
+ .contentShape(Rectangle())
+ }
+ .buttonStyle(.plain)
+ .accessibilityLabel("Show \(example.title)")
+ .accessibilityValue(self.selectedID == example.id ? "Current page" : "")
+ }
+ }
+ self.arrow(forward: true)
+ }
+ }
+ }
+ .onReceive(self.autoplay.advance) { self.advance(forward: true) }
+ }
+
+ private func card(_ example: Example, compact: Bool, contentWidth: CGFloat, visibleWidth: CGFloat) -> some View {
+ VStack(alignment: .leading, spacing: 14) {
+ Group {
+ Text(example.title)
+ .font(.fluidSystem(size: 28, weight: .regular, design: .serif))
+ .tracking(-0.5)
+ .foregroundStyle(Color(red: 0.96, green: 0.95, blue: 0.91))
+ .multilineTextAlignment(.center)
+ .fixedSize(horizontal: false, vertical: true)
+ .frame(maxWidth: .infinity)
+ .frame(height: 68)
+ .accessibilityAddTraits(.isHeader)
+ self.mode(title: "Basic mode", text: example.spoken)
+ .frame(minHeight: 88, alignment: .topLeading)
+ Rectangle()
+ .fill(.white.opacity(0.12))
+ .frame(height: 1)
+ self.mode(title: "Smart mode", text: example.cleaned)
+ }
+ }
+ // Keep text at its final reading width while the glass surface slides and narrows.
+ .frame(width: contentWidth - 64, alignment: .leading)
+ .opacity(compact ? 0 : 1)
+ .animation(self.reduceMotion ? nil : .easeOut(duration: 0.18), value: compact)
+ .padding(32)
+ .frame(width: visibleWidth, height: 420, alignment: .top)
+ .clipped()
+ .accessibilityHidden(compact)
+ .modifier(OnboardingGlassSurface(selected: !compact))
+ .overlay {
+ if compact {
+ Button { self.browse(example.id) } label: {
+ Color.clear.contentShape(RoundedRectangle(cornerRadius: AppTheme.Metrics.Showcase.cardRadius))
+ }
+ .buttonStyle(.plain)
+ .accessibilityLabel("Show \(example.title)")
+ }
+ }
+ }
+
+ private func mode(title: String, text: String) -> some View {
+ VStack(alignment: .leading, spacing: 12) {
+ Text(title)
+ .font(.fluidSystem(size: 18, weight: .regular, design: .serif))
+ .tracking(-0.5)
+ .foregroundStyle(Color(red: 0.96, green: 0.95, blue: 0.91))
+ Text(text)
+ .font(.fluidSystem(size: 13, weight: .regular))
+ .foregroundStyle(.white.opacity(0.9))
+ .lineSpacing(4)
+ .fixedSize(horizontal: false, vertical: true)
+ }
+ .frame(maxWidth: .infinity, alignment: .topLeading)
+ .accessibilityElement(children: .combine)
+ }
+
+ private func browse(_ id: String) {
+ self.autoplay.interact()
+ withAnimation(self.reduceMotion ? nil : .spring(response: 0.48, dampingFraction: 0.94)) { self.selectedID = id }
+ }
+
+ private func advance(forward: Bool) {
+ guard let id = PrivateAIModelCarouselNavigation.next(in: self.ids, current: self.selectedID, forward: forward) else { return }
+ self.browse(id)
+ }
+
+ private func arrow(forward: Bool) -> some View {
+ Button { self.advance(forward: forward) } label: {
+ Image(systemName: forward ? "chevron.right" : "chevron.left")
+ .font(self.theme.typography.sectionTitle)
+ .foregroundStyle(self.theme.palette.primaryText)
+ .frame(width: 34, height: 34)
+ .contentShape(Circle())
+ }
+ .fluidGlassAction(circular: true)
+ .accessibilityLabel(forward ? "Next example" : "Previous example")
+ }
+}
diff --git a/Sources/Fluid/UI/OnboardingPolishPracticeView.swift b/Sources/Fluid/UI/OnboardingPolishPracticeView.swift
new file mode 100644
index 00000000..88f937ef
--- /dev/null
+++ b/Sources/Fluid/UI/OnboardingPolishPracticeView.swift
@@ -0,0 +1,88 @@
+import SwiftUI
+
+/// Mirrors the iOS practice composition using the Mac onboarding palette.
+struct OnboardingPolishPracticeView: View {
+ let practice: OnboardingPolishPractice
+ let isRunning: Bool
+ let isProcessing: Bool
+ let isRecordingShortcut: Bool
+ let shortcutDisplay: String
+ let shortcutRecordingMessage: String?
+ let onToggleShortcut: () -> Void
+
+ private var blue: Color { FluidOnboardingLandingColors.blue }
+
+ var body: some View {
+ VStack(spacing: 20) {
+ HStack(spacing: 12) {
+ ForEach(0..<OnboardingPolishPractice.examples.count, id: \.self) { index in
+ let done = self.practice.results[index] != nil
+ ZStack {
+ Circle().fill(done || index == self.practice.index ? self.blue : .white.opacity(0.1))
+ if done {
+ Image(systemName: "checkmark").font(.fluidSystem(size: 11, weight: .bold))
+ } else {
+ Text("\(index + 1)").font(.fluidSystem(size: 12, weight: .bold))
+ }
+ }
+ .foregroundStyle(.white.opacity(done || index == self.practice.index ? 1 : 0.45))
+ .frame(width: 28, height: 28)
+ .accessibilityLabel("Step \(index + 1), \(done ? "complete" : (index == self.practice.index ? "current" : "upcoming"))")
+ }
+ }
+ self.exampleText("Try saying this", text: self.practice.example.spoken, accent: false)
+ self.exampleText("It should come out as", text: self.practice.example.expected, accent: true)
+ Text(self.practice.result ?? "Your polished words appear here")
+ .font(.fluidSystem(size: 18, weight: .medium))
+ .foregroundStyle(.white.opacity(self.practice.result == nil ? 0.35 : 0.92))
+ .frame(maxWidth: .infinity, alignment: .leading)
+ .padding(16)
+ .textSelection(.enabled)
+ .fixedSize(horizontal: false, vertical: true)
+ .frame(minHeight: 105)
+ .background(.white.opacity(0.04), in: RoundedRectangle(cornerRadius: 14))
+ .overlay(RoundedRectangle(cornerRadius: 14).stroke(.white.opacity(0.15)))
+ .accessibilityLabel("Your dictation result")
+ VStack(spacing: 8) {
+ HStack(spacing: 16) {
+ Text(self.isRecordingShortcut ? "Press your new shortcut…" : self.shortcutDisplay)
+ .font(.fluidSystem(size: 14, weight: .semibold))
+ .foregroundStyle(.white)
+ Button(self.isRecordingShortcut ? "Cancel" : "Change shortcut", action: self.onToggleShortcut)
+ .buttonStyle(.plain)
+ .font(.fluidSystem(size: 12, weight: .semibold))
+ .foregroundStyle(self.blue)
+ .disabled(self.isRunning || self.isProcessing)
+ }
+ Text(self.status)
+ .font(.fluidSystem(size: 12))
+ .foregroundStyle(.white.opacity(0.58))
+ if let message = self.shortcutRecordingMessage, self.isRecordingShortcut {
+ Text(message).font(.fluidSystem(size: 12)).foregroundStyle(.orange)
+ }
+ }
+ .multilineTextAlignment(.center)
+ }
+ .frame(maxWidth: 500)
+ }
+
+ private var status: String {
+ if self.isRunning { return "Press your shortcut again when you’re done." }
+ if self.isProcessing { return "Polishing your words…" }
+ return self.practice.result == nil ? "Choose Smart mode below, then press your shortcut to try this one." : "Press your shortcut to try it again."
+ }
+
+ private func exampleText(_ label: String, text: String, accent: Bool) -> some View {
+ VStack(spacing: 8) {
+ Text(label.uppercased())
+ .font(.fluidSystem(size: 10, weight: .bold))
+ .tracking(0.8)
+ .foregroundStyle(accent ? self.blue : .white.opacity(0.4))
+ Text(text)
+ .font(.fluidSystem(size: accent ? 17 : 18, weight: accent ? .regular : .semibold))
+ .foregroundStyle(.white.opacity(accent ? 0.6 : 0.9))
+ .multilineTextAlignment(.center)
+ .fixedSize(horizontal: false, vertical: true)
+ }
+ }
+}
diff --git a/Sources/Fluid/UI/SettingsView.swift b/Sources/Fluid/UI/SettingsView.swift
index 70b37403..125fc5a2 100644
--- a/Sources/Fluid/UI/SettingsView.swift
+++ b/Sources/Fluid/UI/SettingsView.swift
@@ -182,15 +182,15 @@ struct SettingsView: View {
Spacer()
Picker("", selection: self.dictationPromptSelectionBinding(for: slot)) {
Section("ON-DEVICE") {
- Text("Fast — No cleanup").tag("__OFF__")
+ Text("Basic — No cleanup").tag("__OFF__")
if PrivateFeatures.privateAIProvider {
- Text("Cleanup — Fluid-1")
+ Text("Smart — Fluid-1")
.tag(PrivateAIProviderPromptFormat.promptSelectionID)
.disabled(!privateAIAvailable)
}
}
Section("EXTERNAL") {
- Text("Cleanup").tag("__DEFAULT__")
+ Text("Smart").tag("__DEFAULT__")
ForEach(profiles) { profile in
Text(profile.name.isEmpty ? "Untitled" : profile.name)
.tag(profile.id)
diff --git a/Sources/Fluid/UI/WelcomeView.swift b/Sources/Fluid/UI/WelcomeView.swift
index e6bf7f8d..a127f37a 100644
--- a/Sources/Fluid/UI/WelcomeView.swift
+++ b/Sources/Fluid/UI/WelcomeView.swift
@@ -346,6 +346,7 @@ struct OnboardingFlowView: View {
@State private var selectedModelRouteID: String?
@State private var hoveredLanguageID: String?
@State private var hoveredModelRouteID: String?
+ @State private var hoveredModelInfoRouteID: String?
@State private var hoveredModelActionButtonID: String?
@State private var hoveredPermissionButtonID: String?
@State private var onboardingInputDevices: [AudioDevice.Device] = []
@@ -359,6 +360,7 @@ struct OnboardingFlowView: View {
@State private var isOnboardingFlowVisible = false
@State private var hoveredFooterButton: OnboardingFooterButton?
@State private var isShowingAllLanguages = false
+ @State private var otherModelsPage = 0
@State private var isShowingOtherModelRoutes = false
@State private var preparingModelRouteID: String?
@State private var uninstallingModelRouteID: String?
@@ -786,29 +788,28 @@ struct OnboardingFlowView: View {
let landing = self.theme.metrics.onboardingSurface.landing
ZStack {
- VStack(alignment: .center, spacing: self.theme.metrics.onboardingSurface.landing.sectionSpacing) {
- FluidOnboardingLandingHero(
- eyebrow: "",
- title: "Just speak.",
- accentTitle: "We'll handle the rest.",
- firstDetail: "Accurate. Fast. Private. Free.",
- secondDetail: "Built for creators, thinkers, and builders."
- ) {
- FluidOnboardingLandingPrimaryButton(title: "Next") {
- self.goNext()
- }
- .frame(
- width: FluidOnboardingLandingPrimaryButton.size.width,
- height: FluidOnboardingLandingPrimaryButton.size.height
- )
+ VStack(spacing: 0) {
+ OnboardingFittedContent(width: landing.contentWidth + 48) {
+ FluidOnboardingLandingHero(
+ eyebrow: "",
+ title: "Just speak.",
+ accentTitle: "We'll handle the rest.",
+ firstDetail: "Accurate. Fast. Private. Free.",
+ secondDetail: "Built for creators, thinkers, and builders."
+ ) { EmptyView() }
+ .padding(24)
+ }
+ HStack {
+ Spacer()
+ FluidOnboardingLandingPrimaryButton(title: "Next") { self.goNext() }
+ .frame(
+ width: FluidOnboardingLandingPrimaryButton.size.width,
+ height: FluidOnboardingLandingPrimaryButton.size.height
+ )
}
+ .padding(.horizontal, 30)
+ .padding(.bottom, 24)
}
- .frame(width: landing.contentWidth, alignment: .center)
- .frame(maxWidth: .infinity)
- .frame(minHeight: proxy.size.height, alignment: .center)
- .offset(y: -78)
- .padding(.horizontal, 24)
- .padding(.vertical, 24)
FluidOnboardingLandingHoverTracker(
onMove: { location, size in
@@ -877,7 +878,7 @@ struct OnboardingFlowView: View {
FluidOnboardingCompactProgress(value: self.compactProgressValue)
.padding(.top, 28)
- ScrollView(.vertical, showsIndicators: false) {
+ OnboardingFittedContent(width: 760) {
VStack(spacing: 0) {
FluidOnboardingCompactAppIconMark(size: 66)
.padding(.bottom, 22)
@@ -1119,15 +1120,12 @@ struct OnboardingFlowView: View {
)
)
- ScrollView(.vertical, showsIndicators: true) {
- LazyVStack(spacing: 6) {
- ForEach(self.searchedOnboardingLanguages) { language in
- self.languageSearchRow(for: language)
- }
+ Menu("Choose a language") {
+ ForEach(self.searchedOnboardingLanguages) { language in
+ Button(language.displayName) { self.selectOnboardingLanguage(language) }
}
- .padding(8)
}
- .frame(width: 530, height: 156)
+ .frame(width: 530, height: 38)
.background(
RoundedRectangle(cornerRadius: 12, style: .continuous)
.fill(Color.white.opacity(0.045))
@@ -1337,7 +1335,7 @@ struct OnboardingFlowView: View {
FluidOnboardingCompactProgress(value: self.compactProgressValue)
.padding(.top, 28)
- ScrollView(.vertical, showsIndicators: self.isShowingOtherModelRoutes) {
+ OnboardingFittedContent(width: 760) {
VStack(spacing: 0) {
FluidOnboardingCompactAppIconMark(size: 66)
.padding(.bottom, 22)
@@ -1369,7 +1367,7 @@ struct OnboardingFlowView: View {
.padding(.bottom, 18)
VStack(spacing: 10) {
- let defaultRoutes = self.defaultDisplayedModelRoutes
+ let defaultRoutes = self.isShowingOtherModelRoutes ? [] : self.defaultDisplayedModelRoutes
if defaultRoutes.count == 1, let route = defaultRoutes.first {
self.onboardingRouteCard(for: route)
} else if !defaultRoutes.isEmpty {
@@ -1392,10 +1390,21 @@ struct OnboardingFlowView: View {
],
spacing: 16
) {
- ForEach(self.otherModelRoutes) { route in
+ let page = min(self.otherModelsPage, max(0, (self.otherModelRoutes.count - 1) / 2))
+ ForEach(Array(self.otherModelRoutes.dropFirst(page * 2).prefix(2))) { route in
self.onboardingRouteCard(for: route, enablesHover: false)
}
}
+ HStack(spacing: 16) {
+ let lastPage = max(0, (self.otherModelRoutes.count - 1) / 2)
+ let page = min(self.otherModelsPage, lastPage)
+ Button("Previous models") { self.otherModelsPage = max(0, page - 1) }
+ .disabled(page == 0)
+ Text("\(page + 1) / \(lastPage + 1)")
+ Button("Next models") { self.otherModelsPage = min(lastPage, page + 1) }
+ .disabled(page == lastPage)
+ }
+ .font(self.theme.typography.caption)
}
}
.frame(maxWidth: .infinity)
@@ -1406,9 +1415,9 @@ struct OnboardingFlowView: View {
.frame(width: 608)
if self.isModelPreparationInProgress {
- Label("Initial preparation can take a while to get your Mac ready for near-instant transcription.", systemImage: "clock.arrow.circlepath")
+ Label("First-time setup can take a few minutes while your Mac prepares the model. Please keep FluidVoice open.", systemImage: "clock.arrow.circlepath")
.font(self.theme.typography.captionStrong)
- .foregroundStyle(Color.white.opacity(0.58))
+ .foregroundStyle(self.theme.palette.warning)
.labelStyle(.titleAndIcon)
.lineLimit(1)
.minimumScaleFactor(0.86)
@@ -1416,8 +1425,8 @@ struct OnboardingFlowView: View {
.padding(.vertical, 5)
.background(
Capsule()
- .fill(Color.white.opacity(0.06))
- .overlay(Capsule().stroke(Color.white.opacity(0.10), lineWidth: 1))
+ .fill(self.theme.palette.warning.opacity(0.10))
+ .overlay(Capsule().stroke(self.theme.palette.warning.opacity(0.24), lineWidth: 1))
)
.padding(.top, 14)
}
@@ -1463,7 +1472,7 @@ struct OnboardingFlowView: View {
FluidOnboardingCompactProgress(value: self.compactProgressValue)
.padding(.top, 28)
- ScrollView(.vertical, showsIndicators: false) {
+ OnboardingFittedContent(width: 760) {
VStack(spacing: 0) {
FluidOnboardingCompactAppIconMark(size: 66)
.padding(.bottom, 22)
@@ -1561,12 +1570,11 @@ struct OnboardingFlowView: View {
),
progressValue: self.compactProgressValue,
glowCenter: self.landingGlowCenter,
- language: self.selectedOnboardingLanguage,
shortcutDisplay: self.onboardingShortcutDisplay,
- isTestReady: self.isPlaygroundReady,
- isRunning: self.asr.isRunning,
+ isRunning: self.asr.isRunning || self.asr.isStarting,
isRecordingShortcut: self.isRecordingPrimaryShortcut,
- shortcutRecordingMessage: self.isRecordingPrimaryShortcut ? self.shortcutRecordingMessage : nil,
+ shortcutRecordingMessage: self.shortcutRecordingMessage,
+ onToggleShortcut: self.togglePrimaryShortcutRecording,
onGlowMove: self.updateLandingGlow(location:in:),
onGlowExit: self.resetLandingGlow,
onBack: self.goBack,
@@ -1580,15 +1588,6 @@ struct OnboardingFlowView: View {
completesFlow: self.settings.onboardingCompleted
)
},
- onUseAIProvider: {
- let origin = self.settings.analyticsOnboardingOrigin
- self.openAIEnhancementSettingsFromOnboarding()
- self.completeCurrentStep(
- outcome: .openedSettings,
- origin: origin,
- completesFlow: self.settings.onboardingCompleted
- )
- },
onFinishSetup: {
let origin = self.settings.analyticsOnboardingOrigin
self.finishOnboardingAtGettingStarted()
@@ -1610,7 +1609,7 @@ struct OnboardingFlowView: View {
FluidOnboardingCompactProgress(value: self.compactProgressValue)
.padding(.top, 28)
- ScrollView(.vertical, showsIndicators: false) {
+ OnboardingFittedContent(width: 760) {
VStack(spacing: 0) {
FluidOnboardingCompactAppIconMark(size: 66)
.padding(.bottom, 22)
@@ -1883,8 +1882,10 @@ struct OnboardingFlowView: View {
.foregroundStyle(Color.white.opacity(0.58))
.frame(width: 24, height: 24)
.contentShape(Circle())
- .help(self.onboardingModelTooltip(for: route))
.accessibilityLabel(self.onboardingModelTooltip(for: route))
+ .onHover { isHovered in
+ self.hoveredModelInfoRouteID = isHovered ? route.id : nil
+ }
}
.frame(height: 38, alignment: .top)
@@ -1998,6 +1999,13 @@ struct OnboardingFlowView: View {
)
.shadow(color: Color.black.opacity(0.34), radius: isHovered ? 20 : 14, x: 0, y: isHovered ? 12 : 8)
.contentShape(shape)
+ .overlay(alignment: .topTrailing) {
+ if self.hoveredModelInfoRouteID == route.id {
+ OnboardingModelInfoTooltip(text: self.onboardingModelTooltip(for: route), font: self.theme.typography.caption)
+ .padding(.top, 46)
+ .padding(.trailing, 16)
+ }
+ }
.onTapGesture {
guard !areModelActionsBlocked else { return }
self.selectOnboardingRoute(route)
diff --git a/Sources/Fluid/Views/BottomOverlayView.swift b/Sources/Fluid/Views/BottomOverlayView.swift
index 71e79c85..cd113be8 100644
--- a/Sources/Fluid/Views/BottomOverlayView.swift
+++ b/Sources/Fluid/Views/BottomOverlayView.swift
@@ -1596,7 +1596,7 @@ private struct BottomOverlayPromptMenuView: View {
self.onDismissRequested()
}) {
HStack(alignment: .firstTextBaseline, spacing: 8) {
- Text("Fast")
+ Text("Basic")
Spacer(minLength: 12)
Text("No cleanup")
.font(.fluidSystem(size: 10, weight: .medium))
@@ -1635,7 +1635,7 @@ private struct BottomOverlayPromptMenuView: View {
self.onDismissRequested()
}) {
HStack {
- Text("Cleanup")
+ Text("Smart")
Spacer()
if isSelected {
Image(systemName: "checkmark")
@@ -1665,7 +1665,7 @@ private struct BottomOverlayPromptMenuView: View {
self.onDismissRequested()
}) {
HStack(alignment: .firstTextBaseline, spacing: 8) {
- Text("Cleanup")
+ Text("Smart")
Spacer(minLength: 12)
Text("Fluid-1")
.font(.fluidSystem(size: 10, weight: .medium))
@@ -2134,6 +2134,9 @@ private struct DynamicPreviewHeightPreferenceKey: PreferenceKey {
// MARK: - Bottom Overlay SwiftUI View
struct BottomOverlayView: View {
+ private var showsOnboardingHint: Bool { self.contentState.showsOnboardingModeHint }
+ @State private var onboardingHighlight = false
+
@ObservedObject private var contentState = NotchContentState.shared
@ObservedObject private var appServices = AppServices.shared
@ObservedObject private var activeAppMonitor = ActiveAppMonitor.shared
@@ -2428,15 +2431,15 @@ struct BottomOverlayView: View {
if activePromptMode.normalized == .dictate {
switch self.settings.dictationPromptSelection(for: self.activeDictationShortcutSlot) {
case .off:
- return "Fast"
+ return "Basic"
case .privateAI:
- return "Cleanup"
+ return "Smart"
case .default:
let hasAppOverride = self.settings.resolvedDictationPromptProfile(
for: self.activeDictationShortcutSlot,
appBundleID: self.promptResolutionBundleID
) != nil
- return hasAppOverride ? nil : "Cleanup"
+ return hasAppOverride ? nil : "Smart"
case .profile:
return nil
}
@@ -2445,7 +2448,7 @@ struct BottomOverlayView: View {
return self.settings.resolvedPromptProfile(
for: activePromptMode,
appBundleID: self.promptResolutionBundleID
- ) == nil ? "Cleanup" : nil
+ ) == nil ? "Smart" : nil
}
private var promptSelectorDisplayLabel: String {
@@ -2469,9 +2472,9 @@ struct BottomOverlayView: View {
private var promptSelectorIconName: String? {
switch self.promptSelectorBuiltInLabel {
- case "Fast"?:
+ case "Basic"?:
return "bolt.fill"
- case "Cleanup"?:
+ case "Smart"?:
return "sparkles"
default:
return nil
@@ -2886,8 +2889,8 @@ struct BottomOverlayView: View {
)
)
.overlay(alignment: .top) {
- if self.isHoveringPromptChip, self.isPromptSelectableMode, !self.contentState.isProcessing {
- Text("Select cleanup mode")
+ if self.isHoveringPromptChip, !self.showsOnboardingHint, self.isPromptSelectableMode, !self.contentState.isProcessing {
+ Text("Select dictation mode")
.font(.fluidSystem(size: 11, weight: .semibold))
.foregroundStyle(.white.opacity(0.9))
.padding(.horizontal, 8)
@@ -2904,7 +2907,42 @@ struct BottomOverlayView: View {
}
}
.accessibilityElement(children: .combine)
- .accessibilityLabel("Select cleanup mode")
+ .accessibilityLabel("Select dictation mode")
+ .overlay {
+ if self.showsOnboardingHint {
+ RoundedRectangle(cornerRadius: self.promptSelectorCornerRadius)
+ .stroke(FluidOnboardingLandingColors.blue, lineWidth: 1.5)
+ .padding(-3)
+ .opacity(self.reduceMotion || self.onboardingHighlight ? 1 : 0.2)
+ .allowsHitTesting(false)
+ }
+ }
+ .overlay(alignment: .top) {
+ if self.showsOnboardingHint {
+ VStack(spacing: 5) {
+ Text("Switch modes here")
+ .font(.fluidSystem(size: 12, weight: .semibold))
+ Text("Click to switch between Basic and Smart")
+ .font(.fluidSystem(size: 11))
+ .foregroundStyle(.white.opacity(0.65))
+ Image(systemName: "arrow.down")
+ .font(.fluidSystem(size: 11, weight: .medium))
+ .foregroundStyle(FluidOnboardingLandingColors.blue)
+ }
+ .fixedSize()
+ .offset(y: -78)
+ .allowsHitTesting(false)
+ }
+ }
+ .task(id: self.showsOnboardingHint) {
+ guard self.showsOnboardingHint, !self.reduceMotion else { return }
+ for _ in 0..<2 {
+ withAnimation(.easeInOut(duration: 0.45)) { self.onboardingHighlight = true }
+ do { try await Task.sleep(for: .milliseconds(500)) } catch { return }
+ withAnimation(.easeInOut(duration: 0.45)) { self.onboardingHighlight = false }
+ do { try await Task.sleep(for: .milliseconds(500)) } catch { return }
+ }
+ }
}
private var promptSelectorView: some View {
@@ -2923,6 +2961,7 @@ struct BottomOverlayView: View {
}
.onTapGesture {
guard self.layout.showsTopControls, self.isPromptSelectableMode, !self.contentState.isProcessing else { return }
+ self.contentState.showsOnboardingModeHint = false
self.closeModeMenu()
self.closeActionsMenu()
BottomOverlayPromptMenuController.shared.updateAnchor(
@@ -3482,6 +3521,10 @@ struct BottomOverlayView: View {
)
// Reserve space around the pill so its drop shadow isn't clipped by the (content-sized) window.
.padding(self.isPillSize ? 26 : 0)
+ .padding(.top, self.showsOnboardingHint ? 82 : 0)
+ .onChange(of: self.showsOnboardingHint) { _, _ in
+ BottomOverlayWindowController.shared.refreshSizeForContent()
+ }
.frame(maxHeight: .infinity, alignment: .top)
.scaleEffect(self.overlayAnimatedScale, anchor: .center)
.offset(y: self.overlayAnimatedOffsetY)
diff --git a/Sources/Fluid/Views/NotchContentViews.swift b/Sources/Fluid/Views/NotchContentViews.swift
index 67ae4387..0ed9d6a3 100644
--- a/Sources/Fluid/Views/NotchContentViews.swift
+++ b/Sources/Fluid/Views/NotchContentViews.swift
@@ -97,6 +97,7 @@ class NotchContentState: ObservableObject {
/// Keep overlay state bounded even during very long recordings.
private static let maxStoredTranscriptionCharacters = SettingsStore.transcriptionPreviewCharLimitRange.upperBound
+ @Published var showsOnboardingModeHint = false
@Published var transcriptionText: String = ""
@Published var mode: OverlayMode = .dictation
@Published var promptPickerMode: SettingsStore.PromptMode = .dictate
@@ -822,7 +823,7 @@ struct NotchExpandedView: View {
if promptMode.normalized == .dictate {
self.promptMenuRow(
- "Off",
+ "Basic",
rowID: "off",
isSelected: self.settings.dictationPromptSelection(for: activeDictationSlot) == .off,
isEnabled: true
@@ -833,7 +834,7 @@ struct NotchExpandedView: View {
}
}
- self.promptMenuRow("Default", rowID: "default", isSelected: defaultSelected) {
+ self.promptMenuRow(promptMode.normalized == .dictate ? "Smart" : "Default", rowID: "default", isSelected: defaultSelected) {
if promptMode.normalized == .dictate {
self.contentState.onDictationPromptSelectionRequested?(.default)
} else {
@@ -846,7 +847,7 @@ struct NotchExpandedView: View {
if promptMode.normalized == .dictate && PrivateFeatures.privateAIProvider {
let privateAIAvailable = PrivateAIProviderPromptFormat.isAvailable(settings: self.settings)
self.promptMenuRow(
- PrivateAIProviderFeature.displayName,
+ "Smart — Fluid-1",
rowID: PrivateAIProviderFeature.shared.providerID,
isSelected: self.settings.dictationPromptSelection(for: activeDictationSlot) == .privateAI,
isEnabled: privateAIAvailable
diff --git a/Tests/FluidDictationIntegrationTests/DictationE2ETests.swift b/Tests/FluidDictationIntegrationTests/DictationE2ETests.swift
index 0e9628ad..4d4a7b8e 100644
--- a/Tests/FluidDictationIntegrationTests/DictationE2ETests.swift
+++ b/Tests/FluidDictationIntegrationTests/DictationE2ETests.swift
@@ -2046,7 +2046,7 @@ extension DictationE2ETests {
settings.setDictationPromptSelection(.off)
XCTAssertEqual(settings.dictationPromptSelection(for: .primary), .off)
- XCTAssertEqual(settings.dictationPromptDisplayName(for: .primary, appBundleID: nil), "Off")
+ XCTAssertEqual(settings.dictationPromptDisplayName(for: .primary, appBundleID: nil), "Basic")
settings.selectedProviderID = "openai"
settings.setDictationPromptSelection(.profile(custom.id))
diff --git a/Tests/FluidDictationIntegrationTests/HotkeyShortcutTests.swift b/Tests/FluidDictationIntegrationTests/HotkeyShortcutTests.swift
index 090d3276..0ae95894 100644
--- a/Tests/FluidDictationIntegrationTests/HotkeyShortcutTests.swift
+++ b/Tests/FluidDictationIntegrationTests/HotkeyShortcutTests.swift
@@ -2170,3 +2170,54 @@ private final class ModifierOnlyFlagsReplay {
self.keyDown()
}
}
+
+@MainActor
+final class FloatingOnboardingOverlayTests: XCTestCase {
+ func testOnboardingUsesRealFloatingWindowWithoutChangingPreferences() async {
+ let manager = NotchOverlayManager.shared
+ let owner = UUID()
+ let settings = SettingsStore.shared
+ let position = settings.overlayPosition
+ let selection = settings.dictationPromptSelection(for: .primary)
+ let audio = PassthroughSubject<CGFloat, Never>()
+ manager.beginOnboardingOverlay(owner: owner)
+ defer { manager.endOnboardingOverlay(owner: owner) }
+ manager.show(audioLevelPublisher: audio.eraseToAnyPublisher(), mode: .dictation)
+ audio.send(0.4)
+ try? await Task.sleep(for: .milliseconds(30))
+ XCTAssertEqual(NotchContentState.shared.bottomOverlayAudioLevel, 0.4)
+ XCTAssertTrue(manager.isBottomOverlayVisible)
+ XCTAssertFalse(manager.isOverlayVisible)
+ manager.setProcessing(true)
+ XCTAssertTrue(NotchContentState.shared.isProcessing)
+ XCTAssertTrue(manager.isBottomOverlayVisible)
+ XCTAssertFalse(manager.isOverlayVisible)
+ let outcome = await manager.hideAndWait()
+ XCTAssertEqual(outcome, .hidden)
+ audio.send(0.9)
+ try? await Task.sleep(for: .milliseconds(30))
+ XCTAssertEqual(NotchContentState.shared.bottomOverlayAudioLevel, 0)
+ XCTAssertEqual(settings.overlayPosition, position)
+ XCTAssertEqual(settings.dictationPromptSelection(for: .primary), selection)
+ }
+
+ func testStalePageExitDoesNotReleaseNewFloatingPresentation() async {
+ let manager = NotchOverlayManager.shared
+ let first = UUID()
+ let second = UUID()
+ manager.beginOnboardingOverlay(owner: first)
+ manager.beginOnboardingOverlay(owner: second)
+ defer { manager.endOnboardingOverlay(owner: second) }
+ manager.endOnboardingOverlay(owner: first)
+ manager.show(audioLevelPublisher: Empty<CGFloat, Never>().eraseToAnyPublisher(), mode: .dictation)
+ manager.setProcessing(true)
+ XCTAssertTrue(manager.isBottomOverlayVisible)
+ XCTAssertFalse(manager.isOverlayVisible)
+ manager.hideImmediately()
+ manager.show(audioLevelPublisher: Empty<CGFloat, Never>().eraseToAnyPublisher(), mode: .dictation)
+ await Task.yield()
+ XCTAssertTrue(manager.isBottomOverlayVisible)
+ XCTAssertFalse(manager.isOverlayVisible)
+ _ = await manager.hideAndWait()
+ }
+}
diff --git a/Tests/OnboardingAISetupControllerTests.swift b/Tests/OnboardingAISetupControllerTests.swift
new file mode 100644
index 00000000..47fab507
--- /dev/null
+++ b/Tests/OnboardingAISetupControllerTests.swift
@@ -0,0 +1,148 @@
+import Foundation
+
+@MainActor
+private final class Harness {
+ typealias Controller = OnboardingAISetupController
+ var installed = false
+ var failRecommendation = false
+ var failDownload = false
+ var failLoad = false
+ var pauseDownload = false
+ var pauseLoad = false
+ var readCount = 0
+ var downloads = 0
+ var loads = 0
+ var commits = 0
+ var downloadContinuation: CheckedContinuation<Void, Never>?
+ var loadContinuation: CheckedContinuation<Void, Never>?
+ var progressCallback: (@Sendable (Controller.Progress) async -> Void)?
+ var lastID: String?
+ enum Failure: Error { case simulated }
+
+ func controller() -> Controller {
+ Controller(dependencies: .init(
+ recommend: {
+ self.readCount += 1
+ if self.failRecommendation { throw Failure.simulated }
+ return .init(id: "pico", name: "Pico", byteCount: 100, installed: self.installed)
+ },
+ prepare: { model, progress in
+ self.downloads += 1
+ self.lastID = model.id
+ self.progressCallback = progress
+ await progress(.init(fraction: 0.5, status: "Downloading", bytes: "50 of 100"))
+ if self.pauseDownload {
+ await withCheckedContinuation { self.downloadContinuation = $0 }
+ }
+ if self.failDownload { throw Failure.simulated }
+ },
+ load: { model in
+ self.loads += 1
+ self.lastID = model.id
+ if self.pauseLoad {
+ await withCheckedContinuation { self.loadContinuation = $0 }
+ }
+ if self.failLoad { throw Failure.simulated }
+ }
+ ))
+ }
+}
+
+@main
+struct OnboardingAISetupControllerTests {
+ @MainActor
+ static func waitUntil(_ predicate: () -> Bool) async {
+ for _ in 0..<10_000 {
+ if predicate() { return }
+ await Task.yield()
+ }
+ preconditionFailure("Timed out waiting for controller")
+ }
+
+ @MainActor
+ static func main() async {
+ let fresh = Harness()
+ let controller = fresh.controller()
+ controller.refresh()
+ controller.refresh()
+ await self.waitUntil { controller.phase == .offered }
+ precondition(fresh.readCount == 1 && fresh.downloads == 0 && fresh.loads == 0 && fresh.commits == 0)
+ controller.enable { _ in fresh.commits += 1 }
+ controller.enable { _ in preconditionFailure("Duplicate action") }
+ await self.waitUntil { controller.phase == .ready }
+ precondition(fresh.downloads == 1 && fresh.loads == 1 && fresh.commits == 1 && fresh.lastID == "pico")
+ await fresh.progressCallback?(.init(fraction: 0.1, status: "stale", bytes: nil))
+ precondition(controller.phase == .ready && controller.progress == nil)
+ controller.refresh()
+ precondition(fresh.readCount == 1)
+
+ let cached = Harness()
+ cached.installed = true
+ let cachedController = cached.controller()
+ cachedController.refresh()
+ await self.waitUntil { cachedController.phase == .offered }
+ cachedController.enable { _ in cached.commits += 1 }
+ await self.waitUntil { cachedController.phase == .ready }
+ precondition(cached.downloads == 0 && cached.loads == 1 && cached.commits == 1)
+
+ for cancelDuringLoad in [false, true] {
+ let harness = Harness()
+ harness.pauseDownload = !cancelDuringLoad
+ harness.pauseLoad = cancelDuringLoad
+ let operation = harness.controller()
+ operation.refresh()
+ await self.waitUntil { operation.phase == .offered }
+ operation.enable { _ in harness.commits += 1 }
+ await self.waitUntil { cancelDuringLoad ? harness.loadContinuation != nil : harness.downloadContinuation != nil }
+ operation.cancel()
+ operation.cancel()
+ precondition(operation.phase == .cancelling && operation.progress == nil)
+ operation.enable { _ in preconditionFailure("Cannot overlap cancelled work") }
+ await harness.progressCallback?(.init(fraction: 0.9, status: "late", bytes: nil))
+ precondition(operation.progress == nil)
+ harness.downloadContinuation?.resume()
+ harness.loadContinuation?.resume()
+ await self.waitUntil { operation.phase == .offered }
+ precondition(harness.commits == 0 && operation.errorMessage == nil)
+ precondition(harness.loads == (cancelDuringLoad ? 1 : 0))
+ let oldProgress = harness.progressCallback
+ harness.pauseDownload = false
+ harness.pauseLoad = false
+ operation.enable { _ in harness.commits += 1 }
+ await self.waitUntil { operation.phase == .ready }
+ await oldProgress?(.init(fraction: 0.2, status: "old operation", bytes: nil))
+ precondition(operation.progress == nil && harness.commits == 1)
+ }
+
+ for downloadFailure in [true, false] {
+ let harness = Harness()
+ harness.failDownload = downloadFailure
+ harness.failLoad = !downloadFailure
+ let operation = harness.controller()
+ operation.refresh()
+ await self.waitUntil { operation.phase == .offered }
+ operation.enable { _ in harness.commits += 1 }
+ await self.waitUntil { operation.errorMessage != nil }
+ precondition(operation.phase == .offered && harness.commits == 0 && operation.progress == nil)
+ harness.failDownload = false
+ harness.failLoad = false
+ operation.enable { _ in harness.commits += 1 }
+ await self.waitUntil { operation.phase == .ready }
+ precondition(harness.commits == 1)
+ }
+
+ let unavailable = Harness()
+ unavailable.failRecommendation = true
+ let missing = unavailable.controller()
+ missing.refresh()
+ await self.waitUntil { missing.phase == .unavailable }
+ precondition(unavailable.downloads == 0 && unavailable.commits == 0)
+ unavailable.failRecommendation = false
+ missing.refresh()
+ await self.waitUntil { missing.phase == .offered }
+ missing.enable { _ in throw Harness.Failure.simulated }
+ await self.waitUntil { missing.errorMessage != nil }
+ precondition(missing.phase == .offered && unavailable.commits == 0)
+ print("PASS: read-only recommendation, fresh/cached activation, duplicate actions, cancellation during download/load, stale progress, failure/retry and commit rejection")
+ }
+}
diff --git a/Tests/OnboardingDictationOutputPolicyTests.swift b/Tests/OnboardingDictationOutputPolicyTests.swift
new file mode 100644
index 00000000..ffc88f82
--- /dev/null
+++ b/Tests/OnboardingDictationOutputPolicyTests.swift
@@ -0,0 +1,16 @@
+@main
+struct OnboardingDictationOutputPolicyTests {
+ static func main() {
+ var cases = 0
+ for active in [false, true] {
+ for dictation in [false, true] {
+ for target: Int32? in [nil, 100, 200] {
+ let actual = OnboardingDictationOutputPolicy.usesSandbox(onboardingPracticeActive: active, isDictation: dictation, targetProcessID: target, fluidVoiceProcessID: 100)
+ precondition(actual == (active && dictation && target != 200))
+ cases += 1
+ }
+ }
+ }
+ print("Passed \(cases) onboarding output routing cases")
+ }
+}
diff --git a/Tests/OnboardingPolishPracticeTests.swift b/Tests/OnboardingPolishPracticeTests.swift
new file mode 100644
index 00000000..cd204836
--- /dev/null
+++ b/Tests/OnboardingPolishPracticeTests.swift
@@ -0,0 +1,37 @@
+import Foundation
+
+@main
+struct OnboardingPolishPracticeTests {
+ static func main() {
+ var practice = OnboardingPolishPractice()
+ practice.receive("Stale result from earlier onboarding")
+ precondition(practice.result == nil)
+ precondition(!practice.advance(isBusy: false))
+ practice.beginAttempt()
+ practice.receive(" \n ")
+ precondition(practice.result == nil)
+ precondition(!practice.advance(isBusy: false))
+ practice.receive("Hey John,\nHow are you doing today?")
+ precondition(practice.result != nil)
+ precondition(!practice.advance(isBusy: true))
+ precondition(practice.index == 0)
+ precondition(practice.advance(isBusy: false))
+ precondition(!practice.advance(isBusy: false))
+ practice.receive("Late duplicate")
+ precondition(practice.result == nil && practice.results.count == 1)
+ practice.beginAttempt()
+ practice.receive("Correction result")
+ practice.beginAttempt()
+ precondition(practice.result == nil && practice.results[0] != nil)
+ practice.receive("")
+ precondition(!practice.advance(isBusy: false))
+ practice.receive("Retried correction")
+ precondition(practice.advance(isBusy: false))
+ practice.beginAttempt()
+ practice.receive("Grocery list:\n- banana\n- apple\n- orange")
+ precondition(practice.isLast && practice.results.count == 3)
+ precondition(!practice.advance(isBusy: false))
+ precondition(practice.index == 2)
+ print("Practice progression, empty/failure, retry, busy, stale output, and bounded final-step checks passed")
+ }
+}
diff --git a/Tests/PrivateAIHardwareRecommendationTests.swift b/Tests/PrivateAIHardwareRecommendationTests.swift
new file mode 100644
index 00000000..6450dba9
--- /dev/null
+++ b/Tests/PrivateAIHardwareRecommendationTests.swift
@@ -0,0 +1,50 @@
+import Foundation
+
+@main
+struct PrivateAIHardwareRecommendationTests {
+ static func main() async {
+ typealias Policy = PrivateAIHardwareRecommendation
+ let gib: UInt64 = 1024 * 1024 * 1024
+ let cases: [(String, Int?, UInt64, Policy.Model)] = [
+ ("Apple M1", 8, 8, .pico), ("Apple M1", 8, 16, .pico),
+ ("Apple M1 Pro", 16, 32, .mini), ("Apple M1 Max", 24, 32, .mini),
+ ("Apple M2", 10, 24, .pico), ("Apple M2 Pro", 19, 32, .mini),
+ ("Apple M2 Max", 30, 32, .mini), ("Apple M3", 10, 24, .pico),
+ ("Apple M3 Pro", 18, 36, .mini), ("Apple M3 Max", 30, 36, .mini),
+ ("Apple M3 Max", 40, 48, .mini), ("Apple M3 Max", nil, 128, .mini),
+ ("Apple M3 Max", 99, 128, .mini), ("Apple M4", 10, 32, .pico),
+ ("Apple M4 Pro", 20, 64, .mini), ("Apple M4 Max", 32, 36, .mini),
+ ("Apple M4 Max", 40, 128, .mini), ("Apple M5", 10, 32, .pico),
+ ("Apple M5 Pro", 20, 64, .mini), ("Apple M5 Max", 32, 36, .mini),
+ ("Apple M5 Max", 40, 128, .mini), ("Apple M1 Ultra", 48, 64, .mini),
+ ("Apple M2 Ultra", 60, 64, .mini), ("Apple M3 Ultra", 60, 96, .mini),
+ ("Apple M5 Max", 40, 8, .pico), ("Apple M5 Max", 40, 16, .pico), ("Apple M5 Max", 40, 24, .mini),
+ ("Apple M3 Pro", 18, 18, .mini),
+ ("Intel Core i9", nil, 64, .pico), ("Apple M99 Max", 40, 128, .pico),
+ ("", nil, 0, .pico), (" APPLE M1 MAX ", nil, 32, .mini),
+ ]
+ for (chip, cores, ram, expected) in cases {
+ let hardware = Policy.Hardware(chip: chip, memoryBytes: ram * gib, gpuCoreCount: cores)
+ precondition(Policy.recommend(for: hardware).model == expected, "Unexpected recommendation: \(chip), \(ram) GB")
+ }
+ let belowBoundary = Policy.Hardware(chip: "Apple M1 Max", memoryBytes: 18 * gib - 1, gpuCoreCount: nil)
+ precondition(Policy.recommend(for: belowBoundary).reason == .insufficientMemory)
+ let unknown = Policy.Hardware(chip: "unknown", memoryBytes: 128 * gib, gpuCoreCount: nil)
+ precondition(Policy.recommend(for: unknown).reason == .unknownHardware)
+ precondition(Policy.recommend(for: unknown).bandwidthGBps == nil)
+ let hardware = await Policy.currentHardware()
+ let expected = Policy.recommend(for: hardware)
+ // Concurrent requests share an immutable snapshot and return the same recommendation.
+ await withTaskGroup(of: Policy.Recommendation.self) { group in
+ for _ in 0..<32 {
+ group.addTask { await Policy.current() }
+ }
+ for await result in group {
+ precondition(result == expected)
+ }
+ }
+ print("PASS: \(cases.count) hardware cases, boundary/failure checks, 32 concurrent requests")
+ print("LIVE: \(hardware.chip), GPU cores \(hardware.gpuCoreCount ?? 0), RAM \(hardware.memoryBytes / gib) GiB")
+ print("RESULT: \(expected.model.rawValue), \(expected.bandwidthGBps ?? 0) GB/s, \(expected.reason.rawValue)")
+ }
+}
diff --git a/Tests/PrivateAISettingsControllerDoubles.swift b/Tests/PrivateAISettingsControllerDoubles.swift
index b37e644d..c733feae 100644
--- a/Tests/PrivateAISettingsControllerDoubles.swift
+++ b/Tests/PrivateAISettingsControllerDoubles.swift
@@ -60,6 +60,13 @@ final class AIEnhancementSettingsViewModel {
var verificationCount = 0
var resetCount = 0
var verified = true
+ var smartSelectionCount = 0
+ var smartSelected = false
+ func selectPrivateAIPromptIfAvailable() {
+ guard verified else { return }
+ smartSelectionCount += 1
+ smartSelected = true
+ }
func providerKey(for id: String) -> String { id }
func refreshProviderItems() {}
func connectionErrorMessage(for id: String) -> String { "test failure" }
@@ -239,7 +246,7 @@ enum PrivateAIControllerChecks {
controller.usePreviewModel(isInstalled: true) { activations += 1 }
controller.usePreviewModel(isInstalled: true) { activations += 1 }
await eventually { !controller.isBusy }
- check(activations == 0, "Failed activation must not switch shortcut routing")
+ check(activations == 0 && vm.smartSelectionCount == 0, "Failed activation must not switch shortcut routing")
controller.refreshPrivateAILoadState()
for _ in 0..<20 { await Task.yield() }
check(controller.privateAILoadState.failureMessage(for: "mini") != nil, "Passive runtime refresh preserves failed activation")
@@ -247,7 +254,11 @@ enum PrivateAIControllerChecks {
controller.usePreviewModel(isInstalled: true) { activations += 1 }
await eventually { !controller.isBusy }
check(activations == 1 && controller.privateAILoadState.isLoaded("mini"), "Explicit activation calls routing once after successful verification")
+ check(vm.smartSelected && vm.smartSelectionCount == 1, "Successful explicit activation selects Smart once")
check(vm.selectedProviderID == "external" && vm.selectedModel == "external-model", "Activation preserves external editor configuration")
+ vm.smartSelected = false // User manually chooses Basic after activation.
+ controller.synchronizeSelection()
+ check(!vm.smartSelected, "Reopening settings preserves manually selected Basic")
var completionCount = 0
var reportedError: String?
let writesBeforeVerification = UserDefaults.standard.writes
@@ -258,6 +269,7 @@ enum PrivateAIControllerChecks {
controller.verifyPrivateAIConnection(.init(id: "mini"), onCompletion: { _ in completionCount += 100 })
await eventually { !controller.isBusy }
check(completionCount == 1 && reportedError == nil, "Manual verification reports success once; duplicate clicks do not report")
+ check(!vm.smartSelected && vm.smartSelectionCount == 1, "Verification preserves manually selected Basic")
vm.verified = false
controller.verifyPrivateAIConnection(.init(id: "mini"), onCompletion: { error in
completionCount += 1
@@ -267,5 +279,9 @@ enum PrivateAIControllerChecks {
check(completionCount == 2 && reportedError?.contains("test failure") == true, "Manual verification reports the actual failure")
controller.verifyPrivateAIConnection(.init(id: "pico"), onCompletion: { _ in completionCount += 100 })
check(completionCount == 2 && UserDefaults.standard.writes == writesBeforeVerification, "Inactive verification has no result or persistence side effects")
+ vm.verified = true
+ controller.usePreviewModel(isInstalled: true) {}
+ await eventually { !controller.isBusy }
+ check(vm.smartSelected && vm.smartSelectionCount == 2, "Another explicit activation switches Basic back to Smart")
}
}