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

Polish dashboard and add Fluid Intelligence demo

altic-devc46689517977
diff --git a/Sources/Fluid/ContentView.swift b/Sources/Fluid/ContentView.swift
index 4d4f86cc..430eb017 100644
--- a/Sources/Fluid/ContentView.swift
+++ b/Sources/Fluid/ContentView.swift
@@ -317,6 +317,7 @@ struct ContentView: View {
@State private var isSettingsBackHovered = false
@FocusState private var isSettingsSearchFocused: Bool
@State private var playgroundUsed: Bool = SettingsStore.shared.playgroundUsed
+ @State private var showsFluidIntelligenceDemo = false
@State private var recordingAppInfo: (name: String, bundleId: String, windowTitle: String)? = nil
@State private var recordingPrecedingText: String = ""
@State private var recordingFocusTarget: TypingService.CapturedFocusTarget? = nil
@@ -454,6 +455,21 @@ struct ContentView: View {
self.handleSpokenSendPartialTranscription(text)
}
.overlay(alignment: .center) {}
+ .sheet(isPresented: self.$showsFluidIntelligenceDemo) {
+ FluidIntelligenceDemoView(
+ asr: self.asr,
+ onStart: self.startRecording,
+ onStop: { await self.stopAndProcessTranscription() },
+ onCancel: { _ = self.handleCancelShortcut() },
+ onSetup: {
+ self.showsFluidIntelligenceDemo = false
+ self.navigateToApp(.aiEnhancements)
+ },
+ runExample: { text, model in
+ try await self.processTextWithAI(text, overrideProviderID: PrivateAIProviderFeature.shared.providerID, overrideModel: model, dictationSlot: .primary)
+ }
+ )
+ }
.alert(
self.asr.errorTitle,
isPresented: Binding(
@@ -1614,8 +1630,18 @@ struct ContentView: View {
}
private var helpEntryButton: some View {
- Button {
- self.openHelpDocumentation()
+ Menu {
+ Button("Documentation", systemImage: "book") { self.openHelpDocumentation() }
+ if PrivateAIProviderFeature.shared.isAvailable {
+ Button("Try Fluid Intelligence", systemImage: "sparkles") { self.showsFluidIntelligenceDemo = true }
+ .disabled(self.asr.isRunningOrStarting || NotchContentState.shared.isProcessing || DictationPromptTestCoordinator.shared.isActive)
+ }
+ Button("Replay onboarding", systemImage: "arrow.counterclockwise") {
+ guard !self.asr.isRunning, !self.asr.isStarting, !NotchContentState.shared.isProcessing else { return }
+ self.settings.resetOnboardingProgress()
+ self.playgroundUsed = false
+ }
+ .disabled(self.asr.isRunning || self.asr.isStarting || NotchContentState.shared.isProcessing)
} label: {
HStack(spacing: self.theme.metrics.spacing.sm) {
Image(systemName: "questionmark.circle")
@@ -1627,7 +1653,7 @@ struct ContentView: View {
Spacer(minLength: self.theme.metrics.spacing.sm)
- Image(systemName: "arrow.up.right")
+ Image(systemName: "chevron.up.chevron.down")
.font(.fluidSystem(size: 10, weight: .semibold))
.foregroundStyle(.tertiary)
}
@@ -1636,6 +1662,8 @@ struct ContentView: View {
.frame(maxWidth: .infinity, minHeight: 40, alignment: .leading)
.contentShape(Rectangle())
}
+ .menuStyle(.button)
+ .menuIndicator(.hidden)
.buttonStyle(SidebarChromeButtonStyle(
isHovered: self.isHelpEntryHovered,
reduceMotion: self.accessibilityReduceMotion
@@ -1643,7 +1671,7 @@ struct ContentView: View {
.onHover { self.isHelpEntryHovered = $0 }
.help("Open FluidVoice Help")
.accessibilityLabel("Help")
- .accessibilityHint("Opens FluidVoice documentation in your default browser")
+ .accessibilityHint("Documentation, Fluid Intelligence demo, and replay onboarding")
}
private var modeTransitionAnimation: Animation {
@@ -1826,9 +1854,9 @@ struct ContentView: View {
private var welcomeView: some View {
WelcomeView(
selectedSidebarItem: self.$selectedSidebarItem,
- playgroundUsed: self.$playgroundUsed,
accessibilityEnabled: self.accessibilityEnabled,
openAccessibilitySettings: self.openAccessibilitySettings,
+ openFluidIntelligenceDemo: { self.showsFluidIntelligenceDemo = true },
openShortcutSettings: { self.openSettings(.shortcuts) }
)
}
@@ -2666,6 +2694,7 @@ struct ContentView: View {
streamHandler: streamHandler
)
self.appBench("ai_private_return")
+ self.settings.recordFluidIntelligenceUse(output: response.outputText)
if self.shouldTracePromptProcessing {
self.logDictationPromptTrace("Model answer (A)", value: response.outputText)
@@ -2899,6 +2928,7 @@ struct ContentView: View {
let activeDictationSlot = self.currentDictationShortcutSlot(for: modeAtStop)
let promptOverride = self.promptModeOverrideText
let promptTest = DictationPromptTestCoordinator.shared
+ let promptTestSessionID = promptTest.isActive ? promptTest.sessionID : nil
var stopSnapshot = route == .normal && !wasRewriteMode && !wasCommandMode && !promptTest.isActive
? self.captureDictationStopSnapshot(slot: activeDictationSlot ?? .primary) : nil
let shouldUseAIOnStop = stopSnapshot?.usesAI ?? activeDictationSlot.map {
@@ -2964,8 +2994,7 @@ struct ContentView: View {
}
// Prompt Test Mode: reroute dictation hotkey output into the prompt editor (no typing/clipboard/history).
- if promptTest.isActive {
- await self.processDictationPromptTest(transcribedText, lifecycleID: expectedOverlayLifecycleID)
+ if await self.routePromptTestResult(transcribedText, sessionID: promptTestSessionID, lifecycleID: expectedOverlayLifecycleID) {
return
}
@@ -3352,6 +3381,7 @@ struct ContentView: View {
private func processDictationPromptTest(_ transcribedText: String, lifecycleID: UInt64) async {
let promptTest = DictationPromptTestCoordinator.shared
+ let sessionID = promptTest.sessionID
promptTest.lastTranscriptionText = transcribedText
promptTest.lastOutputText = ""
promptTest.lastError = ""
@@ -3372,14 +3402,15 @@ struct ContentView: View {
if self.overlayLifecycleID == lifecycleID {
self.menuBarManager.setProcessing(false)
}
- promptTest.isProcessing = false
+ if promptTest.sessionID == sessionID { promptTest.isProcessing = false }
}
do {
let result = try await self.processTextWithAI(
transcribedText,
- overrideSystemPrompt: promptTest.draftPromptText,
+ overrideSystemPrompt: promptTest.usesBuiltInPrompt ? nil : promptTest.draftPromptText,
overrideProviderID: promptTest.draftProviderID,
- overrideModel: promptTest.draftModel
+ overrideModel: promptTest.draftModel,
+ dictationSlot: promptTest.usesBuiltInPrompt ? .primary : nil
)
let appInfo = self.recordingAppInfo ?? self.getCurrentAppInfo()
let literalFormattedResult = ASRService.applyDictationLiteralFormatting(
@@ -3388,13 +3419,26 @@ struct ContentView: View {
bundleID: appInfo.bundleId,
windowTitle: appInfo.windowTitle
)
+ guard promptTest.acceptsResult(for: sessionID) else { return }
promptTest.lastOutputText = ASRService.applyGAAVFormatting(literalFormattedResult)
} catch {
+ guard promptTest.acceptsResult(for: sessionID) else { return }
DebugLogger.shared.error("Prompt test AI call failed: \(error.localizedDescription)", source: "ContentView")
promptTest.lastError = error.localizedDescription
}
}
+ private func routePromptTestResult(_ text: String, sessionID: UUID?, lifecycleID: UInt64) async -> Bool {
+ guard let sessionID else { return false }
+ // A closed/replaced practice session must never fall through to external typing.
+ guard DictationPromptTestCoordinator.shared.acceptsResult(for: sessionID) else {
+ if self.overlayLifecycleID == lifecycleID { self.menuBarManager.setProcessing(false) }
+ return true
+ }
+ await self.processDictationPromptTest(text, lifecycleID: lifecycleID)
+ return true
+ }
+
private func makeAIProcessingFeedback(
lifecycleID: UInt64
) -> (statusTask: Task<Void, Never>, streamPreview: DictationAIStreamPreviewBuffer) {
@@ -4387,6 +4431,8 @@ struct ContentView: View {
/// Capture app context at start to avoid mismatches if the user switches apps mid-session
private func startRecording() {
+ // Browsing the demo must not send dictation to a previously focused app.
+ guard !self.showsFluidIntelligenceDemo || (DictationPromptTestCoordinator.shared.isActive && !DictationPromptTestCoordinator.shared.isProcessing) else { return }
guard !self.presentExclusiveActivityBlockIfNeeded() else { return }
let model = SettingsStore.shared.selectedSpeechModel
DebugLogger.shared.info(
diff --git a/Sources/Fluid/Services/DictationPostProcessingService.swift b/Sources/Fluid/Services/DictationPostProcessingService.swift
index 2a4dc0de..560a8869 100644
--- a/Sources/Fluid/Services/DictationPostProcessingService.swift
+++ b/Sources/Fluid/Services/DictationPostProcessingService.swift
@@ -256,6 +256,7 @@ final class DictationPostProcessingService {
appVersion: Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
)
)
+ settings.recordFluidIntelligenceUse(output: response.outputText)
return Result(
text: ASRService.applyGAAVFormatting(response.outputText),
providerID: resolved.providerID,
diff --git a/Sources/Fluid/Services/DictationPromptTestCoordinator.swift b/Sources/Fluid/Services/DictationPromptTestCoordinator.swift
index 63f479ac..be6741ce 100644
--- a/Sources/Fluid/Services/DictationPromptTestCoordinator.swift
+++ b/Sources/Fluid/Services/DictationPromptTestCoordinator.swift
@@ -9,22 +9,30 @@ final class DictationPromptTestCoordinator: ObservableObject {
static let shared = DictationPromptTestCoordinator()
@Published private(set) var isActive: Bool = false
+ private(set) var sessionID = UUID()
@Published private(set) var draftPromptText: String = ""
@Published private(set) var draftProviderID: String = ""
@Published private(set) var draftModel: String = ""
+ private(set) var usesBuiltInPrompt = false
@Published var isProcessing: Bool = false
@Published var lastTranscriptionText: String = ""
@Published var lastOutputText: String = ""
@Published var lastError: String = ""
- private init() {}
+ init() {}
- func activate(draftPromptText: String, providerID: String, model: String) {
+ func acceptsResult(for sessionID: UUID) -> Bool {
+ self.isActive && self.sessionID == sessionID
+ }
+
+ func activate(draftPromptText: String, providerID: String, model: String, usesBuiltInPrompt: Bool = false) {
+ self.sessionID = UUID()
self.isActive = true
self.draftPromptText = draftPromptText
self.draftProviderID = providerID
self.draftModel = model
+ self.usesBuiltInPrompt = usesBuiltInPrompt
self.isProcessing = false
self.lastTranscriptionText = ""
self.lastOutputText = ""
@@ -32,10 +40,12 @@ final class DictationPromptTestCoordinator: ObservableObject {
}
func deactivate() {
+ self.sessionID = UUID()
self.isActive = false
self.draftPromptText = ""
self.draftProviderID = ""
self.draftModel = ""
+ self.usesBuiltInPrompt = false
self.isProcessing = false
}
diff --git a/Sources/Fluid/Services/OnboardingPolishPractice.swift b/Sources/Fluid/Services/OnboardingPolishPractice.swift
index 2f9025c0..7ceb8a79 100644
--- a/Sources/Fluid/Services/OnboardingPolishPractice.swift
+++ b/Sources/Fluid/Services/OnboardingPolishPractice.swift
@@ -1,5 +1,40 @@
+import Combine
import Foundation
+enum FluidIntelligenceInvitation {
+ static let dismissedKey = "FluidIntelligenceInvitationDismissed"
+ static let usedKey = "HasUsedFluidIntelligence"
+
+ static func shouldShow(available: Bool, dismissed: Bool, hasUsed: Bool) -> Bool {
+ available && !dismissed && !hasUsed
+ }
+
+ static func recordSuccess(output: String, defaults: UserDefaults) {
+ guard !output.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty else { return }
+ defaults.set(true, forKey: self.usedKey)
+ }
+}
+
+extension SettingsStore {
+ var fluidIntelligenceInvitationDismissed: Bool {
+ get { UserDefaults.standard.bool(forKey: FluidIntelligenceInvitation.dismissedKey) }
+ set {
+ self.objectWillChange.send()
+ UserDefaults.standard.set(newValue, forKey: FluidIntelligenceInvitation.dismissedKey)
+ }
+ }
+
+ var hasUsedFluidIntelligence: Bool {
+ UserDefaults.standard.bool(forKey: FluidIntelligenceInvitation.usedKey)
+ }
+
+ func recordFluidIntelligenceUse(output: String) {
+ guard !output.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty, !self.hasUsedFluidIntelligence else { return }
+ self.objectWillChange.send()
+ FluidIntelligenceInvitation.recordSuccess(output: output, defaults: .standard)
+ }
+}
+
/// Local practice progress; never writes dictation, provider, or persisted settings.
struct OnboardingPolishPractice {
struct Example {
diff --git a/Sources/Fluid/UI/DashboardView.swift b/Sources/Fluid/UI/DashboardView.swift
index 1079b51f..f82659db 100644
--- a/Sources/Fluid/UI/DashboardView.swift
+++ b/Sources/Fluid/UI/DashboardView.swift
@@ -17,7 +17,10 @@ struct DashboardLayout {
var hasActionColumn: Bool { self.contentWidth >= 640 + Self.gap + Self.actionWidth }
var mainWidth: CGFloat { self.hasActionColumn ? self.contentWidth - Self.gap - Self.actionWidth : self.contentWidth }
var hasHorizontalActions: Bool { !self.hasActionColumn && self.contentWidth >= 620 }
- var lessonColumns: Int { self.contentWidth >= 1040 ? 4 : (self.contentWidth >= 520 ? 2 : 1) }
+ func setupColumns(count: Int) -> Int {
+ guard count > 0 else { return 1 }
+ return self.contentWidth >= CGFloat(count) * 280 + CGFloat(count - 1) * 10 ? count : 1
+ }
func statisticColumns(count: Int) -> Int {
if self.mainWidth >= CGFloat(count) * 160 + 40 { return count }
@@ -25,14 +28,31 @@ struct DashboardLayout {
}
}
+struct DashboardSetupStatus {
+ enum Requirement: CaseIterable { case voiceModel, microphone, typingAccess }
+ let voiceModelReady: Bool
+ let microphoneReady: Bool
+ let typingAccessReady: Bool
+
+ var missing: [Requirement] {
+ Requirement.allCases.filter {
+ switch $0 {
+ case .voiceModel: !self.voiceModelReady
+ case .microphone: !self.microphoneReady
+ case .typingAccess: !self.typingAccessReady
+ }
+ }
+ }
+}
+
/// Home reuses the history and stats snapshots; no polling or duplicate aggregation.
struct DashboardView: View {
@ObservedObject var asr: ASRService
@Binding var selectedSidebarItem: SidebarItem?
let accessibilityEnabled: Bool
let openAccessibilitySettings: () -> Void
+ let openFluidIntelligenceDemo: () -> Void
let openShortcutSettings: () -> Void
- let replayOnboarding: () -> Void
@ObservedObject private var history = TranscriptionHistoryStore.shared
@ObservedObject private var stats = StatsSnapshotStore.shared
@@ -56,6 +76,7 @@ struct DashboardView: View {
ScrollView {
VStack(alignment: .leading, spacing: 28) {
self.header
+ self.finishSetup(layout: layout)
if layout.hasActionColumn {
HStack(alignment: .top, spacing: 28) {
self.mainColumn(layout: layout)
@@ -67,7 +88,6 @@ struct DashboardView: View {
self.mainColumn(layout: layout)
self.quickActions(horizontal: layout.hasHorizontalActions)
}
- self.learningCenter(columns: layout.lessonColumns)
}
.padding(DashboardLayout.inset)
.frame(maxWidth: DashboardLayout.maximumWidth, alignment: .leading)
@@ -84,6 +104,9 @@ struct DashboardView: View {
self.greeting = name.isEmpty ? "\(salutation)." : "\(salutation), \(name)."
}
.onDisappear { self.stats.deactivate(self.statsOwner) }
+ .onChange(of: self.stats.snapshot?.hasFluidIntelligenceUse, initial: true) { _, hasUsed in
+ if hasUsed == true { self.settings.recordFluidIntelligenceUse(output: "existing successful use") }
+ }
}
private var header: some View {
@@ -96,6 +119,13 @@ struct DashboardView: View {
private func mainColumn(layout: DashboardLayout) -> some View {
VStack(alignment: .leading, spacing: 28) {
self.statistics(layout: layout)
+ if self.stats.snapshot != nil, FluidIntelligenceInvitation.shouldShow(
+ available: PrivateAIProviderFeature.shared.isAvailable,
+ dismissed: self.settings.fluidIntelligenceInvitationDismissed,
+ hasUsed: self.settings.hasUsedFluidIntelligence || self.stats.snapshot?.hasFluidIntelligenceUse == true
+ ) {
+ self.intelligenceInvitation
+ }
self.recents
}
}
@@ -174,40 +204,42 @@ struct DashboardView: View {
}
}
- private struct Lesson {
+ private struct SetupItem {
let title: String
let icon: String
- let complete: Bool
let detail: String
let action: () -> Void
}
- private func learningCenter(columns: Int) -> some View {
- let lessons: [Lesson] = [
- .init(title: "Voice model", icon: "waveform", complete: self.asr.modelsExistOnDisk || self.asr.isAsrReady, detail: "Pick your engine", action: { self.selectedSidebarItem = .voiceEngine }),
- .init(title: "Microphone", icon: "mic", complete: self.asr.micStatus == .authorized, detail: "Set up voice input", action: {
+ private func setupItem(for requirement: DashboardSetupStatus.Requirement) -> SetupItem {
+ switch requirement {
+ case .voiceModel:
+ .init(title: "Voice model", icon: "waveform", detail: "Pick your engine", action: { self.selectedSidebarItem = .voiceEngine })
+ case .microphone:
+ .init(title: "Microphone", icon: "mic", detail: "Set up voice input", action: {
if self.asr.micStatus == .notDetermined { self.asr.requestMicAccess() } else { self.asr.openSystemSettingsForMic() }
- }),
- .init(title: "Typing access", icon: "keyboard", complete: self.accessibilityEnabled, detail: "Dictate in any app", action: self.openAccessibilitySettings),
- .init(title: "AI cleanup", icon: "sparkles", complete: DictationAIPostProcessingGate.isProviderConfigured(), detail: "Optional polish", action: { self.selectedSidebarItem = .aiEnhancements }),
- ]
- let completed = lessons.filter(\.complete).count
+ })
+ case .typingAccess:
+ .init(title: "Typing access", icon: "keyboard", detail: "Dictate in any app", action: self.openAccessibilitySettings)
+ }
+ }
- return VStack(alignment: .leading, spacing: 14) {
- HStack(alignment: .firstTextBaseline, spacing: 10) {
- Text("Learning center").font(self.theme.typography.sectionTitle)
- Text("\(completed) of \(lessons.count) ready")
- .font(self.theme.typography.caption).foregroundStyle(.secondary)
- Spacer()
- Button("Replay onboarding", systemImage: "arrow.counterclockwise", action: self.replayOnboarding)
- .buttonStyle(.plain).font(self.theme.typography.caption)
- .foregroundStyle(.secondary).disabled(self.busy)
- }
- // Four items always form complete rows; never a cramped three-plus-one layout.
- LazyVGrid(columns: Array(repeating: GridItem(.flexible(), spacing: 10), count: columns), alignment: .leading, spacing: 10) {
- ForEach(lessons, id: \.title) { lesson in
- DashboardLessonCard(title: lesson.title, detail: lesson.detail, icon: lesson.icon, complete: lesson.complete, action: lesson.action)
- .disabled(self.busy)
+ @ViewBuilder
+ private func finishSetup(layout: DashboardLayout) -> some View {
+ let missing = DashboardSetupStatus(
+ voiceModelReady: self.asr.modelsExistOnDisk || self.asr.isAsrReady,
+ microphoneReady: self.asr.micStatus == .authorized,
+ typingAccessReady: self.accessibilityEnabled
+ ).missing
+ if !missing.isEmpty {
+ VStack(alignment: .leading, spacing: 14) {
+ Text("Finish setup").font(self.theme.typography.sectionTitle)
+ LazyVGrid(columns: Array(repeating: GridItem(.flexible(), spacing: 10), count: layout.setupColumns(count: missing.count)), alignment: .leading, spacing: 10) {
+ ForEach(missing, id: \.self) { requirement in
+ let item = self.setupItem(for: requirement)
+ DashboardSetupCard(title: item.title, detail: item.detail, icon: item.icon, action: item.action)
+ .disabled(self.busy)
+ }
}
}
}
@@ -218,66 +250,50 @@ struct DashboardView: View {
? AnyLayout(HStackLayout(alignment: .top, spacing: 18))
: AnyLayout(VStackLayout(alignment: .leading, spacing: 18))
return VStack(alignment: .leading, spacing: 18) {
- Text("Quick actions").font(self.theme.typography.sectionTitle)
- layout {
- if !self.shortcut.isEmpty {
- VStack(spacing: 18) {
- Text("YOUR SHORTCUT")
- .font(.fluidSystem(size: 10, weight: .semibold))
- .tracking(1.4).foregroundStyle(.secondary)
- self.shortcutKey
- if self.settings.primaryDictationShortcuts.count > 1 {
- Text("+\(self.settings.primaryDictationShortcuts.count - 1) more")
- .font(self.theme.typography.caption).foregroundStyle(.secondary)
- }
- Button(action: self.openShortcutSettings) {
- HStack(spacing: 6) {
- Text("Change shortcut")
- Image(systemName: "arrow.up.right").font(.fluidSystem(size: 10, weight: .medium))
+ Text("Make it yours").font(self.theme.typography.sectionTitle)
+ FluidGlassControlGroup {
+ layout {
+ if !self.shortcut.isEmpty {
+ VStack(spacing: 18) {
+ Text("YOUR SHORTCUT")
+ .font(.fluidSystem(size: 10, weight: .semibold))
+ .tracking(1.4).foregroundStyle(.secondary)
+ self.shortcutKey
+ if self.settings.primaryDictationShortcuts.count > 1 {
+ Text("+\(self.settings.primaryDictationShortcuts.count - 1) more")
+ .font(self.theme.typography.caption).foregroundStyle(.secondary)
}
- .font(self.theme.typography.captionStrong)
+ Button(action: self.openShortcutSettings) {
+ HStack(spacing: 6) {
+ Text("Change shortcut")
+ Image(systemName: "arrow.up.right").font(.fluidSystem(size: 10, weight: .medium))
+ }
+ .font(self.theme.typography.captionStrong)
+ }
+ .fluidGlassAction()
}
- .buttonStyle(.plain).foregroundStyle(self.theme.palette.accent)
- }
- .frame(maxWidth: .infinity)
- .padding(.vertical, 16).padding(.horizontal, 14)
- .background {
- RoundedRectangle(cornerRadius: 20)
- .fill(LinearGradient(colors: [self.theme.palette.accent.opacity(0.12), self.theme.palette.cardBackground], startPoint: .topLeading, endPoint: .bottomTrailing))
- }
- .overlay(RoundedRectangle(cornerRadius: 20).strokeBorder(self.theme.palette.accent.opacity(0.13), lineWidth: 1))
- .disabled(self.busy)
- .frame(width: horizontal ? 220 : nil)
- }
- VStack(alignment: .leading, spacing: 18) {
- DashboardQuickAction(title: "Add a word", detail: "Names & terms", icon: "text.book.closed", tint: self.theme.palette.accent) {
- self.selectedSidebarItem = .customDictionary
- }
- .disabled(self.busy)
- DashboardQuickAction(title: "Cleanup styles", detail: "Shape your writing", icon: "wand.and.stars", tint: self.theme.palette.accent) {
- self.selectedSidebarItem = .cleanupStyles
+ .frame(maxWidth: .infinity)
+ .padding(.vertical, 16).padding(.horizontal, 14)
+ .disabled(self.busy)
+ .frame(width: horizontal ? 220 : nil)
}
- .disabled(self.busy)
- HStack(spacing: 12) {
- Image(systemName: "note.text").font(.fluidSystem(size: 20))
- .frame(width: 36, height: 40)
- VStack(alignment: .leading, spacing: 5) {
- Text("Notepad").font(self.theme.typography.bodySmallStrong)
- Text("Coming soon").font(self.theme.typography.caption)
+ VStack(alignment: .leading, spacing: 0) {
+ DashboardQuickAction(title: "Vocabulary", detail: "Names & terms", icon: "text.book.closed") {
+ self.selectedSidebarItem = .customDictionary
+ }
+ .disabled(self.busy)
+ Divider().padding(.leading, 46).padding(.trailing, 12)
+ DashboardQuickAction(title: "Writing style", detail: "Make it sound like you", icon: "wand.and.stars") {
+ self.selectedSidebarItem = .cleanupStyles
}
- Spacer(minLength: 0)
+ .disabled(self.busy)
}
- .foregroundStyle(.secondary)
- .padding(14)
- .frame(maxWidth: .infinity, alignment: .leading)
- .overlay(RoundedRectangle(cornerRadius: 16).strokeBorder(self.theme.palette.cardBorder.opacity(0.5), style: StrokeStyle(lineWidth: 1, dash: [4, 4])))
- .accessibilityElement(children: .combine)
+ .frame(maxWidth: .infinity)
}
- .frame(maxWidth: .infinity)
}
}
.padding(20)
- .background(self.reduceTransparency ? self.theme.palette.cardBackground : self.theme.palette.accent.opacity(0.025), in: RoundedRectangle(cornerRadius: 24))
+ .background(self.reduceTransparency ? self.theme.palette.cardBackground : Color.primary.opacity(0.025), in: RoundedRectangle(cornerRadius: 24))
.background {
if !self.reduceTransparency {
RoundedRectangle(cornerRadius: 24).fill(.ultraThinMaterial)
@@ -285,6 +301,34 @@ struct DashboardView: View {
}
}
+ private var intelligenceInvitation: some View {
+ VStack(alignment: .leading, spacing: 14) {
+ HStack(alignment: .top) {
+ VStack(alignment: .leading, spacing: 6) {
+ Label("Try Fluid Intelligence", systemImage: "sparkles")
+ .font(self.theme.typography.sectionTitle)
+ Text("Turn spoken thoughts into lists, emails, and polished paragraphs.")
+ .font(self.theme.typography.bodySmall).foregroundStyle(.secondary)
+ .fixedSize(horizontal: false, vertical: true)
+ }
+ Spacer(minLength: 12)
+ Button { self.settings.fluidIntelligenceInvitationDismissed = true } label: {
+ Image(systemName: "xmark").frame(width: 28, height: 28).contentShape(Rectangle())
+ }
+ .buttonStyle(.plain)
+ .accessibilityLabel("Dismiss Fluid Intelligence invitation")
+ .help("Hide this invitation. You can still try it from Help.")
+ }
+ Button("Try it", systemImage: "arrow.up.right", action: self.openFluidIntelligenceDemo)
+ .fluidGlassAction(prominent: true)
+ .disabled(self.busy || DictationPromptTestCoordinator.shared.isActive)
+ }
+ .padding(20)
+ .frame(maxWidth: .infinity, alignment: .leading)
+ .background(self.theme.palette.accent.opacity(0.07), in: RoundedRectangle(cornerRadius: 18))
+ .overlay(RoundedRectangle(cornerRadius: 18).strokeBorder(self.theme.palette.accent.opacity(0.18)))
+ }
+
@ViewBuilder
private var shortcutKey: some View {
let button = Button(action: self.openShortcutSettings) {
@@ -365,7 +409,6 @@ private struct DashboardQuickAction: View {
let title: String
let detail: String
let icon: String
- let tint: Color
let action: () -> Void
@Environment(\.theme) private var theme
@Environment(\.accessibilityReduceMotion) private var reduceMotion
@@ -375,7 +418,10 @@ private struct DashboardQuickAction: View {
var body: some View {
Button(action: self.action) {
HStack(spacing: 12) {
- FluidIconTile(icon: self.icon, tint: self.tint)
+ Image(systemName: self.icon)
+ .font(self.theme.typography.bodySmall)
+ .foregroundStyle(.secondary)
+ .frame(width: 22)
VStack(alignment: .leading, spacing: 3) {
Text(self.title).font(self.theme.typography.bodySmallStrong).lineLimit(1)
Text(self.detail).font(self.theme.typography.caption).foregroundStyle(.secondary)
@@ -385,11 +431,12 @@ private struct DashboardQuickAction: View {
Image(systemName: "chevron.right")
.font(.fluidSystem(size: 10, weight: .semibold))
.foregroundStyle(.tertiary)
- .opacity(self.hovered ? 1 : 0)
- .offset(x: self.hovered || self.reduceMotion ? 0 : -4)
}
.frame(maxWidth: .infinity, alignment: .leading)
- .dashboardTile(hovered: self.hovered)
+ .padding(.horizontal, 12)
+ .padding(.vertical, 16)
+ .background(Color.primary.opacity(self.hovered ? 0.045 : 0), in: RoundedRectangle(cornerRadius: 12))
+ .contentShape(RoundedRectangle(cornerRadius: 12))
}
.buttonStyle(.plain)
.onHover { self.hovered = $0 && self.isEnabled }
@@ -397,11 +444,10 @@ private struct DashboardQuickAction: View {
}
}
-private struct DashboardLessonCard: View {
+private struct DashboardSetupCard: View {
let title: String
let detail: String
let icon: String
- let complete: Bool
let action: () -> Void
@Environment(\.theme) private var theme
@Environment(\.accessibilityReduceMotion) private var reduceMotion
@@ -418,16 +464,10 @@ private struct DashboardLessonCard: View {
.lineLimit(1)
}
Spacer(minLength: 0)
- if self.complete {
- Image(systemName: "checkmark.circle.fill")
- .font(.fluidSystem(size: 13))
- .foregroundStyle(self.theme.palette.success)
- } else {
- Text("Set up")
- .font(self.theme.typography.captionStrong)
- .foregroundStyle(self.theme.palette.accent)
- .fixedSize()
- }
+ Text("Set up")
+ .font(self.theme.typography.captionStrong)
+ .foregroundStyle(self.theme.palette.accent)
+ .fixedSize()
}
.frame(maxWidth: .infinity, alignment: .leading)
.dashboardTile(hovered: self.hovered)
@@ -435,7 +475,7 @@ private struct DashboardLessonCard: View {
.buttonStyle(.plain)
.onHover { self.hovered = $0 && self.isEnabled }
.animation(self.reduceMotion ? nil : .easeOut(duration: 0.15), value: self.hovered)
- .accessibilityLabel("\(self.title), \(self.complete ? "configured" : self.detail)")
+ .accessibilityLabel("\(self.title), \(self.detail)")
}
}
diff --git a/Sources/Fluid/UI/FluidIntelligenceDemoView.swift b/Sources/Fluid/UI/FluidIntelligenceDemoView.swift
new file mode 100644
index 00000000..e142d731
--- /dev/null
+++ b/Sources/Fluid/UI/FluidIntelligenceDemoView.swift
@@ -0,0 +1,180 @@
+import AVFoundation
+import SwiftUI
+
+/// Reuses the prompt-test sandbox: no provider selection, history, clipboard, or external typing writes.
+struct FluidIntelligenceDemoView: View {
+ @ObservedObject var asr: ASRService
+ let onStart: () -> Void
+ let onStop: () async -> Void
+ let onCancel: () -> Void
+ let onSetup: () -> Void
+ let runExample: (String, String) async throws -> String
+ @Environment(\.dismiss) private var dismiss
+ @Environment(\.theme) private var theme
+ @ObservedObject private var sandbox = DictationPromptTestCoordinator.shared
+ @ObservedObject private var overlay = NotchContentState.shared
+ @State private var selected = 0
+ @State private var modelID: String?
+ @State private var checking = true
+ @State private var sessionID: UUID?
+ @State private var sampleTask: Task<Void, Never>?
+ @State private var runningSample = false
+ @State private var stoppingVoice = false
+ @State private var result = ""
+ @State private var error = ""
+
+ private struct Example {
+ let title: String
+ let spoken: String
+ let expected: String
+ }
+
+ private static let examples: [Example] = {
+ let practice = OnboardingPolishPractice.examples
+ return [
+ Example(title: "Corrections", spoken: practice[0].spoken, expected: practice[0].expected),
+ Example(title: "Lists", spoken: practice[1].spoken, expected: practice[1].expected),
+ Example(title: "Paragraphs", spoken: practice[2].spoken, expected: practice[2].expected),
+ Example(title: "Emails", spoken: "Hi Maya, thanks for the update. Could you send the revised plan by Friday? Thanks, Alex.", expected: "Hi Maya,\n\nThanks for the update. Could you send the revised plan by Friday?\n\nThanks,\nAlex"),
+ Example(title: "Repetitions", spoken: "I think we should, we should review the plan tomorrow, um, before the meeting.", expected: "I think we should review the plan tomorrow before the meeting."),
+ ]
+ }()
+
+ private var busy: Bool { self.asr.isRunningOrStarting || self.overlay.isProcessing || self.sandbox.isProcessing || self.runningSample || self.stoppingVoice }
+
+ var body: some View {
+ VStack(alignment: .leading, spacing: 20) {
+ HStack(alignment: .top) {
+ VStack(alignment: .leading, spacing: 6) {
+ Label("Fluid Intelligence", systemImage: "sparkles").font(self.theme.typography.captionStrong).foregroundStyle(self.theme.palette.accent)
+ Text("Your words, ready to use.").font(.fluidSystem(size: 30, weight: .regular, design: .serif))
+ }
+ Spacer()
+ Button { self.dismiss() } label: {
+ Image(systemName: "xmark").frame(width: 32, height: 32).contentShape(Rectangle())
+ }
+ .buttonStyle(.plain).disabled(self.busy).accessibilityLabel("Close demo")
+ }
+ Picker("Example", selection: self.$selected) {
+ ForEach(Self.examples.indices, id: \.self) { index in Text(Self.examples[index].title).tag(index) }
+ }
+ .pickerStyle(.segmented).disabled(self.busy)
+ ScrollView {
+ VStack(alignment: .leading, spacing: 16) {
+ self.textPanel("You say", text: Self.examples[self.selected].spoken, accented: false)
+ self.textPanel(self.result.isEmpty ? "Example result" : "Your result", text: self.result.isEmpty ? Self.examples[self.selected].expected : self.result, accented: true)
+ Text("Illustrative examples. Run one to see your model’s actual output.")
+ .font(self.theme.typography.caption).foregroundStyle(.secondary)
+ if !self.error.isEmpty { Text(self.error).font(self.theme.typography.bodySmall).foregroundStyle(.red) }
+ }
+ .id(self.selected)
+ }
+ if self.busy {
+ Label(self.asr.isRunning ? "Listening — stop when you’re finished" : "Preparing your result…", systemImage: self.asr.isRunning ? "waveform" : "sparkles")
+ .font(self.theme.typography.bodySmall)
+ }
+ FluidGlassControlGroup {
+ HStack(spacing: 12) {
+ Button("Not now") { self.dismiss() }.fluidGlassAction().disabled(self.busy).keyboardShortcut(.cancelAction)
+ Spacer()
+ if self.checking {
+ ProgressView("Checking model…").controlSize(.small)
+ } else if let modelID {
+ Button("Try example") { self.tryExample(modelID: modelID) }.fluidGlassAction().disabled(self.busy)
+ Button(self.asr.isRunning ? "Stop and polish" : "Try with your voice", systemImage: self.asr.isRunning ? "stop.fill" : "mic") {
+ if self.asr.isRunning {
+ self.stoppingVoice = true
+ Task {
+ await self.onStop()
+ self.stoppingVoice = false
+ }
+ } else {
+ self.activateSandbox(modelID: modelID)
+ self.onStart()
+ }
+ }
+ .fluidGlassAction(prominent: true)
+ .disabled(self.runningSample || self.stoppingVoice || self.overlay.isProcessing || self.sandbox.isProcessing || self.asr.isStarting || !self.asr.isAsrReady || self.asr.micStatus != .authorized)
+ } else {
+ Button("Set up Fluid Intelligence", action: self.onSetup).fluidGlassAction(prominent: true)
+ }
+ }
+ }
+ Text(self.modelID == nil ? "A local Fluid Intelligence model is needed to try these examples." : "Practice stays here. Nothing is typed into another app or saved to history.")
+ .font(self.theme.typography.caption).foregroundStyle(.secondary)
+ if self.modelID != nil, !self.asr.isAsrReady || self.asr.micStatus != .authorized {
+ Text("Voice practice needs a ready Voice Engine model and microphone access. You can still try the written examples.")
+ .font(self.theme.typography.caption).foregroundStyle(.secondary)
+ }
+ }
+ .padding(28)
+ .frame(width: 740, height: 620)
+ .background(self.theme.palette.contentBackground)
+ .interactiveDismissDisabled(self.busy)
+ .task {
+ let model = PrivateAIIntegrationService.selectedModel
+ let installed = await Task.detached(priority: .utility) { PrivateAIIntegrationService.isModelInstalled(model) }.value
+ guard !Task.isCancelled else { return }
+ self.modelID = installed ? PrivateAIProviderPromptFormat.verifiedModelID(for: model.id) : nil
+ self.checking = false
+ }
+ .onChange(of: self.selected) { _, _ in self.result = ""; self.error = "" }
+ .onChange(of: self.sandbox.lastOutputText) { _, text in
+ guard self.sessionID == self.sandbox.sessionID else { return }
+ self.result = text
+ }
+ .onChange(of: self.sandbox.lastError) { _, text in
+ guard self.sessionID == self.sandbox.sessionID else { return }
+ self.error = text
+ }
+ .onDisappear {
+ self.sampleTask?.cancel()
+ if self.sessionID == self.sandbox.sessionID {
+ if self.asr.isRunningOrStarting { self.onCancel() }
+ self.sandbox.deactivate()
+ }
+ }
+ }
+
+ private func textPanel(_ title: String, text: String, accented: Bool) -> some View {
+ VStack(alignment: .leading, spacing: 10) {
+ Text(title).font(self.theme.typography.captionStrong).foregroundStyle(accented ? self.theme.palette.accent : self.theme.palette.secondaryText)
+ Text(text).font(self.theme.typography.body).textSelection(.enabled).fixedSize(horizontal: false, vertical: true)
+ }
+ .padding(18).frame(maxWidth: .infinity, alignment: .leading)
+ .background(accented ? self.theme.palette.accent.opacity(0.07) : self.theme.palette.cardBackground, in: RoundedRectangle(cornerRadius: 16))
+ }
+
+ private func activateSandbox(modelID: String) {
+ guard !self.sandbox.isActive || self.sessionID == self.sandbox.sessionID else { return }
+ self.sandbox.activate(draftPromptText: "", providerID: PrivateAIProviderFeature.shared.providerID, model: modelID, usesBuiltInPrompt: true)
+ self.sessionID = self.sandbox.sessionID
+ self.result = ""
+ self.error = ""
+ }
+
+ private func tryExample(modelID: String) {
+ self.activateSandbox(modelID: modelID)
+ guard self.sessionID == self.sandbox.sessionID else { return }
+ self.runningSample = true
+ self.sandbox.isProcessing = true
+ let input = Self.examples[self.selected].spoken
+ self.sampleTask = Task { @MainActor in
+ defer {
+ self.runningSample = false
+ if self.sessionID == self.sandbox.sessionID { self.sandbox.isProcessing = false }
+ }
+ do {
+ let output = try await self.runExample(input, modelID)
+ try Task.checkCancellation()
+ guard !output.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty else {
+ self.error = "No text was returned. Try again."
+ return
+ }
+ self.result = output
+ } catch {
+ if !Task.isCancelled { self.error = error.localizedDescription }
+ }
+ }
+ }
+}
diff --git a/Sources/Fluid/UI/StatsSnapshot.swift b/Sources/Fluid/UI/StatsSnapshot.swift
index 00d31892..ffc1a15b 100644
--- a/Sources/Fluid/UI/StatsSnapshot.swift
+++ b/Sources/Fluid/UI/StatsSnapshot.swift
@@ -7,6 +7,7 @@ nonisolated struct StatsSnapshot: Sendable {
var totalCharacters = 0
/// Words Fluid Intelligence changed, dropped or added compared with the raw transcript.
var fluidFixedWords = 0
+ var hasFluidIntelligenceUse = false
/// Words and recording time from entries that carry a real audio length.
var timedWords = 0
var timedMilliseconds = 0
@@ -108,6 +109,7 @@ nonisolated struct StatsSnapshot: Sendable {
result.longestTranscriptionWords = max(result.longestTranscriptionWords, words)
if entry.wasAIProcessed { result.aiProcessedCount += 1 }
if entry.wasAIProcessed, entry.processingModel?.lowercased().hasPrefix("fluid-1") == true {
+ result.hasFluidIntelligenceUse = true
result.fluidFixedWords += Self.changedWordCount(raw: entry.rawText, processed: entry.processedText)
}
}
diff --git a/Sources/Fluid/UI/WelcomeView.swift b/Sources/Fluid/UI/WelcomeView.swift
index fba7c32c..b37697db 100644
--- a/Sources/Fluid/UI/WelcomeView.swift
+++ b/Sources/Fluid/UI/WelcomeView.swift
@@ -5,11 +5,10 @@ import SwiftUI
struct WelcomeView: View {
@EnvironmentObject var appServices: AppServices
- @ObservedObject private var settings = SettingsStore.shared
@Binding var selectedSidebarItem: SidebarItem?
- @Binding var playgroundUsed: Bool
let accessibilityEnabled: Bool
let openAccessibilitySettings: () -> Void
+ let openFluidIntelligenceDemo: () -> Void
let openShortcutSettings: () -> Void
var body: some View {
@@ -18,11 +17,8 @@ struct WelcomeView: View {
selectedSidebarItem: self.$selectedSidebarItem,
accessibilityEnabled: self.accessibilityEnabled,
openAccessibilitySettings: self.openAccessibilitySettings,
- openShortcutSettings: self.openShortcutSettings,
- replayOnboarding: {
- self.settings.resetOnboardingProgress()
- self.playgroundUsed = false
- }
+ openFluidIntelligenceDemo: self.openFluidIntelligenceDemo,
+ openShortcutSettings: self.openShortcutSettings
)
.task {
await AudioStartupGate.shared.scheduleOpenAfterInitialUISettled()
diff --git a/Sources/Fluid/Views/BottomOverlayView.swift b/Sources/Fluid/Views/BottomOverlayView.swift
index 4772182c..216e0da1 100644
--- a/Sources/Fluid/Views/BottomOverlayView.swift
+++ b/Sources/Fluid/Views/BottomOverlayView.swift
@@ -2669,8 +2669,9 @@ struct BottomOverlayView: View {
private var promptSelectorDisplayLabel: String {
if self.activePromptMode?.normalized == .dictate {
let label = self.selectedPromptLabel
- guard self.isPillSize, label.count > 18 else { return label }
- return "\(label.prefix(17))…"
+ let limit = self.isCompactControls ? 12 : 18
+ guard label.count > limit else { return label }
+ return "\(label.prefix(limit - 1))…"
}
let selectedLabel = self.selectedPromptLabel.trimmingCharacters(in: .whitespacesAndNewlines)
let label = self.promptSelectorBuiltInLabel ?? selectedLabel
@@ -2729,6 +2730,15 @@ struct BottomOverlayView: View {
self.isPillSize ? 220 : self.layout.waveformWidth * 1.75
}
+ private var promptSelectorTriggerMaxWidth: CGFloat {
+ guard self.layout.showsTopControls else { return 120 }
+ // Trailing controls are overlaid on the waveform row. Reserve the waveform,
+ // an 8pt gap, and the 32pt actions button plus its 8pt spacing.
+ let rowWidth = self.layout.containerWidth - self.layout.hPadding * 2
+ let waveformRight = rowWidth / 2 + self.waveformHorizontalOffset + self.layout.waveformWidth / 2
+ return max(0, rowWidth - waveformRight - 8 - 32 - 8)
+ }
+
private var previewMaxHeight: CGFloat {
self.layout.usesFixedCanvas ? self.layout.previewBoxHeight : self.layout.transFontSize * 4.2
}
@@ -3097,10 +3107,6 @@ struct BottomOverlayView: View {
.foregroundStyle(.white.opacity(0.82))
.lineLimit(1)
.truncationMode(.tail)
- .frame(
- maxWidth: self.activePromptMode?.normalized == .dictate ? nil : (self.promptSelectorBuiltInLabel == nil ? 72 : nil),
- alignment: .leading
- )
if self.isAppPromptOverrideActive {
Text("App")
.font(.fluidSystem(size: max(self.promptSelectorFontSize - 2, 8), weight: .semibold))
@@ -3118,6 +3124,8 @@ struct BottomOverlayView: View {
}
.padding(.horizontal, 7)
.padding(.vertical, self.promptSelectorVerticalPadding)
+ .frame(maxWidth: self.promptSelectorTriggerMaxWidth, alignment: .trailing)
+ .help(self.selectedPromptLabel)
.background(
RoundedRectangle(cornerRadius: self.promptSelectorCornerRadius, style: .continuous)
.fill(
diff --git a/Tests/FluidDictationIntegrationTests/DashboardLayoutTests.swift b/Tests/FluidDictationIntegrationTests/DashboardLayoutTests.swift
index c9637ddf..b7bb3c49 100644
--- a/Tests/FluidDictationIntegrationTests/DashboardLayoutTests.swift
+++ b/Tests/FluidDictationIntegrationTests/DashboardLayoutTests.swift
@@ -3,10 +3,15 @@ import XCTest
@MainActor
final class DashboardLayoutTests: XCTestCase {
- func testLearningCardsAlwaysFillTheirRows() {
+ func testSetupCardsAlwaysFillTheirRows() {
for width in stride(from: 320, through: 2000, by: 1) {
let layout = DashboardLayout(width: CGFloat(width))
- XCTAssertEqual(4 % layout.lessonColumns, 0)
+ for count in 1 ... 3 {
+ XCTAssertEqual(count % layout.setupColumns(count: count), 0)
+ if layout.setupColumns(count: count) > 1 {
+ XCTAssertGreaterThanOrEqual((layout.contentWidth - CGFloat(count - 1) * 10) / CGFloat(count), 280)
+ }
+ }
if layout.hasActionColumn {
XCTAssertGreaterThanOrEqual(layout.mainWidth, 640)
}
@@ -16,9 +21,9 @@ final class DashboardLayoutTests: XCTestCase {
func testBreakpointsAndCappedWidth() {
XCTAssertFalse(DashboardLayout(width: 1023).hasActionColumn)
XCTAssertTrue(DashboardLayout(width: 1024).hasActionColumn)
- XCTAssertEqual(DashboardLayout(width: 575).lessonColumns, 1)
- XCTAssertEqual(DashboardLayout(width: 576).lessonColumns, 2)
- XCTAssertEqual(DashboardLayout(width: 1096).lessonColumns, 4)
+ XCTAssertEqual(DashboardLayout(width: 625).setupColumns(count: 2), 1)
+ XCTAssertEqual(DashboardLayout(width: 626).setupColumns(count: 2), 2)
+ XCTAssertEqual(DashboardLayout(width: 916).setupColumns(count: 3), 3)
XCTAssertFalse(DashboardLayout(width: 675).hasHorizontalActions)
XCTAssertTrue(DashboardLayout(width: 676).hasHorizontalActions)
XCTAssertFalse(DashboardLayout(width: 1024).hasHorizontalActions)
@@ -30,4 +35,72 @@ final class DashboardLayoutTests: XCTestCase {
XCTAssertEqual(DashboardLayout(width: 1440).statisticColumns(count: 4), 4)
XCTAssertEqual(DashboardLayout(width: 320).statisticColumns(count: 4), 1)
}
+
+ func testOnlyMissingEssentialsAreShown() {
+ for model in [false, true] {
+ for microphone in [false, true] {
+ for typing in [false, true] {
+ let missing = DashboardSetupStatus(voiceModelReady: model, microphoneReady: microphone, typingAccessReady: typing).missing
+ XCTAssertEqual(missing.contains(.voiceModel), !model)
+ XCTAssertEqual(missing.contains(.microphone), !microphone)
+ XCTAssertEqual(missing.contains(.typingAccess), !typing)
+ XCTAssertEqual(missing.isEmpty, model && microphone && typing)
+ }
+ }
+ }
+ }
+
+ func testIntelligenceInvitationOnlyAppearsForUntriedUndismissedUsers() {
+ for available in [false, true] {
+ for dismissed in [false, true] {
+ for used in [false, true] {
+ XCTAssertEqual(FluidIntelligenceInvitation.shouldShow(available: available, dismissed: dismissed, hasUsed: used), available && !dismissed && !used)
+ }
+ }
+ }
+ }
+
+ func testIntelligenceUsePersistsWithoutChangingProviderOrOnboarding() throws {
+ let suite = "FluidIntelligenceInvitationTests.\(UUID().uuidString)"
+ let defaults = try XCTUnwrap(UserDefaults(suiteName: suite))
+ defer { defaults.removePersistentDomain(forName: suite) }
+ defaults.set("external-provider", forKey: "SelectedProviderID")
+ defaults.set(true, forKey: "OnboardingCompleted")
+ FluidIntelligenceInvitation.recordSuccess(output: " \n", defaults: defaults)
+ XCTAssertFalse(defaults.bool(forKey: FluidIntelligenceInvitation.usedKey))
+ FluidIntelligenceInvitation.recordSuccess(output: "Unchanged but successful text", defaults: defaults)
+ let reloaded = try XCTUnwrap(UserDefaults(suiteName: suite))
+ XCTAssertTrue(reloaded.bool(forKey: FluidIntelligenceInvitation.usedKey))
+ FluidIntelligenceInvitation.recordSuccess(output: "", defaults: defaults)
+ XCTAssertTrue(defaults.bool(forKey: FluidIntelligenceInvitation.usedKey))
+ defaults.set(true, forKey: FluidIntelligenceInvitation.dismissedKey)
+ XCTAssertTrue(reloaded.bool(forKey: FluidIntelligenceInvitation.dismissedKey))
+ XCTAssertEqual(defaults.string(forKey: "SelectedProviderID"), "external-provider")
+ XCTAssertTrue(defaults.bool(forKey: "OnboardingCompleted"))
+ }
+
+ func testPracticeRejectsResultsAfterCloseAndReopen() {
+ let sandbox = DictationPromptTestCoordinator()
+ sandbox.activate(draftPromptText: "", providerID: "fluid-1", model: "example", usesBuiltInPrompt: true)
+ XCTAssertTrue(sandbox.usesBuiltInPrompt)
+ let oldSession = sandbox.sessionID
+ XCTAssertTrue(sandbox.acceptsResult(for: oldSession))
+ sandbox.deactivate()
+ XCTAssertFalse(sandbox.acceptsResult(for: oldSession))
+ sandbox.activate(draftPromptText: "different", providerID: "other", model: "new")
+ XCTAssertFalse(sandbox.usesBuiltInPrompt)
+ XCTAssertFalse(sandbox.acceptsResult(for: oldSession))
+ XCTAssertTrue(sandbox.acceptsResult(for: sandbox.sessionID))
+ XCTAssertEqual(sandbox.draftProviderID, "other")
+ XCTAssertEqual(sandbox.draftPromptText, "different")
+ }
+
+ func testExistingSuccessfulUseCountsEvenWhenNoWordsChanged() throws {
+ let entry = TranscriptionHistoryEntry(timestamp: Date(), rawText: "Already correct.", processedText: "Already correct.", appName: "Notes", windowTitle: "", wasAIProcessed: true, processingModel: "fluid-1-mini")
+ let snapshot = try StatsSnapshot.build(entries: [entry], now: Date(), calendar: .current)
+ XCTAssertTrue(snapshot.hasFluidIntelligenceUse)
+ XCTAssertEqual(snapshot.fluidFixedWords, 0)
+ let failed = TranscriptionHistoryEntry(timestamp: Date(), rawText: "Raw", processedText: "Raw", appName: "Notes", windowTitle: "", wasAIProcessed: false, processingModel: "fluid-1-mini")
+ XCTAssertFalse(try StatsSnapshot.build(entries: [failed], now: Date(), calendar: .current).hasFluidIntelligenceUse)
+ }
}