A tiny friend in your Mac's notch and on your iPhone that keeps an eye on your AI coding agents: Claude Code, Codex, Cursor, Gemini CLI, Antigravity and more. Approve from the notch or your Lock Screen.
Swift ai-agentsanthropicantigravityclaudeclaude-codecodexcursordynamic-islandgemini-cliiosiphonlinuxmacosmacos-appmenubar-appnotchopen-sourceswiftswiftuiwindows
Notetaker: review fixes
Claude470de9757c76
diff --git a/NotchBuddy/Sources/App/AppDelegate.swift b/NotchBuddy/Sources/App/AppDelegate.swiftindex b08accf3..1d61217d 100644--- a/NotchBuddy/Sources/App/AppDelegate.swift+++ b/NotchBuddy/Sources/App/AppDelegate.swift@@ -8,6 +8,9 @@ final class AppDelegate: NSObject, NSApplicationDelegate {private var demoMenuItem: NSMenuItem?func applicationWillTerminate(_ notification: Notification) {+ #if !APPSTORE+ NoteTaker.shared.shutdown()+ #endifDemoEngine.shared.stop()HotKeyCenter.shared.unregisterAll()}diff --git a/NotchBuddy/Sources/App/FlowPill.swift b/NotchBuddy/Sources/App/FlowPill.swiftindex 83acf317..35b825f3 100644--- a/NotchBuddy/Sources/App/FlowPill.swift+++ b/NotchBuddy/Sources/App/FlowPill.swift@@ -90,7 +90,7 @@ struct FlowPillView: View {case .copied: return Self.messageWidth(String(localized: "flow.copied-noaccess"))case .failed: return Self.messageWidth(String(localized: "flow.failed"))case .pastedAgain: return Self.messageWidth(String(localized: "flow.pasted-again"))- case .idle: return 150+ case .idle: return 172default: return 118}}@@ -155,7 +155,8 @@ struct FlowPillView: View {/// Mochi, drawn by the same engine as the compact island's mini Mochis: his eyes wander all/// around while you speak. 22 pt wide like a pill's Mochi (the canvas is larger, as there).private var mochi: some View {- FlowMochiView(active: open)+ // Still while only a recorded call shows: the pill costs nothing during a long call.+ FlowMochiView(active: model.phase != .idle).frame(width: 22 / 0.6, height: 22 / 0.6).frame(width: 22, height: 22, alignment: .center)}@@ -262,15 +263,41 @@ final class FlowPillController {if start != nil {if panel == nil { build() }guard let panel else { return }- panel.ignoresMouseEvents = falseif !panel.isVisible { place(panel, onMouseScreen: false) }panel.orderFrontRegardless()+ watchMouse()} else {+ mouseMonitors.forEach { NSEvent.removeMonitor($0) }+ mouseMonitors.removeAll()panel?.ignoresMouseEvents = trueif !dictationOn { panel?.orderOut(nil) }}}+ /// The panel is wider than the pill: it takes clicks only while the mouse is over the pill, so+ /// the stop button works and everything around it stays clickable.+ private var mouseMonitors: [Any] = []++ private func watchMouse() {+ guard mouseMonitors.isEmpty else { return }+ if let global = NSEvent.addGlobalMonitorForEvents(matching: [.mouseMoved, .leftMouseDragged], handler: { [weak self] _ in+ MainActor.assumeIsolated { self?.updateMouse() }+ }) { mouseMonitors.append(global) }+ if let local = NSEvent.addLocalMonitorForEvents(matching: [.mouseMoved, .leftMouseDragged], handler: { [weak self] event in+ MainActor.assumeIsolated { self?.updateMouse() }+ return event+ }) { mouseMonitors.append(local) }+ updateMouse()+ }++ private func updateMouse() {+ guard let panel, model.noteStartedAt != nil else { return }+ let width: CGFloat = 190, height: CGFloat = 44+ let pill = NSRect(x: panel.frame.midX - width / 2, y: panel.frame.minY, width: width, height: height)+ let over = NSMouseInRect(NSEvent.mouseLocation, pill, false)+ if panel.ignoresMouseEvents == over { panel.ignoresMouseEvents = !over }+ }+/// Flow dictation on: the resting pill shows. Off: it goes away.func setEnabled(_ on: Bool) {restTask?.cancel()diff --git a/NotchBuddy/Sources/App/NoteAudio.swift b/NotchBuddy/Sources/App/NoteAudio.swiftindex 513481a5..0565ab71 100644--- a/NotchBuddy/Sources/App/NoteAudio.swift+++ b/NotchBuddy/Sources/App/NoteAudio.swift@@ -79,6 +79,11 @@ final class ChannelRecorder: @unchecked Sendable {}}+ /// Closes the file at once, waiting for what is queued (when Coucou quits).+ func closeNow() {+ queue.sync { file = nil }+ }+/// Closes the file once everything queued is written.func close() async {await withCheckedContinuation { (continuation: CheckedContinuation<Void, Never>) in@@ -142,6 +147,8 @@ final class SystemAudioTap: @unchecked Sendable {private var tapID = AudioObjectID(kAudioObjectUnknown)private var aggregateID = AudioObjectID(kAudioObjectUnknown)private var procID: AudioDeviceIOProcID?+ /// The tap's own buffers, when the aggregate also brings the output device's inputs (a headset's mic).+ private var tapList: UnsafeMutableAudioBufferListPointer?private let queue = DispatchQueue(label: "fr.louisraille.NotchBuddy.notetaker.system", qos: .userInitiated)func start(sink: @escaping @Sendable ([Float]) -> Void) throws {@@ -188,9 +195,20 @@ final class SystemAudioTap: @unchecked Sendable {}aggregateID = device+ // The aggregate's input is the output device's own inputs (a headset's microphone), if it has+ // any, then the tap: the tap's buffers are the last ones.+ let tapBuffers = format.isInterleaved ? 1 : Int(format.channelCount)+ let scratch = AudioBufferList.allocate(maximumBuffers: tapBuffers)+ tapList = scratchvar proc: AudioDeviceIOProcID?status = AudioDeviceCreateIOProcIDWithBlock(&proc, device, queue) { _, input, _, _, _ in- guard let buffer = AVAudioPCMBuffer(pcmFormat: format, bufferListNoCopy: input, deallocator: nil) else { return }+ let all = UnsafeMutableAudioBufferListPointer(UnsafeMutablePointer(mutating: input))+ var list = input+ if all.count > tapBuffers {+ for i in 0..<tapBuffers { scratch[i] = all[all.count - tapBuffers + i] }+ list = UnsafePointer(scratch.unsafePointer)+ }+ guard let buffer = AVAudioPCMBuffer(pcmFormat: format, bufferListNoCopy: list, deallocator: nil) else { return }sink(resampler.convert(buffer))}guard status == noErr, let proc else {@@ -215,6 +233,8 @@ final class SystemAudioTap: @unchecked Sendable {}if tapID != AudioObjectID(kAudioObjectUnknown) { AudioHardwareDestroyProcessTap(tapID) }procID = nil+ if let tapList { free(tapList.unsafeMutablePointer) }+ tapList = nilaggregateID = AudioObjectID(kAudioObjectUnknown)tapID = AudioObjectID(kAudioObjectUnknown)}diff --git a/NotchBuddy/Sources/App/NoteTaker.swift b/NotchBuddy/Sources/App/NoteTaker.swiftindex 6744515f..e0859bd2 100644--- a/NotchBuddy/Sources/App/NoteTaker.swift+++ b/NotchBuddy/Sources/App/NoteTaker.swift@@ -57,6 +57,11 @@ final class NoteTaker: ObservableObject {private var micChannel: ChannelRecorder?private var systemChannel: ChannelRecorder?private var liveTask: Task<Void, Never>?+ /// Between the click and the microphone's permission: a second click starts nothing.+ private var starting = false+ /// The last app in front other than Coucou: the call app when you click Record in Coucou Flow.+ private var lastApp: String?+ private var appObserver: NSObjectProtocol?static var folder: URL { HookServer.supportDir.appendingPathComponent("Notes", isDirectory: true) }@@ -67,6 +72,14 @@ final class NoteTaker: ObservableObject {summaryEngine = FlowCleanup.hasKey ? .claude : (Self.appleModelAvailable ? .apple : .off)}load()+ appObserver = NSWorkspace.shared.notificationCenter.addObserver(+ forName: NSWorkspace.didActivateApplicationNotification, object: nil, queue: .main+ ) { note in+ guard let app = note.userInfo?[NSWorkspace.applicationUserInfoKey] as? NSRunningApplication,+ app.bundleIdentifier != Bundle.main.bundleIdentifier else { return }+ let name = app.localizedName+ MainActor.assumeIsolated { NoteTaker.shared.lastApp = name }+ }}var isRecording: Bool { recording != nil }@@ -74,7 +87,9 @@ final class NoteTaker: ObservableObject {// MARK: - Recordingfunc start() async {- guard recording == nil else { return }+ guard recording == nil, !starting else { return }+ starting = true+ defer { starting = false }startError = nilguard Parakeet.shared.isReady else {startError = String(localized: "notes.error.models")@@ -88,7 +103,8 @@ final class NoteTaker: ObservableObject {var note = Note(title: String(format: String(localized: "notes.default-title %@"),now.formatted(.dateTime.day().month(.abbreviated).hour().minute())),start: now)- note.app = NSWorkspace.shared.frontmostApplication?.localizedName+ let front = NSWorkspace.shared.frontmostApplication+ note.app = front?.bundleIdentifier == Bundle.main.bundleIdentifier ? lastApp : front?.localizedNamelet dir = Self.folder(for: note.id)do {try FileManager.default.createDirectory(at: dir, withIntermediateDirectories: true)@@ -125,6 +141,21 @@ final class NoteTaker: ObservableObject {startLiveLoop()}+ /// Coucou quits during a call: the recordings are closed properly, and the transcript is+ /// written at the next launch.+ func shutdown() {+ guard var note = recording else { return }+ liveTask?.cancel()+ mic?.stop()+ tap?.stop()+ micChannel?.closeNow()+ systemChannel?.closeNow()+ note.end = Date()+ note.status = .processing+ recording = nil+ replace(note)+ }+func stop() {guard var note = recording else { return }liveTask?.cancel()@@ -210,19 +241,23 @@ final class NoteTaker: ObservableObject {} else {built = NoteBuilder.build(mine: mine, others: theirs, turns: [], meName: me, personName: Self.personName)}- note.speakers = built.speakers- note.lines = built.lines- note.status = .ready- note.error = nil- replace(note)+ // Renamed (or deleted) meanwhile: write onto what is there now.+ guard var current = self.note(id) else { return }+ current.speakers = built.speakers+ current.lines = built.lines+ current.status = .ready+ current.error = nil+ replace(current)+ note = currenttry? FileManager.default.removeItem(at: micURL)try? FileManager.default.removeItem(at: systemURL)appendAppLog("nb.log", "[Notetaker] transcript: \(note.lines.count) lines, \(note.speakers.count) speakers")} catch {appendAppLog("nb.log", "[Notetaker] transcript failed: \(error.localizedDescription)")- note.status = .failed- note.error = error.localizedDescription- replace(note)+ guard var current = self.note(id) else { return }+ current.status = .failed+ current.error = error.localizedDescription+ replace(current)return}if summaryEngine != .off, !note.lines.isEmpty {@@ -342,7 +377,7 @@ final class NoteTaker: ObservableObject {guard SystemLanguageModel.default.availability == .available else { return nil }let words = transcript.split(separator: " ")var material = transcript- if words.count > 1_800 {+ if words.count > 1_200 {var notes: [String] = []var index = 0while index < words.count {@@ -391,7 +426,7 @@ final class NoteTaker: ObservableObject {}func delete(_ id: UUID) {- guard recording?.id != id else { return }+ guard recording?.id != id, !working.contains(id) else { return }notes.removeAll { $0.id == id }try? FileManager.default.removeItem(at: Self.folder(for: id))}@@ -407,7 +442,7 @@ final class NoteTaker: ObservableObject {func export(_ note: Note) {let panel = NSSavePanel()panel.nameFieldStringValue = note.title.replacingOccurrences(of: "/", with: "-") + ".md"- panel.allowedContentTypes = [.init(filenameExtension: "md") ?? .plainText]+ panel.allowedContentTypes = [UTType(filenameExtension: "md") ?? .plainText]guard panel.runModal() == .OK, let url = panel.url else { return }try? markdown(note).write(to: url, atomically: true, encoding: .utf8)}@@ -451,13 +486,19 @@ final class NoteTaker: ObservableObject {}notes = loaded.sorted { $0.start > $1.start }let pending = notes.filter { $0.status == .processing }.map(\.id)- if !pending.isEmpty {- Task { @MainActor in- // Parakeet loads in the background; then the unfinished notes are written.- for id in pending {- if Parakeet.shared.isReady { await self.process(id) }- }+ guard !pending.isEmpty else { return }+ guard Parakeet.shared.isReady else {+ // No models any more: shown as failed, with Retry once they are back.+ for id in pending {+ guard var note = self.note(id) else { continue }+ note.status = .failed+ note.error = String(localized: "notes.error.models")+ replace(note)}+ return+ }+ Task { @MainActor in+ for id in pending { await self.process(id) }}}}