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
formatting, lint and alignment issues fixed
altic-devf843b398a647
diff --git a/Sources/Fluid/Persistence/SettingsStore.swift b/Sources/Fluid/Persistence/SettingsStore.swiftindex cdba6d3a..d2656b57 100644--- a/Sources/Fluid/Persistence/SettingsStore.swift+++ b/Sources/Fluid/Persistence/SettingsStore.swift@@ -80,6 +80,11 @@ final class SettingsStore: ObservableObject {// Unified Speech Model (replaces above two)static let selectedSpeechModel = "SelectedSpeechModel"++ // Overlay Position+ static let overlayPosition = "OverlayPosition"+ static let overlayBottomOffset = "OverlayBottomOffset"+ static let overlaySize = "OverlaySize"}// MARK: - Model Reasoning Configuration@@ -330,7 +335,94 @@ final class SettingsStore: ObservableObject {let value = self.defaults.double(forKey: Keys.visualizerNoiseThreshold)return value == 0.0 ? 0.4 : value // Default to 0.4 if not set}- set { self.defaults.set(newValue, forKey: Keys.visualizerNoiseThreshold) }+ set {+ // Clamp between 0.0 and 0.95 to avoid division by zero issues in visualizers+ let clamped = max(min(newValue, 0.95), 0.0)+ self.defaults.set(clamped, forKey: Keys.visualizerNoiseThreshold)+ }+ }++ // MARK: - Overlay Position++ /// Size options for the recording overlay+ enum OverlaySize: String, CaseIterable {+ case small+ case medium+ case large++ var displayName: String {+ switch self {+ case .small: return "Small"+ case .medium: return "Medium"+ case .large: return "Large"+ }+ }+ }++ /// Position options for the recording overlay+ enum OverlayPosition: String, CaseIterable {+ case top // Top of screen (notch area or floating)+ case bottom // Bottom of screen++ var displayName: String {+ switch self {+ case .top: return "Top of Screen"+ case .bottom: return "Bottom of Screen"+ }+ }+ }++ /// Where the recording overlay appears (default: top)+ var overlayPosition: OverlayPosition {+ get {+ guard let raw = self.defaults.string(forKey: Keys.overlayPosition),+ let position = OverlayPosition(rawValue: raw)+ else {+ return .top // Default to top (current behavior)+ }+ return position+ }+ set {+ objectWillChange.send()+ self.defaults.set(newValue.rawValue, forKey: Keys.overlayPosition)+ }+ }++ /// Vertical offset for the bottom overlay (distance from bottom of screen/dock)+ var overlayBottomOffset: Double {+ get {+ let value = self.defaults.double(forKey: Keys.overlayBottomOffset)+ return value == 0.0 ? 80.0 : value // Default to 80.0+ }+ set {+ objectWillChange.send()+ // Clamp between a safe range (20px to 1000px)+ // Even though slider is 20-500, we clamp for safety+ let clamped = max(min(newValue, 1000.0), 10.0)+ self.defaults.set(clamped, forKey: Keys.overlayBottomOffset)++ // Post notification for live update if overlay is visible+ NotificationCenter.default.post(name: NSNotification.Name("OverlayOffsetChanged"), object: nil)+ }+ }++ /// The size of the recording overlay (default: medium)+ var overlaySize: OverlaySize {+ get {+ guard let raw = self.defaults.string(forKey: Keys.overlaySize),+ let size = OverlaySize(rawValue: raw)+ else {+ return .medium // Default to medium+ }+ return size+ }+ set {+ objectWillChange.send()+ self.defaults.set(newValue.rawValue, forKey: Keys.overlaySize)++ // Post notification for live update if overlay is visible+ NotificationCenter.default.post(name: NSNotification.Name("OverlaySizeChanged"), object: nil)+ }}// MARK: - Preferences Settingsdiff --git a/Sources/Fluid/Services/ActiveAppMonitor.swift b/Sources/Fluid/Services/ActiveAppMonitor.swiftnew file mode 100644index 00000000..04f3ce4d--- /dev/null+++ b/Sources/Fluid/Services/ActiveAppMonitor.swift@@ -0,0 +1,93 @@+import AppKit+import Combine++/// A centralized service that monitors the currently active (frontmost) application.+/// This can be used by overlays, AI prompts, custom commands, etc.+@MainActor+final class ActiveAppMonitor: ObservableObject {+ static let shared = ActiveAppMonitor()++ /// The currently active application (excluding FluidVoice itself)+ @Published private(set) var activeApp: NSRunningApplication?++ /// The icon of the currently active application+ @Published private(set) var activeAppIcon: NSImage?++ /// The bundle identifier of the currently active application+ var activeAppBundleID: String? {+ self.activeApp?.bundleIdentifier+ }++ /// The localized name of the currently active application+ var activeAppName: String? {+ self.activeApp?.localizedName+ }++ private var observer: NSObjectProtocol?+ private var isMonitoring = false++ private init() {}++ /// Start monitoring active app changes.+ /// Call this when showing overlays or when you need real-time app tracking.+ func startMonitoring() {+ guard !self.isMonitoring else { return }+ self.isMonitoring = true++ // Capture the current app immediately+ self.updateActiveApp()++ // Subscribe to app activation notifications+ self.observer = NSWorkspace.shared.notificationCenter.addObserver(+ forName: NSWorkspace.didActivateApplicationNotification,+ object: nil,+ queue: .main+ ) { [weak self] _ in+ Task { @MainActor in+ self?.updateActiveApp()+ }+ }+ }++ /// Stop monitoring active app changes.+ /// Call this when hiding overlays to conserve resources.+ func stopMonitoring() {+ guard self.isMonitoring else { return }+ self.isMonitoring = false++ if let observer = observer {+ NSWorkspace.shared.notificationCenter.removeObserver(observer)+ self.observer = nil+ }++ // Clear state to ensure fresh capture on next start+ self.activeApp = nil+ self.activeAppIcon = nil+ }++ /// Manually refresh the active app (useful for one-shot captures)+ func refreshActiveApp() {+ self.updateActiveApp()+ }++ private func updateActiveApp() {+ guard let frontApp = NSWorkspace.shared.frontmostApplication else {+ // No frontmost app (rare edge case during fast app switches)+ return+ }++ // Don't track ourselves+ guard frontApp.bundleIdentifier != Bundle.main.bundleIdentifier else {+ return+ }++ // Only update if the app actually changed+ if self.activeApp?.bundleIdentifier != frontApp.bundleIdentifier {+ self.activeApp = frontApp+ self.activeAppIcon = frontApp.icon++ // Also update NotchContentState for overlay compatibility+ NotchContentState.shared.targetAppIcon = frontApp.icon+ }+ }+}diff --git a/Sources/Fluid/Services/NotchOverlayManager.swift b/Sources/Fluid/Services/NotchOverlayManager.swiftindex 22878df1..e650c252 100644--- a/Sources/Fluid/Services/NotchOverlayManager.swift+++ b/Sources/Fluid/Services/NotchOverlayManager.swift@@ -51,6 +51,9 @@ final class NotchOverlayManager {// Track if expanded command output is showingprivate(set) var isCommandOutputExpanded: Bool = false+ // Track if bottom overlay is visible+ private(set) var isBottomOverlayVisible: Bool = false+// Callbacks for command output interactionvar onCommandOutputDismiss: (() -> Void)?var onCommandFollowUp: ((String) async -> Void)?@@ -99,7 +102,11 @@ final class NotchOverlayManager {self.hideExpandedCommandOutput()self.onCommandOutputDismiss?()}- // Also hide regular notch if visible+ // Hide bottom overlay if visible+ else if self.isBottomOverlayVisible {+ self.hide()+ }+ // Hide regular notch if visibleelse if self.state == .visible {self.hide()}@@ -162,6 +169,41 @@ final class NotchOverlayManager {// Store for potential re-show during processingself.lastAudioPublisher = audioLevelPublisher+ // Start monitoring active app changes (updates icon in real-time)+ ActiveAppMonitor.shared.startMonitoring()++ // Route to bottom overlay if user preference is set+ if SettingsStore.shared.overlayPosition == .bottom {+ self.showBottomOverlay(audioLevelPublisher: audioLevelPublisher, mode: mode)+ return+ }++ // Otherwise show notch overlay (original behavior)+ self.showNotchOverlay(audioLevelPublisher: audioLevelPublisher, mode: mode)+ }++ /// Show bottom overlay (alternative to notch)+ private func showBottomOverlay(audioLevelPublisher: AnyPublisher<CGFloat, Never>, mode: OverlayMode) {+ // Hide any existing notch first+ if self.notch != nil {+ Task { await self.performCleanup() }+ }++ self.lastAudioPublisher = audioLevelPublisher+ self.currentMode = mode++ BottomOverlayWindowController.shared.show(audioPublisher: audioLevelPublisher, mode: mode)+ self.isBottomOverlayVisible = true+ }++ /// Show notch overlay (original behavior)+ private func showNotchOverlay(audioLevelPublisher: AnyPublisher<CGFloat, Never>, mode: OverlayMode) {+ // Hide bottom overlay if it was visible+ if self.isBottomOverlayVisible {+ BottomOverlayWindowController.shared.hide()+ self.isBottomOverlayVisible = false+ }+// Increment generation for this operationself.generation &+= 1let currentGeneration = self.generation@@ -176,7 +218,7 @@ final class NotchOverlayManager {// Create notch with SwiftUI viewslet newNotch = DynamicNotch(hoverBehavior: [.keepVisible, .hapticFeedback],- style: .notch(topCornerRadius: 12, bottomCornerRadius: 18)+ style: .auto) {NotchExpandedView(audioPublisher: audioLevelPublisher)} compactLeading: {@@ -197,6 +239,15 @@ final class NotchOverlayManager {}func hide() {+ // Stop monitoring active app changes+ ActiveAppMonitor.shared.stopMonitoring()++ // Hide bottom overlay if visible+ if self.isBottomOverlayVisible {+ BottomOverlayWindowController.shared.hide()+ self.isBottomOverlayVisible = false+ }+// Cancel any pending retry operationsself.pendingRetryTask?.cancel()self.pendingRetryTask = nil@@ -258,6 +309,12 @@ final class NotchOverlayManager {return}+ // If bottom overlay is visible, update its processing state+ if self.isBottomOverlayVisible {+ BottomOverlayWindowController.shared.setProcessing(processing)+ return+ }+if processing {// If notch isn't visible, re-show it for processing stateif self.state == .idle || self.state == .hiding {@@ -301,7 +358,7 @@ final class NotchOverlayManager {let newNotch = DynamicNotch(hoverBehavior: [], // No keepVisible - allows closing with X/Escape even when cursor is on notch- style: .notch(topCornerRadius: 12, bottomCornerRadius: 16)+ style: .auto) {NotchCommandOutputExpandedView(audioPublisher: publisher,diff --git a/Sources/Fluid/UI/SettingsView.swift b/Sources/Fluid/UI/SettingsView.swiftindex d3d7c9bb..f5c40cf3 100644--- a/Sources/Fluid/UI/SettingsView.swift+++ b/Sources/Fluid/UI/SettingsView.swift@@ -13,6 +13,7 @@ struct SettingsView: View {@EnvironmentObject var appServices: AppServicesprivate var asr: ASRService { self.appServices.asr }@Environment(\.theme) private var theme+ @ObservedObject private var settings = SettingsStore.shared@Binding var appear: Bool@Binding var visualizerNoiseThreshold: Double@Binding var selectedInputUID: String@@ -547,7 +548,7 @@ struct SettingsView: View {Text("Input Device").font(.body)Spacer()- Picker("Input Device", selection: self.$selectedInputUID) {+ Picker("", selection: self.$selectedInputUID) {// Handle empty state gracefullyif self.inputDevices.isEmpty {Text("Loading...").tag("")@@ -608,7 +609,7 @@ struct SettingsView: View {Text("Output Device").font(.body)Spacer()- Picker("Output Device", selection: self.$selectedOutputUID) {+ Picker("", selection: self.$selectedOutputUID) {// Handle empty state gracefullyif self.outputDevices.isEmpty {Text("Loading...").tag("")@@ -731,6 +732,89 @@ struct SettingsView: View {.foregroundStyle(.tertiary).frame(width: 36)}++ Divider().padding(.vertical, 8)++ // Overlay Position+ HStack {+ VStack(alignment: .leading, spacing: 2) {+ Text("Overlay Position")+ .font(.body)+ Text("Where the recording indicator appears on screen")+ .font(.subheadline)+ .foregroundStyle(.secondary)+ }++ Spacer()++ Picker("", selection: self.$settings.overlayPosition) {+ ForEach(SettingsStore.OverlayPosition.allCases, id: \.self) { position in+ Text(position.displayName).tag(position)+ }+ }+ .pickerStyle(.menu)+ .frame(width: 170, alignment: .trailing)+ }++ // Bottom overlay specific settings (only show when bottom is selected)+ if self.settings.overlayPosition == .bottom {+ Divider().padding(.vertical, 4)++ // Overlay Size+ HStack {+ VStack(alignment: .leading, spacing: 2) {+ Text("Overlay Size")+ .font(.body)+ Text("How large the recording indicator appears")+ .font(.subheadline)+ .foregroundStyle(.secondary)+ }++ Spacer()++ Picker("", selection: self.$settings.overlaySize) {+ ForEach(SettingsStore.OverlaySize.allCases, id: \.self) { size in+ Text(size.displayName).tag(size)+ }+ }+ .pickerStyle(.menu)+ .frame(width: 170, alignment: .trailing)+ }++ // Bottom Offset+ HStack {+ VStack(alignment: .leading, spacing: 2) {+ Text("Bottom Offset")+ .font(.body)+ Text("Distance from bottom of screen")+ .font(.subheadline)+ .foregroundStyle(.secondary)+ }++ Spacer()++ HStack(spacing: 6) {+ Slider(value: self.$settings.overlayBottomOffset, in: 20...500)+ .frame(width: 110)+ .controlSize(.small)++ Text("\(Int(self.settings.overlayBottomOffset)) px")+ .font(.caption.monospaced())+ .foregroundStyle(.secondary)+ .frame(width: 54, alignment: .trailing)+ }+ .frame(width: 170, alignment: .trailing)+ }+ }++ if self.asr.isRunning {+ Text("Settings are disabled during active recording")+ .font(.caption)+ .foregroundStyle(.secondary)+ .italic()+ .frame(maxWidth: .infinity, alignment: .leading)+ .padding(.top, 4)+ }}}.padding(16)diff --git a/Sources/Fluid/Views/BottomOverlayView.swift b/Sources/Fluid/Views/BottomOverlayView.swiftnew file mode 100644index 00000000..257759f1--- /dev/null+++ b/Sources/Fluid/Views/BottomOverlayView.swift@@ -0,0 +1,509 @@+//+// BottomOverlayView.swift+// Fluid+//+// Bottom overlay for transcription (alternative to notch overlay)+//++import AppKit+import Combine+import SwiftUI++// MARK: - Bottom Overlay Window Controller++@MainActor+final class BottomOverlayWindowController {+ static let shared = BottomOverlayWindowController()++ private var window: NSPanel?+ private var audioSubscription: AnyCancellable?++ private init() {+ NotificationCenter.default.addObserver(forName: NSNotification.Name("OverlayOffsetChanged"), object: nil, queue: .main) { [weak self] _ in+ Task { @MainActor [weak self] in+ self?.positionWindow()+ }+ }+ NotificationCenter.default.addObserver(forName: NSNotification.Name("OverlaySizeChanged"), object: nil, queue: .main) { [weak self] _ in+ Task { @MainActor [weak self] in+ self?.updateSizeAndPosition()+ }+ }+ }++ func show(audioPublisher: AnyPublisher<CGFloat, Never>, mode: OverlayMode) {+ // Update mode in content state+ NotchContentState.shared.mode = mode+ NotchContentState.shared.updateTranscription("")+ NotchContentState.shared.bottomOverlayAudioLevel = 0++ // Subscribe to audio levels and route through NotchContentState+ self.audioSubscription?.cancel()+ self.audioSubscription = audioPublisher+ .receive(on: DispatchQueue.main)+ .sink { level in+ NotchContentState.shared.bottomOverlayAudioLevel = level+ }++ // Create window if needed+ if self.window == nil {+ self.createWindow()+ }++ // Position at bottom center of main screen+ self.positionWindow()++ // Show with animation+ self.window?.alphaValue = 0+ self.window?.orderFrontRegardless()++ NSAnimationContext.runAnimationGroup { context in+ context.duration = 0.25+ context.timingFunction = CAMediaTimingFunction(name: .easeOut)+ self.window?.animator().alphaValue = 1+ }+ }++ func hide() {+ // Cancel audio subscription+ self.audioSubscription?.cancel()+ self.audioSubscription = nil++ // Reset state+ NotchContentState.shared.setProcessing(false)+ NotchContentState.shared.bottomOverlayAudioLevel = 0+ NotchContentState.shared.targetAppIcon = nil++ guard let window = window else { return }++ NSAnimationContext.runAnimationGroup { context in+ context.duration = 0.2+ context.timingFunction = CAMediaTimingFunction(name: .easeIn)+ window.animator().alphaValue = 0+ } completionHandler: { [weak self] in+ self?.window?.orderOut(nil)+ }+ }++ func setProcessing(_ processing: Bool) {+ NotchContentState.shared.setProcessing(processing)+ }++ /// Update window size based on current SwiftUI content and re-position+ private func updateSizeAndPosition() {+ guard let window = window, let hostingView = window.contentView as? NSHostingView<BottomOverlayView> else { return }++ // Re-calculate fitting size for the new layout constants+ let newSize = hostingView.fittingSize++ // Update window size+ window.setContentSize(newSize)+ hostingView.frame = NSRect(origin: .zero, size: newSize)++ // Re-position+ self.positionWindow()+ }++ private func createWindow() {+ let panel = NSPanel(+ contentRect: .zero,+ styleMask: [.borderless, .nonactivatingPanel],+ backing: .buffered,+ defer: false+ )++ panel.isFloatingPanel = true+ panel.level = .floating+ panel.collectionBehavior = [.canJoinAllSpaces, .fullScreenAuxiliary]+ panel.isOpaque = false+ panel.backgroundColor = .clear+ panel.hasShadow = false // SwiftUI handles shadow+ panel.isMovableByWindowBackground = false+ panel.hidesOnDeactivate = false++ let contentView = BottomOverlayView()+ let hostingView = NSHostingView(rootView: contentView)++ // Let SwiftUI determine the size+ let fittingSize = hostingView.fittingSize+ hostingView.frame = NSRect(origin: .zero, size: fittingSize)++ // Make hosting view fully transparent+ hostingView.wantsLayer = true+ hostingView.layer?.backgroundColor = .clear++ panel.setContentSize(fittingSize)+ panel.contentView = hostingView++ self.window = panel+ }++ private func positionWindow() {+ // Safe check for window and screen availability+ guard let window = window else { return }++ // Use the screen that contains the window, or fallback to the main screen+ let screen = window.screen ?? NSScreen.main+ guard let screen = screen else { return }++ let fullFrame = screen.frame+ let visibleFrame = screen.visibleFrame+ let windowSize = window.frame.size++ // Horizontal centering+ let x = fullFrame.midX - windowSize.width / 2++ // Vertical positioning with safety clamping+ let offset = SettingsStore.shared.overlayBottomOffset++ // Calculate raw position+ var y = visibleFrame.minY + CGFloat(offset)++ // Safety Clamping:+ // 1. Min: Ensure it's at least visibleFrame.minY (not below the dock/visible area)+ // 2. Max: Ensure it doesn't cross the top of the visible frame minus its own height+ let minY = visibleFrame.minY + 10 // Small buffer from absolute bottom+ let maxY = visibleFrame.maxY - windowSize.height - 40 // Buffer from top++ y = max(min(y, maxY), minY)++ // Apply position using animator for smoother live transition if already visible+ if window.isVisible {+ window.animator().setFrameOrigin(NSPoint(x: x, y: y))+ } else {+ window.setFrameOrigin(NSPoint(x: x, y: y))+ }+ }+}++// MARK: - Bottom Overlay SwiftUI View++struct BottomOverlayView: View {+ @ObservedObject private var contentState = NotchContentState.shared+ @ObservedObject private var settings = SettingsStore.shared++ struct LayoutConstants {+ let hPadding: CGFloat+ let vPadding: CGFloat+ let waveformWidth: CGFloat+ let waveformHeight: CGFloat+ let iconSize: CGFloat+ let transFontSize: CGFloat+ let modeFontSize: CGFloat+ let cornerRadius: CGFloat+ let barCount: Int+ let barWidth: CGFloat+ let barSpacing: CGFloat+ let minBarHeight: CGFloat+ let maxBarHeight: CGFloat++ static func get(for size: SettingsStore.OverlaySize) -> LayoutConstants {+ switch size {+ case .small:+ return LayoutConstants(+ hPadding: 14,+ vPadding: 8,+ waveformWidth: 90,+ waveformHeight: 20,+ iconSize: 16,+ transFontSize: 11,+ modeFontSize: 10,+ cornerRadius: 14,+ barCount: 7,+ barWidth: 3.0,+ barSpacing: 3.5,+ minBarHeight: 5,+ maxBarHeight: 16+ )+ case .medium:+ return LayoutConstants(+ hPadding: 18,+ vPadding: 12,+ waveformWidth: 130,+ waveformHeight: 32,+ iconSize: 20,+ transFontSize: 13,+ modeFontSize: 12,+ cornerRadius: 18,+ barCount: 9,+ barWidth: 3.5,+ barSpacing: 4.5,+ minBarHeight: 6,+ maxBarHeight: 28+ )+ case .large:+ return LayoutConstants(+ hPadding: 24,+ vPadding: 18,+ waveformWidth: 180,+ waveformHeight: 48,+ iconSize: 26,+ transFontSize: 15,+ modeFontSize: 14,+ cornerRadius: 24,+ barCount: 11,+ barWidth: 5.0,+ barSpacing: 6.0,+ minBarHeight: 8,+ maxBarHeight: 44+ )+ }+ }+ }++ private var layout: LayoutConstants {+ LayoutConstants.get(for: self.settings.overlaySize)+ }++ private var modeColor: Color {+ self.contentState.mode.notchColor+ }++ private var modeLabel: String {+ switch self.contentState.mode {+ case .dictation: return "Dictate"+ case .rewrite: return "Rewrite"+ case .write: return "Write"+ case .command: return "Command"+ }+ }++ private var processingLabel: String {+ switch self.contentState.mode {+ case .dictation: return "Refining..."+ case .rewrite: return "Thinking..."+ case .write: return "Thinking..."+ case .command: return "Working..."+ }+ }++ private var hasTranscription: Bool {+ !self.contentState.transcriptionText.isEmpty+ }++ // Show last ~60 characters of transcription on single line+ private var transcriptionSuffix: String {+ let text = self.contentState.transcriptionText+ let maxChars = 60+ return text.count > maxChars ? "..." + String(text.suffix(maxChars)) : text+ }++ var body: some View {+ VStack(spacing: self.layout.vPadding / 2) {+ // Transcription text area (single line)+ Group {+ if self.hasTranscription && !self.contentState.isProcessing {+ Text(self.transcriptionSuffix)+ .font(.system(size: self.layout.transFontSize, weight: .medium))+ .foregroundStyle(.white.opacity(0.9))+ .lineLimit(1)+ .truncationMode(.head)+ } else if self.contentState.isProcessing {+ Text(self.processingLabel)+ .font(.system(size: self.layout.transFontSize, weight: .medium))+ .foregroundStyle(self.modeColor.opacity(0.8))+ }+ }+ .frame(maxWidth: self.layout.waveformWidth * 2.2, minHeight: self.hasTranscription || self.contentState.isProcessing ? self.layout.transFontSize * 1.5 : 0)++ // Waveform + Mode label row+ HStack(spacing: self.layout.hPadding / 1.5) {+ // Target app icon (the app where text will be typed)+ if let appIcon = contentState.targetAppIcon {+ Image(nsImage: appIcon)+ .resizable()+ .aspectRatio(contentMode: .fit)+ .frame(width: self.layout.iconSize, height: self.layout.iconSize)+ .clipShape(RoundedRectangle(cornerRadius: self.layout.iconSize / 4))+ }++ // Waveform visualization+ BottomWaveformView(color: self.modeColor, layout: self.layout)+ .frame(width: self.layout.waveformWidth, height: self.layout.waveformHeight)++ // Mode label+ Text(self.modeLabel)+ .font(.system(size: self.layout.modeFontSize, weight: .semibold))+ .foregroundStyle(self.modeColor)+ .lineLimit(1)+ .fixedSize(horizontal: true, vertical: false)+ }+ }+ .padding(.horizontal, self.layout.hPadding)+ .padding(.vertical, self.layout.vPadding)+ .background(+ ZStack {+ // Solid black background+ RoundedRectangle(cornerRadius: self.layout.cornerRadius)+ .fill(Color.black)++ // Inner border+ RoundedRectangle(cornerRadius: self.layout.cornerRadius)+ .strokeBorder(+ LinearGradient(+ colors: [.white.opacity(0.15), .white.opacity(0.05)],+ startPoint: .top,+ endPoint: .bottom+ ),+ lineWidth: 1+ )+ }+ )+ // TODO: Add tap-to-expand for command mode history (future enhancement)+ // .contentShape(Rectangle())+ // .onTapGesture {+ // if contentState.mode == .command && !contentState.commandConversationHistory.isEmpty {+ // NotchOverlayManager.shared.onNotchClicked?()+ // }+ // }+ .animation(.easeInOut(duration: 0.15), value: self.hasTranscription)+ .animation(.easeInOut(duration: 0.2), value: self.contentState.mode)+ .animation(.easeInOut(duration: 0.2), value: self.contentState.isProcessing)+ }+}++// MARK: - Bottom Waveform View (reads from NotchContentState)++struct BottomWaveformView: View {+ let color: Color+ let layout: BottomOverlayView.LayoutConstants++ @ObservedObject private var contentState = NotchContentState.shared+ // Initialize with max possible bar count (11 for large) to prevent index-out-of-range before onAppear+ @State private var barHeights: [CGFloat] = Array(repeating: 6, count: 11)+ @State private var glowPhase: CGFloat = 0+ @State private var glowTimer: Timer? = nil+ @State private var noiseThreshold: CGFloat = .init(SettingsStore.shared.visualizerNoiseThreshold)++ private var barCount: Int { self.layout.barCount }+ private var barWidth: CGFloat { self.layout.barWidth }+ private var barSpacing: CGFloat { self.layout.barSpacing }+ private var minHeight: CGFloat { self.layout.minBarHeight }+ private var maxHeight: CGFloat { self.layout.maxBarHeight }++ private var currentGlowIntensity: CGFloat {+ self.contentState.isProcessing ? 0.6 + 0.3 * sin(self.glowPhase * .pi * 2) : 0.5+ }++ private var currentGlowRadius: CGFloat {+ self.contentState.isProcessing ? 5 + 7 * sin(self.glowPhase * .pi * 2) : 4+ }++ /// Safe accessor for bar heights to prevent index-out-of-range crashes+ private func safeBarHeight(at index: Int) -> CGFloat {+ guard index >= 0 && index < self.barHeights.count else {+ return self.minHeight+ }+ return self.barHeights[index]+ }++ var body: some View {+ HStack(spacing: self.barSpacing) {+ ForEach(0..<self.barCount, id: \.self) { index in+ RoundedRectangle(cornerRadius: self.barWidth / 2)+ .fill(self.color)+ .frame(width: self.barWidth, height: self.safeBarHeight(at: index))+ .shadow(color: self.color.opacity(self.currentGlowIntensity), radius: self.currentGlowRadius, x: 0, y: 0)+ }+ }+ .onChange(of: self.contentState.bottomOverlayAudioLevel) { _, level in+ if !self.contentState.isProcessing {+ self.updateBars(level: level)+ }+ }+ .onChange(of: self.contentState.isProcessing) { _, processing in+ if processing {+ self.setStaticProcessingBars()+ self.startGlowAnimation()+ } else {+ self.stopGlowAnimation()+ }+ }+ .onChange(of: self.layout.barCount) { _, newCount in+ self.barHeights = Array(repeating: self.minHeight, count: newCount)+ }+ .onAppear {+ // Ensure bar count matches current layout+ if self.barHeights.count != self.barCount {+ self.barHeights = Array(repeating: self.minHeight, count: self.barCount)+ }+ if self.contentState.isProcessing {+ self.setStaticProcessingBars()+ self.startGlowAnimation()+ } else {+ self.updateBars(level: 0)+ }+ }+ .onDisappear {+ self.stopGlowAnimation()+ }+ .onReceive(NotificationCenter.default.publisher(for: UserDefaults.didChangeNotification)) { _ in+ // Update threshold when user changes sensitivity setting+ let newThreshold = CGFloat(SettingsStore.shared.visualizerNoiseThreshold)+ if newThreshold != self.noiseThreshold {+ self.noiseThreshold = newThreshold+ }+ }+ }++ private func startGlowAnimation() {+ self.stopGlowAnimation()+ self.glowPhase = 0++ self.glowTimer = Timer.scheduledTimer(withTimeInterval: 1.0 / 30.0, repeats: true) { _ in+ withAnimation(.linear(duration: 1.0 / 30.0)) {+ self.glowPhase += 1.0 / 30.0 / 1.5+ if self.glowPhase >= 1.0 {+ self.glowPhase = 0+ }+ }+ }+ }++ private func stopGlowAnimation() {+ self.glowTimer?.invalidate()+ self.glowTimer = nil+ self.glowPhase = 0+ }++ private func setStaticProcessingBars() {+ // Ensure array is properly sized before modifying+ guard self.barHeights.count >= self.barCount else { return }++ withAnimation(.easeInOut(duration: 0.3)) {+ for i in 0..<self.barCount {+ let centerDistance = abs(CGFloat(i) - CGFloat(self.barCount - 1) / 2)+ let centerFactor = 1.0 - (centerDistance / CGFloat(self.barCount / 2)) * 0.35+ self.barHeights[i] = self.minHeight + (self.maxHeight - self.minHeight) * 0.5 * centerFactor+ }+ }+ }++ private func updateBars(level: CGFloat) {+ // Ensure array is properly sized before modifying+ guard self.barHeights.count >= self.barCount else { return }++ let normalizedLevel = min(max(level, 0), 1)+ let isActive = normalizedLevel > self.noiseThreshold // Use user's sensitivity setting++ withAnimation(.spring(response: 0.08, dampingFraction: 0.55)) {+ for i in 0..<self.barCount {+ let centerDistance = abs(CGFloat(i) - CGFloat(self.barCount - 1) / 2)+ let centerFactor = 1.0 - (centerDistance / CGFloat(self.barCount / 2)) * 0.3++ if isActive, self.noiseThreshold < 1.0 {+ // Amplify the level for more dramatic response+ // Safety check: ensure denominator is never zero+ let denominator = max(1.0 - self.noiseThreshold, 0.001)+ let adjustedLevel = max(min((normalizedLevel - self.noiseThreshold) / denominator, 1.0), 0.0)++ let amplifiedLevel = pow(adjustedLevel, 0.6) // More responsive to quieter sounds+ let randomVariation = CGFloat.random(in: 0.8...1.0)+ self.barHeights[i] = self.minHeight + (self.maxHeight - self.minHeight) * amplifiedLevel * centerFactor * randomVariation+ } else {+ self.barHeights[i] = self.minHeight+ }+ }+ }+ }+}diff --git a/Sources/Fluid/Views/NotchContentViews.swift b/Sources/Fluid/Views/NotchContentViews.swiftindex 827a316a..bf6291d1 100644--- a/Sources/Fluid/Views/NotchContentViews.swift+++ b/Sources/Fluid/Views/NotchContentViews.swift@@ -18,6 +18,9 @@ class NotchContentState: ObservableObject {@Published var mode: OverlayMode = .dictation@Published var isProcessing: Bool = false // AI processing state+ // Icon of the target app (where text will be typed)+ @Published var targetAppIcon: NSImage?+// Cached transcription lines to avoid recomputing on every render@Published private(set) var cachedLine1: String = ""@Published private(set) var cachedLine2: String = ""@@ -101,6 +104,10 @@ class NotchContentState: ObservableObject {@Published var isRecordingInExpandedMode: Bool = false@Published var expandedModeAudioLevel: CGFloat = 0 // Audio level for waveform in expanded mode+ // MARK: - Bottom Overlay Audio Level++ @Published var bottomOverlayAudioLevel: CGFloat = 0 // Audio level for bottom overlay waveform+/// Set recording state (for waveform visibility in expanded view)func setRecordingInExpandedMode(_ recording: Bool) {self.isRecordingInExpandedMode = recording@@ -258,6 +265,15 @@ struct NotchExpandedView: View {VStack(spacing: 4) {// Visualization + Mode label rowHStack(spacing: 6) {+ // Target app icon (the app where text will be typed)+ if let appIcon = self.contentState.targetAppIcon {+ Image(nsImage: appIcon)+ .resizable()+ .aspectRatio(contentMode: .fit)+ .frame(width: 16, height: 16)+ .clipShape(RoundedRectangle(cornerRadius: 3))+ }+NotchWaveformView(audioPublisher: self.audioPublisher,color: self.modeColor