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

fix(onboarding): retain AI setup and video progress across navigation

altic-dev71ee601c486e
diff --git a/Sources/Fluid/Services/OnboardingAISetupController.swift b/Sources/Fluid/Services/OnboardingAISetupController.swift
index f8234ec2..23cd2abf 100644
--- a/Sources/Fluid/Services/OnboardingAISetupController.swift
+++ b/Sources/Fluid/Services/OnboardingAISetupController.swift
@@ -27,6 +27,8 @@ final class OnboardingAISetupController: ObservableObject {
var load: (Model) async throws -> Void
}
+ /// Retained by the onboarding flow across Back/Continue; Replay is the only reset.
+ @Published var introductionFinished = false
@Published private(set) var model: Model?
@Published private(set) var phase: Phase = .checking
@Published private(set) var progress: Progress?
diff --git a/Sources/Fluid/UI/OnboardingAIEnhancementStepView.swift b/Sources/Fluid/UI/OnboardingAIEnhancementStepView.swift
index 14f571c3..f92ef242 100644
--- a/Sources/Fluid/UI/OnboardingAIEnhancementStepView.swift
+++ b/Sources/Fluid/UI/OnboardingAIEnhancementStepView.swift
@@ -2,6 +2,7 @@ import Foundation
import SwiftUI
struct OnboardingAIEnhancementStepView: View {
+ @ObservedObject var setup: OnboardingAISetupController
@Binding var finalText: String
let progressValue: Double
let glowCenter: UnitPoint
@@ -21,10 +22,8 @@ struct OnboardingAIEnhancementStepView: View {
@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 introductionFinished = false
@State private var showPractice = false
@State private var introductionPlaybackID = UUID()
@State private var practice = OnboardingPolishPractice()
@@ -66,7 +65,7 @@ struct OnboardingAIEnhancementStepView: View {
}
private var canNavigate: Bool { !self.isRunning && !self.isRecordingShortcut && !self.contentState.isProcessing && !self.isShowingIntroduction }
- private var isShowingIntroduction: Bool { self.isReady && !self.introductionFinished && !self.reduceMotion }
+ private var isShowingIntroduction: Bool { self.isReady && !self.setup.introductionFinished && !self.reduceMotion }
private var isReady: Bool { self.setup.phase == .ready }
private var sizeText: String? {
guard let count = self.setup.model?.byteCount, count > 0 else { return nil }
@@ -138,12 +137,12 @@ struct OnboardingAIEnhancementStepView: View {
} else if self.isReady && !self.isShowingIntroduction {
if !self.reduceMotion {
self.action(id: "intro-replay", title: "Replay", tone: .secondary, width: 132) {
- self.introductionFinished = false
+ self.setup.introductionFinished = false
self.introductionPlaybackID = UUID()
}
}
self.action(id: "intro-continue", title: "Continue", tone: .primary, width: 160) {
- self.introductionFinished = true
+ self.setup.introductionFinished = true
self.showPractice = true
}
} else if !self.isReady {
@@ -337,10 +336,10 @@ struct OnboardingAIEnhancementStepView: View {
private var introductionScene: some View {
ZStack(alignment: .top) {
- if self.reduceMotion || self.introductionFinished {
+ if self.reduceMotion || self.setup.introductionFinished {
Color.clear.aspectRatio(1560.0 / 1096.0, contentMode: .fit)
} else {
- OnboardingOverlayIntroductionView { self.introductionFinished = true }
+ OnboardingOverlayIntroductionView { self.setup.introductionFinished = true }
.id(self.introductionPlaybackID)
.offset(y: Self.overlaySceneOffset)
.allowsHitTesting(false)
@@ -370,7 +369,7 @@ struct OnboardingAIEnhancementStepView: View {
.frame(maxWidth: self.showPractice ? 680 : 600)
.padding(.top, 28)
}
- .animation(self.reduceMotion ? nil : .easeOut(duration: 0.45), value: self.introductionFinished)
+ .animation(self.reduceMotion ? nil : .easeOut(duration: 0.45), value: self.setup.introductionFinished)
}
private var introductionSummary: some View {
diff --git a/Sources/Fluid/UI/WelcomeView.swift b/Sources/Fluid/UI/WelcomeView.swift
index 8dec666b..34db9486 100644
--- a/Sources/Fluid/UI/WelcomeView.swift
+++ b/Sources/Fluid/UI/WelcomeView.swift
@@ -41,6 +41,7 @@ struct OnboardingFlowView: View {
}
@ObservedObject private var settings = SettingsStore.shared
+ @StateObject private var aiSetup = OnboardingAISetupController.live
@Binding var currentStep: Int
let accessibilityEnabled: Bool
@@ -1276,45 +1277,6 @@ struct OnboardingFlowView: View {
}
}
- private var aiEnhancementStep: some View {
- OnboardingAIEnhancementStepView(
- finalText: Binding(
- get: { self.asr.finalText },
- set: { self.asr.finalText = $0 }
- ),
- progressValue: self.compactProgressValue,
- glowCenter: self.landingGlowCenter,
- shortcutDisplay: self.onboardingShortcutDisplay,
- isRunning: self.asr.isRunning || self.asr.isStarting,
- isListening: self.asr.isRunning,
- isRecordingShortcut: self.isRecordingPrimaryShortcut,
- shortcutRecordingMessage: self.shortcutRecordingMessage,
- onToggleShortcut: self.togglePrimaryShortcutRecording,
- onGlowMove: self.updateLandingGlow(location:in:),
- onGlowExit: self.resetLandingGlow,
- onBack: self.goBack,
- onSkip: {
- let origin = self.settings.analyticsOnboardingOrigin
- self.markAISkipped()
- self.finishOnboardingAtGettingStarted()
- self.completeCurrentStep(
- outcome: .skipped,
- origin: origin,
- completesFlow: self.settings.onboardingCompleted
- )
- },
- onFinishSetup: {
- let origin = self.settings.analyticsOnboardingOrigin
- self.finishOnboardingAtGettingStarted()
- self.completeCurrentStep(
- outcome: .completed,
- origin: origin,
- completesFlow: self.settings.onboardingCompleted
- )
- }
- )
- }
-
private var playgroundStep: some View {
GeometryReader { proxy in
ZStack {
@@ -2265,6 +2227,46 @@ struct OnboardingFlowView: View {
}
private extension OnboardingFlowView {
+ var aiEnhancementStep: some View {
+ OnboardingAIEnhancementStepView(
+ setup: self.aiSetup,
+ finalText: Binding(
+ get: { self.asr.finalText },
+ set: { self.asr.finalText = $0 }
+ ),
+ progressValue: self.compactProgressValue,
+ glowCenter: self.landingGlowCenter,
+ shortcutDisplay: self.onboardingShortcutDisplay,
+ isRunning: self.asr.isRunning || self.asr.isStarting,
+ isListening: self.asr.isRunning,
+ isRecordingShortcut: self.isRecordingPrimaryShortcut,
+ shortcutRecordingMessage: self.shortcutRecordingMessage,
+ onToggleShortcut: self.togglePrimaryShortcutRecording,
+ onGlowMove: self.updateLandingGlow(location:in:),
+ onGlowExit: self.resetLandingGlow,
+ onBack: self.goBack,
+ onSkip: {
+ let origin = self.settings.analyticsOnboardingOrigin
+ self.markAISkipped()
+ self.finishOnboardingAtGettingStarted()
+ self.completeCurrentStep(
+ outcome: .skipped,
+ origin: origin,
+ completesFlow: self.settings.onboardingCompleted
+ )
+ },
+ onFinishSetup: {
+ let origin = self.settings.analyticsOnboardingOrigin
+ self.finishOnboardingAtGettingStarted()
+ self.completeCurrentStep(
+ outcome: .completed,
+ origin: origin,
+ completesFlow: self.settings.onboardingCompleted
+ )
+ }
+ )
+ }
+
var orderedOnboardingInputDevices: [AudioDevice.Device] {
let devicesByUID = Dictionary(
self.onboardingInputDevices.map { ($0.uid, $0) },
diff --git a/Tests/OnboardingAISetupControllerTests.swift b/Tests/OnboardingAISetupControllerTests.swift
index 47fab507..399e7f7e 100644
--- a/Tests/OnboardingAISetupControllerTests.swift
+++ b/Tests/OnboardingAISetupControllerTests.swift
@@ -73,8 +73,13 @@ struct OnboardingAISetupControllerTests {
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)
+ controller.introductionFinished = true
+ controller.cancel() // Leaving the AI page after setup has finished.
+ controller.refresh() // Returning to that page reuses the flow-owned controller.
+ precondition(controller.phase == .ready && controller.introductionFinished)
+ precondition(fresh.readCount == 1 && fresh.loads == 1 && fresh.commits == 1)
+ controller.introductionFinished = false // Explicit Replay changes only video progress.
+ precondition(controller.phase == .ready && fresh.loads == 1 && fresh.commits == 1)
let cached = Harness()
cached.installed = true