Fastest and only macOS Dictation app with on-device STT and custom trained AI enhancement model. Windows, iOS testflight! Android, Linux waitlist open! A local Wispr Flow alternative. Follow https://x.com/fluidvoiceapp for more
feat(meeting): floating captions window, recording pill, live-engine rotation
Shreeraman A K901de34710ab
diff --git a/Sources/Fluid/Services/AppServices.swift b/Sources/Fluid/Services/AppServices.swiftindex b2c6189a..779120e1 100644--- a/Sources/Fluid/Services/AppServices.swift+++ b/Sources/Fluid/Services/AppServices.swift@@ -120,9 +120,10 @@ final class AppServices: ObservableObject {)self._meetingSessionCoordinator = coordinatorself.setupMeetingCoordinatorForwarding()- Task { @MainActor [weak coordinator] in- await coordinator?.ensureRestored()- await coordinator?.sweepExpiredAudio()+ Task { @MainActor in+ MeetingRecordingPillController.shared.activate(coordinator: coordinator)+ await coordinator.ensureRestored()+ await coordinator.sweepExpiredAudio()}return coordinator}diff --git a/Sources/Fluid/Services/Meeting/LiveTranscription/MeetingLiveModels.swift b/Sources/Fluid/Services/Meeting/LiveTranscription/MeetingLiveModels.swiftindex cfb337ab..23a79e60 100644--- a/Sources/Fluid/Services/Meeting/LiveTranscription/MeetingLiveModels.swift+++ b/Sources/Fluid/Services/Meeting/LiveTranscription/MeetingLiveModels.swift@@ -121,6 +121,7 @@ nonisolated enum MeetingLiveBubbleComposer {}return rows}+}nonisolated enum MeetingLiveTimeConversion {diff --git a/Sources/Fluid/Services/Meeting/LiveTranscription/MeetingLiveTrackEngine.swift b/Sources/Fluid/Services/Meeting/LiveTranscription/MeetingLiveTrackEngine.swiftindex 4c2f371c..1e6434d5 100644--- a/Sources/Fluid/Services/Meeting/LiveTranscription/MeetingLiveTrackEngine.swift+++ b/Sources/Fluid/Services/Meeting/LiveTranscription/MeetingLiveTrackEngine.swift@@ -25,6 +25,8 @@ actor MeetingLiveTrackEngine {/// A 24-slot queue held only ~0.25s and shed 5s of meeting-opening audio during warmup.nonisolated let queue = MeetingLiveBoundedQueue<MeetingLiveSampleCopy.Sample>(capacity: 512)private static let chunkSize: StreamingChunkSize = .ms160+ private static let maxOpenUtteranceSeconds: Double = 20+ private static let partialStallSeconds: Double = 2.5/// The recognizer buffers a full chunk before it can decode it, so the speech behind the first/// token started at least one chunk before the audio we were feeding when that token arrived.private static let decoderLookback = CMTime(value: CMTimeValue(chunkSize.durationMs), timescale: 1000)@@ -37,6 +39,8 @@ actor MeetingLiveTrackEngine {private var converterSourceFormat: AVAudioFormat?private var utteranceStartPTS: CMTime?private var utteranceTurnID: UUID?+ private var lastPartialText = ""+ private var lastPartialUptime: Double?private var lastConsumedPTS: CMTime?private var currentFeedPTS: CMTime?private var lastUtteranceEndPTS: CMTime?@@ -195,6 +199,7 @@ actor MeetingLiveTrackEngine {do {try await self.manager.appendAudio(converted)try await self.manager.processBufferedAudio()+ await self.rotateLongUtteranceIfNeeded()} catch {self.diag("appendAudio/process error: \(error)")self.onDegraded?(self.kind, "Live captions hit an error and resynced.")@@ -202,6 +207,38 @@ actor MeetingLiveTrackEngine {}}+ /// The decoder's own endpointing is unreliable in the field: it can stop emitting partials+ /// mid-utterance (observed after as little as 10s / ~120 chars) and never fire EOU, freezing+ /// captions on stale text. Two fallbacks close the turn: the decoder has gone quiet for a few+ /// seconds (a pause or a stall — either way the turn is over), or the utterance hit the hard+ /// duration ceiling. Both finalize the current partial and reset for a fresh turn.+ private func rotateLongUtteranceIfNeeded() async {+ guard let start = self.utteranceStartPTS,+ let end = self.lastConsumedPTS,+ let turnID = self.utteranceTurnID+ else { return }+ let openSeconds = end.seconds - start.seconds+ let quietSeconds = self.lastPartialUptime.map { ProcessInfo.processInfo.systemUptime - $0 }+ let hitCeiling = openSeconds > Self.maxOpenUtteranceSeconds+ let decoderQuiet = (quietSeconds ?? 0) > Self.partialStallSeconds && !self.lastPartialText.isEmpty+ guard hitCeiling || decoderQuiet else { return }+ let text = self.lastPartialText.trimmingCharacters(in: .whitespacesAndNewlines)+ self.utteranceStartPTS = nil+ self.utteranceTurnID = nil+ self.lastPartialText = ""+ self.lastPartialUptime = nil+ await self.manager.reset()+ guard !text.isEmpty else { return }+ self.lastUtteranceEndPTS = end+ self.diagUtterances += 1+ self.diag(String(+ format: "forced EOU (%@) span=[%.2f–%.2f] chars=%d",+ hitCeiling ? "open>\(Int(Self.maxOpenUtteranceSeconds))s" : String(format: "quiet %.1fs", quietSeconds ?? 0),+ start.seconds, end.seconds, text.count+ ))+ self.onUtterance?(self.kind, turnID, text, start, end)+ }+/// Once every 5s of wall clock: proves audio is still reaching the recognizer, and how long the/// current utterance has been open without an endpoint.private func logFlowIfDue() {@@ -233,6 +270,8 @@ actor MeetingLiveTrackEngine {self.utteranceTurnID = UUID()}guard let start = self.utteranceStartPTS, let turnID = self.utteranceTurnID else { return }+ self.lastPartialText = text+ self.lastPartialUptime = ProcessInfo.processInfo.systemUptimelet end = self.lastConsumedPTS ?? startself.diagPartials += 1if self.diagPartials % 10 == 1 {@@ -250,6 +289,8 @@ actor MeetingLiveTrackEngine {self.diagLastEouUptime = nowself.utteranceStartPTS = nilself.utteranceTurnID = nil+ self.lastPartialText = ""+ self.lastPartialUptime = nilawait self.manager.reset()let trimmed = text.trimmingCharacters(in: .whitespacesAndNewlines)guard !trimmed.isEmpty else { return }@@ -287,6 +328,8 @@ actor MeetingLiveTrackEngine {private func resetUtterance() async {self.utteranceStartPTS = nilself.utteranceTurnID = nil+ self.lastPartialText = ""+ self.lastPartialUptime = nilself.lastConsumedPTS = nilawait self.manager.reset()}diff --git a/Sources/Fluid/Services/Meeting/MeetingSessionCoordinator.swift b/Sources/Fluid/Services/Meeting/MeetingSessionCoordinator.swiftindex 9352b86f..e16bbe0b 100644--- a/Sources/Fluid/Services/Meeting/MeetingSessionCoordinator.swift+++ b/Sources/Fluid/Services/Meeting/MeetingSessionCoordinator.swift@@ -248,9 +248,14 @@ final class MeetingSessionCoordinator: ObservableObject {var captureStartAttempted = falselet liveTranscriptionCoordinator = MeetingLiveTranscriptionCoordinator { [weak self] snapshot in- Task { @MainActor [weak self] in- self?.liveTranscript = snapshot+ // Common-modes trampoline, not the main dispatch queue: the queue is starved while the+ // user drags a window (event-tracking mode), which froze live captions mid-drag.+ CFRunLoopPerformBlock(CFRunLoopGetMain(), CFRunLoopMode.commonModes.rawValue) {+ MainActor.assumeIsolated {+ self?.liveTranscript = snapshot+ }}+ CFRunLoopWakeUp(CFRunLoopGetMain())}self.liveTranscriptionCoordinator = liveTranscriptionCoordinatorself.liveTranscript = .emptydiff --git a/Sources/Fluid/UI/MeetingFloatingCaptionsPanel.swift b/Sources/Fluid/UI/MeetingFloatingCaptionsPanel.swiftnew file mode 100644index 00000000..68899eb8--- /dev/null+++ b/Sources/Fluid/UI/MeetingFloatingCaptionsPanel.swift@@ -0,0 +1,229 @@+import AppKit+import Combine+import SwiftUI++/// Borderless, non-activating panel that mirrors the live captions card while FluidVoice is buried+/// under a meeting app. `canBecomeKey` stays false and `title` stays unset so MenuBarManager's+/// main-window heuristics (level == .normal, styleMask.contains(.titled), canBecomeKey) never treat+/// it as the app's main window — see MenuBarManager.isFluidMainWindow.+final class MeetingFloatingCaptionsPanel: NSPanel {+ override var canBecomeKey: Bool { false }+}++/// Swallows first-mouse so clicks and drags work while FluidVoice is inactive — this panel's+/// normal state, since it exists precisely so captions stay visible while another app has focus.+final class MeetingFloatingHostingView: NSHostingView<AnyView> {+ override func acceptsFirstMouse(for event: NSEvent?) -> Bool { true }+}++enum MeetingFloatingPanelFactory {+ @MainActor+ static func make(size: NSSize, resizable: Bool, content: AnyView) -> MeetingFloatingCaptionsPanel {+ var styleMask: NSWindow.StyleMask = [.borderless, .nonactivatingPanel]+ if resizable { styleMask.insert(.resizable) }+ let panel = MeetingFloatingCaptionsPanel(+ contentRect: NSRect(origin: .zero, size: size),+ styleMask: styleMask,+ backing: .buffered,+ defer: false+ )+ panel.isFloatingPanel = true+ panel.level = .floating+ panel.collectionBehavior = [.canJoinAllSpaces, .fullScreenAuxiliary]+ // Default true would hide the panel the instant the user clicks into Zoom — these panels+ // exist precisely to stay visible while FluidVoice is not the active app.+ panel.hidesOnDeactivate = false+ panel.animationBehavior = .none+ panel.isOpaque = false+ panel.backgroundColor = .clear+ panel.hasShadow = false+ panel.isMovableByWindowBackground = true+ // Must never appear in the user's own screen share.+ panel.sharingType = .none++ let hostingView = MeetingFloatingHostingView(rootView: content)+ hostingView.wantsLayer = true+ hostingView.layer?.backgroundColor = .clear+ panel.contentView = hostingView+ return panel+ }+}++@MainActor+final class MeetingFloatingCaptionsController: ObservableObject {+ static let shared = MeetingFloatingCaptionsController()++ private static let panelSize = NSSize(width: 400, height: 480)+ private static let minimumSize = NSSize(width: 320, height: 240)+ private static let autosaveName = "MeetingFloatingCaptions"+ private static let defaultEdgeInset: CGFloat = 24++ private var panel: MeetingFloatingCaptionsPanel?+ private var stateSubscription: AnyCancellable?+ private var screenParametersObserver: NSObjectProtocol?++ private init() {}++ static func isVisible(for state: MeetingCoordinatorState) -> Bool {+ switch state {+ case .recording, .recordingDegraded:+ return true+ case .idle, .preparing, .stopping, .processing, .completed, .interrupted, .failed:+ return false+ }+ }++ func show() {+ let coordinator = AppServices.shared.meetingSessionCoordinator+ let panel = self.panelOrCreate(coordinator: coordinator)+ self.subscribeIfNeeded(coordinator: coordinator)++ let sourceFrame = MeetingRecordingPillController.shared.expandedPanelFrame+ let reduceMotion = NSWorkspace.shared.accessibilityDisplayShouldReduceMotion+ if let sourceFrame, !panel.isVisible, !reduceMotion {+ let targetFrame = panel.frame+ panel.setFrame(sourceFrame, display: false)+ panel.orderFrontRegardless()+ NSAnimationContext.runAnimationGroup { context in+ context.duration = 0.55+ context.timingFunction = CAMediaTimingFunction(controlPoints: 0.22, 1.0, 0.36, 1.0)+ panel.animator().setFrame(targetFrame, display: true)+ }+ } else {+ panel.orderFrontRegardless()+ }+ MeetingRecordingPillController.shared.collapse()+ }++ func hide() {+ self.panel?.orderOut(nil)+ }++ private func panelOrCreate(coordinator: MeetingSessionCoordinator) -> MeetingFloatingCaptionsPanel {+ if let panel { return panel }++ let content = AnyView(+ AdaptiveAppTheme(accent: SettingsStore.shared.accentColor) {+ MeetingFloatingCaptionsContent(coordinator: coordinator)+ }+ )+ let panel = MeetingFloatingPanelFactory.make(size: Self.panelSize, resizable: true, content: content)+ panel.minSize = Self.minimumSize++ panel.setFrameAutosaveName(Self.autosaveName)+ // setFrameAutosaveName alone does not restore a saved frame; it only enables saving on move.+ if !panel.setFrameUsingName(Self.autosaveName) {+ self.placeAtDefaultPosition(panel)+ }+ self.clampIntoVisibleFrame(panel)++ self.panel = panel+ self.installScreenParametersObserverIfNeeded()+ return panel+ }++ private func subscribeIfNeeded(coordinator: MeetingSessionCoordinator) {+ guard self.stateSubscription == nil else { return }+ self.stateSubscription = coordinator.$state+ .receive(on: DispatchQueue.main)+ .sink { [weak self] state in+ guard Self.isVisible(for: state) else {+ self?.hide()+ return+ }+ }+ }++ private func placeAtDefaultPosition(_ panel: NSPanel) {+ let screen = OverlayScreenResolver.screenForCurrentPointer() ?? NSScreen.main+ guard let screen else { return }+ let visible = screen.visibleFrame+ let origin = NSPoint(+ x: visible.maxX - Self.panelSize.width - Self.defaultEdgeInset,+ y: visible.midY - Self.panelSize.height / 2+ )+ panel.setFrame(NSRect(origin: origin, size: Self.panelSize), display: false)+ }++ private func clampIntoVisibleFrame(_ panel: NSPanel) {+ let visible = (panel.screen ?? NSScreen.main)?.visibleFrame+ guard let visible else { return }+ var frame = panel.frame+ frame.origin.x = min(max(frame.origin.x, visible.minX), visible.maxX - frame.width)+ frame.origin.y = min(max(frame.origin.y, visible.minY), visible.maxY - frame.height)+ panel.setFrame(frame, display: false)+ }++ private func installScreenParametersObserverIfNeeded() {+ guard self.screenParametersObserver == nil else { return }+ self.screenParametersObserver = NotificationCenter.default.addObserver(+ forName: NSApplication.didChangeScreenParametersNotification,+ object: nil,+ queue: .main+ ) { [weak self] _ in+ Task { @MainActor [weak self] in+ self?.repositionIfOffscreen()+ }+ }+ }++ private func repositionIfOffscreen() {+ guard let panel else { return }+ let stillOnScreen = NSScreen.screens.contains { $0.visibleFrame.intersects(panel.frame) }+ guard !stillOnScreen else { return }+ self.placeAtDefaultPosition(panel)+ self.clampIntoVisibleFrame(panel)+ }+}++struct MeetingFloatingCaptionsContent: View {+ @ObservedObject var coordinator: MeetingSessionCoordinator++ @Environment(\.theme) private var theme++ private var rows: [MeetingLiveBubbleComposer.Row] {+ MeetingLiveBubbleComposer.rows(for: self.coordinator.liveTranscript)+ }++ var body: some View {+ let rows = self.rows++ VStack(alignment: .leading, spacing: 8) {+ HStack {+ Text("Live captions")+ .font(self.theme.typography.captionStrong)+ .foregroundStyle(self.theme.palette.secondaryText)+ Spacer()+ Button {+ MeetingFloatingCaptionsController.shared.hide()+ } label: {+ Image(systemName: "xmark")+ .font(.system(size: 11, weight: .semibold))+ .foregroundStyle(self.theme.palette.secondaryText)+ }+ .buttonStyle(.plain)+ .accessibilityLabel("Close floating captions")+ }++ if rows.isEmpty {+ Text("Listening…")+ .font(self.theme.typography.bodySmall)+ .foregroundStyle(self.theme.palette.secondaryText)+ .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center)+ } else {+ MeetingLiveBubbleScrollList(rows: rows, hidesPartialFromAccessibility: false)+ }+ }+ .padding(14)+ .frame(minWidth: 320, maxWidth: .infinity, minHeight: 240, maxHeight: .infinity, alignment: .topLeading)+ .background(+ RoundedRectangle(cornerRadius: 16, style: .continuous)+ .fill(self.theme.palette.contentBackground.opacity(0.96))+ )+ .overlay(+ RoundedRectangle(cornerRadius: 16, style: .continuous)+ .stroke(self.theme.palette.separator.opacity(0.55), lineWidth: 1)+ )+ .shadow(color: .black.opacity(0.35), radius: 16, x: 0, y: 6)+ }+}diff --git a/Sources/Fluid/UI/MeetingLiveCaptionBubbles.swift b/Sources/Fluid/UI/MeetingLiveCaptionBubbles.swiftnew file mode 100644index 00000000..e2fa0f56--- /dev/null+++ b/Sources/Fluid/UI/MeetingLiveCaptionBubbles.swift@@ -0,0 +1,151 @@+import SwiftUI++/// Shared bubble look for final transcript and live captions; callers own alignment, labels, and insets.+struct MeetingBubbleStyle {+ var font: Font+ var lineSpacing: CGFloat+ var horizontalPadding: CGFloat+ var verticalPadding: CGFloat+ var cornerRadius: CGFloat+ var fill: Color+ var foreground: Color++ static func final(fill: Color, foreground: Color) -> MeetingBubbleStyle {+ MeetingBubbleStyle(+ font: .system(size: 15, design: .monospaced), lineSpacing: 5,+ horizontalPadding: 18, verticalPadding: 12, cornerRadius: 18,+ fill: fill, foreground: foreground+ )+ }+}++extension View {+ func meetingBubbleStyle(_ style: MeetingBubbleStyle) -> some View {+ self+ .font(style.font)+ .lineSpacing(style.lineSpacing)+ .foregroundStyle(style.foreground)+ .padding(.horizontal, style.horizontalPadding)+ .padding(.vertical, style.verticalPadding)+ .background(style.fill, in: RoundedRectangle(cornerRadius: style.cornerRadius, style: .continuous))+ }+}++/// Auto-follows the newest row only while the user is pinned to the bottom; scrolling up suspends+/// following and shows a jump-to-bottom button.+struct MeetingLiveBubbleScrollList: View {+ let rows: [MeetingLiveBubbleComposer.Row]+ var hidesPartialFromAccessibility = true++ @Environment(\.theme) private var theme+ @Environment(\.accessibilityReduceMotion) private var reduceMotion+ @State private var isPinnedToBottom = true++ private var trailingPartialLength: Int {+ guard let last = self.rows.last, last.isPartial else { return 0 }+ return last.text.count+ }++ var body: some View {+ let rowIDs = self.rows.map(\.id)+ ScrollViewReader { proxy in+ ZStack(alignment: .bottomTrailing) {+ ScrollView {+ VStack(alignment: .leading, spacing: self.theme.metrics.spacing.sm) {+ ForEach(self.rows) { row in+ MeetingLiveBubbleRow(row: row, hidesPartialFromAccessibility: self.hidesPartialFromAccessibility)+ .equatable()+ .id(row.id)+ .transition(.opacity)+ }+ }+ }+ .animation(self.reduceMotion ? nil : .easeInOut(duration: 0.2), value: rowIDs)+ // Wide threshold so a growing partial (one wrapped line ≈ 20pt) can't out-race the+ // follow-up scrollTo and read as the user scrolling away; only a deliberate+ // scroll-up (> 80pt) disengages following.+ .onScrollGeometryChange(for: Bool.self) { geometry in+ let bottomOffset = geometry.contentSize.height - geometry.containerSize.height+ return geometry.contentOffset.y >= bottomOffset - 80+ } action: { _, isPinned in+ self.isPinnedToBottom = isPinned+ }+ .onChange(of: self.rows.count) {+ self.scrollToBottomIfPinned(proxy: proxy)+ }+ .onChange(of: self.trailingPartialLength) {+ self.scrollToBottomIfPinned(proxy: proxy)+ }++ if !self.isPinnedToBottom {+ Button {+ self.isPinnedToBottom = true+ self.scrollToBottom(proxy: proxy, animated: true)+ } label: {+ Image(systemName: "chevron.down")+ .font(.system(size: 12, weight: .semibold))+ .foregroundStyle(self.theme.palette.primaryText)+ .frame(width: 28, height: 28)+ .background(self.theme.palette.contentBackground, in: Circle())+ }+ .buttonStyle(.plain)+ .padding(6)+ }+ }+ }+ }++ private func scrollToBottomIfPinned(proxy: ScrollViewProxy) {+ guard self.isPinnedToBottom else { return }+ self.scrollToBottom(proxy: proxy, animated: false)+ }++ private func scrollToBottom(proxy: ScrollViewProxy, animated: Bool) {+ guard let lastID = self.rows.last?.id else { return }+ guard animated, !self.reduceMotion else {+ proxy.scrollTo(lastID, anchor: .bottom)+ return+ }+ withAnimation(.easeInOut(duration: 0.2)) {+ proxy.scrollTo(lastID, anchor: .bottom)+ }+ }+}++struct MeetingLiveBubbleRow: View, Equatable {+ let row: MeetingLiveBubbleComposer.Row+ var hidesPartialFromAccessibility: Bool = true++ @Environment(\.theme) private var theme++ static func == (lhs: MeetingLiveBubbleRow, rhs: MeetingLiveBubbleRow) -> Bool {+ lhs.row == rhs.row && lhs.hidesPartialFromAccessibility == rhs.hidesPartialFromAccessibility+ }++ private var isYou: Bool { self.row.speaker == .you }++ /// Same washes as the final transcript: accent for You, the first speaker-palette pastel for Them.+ private var fill: Color {+ let base = self.isYou ? self.theme.palette.accent : MeetingSpeakerPalette.tint(forSpeakerIndex: 0)+ return base.opacity(self.row.isPartial ? 0.05 : 0.10)+ }++ var body: some View {+ VStack(alignment: self.isYou ? .trailing : .leading, spacing: 4) {+ if self.row.showsLabel {+ Text(self.isYou ? "You" : "Them")+ .font(self.theme.typography.captionStrong)+ .foregroundStyle(self.isYou ? self.theme.palette.accent : self.theme.palette.secondaryText)+ }+ Text(self.row.text)+ // The partial→final color swap solidifies in place; it must never animate.+ .transaction { $0.animation = nil }+ .meetingBubbleStyle(.final(fill: self.fill, foreground: self.row.isPartial ? self.theme.palette.secondaryText : self.theme.palette.primaryText))+ }+ .frame(maxWidth: .infinity, alignment: self.isYou ? .trailing : .leading)+ .padding(self.isYou ? .leading : .trailing, 32)+ .accessibilityElement(children: .combine)+ .accessibilityLabel("\(self.isYou ? "You" : "Them"), \(self.row.text)")+ .accessibilityHidden(self.hidesPartialFromAccessibility && self.row.isPartial)+ }+}diff --git a/Sources/Fluid/UI/MeetingRecordingPill.swift b/Sources/Fluid/UI/MeetingRecordingPill.swiftnew file mode 100644index 00000000..b11ae82d--- /dev/null+++ b/Sources/Fluid/UI/MeetingRecordingPill.swift@@ -0,0 +1,349 @@+import AppKit+import Combine+import SwiftUI++/// Small always-on-top pill shown automatically while a meeting is recording: live mic level and a+/// stop button, visible even when FluidVoice is buried under the meeting app.+@MainActor+final class MeetingRecordingPillController: ObservableObject {+ static let shared = MeetingRecordingPillController()++ @Published private(set) var isExpanded = false++ private static let pillSize = NSSize(width: 84, height: 32)+ private static let subtitleSize = NSSize(width: 480, height: 132)+ private static let autosaveName = "MeetingRecordingPill"+ private static let defaultBottomInset: CGFloat = 64++ private var panel: MeetingFloatingCaptionsPanel?+ private var stateSubscription: AnyCancellable?+ private var screenParametersObserver: NSObjectProtocol?++ private init() {}++ func activate(coordinator: MeetingSessionCoordinator) {+ guard self.stateSubscription == nil else { return }+ self.stateSubscription = coordinator.$state+ .receive(on: DispatchQueue.main)+ .sink { [weak self, weak coordinator] state in+ guard let self, let coordinator else { return }+ if MeetingFloatingCaptionsController.isVisible(for: state) {+ self.show(coordinator: coordinator)+ } else {+ self.setExpanded(false)+ self.panel?.orderOut(nil)+ }+ }+ }++ private func show(coordinator: MeetingSessionCoordinator) {+ let panel = self.panelOrCreate(coordinator: coordinator)+ panel.orderFrontRegardless()+ }++ func toggleExpanded() {+ self.setExpanded(!self.isExpanded)+ }++ /// Collapses back to the smallest pill — also called when the full captions window opens.+ func collapse() {+ self.setExpanded(false)+ }++ /// Where the subtitle strip currently sits, if expanded — the captions window slides out from here.+ var expandedPanelFrame: NSRect? {+ guard self.isExpanded, let panel, panel.isVisible else { return nil }+ return panel.frame+ }++ private func setExpanded(_ expanded: Bool) {+ guard self.isExpanded != expanded, let panel else {+ self.isExpanded = expanded+ return+ }+ self.isExpanded = expanded+ let size = expanded ? Self.subtitleSize : Self.pillSize+ var frame = panel.frame+ let centerX = frame.midX+ frame.origin.x = centerX - size.width / 2+ frame.size = size++ let reduceMotion = NSWorkspace.shared.accessibilityDisplayShouldReduceMotion+ guard panel.isVisible, !reduceMotion else {+ panel.setFrame(frame, display: true)+ self.clampIntoVisibleFrame(panel)+ return+ }+ NSAnimationContext.runAnimationGroup { context in+ context.duration = 0.55+ context.timingFunction = CAMediaTimingFunction(controlPoints: 0.22, 1.0, 0.36, 1.0)+ panel.animator().setFrame(frame, display: true)+ } completionHandler: { [weak self] in+ Task { @MainActor [weak self] in+ guard let self, let panel = self.panel else { return }+ self.clampIntoVisibleFrame(panel)+ }+ }+ }++ private func panelOrCreate(coordinator: MeetingSessionCoordinator) -> MeetingFloatingCaptionsPanel {+ if let panel { return panel }++ let content = AnyView(+ AdaptiveAppTheme(accent: SettingsStore.shared.accentColor) {+ MeetingRecordingPillContent(coordinator: coordinator)+ }+ )+ let panel = MeetingFloatingPanelFactory.make(size: Self.pillSize, resizable: false, content: content)++ panel.setFrameAutosaveName(Self.autosaveName)+ if panel.setFrameUsingName(Self.autosaveName) {+ // Only the position is user-controlled; the size must track the current design.+ var frame = panel.frame+ frame.size = Self.pillSize+ panel.setFrame(frame, display: false)+ } else {+ self.placeAtDefaultPosition(panel)+ }+ self.clampIntoVisibleFrame(panel)++ self.panel = panel+ self.installScreenParametersObserverIfNeeded()+ return panel+ }++ private func placeAtDefaultPosition(_ panel: NSPanel) {+ let screen = OverlayScreenResolver.screenForCurrentPointer() ?? NSScreen.main+ guard let screen else { return }+ let visible = screen.visibleFrame+ let origin = NSPoint(+ x: visible.midX - Self.pillSize.width / 2,+ y: visible.minY + Self.defaultBottomInset+ )+ panel.setFrame(NSRect(origin: origin, size: Self.pillSize), display: false)+ }++ private func clampIntoVisibleFrame(_ panel: NSPanel) {+ let visible = (panel.screen ?? NSScreen.main)?.visibleFrame+ guard let visible else { return }+ var frame = panel.frame+ frame.origin.x = min(max(frame.origin.x, visible.minX), visible.maxX - frame.width)+ frame.origin.y = min(max(frame.origin.y, visible.minY), visible.maxY - frame.height)+ panel.setFrame(frame, display: false)+ }++ private func installScreenParametersObserverIfNeeded() {+ guard self.screenParametersObserver == nil else { return }+ self.screenParametersObserver = NotificationCenter.default.addObserver(+ forName: NSApplication.didChangeScreenParametersNotification,+ object: nil,+ queue: .main+ ) { [weak self] _ in+ Task { @MainActor [weak self] in+ self?.repositionIfOffscreen()+ }+ }+ }++ private func repositionIfOffscreen() {+ guard let panel else { return }+ let stillOnScreen = NSScreen.screens.contains { $0.visibleFrame.intersects(panel.frame) }+ guard !stillOnScreen else { return }+ self.placeAtDefaultPosition(panel)+ self.clampIntoVisibleFrame(panel)+ }+}++struct MeetingRecordingPillContent: View {+ @ObservedObject var coordinator: MeetingSessionCoordinator++ @Environment(\.theme) private var theme+ @Environment(\.accessibilityReduceMotion) private var reduceMotion+ @State private var isStopping = false++ private var microphoneLevel: Float {+ self.coordinator.trackHealth[.microphone]?.level ?? 0+ }++ private var isRecordingActive: Bool {+ MeetingFloatingCaptionsController.isVisible(for: self.coordinator.state)+ }++ @ObservedObject private var pill = MeetingRecordingPillController.shared+ @Namespace private var morph++ private var morphAnimation: Animation? {+ self.reduceMotion ? nil : .spring(response: 0.55, dampingFraction: 0.88)+ }++ var body: some View {+ Group {+ if self.pill.isExpanded {+ self.subtitleStrip+ } else {+ self.compactPill+ }+ }+ // The panel and its view persist across meetings; re-arm the stop button per recording.+ .onChange(of: self.isRecordingActive) { _, active in+ if active { self.isStopping = false }+ }+ .animation(self.morphAnimation, value: self.pill.isExpanded)+ .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .bottom)+ .accessibilityElement(children: .contain)+ .accessibilityLabel("Meeting recording in progress")+ }++ private var morphSurface: some View {+ RoundedRectangle(cornerRadius: 16, style: .continuous)+ .fill(self.theme.palette.contentBackground.opacity(0.96))+ .overlay(+ RoundedRectangle(cornerRadius: 16, style: .continuous)+ .stroke(self.theme.palette.accent.opacity(0.7), lineWidth: 1.2)+ )+ .shadow(color: .black.opacity(0.3), radius: 11, x: 0, y: 4)+ .matchedGeometryEffect(id: "surface", in: self.morph)+ }++ private var compactPill: some View {+ HStack(spacing: 7) {+ MeetingRecordingLevelBars(level: self.microphoneLevel, animated: !self.reduceMotion)+ .frame(width: 20, height: 11)+ .matchedGeometryEffect(id: "wave", in: self.morph)++ self.stopButton+ .matchedGeometryEffect(id: "stop", in: self.morph)+ }+ .padding(.horizontal, 9)+ .padding(.vertical, 5)+ .contentShape(Capsule())+ // The whole capsule expands; only the stop button opts out (inner Button wins its hits).+ .onTapGesture { self.pill.toggleExpanded() }+ .background(self.morphSurface)+ .accessibilityAddTraits(.isButton)+ .accessibilityLabel("Show live captions")+ }++ @State private var isHoveringStrip = false++ private var subtitleStrip: some View {+ let rows = MeetingLiveBubbleComposer.rows(for: self.coordinator.liveTranscript)+ return Group {+ if rows.isEmpty {+ Text("Listening…")+ .font(.system(size: 13, design: .monospaced))+ .foregroundStyle(self.theme.palette.secondaryText)+ .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center)+ } else {+ Text(self.rollingSubtitle(rows: rows))+ .font(.system(size: 14, design: .monospaced))+ .lineSpacing(4)+ .foregroundStyle(self.theme.palette.primaryText)+ // fixedSize is load-bearing — a height-constrained Text truncates its END,+ // freezing the display on the oldest words instead of clipping the top.+ .fixedSize(horizontal: false, vertical: true)+ .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .bottomLeading)+ .clipped()+ }+ }+ .transition(.opacity)+ .padding(.horizontal, 16)+ .padding(.vertical, 12)+ .background(self.morphSurface)+ // Pure text island; controls surface only on hover so it reads as subtitles, not a widget.+ .overlay(alignment: .topTrailing) {+ if self.isHoveringStrip {+ HStack(spacing: 8) {+ MeetingRecordingLevelBars(level: self.microphoneLevel, animated: !self.reduceMotion)+ .frame(width: 18, height: 10)+ Button {+ MeetingFloatingCaptionsController.shared.show()+ } label: {+ Image(systemName: "rectangle.portrait.and.arrow.right")+ .font(.system(size: 10, weight: .semibold))+ .foregroundStyle(self.theme.palette.secondaryText)+ }+ .buttonStyle(.plain)+ .accessibilityLabel("Open captions window")+ Button {+ self.pill.collapse()+ } label: {+ Image(systemName: "chevron.down")+ .font(.system(size: 10, weight: .semibold))+ .foregroundStyle(self.theme.palette.secondaryText)+ }+ .buttonStyle(.plain)+ .accessibilityLabel("Collapse captions")+ self.stopButton+ }+ .padding(.horizontal, 8)+ .padding(.vertical, 4)+ .background(Capsule().fill(self.theme.palette.contentBackground.opacity(0.92)))+ .padding(6)+ .transition(.opacity)+ }+ }+ .onHover { hovering in+ withAnimation(.easeInOut(duration: 0.15)) { self.isHoveringStrip = hovering }+ }+ }++ /// One rolling word stream across all turns — no bubbles, no speaker structure, just the last+ /// words spoken. Oldest words fall off the front; "—" marks a speaker change, subtitle-style.+ private func rollingSubtitle(rows: [MeetingLiveBubbleComposer.Row], maxWords: Int = 42) -> String {+ var words: [String] = []+ var previousSpeaker: MeetingLiveSpeaker?+ for row in rows.suffix(8) {+ if previousSpeaker != nil, row.speaker != previousSpeaker {+ words.append("—")+ }+ previousSpeaker = row.speaker+ words.append(contentsOf: row.text.split(separator: " ").map(String.init))+ }+ return words.suffix(maxWords).joined(separator: " ")+ }++ private var stopButton: some View {+ Button {+ guard !self.isStopping else { return }+ self.isStopping = true+ let coordinator = self.coordinator+ Task {+ _ = try? await coordinator.stopAndTranscribe()+ }+ } label: {+ Image(systemName: "stop.fill")+ .font(.system(size: 8, weight: .bold))+ .foregroundStyle(self.theme.palette.primaryText)+ .frame(width: 18, height: 18)+ .background(self.theme.palette.contentBackground, in: Circle())+ .overlay(Circle().stroke(self.theme.palette.separator.opacity(0.5), lineWidth: 1))+ }+ .buttonStyle(.plain)+ .disabled(self.isStopping || !self.isRecordingActive)+ .accessibilityLabel("Stop meeting recording and transcribe")+ }+}++/// Five bars scaled by the published mic level; center-weighted so it reads as a waveform.+private struct MeetingRecordingLevelBars: View {+ let level: Float+ let animated: Bool++ @Environment(\.theme) private var theme++ private static let weights: [CGFloat] = [0.45, 0.75, 1.0, 0.75, 0.45]++ var body: some View {+ HStack(alignment: .center, spacing: 2.5) {+ ForEach(Array(Self.weights.enumerated()), id: \.offset) { _, weight in+ Capsule()+ .fill(self.theme.palette.accent)+ .frame(width: 2, height: max(2.5, CGFloat(self.level) * 11 * weight))+ }+ }+ .frame(maxHeight: .infinity, alignment: .center)+ .animation(self.animated ? .easeOut(duration: 0.12) : nil, value: self.level)+ .accessibilityHidden(true)+ }+}diff --git a/Sources/Fluid/UI/MeetingTranscriptionView.swift b/Sources/Fluid/UI/MeetingTranscriptionView.swiftindex 7914a5f5..ba3b78ed 100644--- a/Sources/Fluid/UI/MeetingTranscriptionView.swift+++ b/Sources/Fluid/UI/MeetingTranscriptionView.swift@@ -2311,8 +2311,6 @@ private struct MeetingLiveTranscriptCard: View {let snapshot: MeetingLiveTranscriptSnapshot@Environment(\.theme) private var theme- @Environment(\.accessibilityReduceMotion) private var reduceMotion- @State private var isPinnedToBottom = truevar body: some View {ThemedCard(style: .subtle) {@@ -2328,6 +2326,15 @@ private struct MeetingLiveTranscriptCard: View {.foregroundStyle(self.theme.palette.secondaryText).labelStyle(.titleAndIcon)}+ Button {+ MeetingFloatingCaptionsController.shared.show()+ } label: {+ Image(systemName: "rectangle.portrait.and.arrow.right")+ .font(.system(size: 12, weight: .semibold))+ .foregroundStyle(self.theme.palette.secondaryText)+ }+ .buttonStyle(.plain)+ .accessibilityLabel("Open floating captions")}if self.rows.isEmpty {@@ -2347,11 +2354,6 @@ private struct MeetingLiveTranscriptCard: View {MeetingLiveBubbleComposer.rows(for: self.snapshot)}- private var trailingPartialLength: Int {- guard let last = self.rows.last, last.isPartial else { return 0 }- return last.text.count- }-private var availabilityIndicator: String? {switch self.snapshot.availability {case .available:@@ -2362,104 +2364,8 @@ private struct MeetingLiveTranscriptCard: View {}private var scrollingBubbleList: some View {- let rows = self.rows- let rowIDs = rows.map(\.id)- return ScrollViewReader { proxy in- ZStack(alignment: .bottomTrailing) {- ScrollView {- VStack(alignment: .leading, spacing: self.theme.metrics.spacing.sm) {- ForEach(rows) { row in- MeetingLiveBubbleRow(row: row)- .equatable()- .id(row.id)- .transition(.opacity)- }- }- }- .animation(self.reduceMotion ? nil : .easeInOut(duration: 0.2), value: rowIDs)- .onScrollGeometryChange(for: Bool.self) { geometry in- let bottomOffset = geometry.contentSize.height - geometry.containerSize.height- return geometry.contentOffset.y >= bottomOffset - 24- } action: { _, isPinned in- self.isPinnedToBottom = isPinned- }- .onChange(of: rows.count) {- self.scrollToBottomIfPinned(proxy: proxy)- }- .onChange(of: self.trailingPartialLength) {- self.scrollToBottomIfPinned(proxy: proxy)- }-- if !self.isPinnedToBottom {- Button {- self.isPinnedToBottom = true- self.scrollToBottom(proxy: proxy, animated: true)- } label: {- Image(systemName: "chevron.down")- .font(.system(size: 12, weight: .semibold))- .foregroundStyle(self.theme.palette.primaryText)- .frame(width: 28, height: 28)- .background(self.theme.palette.contentBackground, in: Circle())- }- .buttonStyle(.plain)- .padding(6)- }- }- }- .frame(minHeight: 120, maxHeight: .infinity)- }-- private func scrollToBottomIfPinned(proxy: ScrollViewProxy) {- guard self.isPinnedToBottom else { return }- self.scrollToBottom(proxy: proxy, animated: false)- }-- private func scrollToBottom(proxy: ScrollViewProxy, animated: Bool) {- guard let lastID = self.rows.last?.id else { return }- guard animated, !self.reduceMotion else {- proxy.scrollTo(lastID, anchor: .bottom)- return- }- withAnimation(.easeInOut(duration: 0.2)) {- proxy.scrollTo(lastID, anchor: .bottom)- }- }-}--private struct MeetingLiveBubbleRow: View, Equatable {- let row: MeetingLiveBubbleComposer.Row-- @Environment(\.theme) private var theme-- static func == (lhs: MeetingLiveBubbleRow, rhs: MeetingLiveBubbleRow) -> Bool {- lhs.row == rhs.row- }-- private var isYou: Bool { self.row.speaker == .you }-- /// Same washes as the final transcript: accent for You, the first speaker-palette pastel for Them.- private var fill: Color {- let base = self.isYou ? self.theme.palette.accent : MeetingSpeakerPalette.tint(forSpeakerIndex: 0)- return base.opacity(self.row.isPartial ? 0.05 : 0.10)- }-- var body: some View {- VStack(alignment: self.isYou ? .trailing : .leading, spacing: 4) {- if self.row.showsLabel {- Text(self.isYou ? "You" : "Them")- .font(self.theme.typography.captionStrong)- .foregroundStyle(self.isYou ? self.theme.palette.accent : self.theme.palette.secondaryText)- }- Text(self.row.text)- // The partial→final color swap solidifies in place; it must never animate.- .transaction { $0.animation = nil }- .meetingBubbleStyle(.final(fill: self.fill, foreground: self.row.isPartial ? self.theme.palette.secondaryText : self.theme.palette.primaryText))- }- .frame(maxWidth: .infinity, alignment: self.isYou ? .trailing : .leading)- .padding(self.isYou ? .leading : .trailing, 32)- .accessibilityElement(children: .combine)- .accessibilityLabel("\(self.isYou ? "You" : "Them"), \(self.row.text)")- .accessibilityHidden(self.row.isPartial)+ MeetingLiveBubbleScrollList(rows: self.rows)+ .frame(minHeight: 120, maxHeight: .infinity)}}@@ -3241,37 +3147,4 @@ private struct MeetingTranscriptSegmentRow: View {.frame(maxWidth: .infinity, alignment: .leading).padding(.trailing, 48)}--}--/// Shared bubble look for final transcript and live captions; callers own alignment, labels, and insets.-fileprivate struct MeetingBubbleStyle {- var font: Font- var lineSpacing: CGFloat- var horizontalPadding: CGFloat- var verticalPadding: CGFloat- var cornerRadius: CGFloat- var fill: Color- var foreground: Color-- static func final(fill: Color, foreground: Color) -> MeetingBubbleStyle {- MeetingBubbleStyle(- font: .system(size: 15, design: .monospaced), lineSpacing: 5,- horizontalPadding: 18, verticalPadding: 12, cornerRadius: 18,- fill: fill, foreground: foreground- )- }--}--extension View {- fileprivate func meetingBubbleStyle(_ style: MeetingBubbleStyle) -> some View {- self- .font(style.font)- .lineSpacing(style.lineSpacing)- .foregroundStyle(style.foreground)- .padding(.horizontal, style.horizontalPadding)- .padding(.vertical, style.verticalPadding)- .background(style.fill, in: RoundedRectangle(cornerRadius: style.cornerRadius, style: .continuous))- }}diff --git a/Tests/FluidDictationIntegrationTests/MeetingLiveTranscriptionTests.swift b/Tests/FluidDictationIntegrationTests/MeetingLiveTranscriptionTests.swiftindex dbe9fc23..f111a1b6 100644--- a/Tests/FluidDictationIntegrationTests/MeetingLiveTranscriptionTests.swift+++ b/Tests/FluidDictationIntegrationTests/MeetingLiveTranscriptionTests.swift@@ -300,3 +300,21 @@ final class MeetingLiveProvisionalContainmentTests: XCTestCase {XCTAssertFalse(liveSnapshot.utterances.isEmpty, "sanity: the live snapshot really did hold provisional content")}}++@MainActor+final class MeetingFloatingCaptionsControllerVisibilityTests: XCTestCase {+ func testVisibleOnlyForRecordingAndRecordingDegraded() {+ let id = MeetingSessionID()+ XCTAssertFalse(MeetingFloatingCaptionsController.isVisible(for: .idle))+ XCTAssertFalse(MeetingFloatingCaptionsController.isVisible(for: .preparing(id)))+ XCTAssertTrue(MeetingFloatingCaptionsController.isVisible(for: .recording(id)))+ XCTAssertTrue(MeetingFloatingCaptionsController.isVisible(for: .recordingDegraded(id)))+ XCTAssertFalse(MeetingFloatingCaptionsController.isVisible(for: .stopping(id)))+ XCTAssertFalse(MeetingFloatingCaptionsController.isVisible(for: .processing(id, .saving)))+ XCTAssertFalse(MeetingFloatingCaptionsController.isVisible(for: .completed(id)))+ XCTAssertFalse(MeetingFloatingCaptionsController.isVisible(for: .interrupted(id)))+ XCTAssertFalse(MeetingFloatingCaptionsController.isVisible(for: .failed(id, MeetingSessionFailure(+ id: UUID(), occurredAt: Date(), domain: .capture, code: "test", message: "test failure", recoverable: true+ ))))+ }+}