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

Add overlay AI/settings quick controls and preferences shortcut

altic-dev018f4862222d
diff --git a/Sources/Fluid/ContentView.swift b/Sources/Fluid/ContentView.swift
index 2f11d956..52bf6e9b 100644
--- a/Sources/Fluid/ContentView.swift
+++ b/Sources/Fluid/ContentView.swift
@@ -600,6 +600,10 @@ struct ContentView: View {
NotchContentState.shared.onPromptModeSwitchRequested = nil
NotchContentState.shared.onOverlayModeSwitchRequested = nil
NotchContentState.shared.onReprocessLastRequested = nil
+ NotchContentState.shared.onCopyLastRequested = nil
+ NotchContentState.shared.onUndoLastAIRequested = nil
+ NotchContentState.shared.onToggleAIProcessingRequested = nil
+ NotchContentState.shared.onOpenPreferencesRequested = nil
Task { await self.asr.stopWithoutTranscription() }
// Note: Overlay lifecycle is now managed by MenuBarManager
@@ -1741,6 +1745,84 @@ struct ContentView: View {
}
}
+ private func copyLastDictationFromHistory() {
+ guard let last = TranscriptionHistoryStore.shared.entries.first else {
+ DebugLogger.shared.info("Actions: Copy requested but history is empty", source: "ContentView")
+ return
+ }
+
+ let text = last.processedText.trimmingCharacters(in: .whitespacesAndNewlines)
+ guard !text.isEmpty else {
+ DebugLogger.shared.info("Actions: Copy skipped because latest history processed text is empty", source: "ContentView")
+ return
+ }
+
+ _ = ClipboardService.copyToClipboard(text)
+ DebugLogger.shared.info("Actions: Copied latest transcription to clipboard", source: "ContentView")
+ }
+
+ private func undoLastAIProcessingFromHistory() {
+ guard let last = TranscriptionHistoryStore.shared.entries.first else {
+ DebugLogger.shared.info("Actions: Undo AI requested but history is empty", source: "ContentView")
+ return
+ }
+
+ let rawText = last.rawText.trimmingCharacters(in: .whitespacesAndNewlines)
+ guard !rawText.isEmpty else {
+ DebugLogger.shared.info("Actions: Undo AI skipped because latest history raw text is empty", source: "ContentView")
+ return
+ }
+
+ guard last.wasAIProcessed else {
+ DebugLogger.shared.info("Actions: Undo AI skipped because latest entry was not AI processed", source: "ContentView")
+ return
+ }
+
+ DebugLogger.shared.info("Actions: Restoring latest transcription raw text (undo AI)", source: "ContentView")
+ Task { @MainActor in
+ await self.applyHistoryTextOutput(rawText, saveToHistory: true)
+ }
+ }
+
+ private func applyHistoryTextOutput(_ text: String, saveToHistory: Bool) async {
+ // Keep hotkey/recording state deterministic before applying output text.
+ if self.asr.isRunning {
+ DebugLogger.shared.info("Actions: stopping active recording before history action output", source: "ContentView")
+ await self.asr.stopWithoutTranscription()
+ }
+
+ let finalText = ASRService.applyGAAVFormatting(text)
+ let appInfo = self.getCurrentAppInfo()
+
+ if saveToHistory, SettingsStore.shared.saveTranscriptionHistory {
+ TranscriptionHistoryStore.shared.addEntry(
+ rawText: text,
+ processedText: finalText,
+ appName: appInfo.name,
+ windowTitle: appInfo.windowTitle
+ )
+ }
+
+ if SettingsStore.shared.copyTranscriptionToClipboard {
+ ClipboardService.copyToClipboard(finalText)
+ }
+
+ let focusedPID = TypingService.captureSystemFocusedPID()
+ ?? NSWorkspace.shared.frontmostApplication?.processIdentifier
+ NotchContentState.shared.recordingTargetPID = focusedPID
+
+ let frontmostApp = NSWorkspace.shared.frontmostApplication
+ let isFluidFrontmost = frontmostApp?.bundleIdentifier?.contains("fluid") == true
+ let shouldTypeExternally = !isFluidFrontmost || self.isTranscriptionFocused == false
+ if shouldTypeExternally {
+ await self.restoreFocusToRecordingTarget()
+ self.asr.typeTextToActiveField(
+ finalText,
+ preferredTargetPID: NotchContentState.shared.recordingTargetPID
+ )
+ }
+ }
+
private func reprocessDictationText(_ transcribedText: String) async {
// If live recording is still active, stop it first so reprocess does not
// leave ASR running in the background (which causes the next hotkey press
@@ -2191,6 +2273,18 @@ struct ContentView: View {
NotchContentState.shared.onReprocessLastRequested = {
self.reprocessLastDictationFromHistory()
}
+ NotchContentState.shared.onCopyLastRequested = {
+ self.copyLastDictationFromHistory()
+ }
+ NotchContentState.shared.onUndoLastAIRequested = {
+ self.undoLastAIProcessingFromHistory()
+ }
+ NotchContentState.shared.onToggleAIProcessingRequested = {
+ _ = self.menuBarManager.toggleAIProcessingEnabled()
+ }
+ NotchContentState.shared.onOpenPreferencesRequested = {
+ self.menuBarManager.openPreferencesFromUI()
+ }
guard self.hotkeyManager == nil else { return }
diff --git a/Sources/Fluid/Services/MenuBarManager.swift b/Sources/Fluid/Services/MenuBarManager.swift
index 5ac0b0da..86d523e0 100644
--- a/Sources/Fluid/Services/MenuBarManager.swift
+++ b/Sources/Fluid/Services/MenuBarManager.swift
@@ -387,14 +387,31 @@ final class MenuBarManager: ObservableObject {
self.aiMenuItem?.title = aiTitle
}
- @objc private func toggleAIProcessing() {
- self.aiProcessingEnabled.toggle()
- // Persist and broadcast change
- SettingsStore.shared.enableAIProcessing = self.aiProcessingEnabled
- // If a ContentView has bound to MenuBarManager, its onChange sync will mirror this
+ /// Centralized entry point to update AI post-processing enablement.
+ /// Use this instead of writing `aiProcessingEnabled` directly so all state stays in sync.
+ func setAIProcessingEnabled(_ enabled: Bool) {
+ guard self.aiProcessingEnabled != enabled else {
+ // Ensure menu text stays correct even if caller repeats the same value.
+ self.updateMenu()
+ return
+ }
+ self.aiProcessingEnabled = enabled
+ SettingsStore.shared.enableAIProcessing = enabled
self.updateMenu()
}
+ /// Toggle AI post-processing and return the new value.
+ @discardableResult
+ func toggleAIProcessingEnabled() -> Bool {
+ let next = !self.aiProcessingEnabled
+ self.setAIProcessingEnabled(next)
+ return next
+ }
+
+ @objc private func toggleAIProcessing() {
+ _ = self.toggleAIProcessingEnabled()
+ }
+
@objc private func checkForUpdates(_ sender: Any?) {
DebugLogger.shared.info("🔎 Menu action: Check for Updates…", source: "MenuBarManager")
@@ -486,6 +503,11 @@ final class MenuBarManager: ObservableObject {
}
}
+ /// Public entry-point for non-menu UI surfaces (e.g. overlay controls) to open Preferences.
+ func openPreferencesFromUI() {
+ self.openPreferences()
+ }
+
/// Create and present a fresh main window hosting `ContentView`
private func createAndShowMainWindow() {
// Build the SwiftUI root view with required environment
diff --git a/Sources/Fluid/UI/AISettings/AIEnhancementSettingsViewModel.swift b/Sources/Fluid/UI/AISettings/AIEnhancementSettingsViewModel.swift
index 4c756db4..f76d6147 100644
--- a/Sources/Fluid/UI/AISettings/AIEnhancementSettingsViewModel.swift
+++ b/Sources/Fluid/UI/AISettings/AIEnhancementSettingsViewModel.swift
@@ -15,8 +15,9 @@ final class AIEnhancementSettingsViewModel: ObservableObject {
@Published var enableAIProcessing: Bool {
didSet {
guard self.enableAIProcessing != oldValue else { return }
- self.settings.enableAIProcessing = self.enableAIProcessing
- self.menuBarManager.aiProcessingEnabled = self.enableAIProcessing
+ // Route through MenuBarManager so all UI surfaces (menu, settings, future overlay)
+ // share one callable code path.
+ self.menuBarManager.setAIProcessingEnabled(self.enableAIProcessing)
}
}
diff --git a/Sources/Fluid/Views/BottomOverlayView.swift b/Sources/Fluid/Views/BottomOverlayView.swift
index e4915b36..5df07190 100644
--- a/Sources/Fluid/Views/BottomOverlayView.swift
+++ b/Sources/Fluid/Views/BottomOverlayView.swift
@@ -1336,6 +1336,23 @@ private struct BottomOverlayActionsMenuView: View {
!self.historyStore.entries.isEmpty && !self.contentState.isProcessing
}
+ private var latestEntry: TranscriptionHistoryEntry? {
+ self.historyStore.entries.first
+ }
+
+ private var canCopyLast: Bool {
+ guard !self.contentState.isProcessing else { return false }
+ guard let latest = self.latestEntry else { return false }
+ return !latest.processedText.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty
+ }
+
+ private var canUndoLastAI: Bool {
+ guard !self.contentState.isProcessing else { return false }
+ guard let latest = self.latestEntry else { return false }
+ let raw = latest.rawText.trimmingCharacters(in: .whitespacesAndNewlines)
+ return latest.wasAIProcessed && !raw.isEmpty
+ }
+
private func rowBackground(isSelected: Bool, rowID: String) -> some View {
let isHovered = self.hoveredRowID == rowID
let fillColor: Color
@@ -1364,32 +1381,73 @@ private struct BottomOverlayActionsMenuView: View {
)
}
- var body: some View {
+ @ViewBuilder
+ private func actionRow(
+ title: String,
+ icon: String,
+ rowID: String,
+ enabled: Bool,
+ action: @escaping () -> Void
+ ) -> some View {
Button(action: {
- guard self.canReprocessLast else { return }
- self.contentState.onReprocessLastRequested?()
+ guard enabled else { return }
+ action()
self.onDismissRequested()
}) {
HStack(spacing: 8) {
- Text("Reprocess Last Dictation")
+ Text(title)
.font(.system(size: 14, weight: .semibold))
Spacer()
- Image(systemName: "arrow.clockwise")
+ Image(systemName: icon)
.font(.system(size: 11, weight: .semibold))
}
.padding(.horizontal, 8)
.padding(.vertical, 6)
- .background(self.rowBackground(isSelected: false, rowID: "reprocess_last"))
+ .background(self.rowBackground(isSelected: false, rowID: rowID))
}
.buttonStyle(.plain)
- .disabled(!self.canReprocessLast)
- .opacity(self.canReprocessLast ? 1 : 0.45)
+ .disabled(!enabled)
+ .opacity(enabled ? 1 : 0.45)
.onHover { hovering in
- guard self.canReprocessLast else {
+ guard enabled else {
self.hoveredRowID = nil
return
}
- self.hoveredRowID = hovering ? "reprocess_last" : nil
+ self.hoveredRowID = hovering ? rowID : nil
+ }
+ }
+
+ var body: some View {
+ VStack(alignment: .leading, spacing: 0) {
+ self.actionRow(
+ title: "Reprocess Last Dictation",
+ icon: "arrow.clockwise",
+ rowID: "reprocess_last",
+ enabled: self.canReprocessLast
+ ) {
+ self.contentState.onReprocessLastRequested?()
+ }
+
+ self.actionRow(
+ title: "Copy Last Transcription",
+ icon: "doc.on.doc",
+ rowID: "copy_last",
+ enabled: self.canCopyLast
+ ) {
+ self.contentState.onCopyLastRequested?()
+ }
+
+ Divider()
+ .padding(.vertical, 4)
+
+ self.actionRow(
+ title: "Undo AI on Last",
+ icon: "arrow.uturn.backward",
+ rowID: "undo_ai_last",
+ enabled: self.canUndoLastAI
+ ) {
+ self.contentState.onUndoLastAIRequested?()
+ }
}
.padding(.horizontal, 8)
.padding(.vertical, 4)
@@ -1511,7 +1569,9 @@ struct BottomOverlayView: View {
@Environment(\.theme) private var theme
@State private var isHoveringModeChip = false
@State private var isHoveringPromptChip = false
+ @State private var isHoveringAIToggleChip = false
@State private var isHoveringActionsChip = false
+ @State private var isHoveringSettingsChip = false
@State private var modeSelectorFrameInScreen: CGRect = .zero
@State private var modeSelectorWindow: NSWindow?
@State private var promptSelectorFrameInScreen: CGRect = .zero
@@ -1990,6 +2050,44 @@ struct BottomOverlayView: View {
)
}
+ private var aiToggleChip: some View {
+ let disabled = self.contentState.isProcessing
+ let isEnabled = self.settings.enableAIProcessing
+ return HStack(spacing: 5) {
+ Text("AI:")
+ .font(.system(size: self.promptSelectorFontSize, weight: .medium))
+ .foregroundStyle(.white.opacity(0.5))
+ Text(isEnabled ? "On" : "Off")
+ .font(.system(size: self.promptSelectorFontSize, weight: .semibold))
+ .foregroundStyle(isEnabled ? .white.opacity(0.82) : .white.opacity(0.7))
+ .lineLimit(1)
+ Image(systemName: isEnabled ? "brain.fill" : "brain")
+ .font(.system(size: max(self.promptSelectorFontSize - 1, 8), weight: .semibold))
+ .foregroundStyle(isEnabled ? .white.opacity(0.65) : .white.opacity(0.45))
+ }
+ .padding(.horizontal, 8)
+ .padding(.vertical, self.promptSelectorVerticalPadding)
+ .background(
+ self.chipBackground(
+ isHovered: self.isHoveringAIToggleChip,
+ disabled: disabled
+ )
+ )
+ .contentShape(Rectangle())
+ .onHover { hovering in
+ self.isHoveringAIToggleChip = hovering && !disabled
+ }
+ .onTapGesture {
+ guard !disabled else { return }
+ self.closePromptMenu()
+ self.closeModeMenu()
+ self.closeActionsMenu()
+ self.contentState.onToggleAIProcessingRequested?()
+ }
+ .help("Toggle AI enhancement for dictation")
+ .opacity(disabled ? 0.65 : 1)
+ }
+
private var actionsSelectorView: some View {
let actionsDisabled = self.historyStore.entries.isEmpty || self.contentState.isProcessing
return self.actionsSelectorTrigger
@@ -2023,15 +2121,46 @@ struct BottomOverlayView: View {
)
}
+ private var settingsChip: some View {
+ let disabled = false
+ return HStack(spacing: 0) {
+ Image(systemName: "gearshape")
+ .font(.system(size: max(self.promptSelectorFontSize + 1, 10), weight: .semibold))
+ .foregroundStyle(.white.opacity(0.72))
+ }
+ .padding(.horizontal, 9)
+ .padding(.vertical, self.promptSelectorVerticalPadding)
+ .background(
+ self.chipBackground(
+ isHovered: self.isHoveringSettingsChip,
+ disabled: disabled
+ )
+ )
+ .contentShape(Rectangle())
+ .onHover { hovering in
+ self.isHoveringSettingsChip = hovering
+ }
+ .onTapGesture {
+ self.closePromptMenu()
+ self.closeModeMenu()
+ self.closeActionsMenu()
+ self.contentState.onOpenPreferencesRequested?()
+ }
+ .help("Open Preferences")
+ }
+
var body: some View {
VStack(spacing: max(4, self.layout.vPadding / 2)) {
if self.layout.showsTopControls {
HStack(spacing: 8) {
self.modeSelectorView
self.promptSelectorView
+ Spacer(minLength: 6)
+ self.aiToggleChip
self.actionsSelectorView
+ self.settingsChip
}
- .frame(maxWidth: .infinity, alignment: .center)
+ .frame(maxWidth: .infinity, alignment: .leading)
.padding(.horizontal, self.layout.hPadding)
}
@@ -2241,7 +2370,9 @@ struct BottomOverlayView: View {
self.closeActionsMenu()
self.isHoveringModeChip = false
self.isHoveringPromptChip = false
+ self.isHoveringAIToggleChip = false
self.isHoveringActionsChip = false
+ self.isHoveringSettingsChip = false
switch self.contentState.mode {
case .dictation: self.contentState.promptPickerMode = .dictate
case .edit, .write, .rewrite: self.contentState.promptPickerMode = .edit
@@ -2259,7 +2390,9 @@ struct BottomOverlayView: View {
}
self.isHoveringModeChip = false
self.isHoveringPromptChip = false
+ self.isHoveringAIToggleChip = false
self.isHoveringActionsChip = false
+ self.isHoveringSettingsChip = false
if !self.layout.usesFixedCanvas {
BottomOverlayWindowController.shared.refreshSizeForContent()
}
@@ -2270,7 +2403,9 @@ struct BottomOverlayView: View {
self.closeActionsMenu()
self.isHoveringModeChip = false
self.isHoveringPromptChip = false
+ self.isHoveringAIToggleChip = false
self.isHoveringActionsChip = false
+ self.isHoveringSettingsChip = false
}
// TODO: Add tap-to-expand for command mode history (future enhancement)
// .contentShape(Rectangle())
diff --git a/Sources/Fluid/Views/NotchContentViews.swift b/Sources/Fluid/Views/NotchContentViews.swift
index c681cfed..eb174e2d 100644
--- a/Sources/Fluid/Views/NotchContentViews.swift
+++ b/Sources/Fluid/Views/NotchContentViews.swift
@@ -131,6 +131,14 @@ class NotchContentState: ObservableObject {
var onOverlayModeSwitchRequested: ((OverlayMode) -> Void)?
/// Called when the user requests reprocessing the latest saved dictation entry.
var onReprocessLastRequested: (() -> Void)?
+ /// Called when the user requests copying the latest saved transcription entry.
+ var onCopyLastRequested: (() -> Void)?
+ /// Called when the user requests undoing AI processing for the latest entry.
+ var onUndoLastAIRequested: (() -> Void)?
+ /// Called when the user requests toggling dictation AI enhancement.
+ var onToggleAIProcessingRequested: (() -> Void)?
+ /// Called when the user requests opening Preferences.
+ var onOpenPreferencesRequested: (() -> Void)?
/// Set recording state (for waveform visibility in expanded view)
func setRecordingInExpandedMode(_ recording: Bool) {