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
voice: log what each wake window heard (no words), rebuild a deaf recognizer
Claude959afe74a5bc
diff --git a/NotchBuddy/Sources/App/Voice/VoiceEngine.swift b/NotchBuddy/Sources/App/Voice/VoiceEngine.swiftindex 8423da9c..3689d654 100644--- a/NotchBuddy/Sources/App/Voice/VoiceEngine.swift+++ b/NotchBuddy/Sources/App/Voice/VoiceEngine.swift@@ -284,8 +284,10 @@ final class VoiceEngine: ObservableObject {firstUnavailableAt = nilwakeWindowWork?.cancel(); wakeWindowWork = nilif !isListeningForCommand && !s.isInCommandPhase {- s.endWindow()- appendAppLog("nb.log", "[Voice] window close")+ let elapsed = Date().timeIntervalSince(self.windowOpenedAt)+ let st = s.endWindow()+ appendAppLog("nb.log", "[Voice] window close \(Self.describe(st))")+ self.checkDeafRecognizer(st, elapsed: elapsed)}}@@ -394,14 +396,38 @@ final class VoiceEngine: ObservableObject {wakeWindowWork?.cancel()let item = DispatchWorkItem { [weak self] inguard let self, !isListeningForCommand else { return }- spotter.endWindow()- appendAppLog("nb.log", "[Voice] window close (20s)")+ let st = spotter.endWindow()+ // Log only: a 20 s window can be steady background noise with no words.+ appendAppLog("nb.log", "[Voice] window close (20s) \(Self.describe(st))")self.openWakeWindow(audio: audio, spotter: spotter, locale: locale)}wakeWindowWork = itemDispatchQueue.main.asyncAfter(deadline: .now() + Self.wakeWindowMax, execute: item)}+ // MARK: - Deaf recognizer detection++ /// Speech was heard (VAD) but the recognizer returned no text at all, window after+ /// window: it is stuck. Rebuild the pipeline instead of staying deaf until relaunch.+ private var deafWindows = 0++ private static func describe(_ st: WakeSpotter.WindowStats) -> String {+ "partials=\(st.partials) words=\(st.maxWords) coucou-like=\(st.nearWake ? "yes" : "no")"+ }++ private func checkDeafRecognizer(_ st: WakeSpotter.WindowStats, elapsed: TimeInterval) {+ if st.partials > 0 { deafWindows = 0; return }+ // A short noise (cough, click) legitimately gives no text: only count windows+ // where speech went on for a while.+ guard elapsed >= 3 else { return }+ deafWindows += 1+ if deafWindows >= 2 {+ deafWindows = 0+ appendAppLog("nb.log", "[Voice] recognizer returned nothing for 2 windows, rebuilding")+ triggerPipelineRebuild(reason: "recognizer deaf")+ }+ }+// MARK: - Pipeline rebuild (rate-limited)private func triggerPipelineRebuild(reason: String) {diff --git a/NotchBuddy/Sources/App/Voice/WakeSpotter.swift b/NotchBuddy/Sources/App/Voice/WakeSpotter.swiftindex 27f5eade..d2eb7cc8 100644--- a/NotchBuddy/Sources/App/Voice/WakeSpotter.swift+++ b/NotchBuddy/Sources/App/Voice/WakeSpotter.swift@@ -49,8 +49,14 @@ final class WakeSpotter: @unchecked Sendable {private var active = falseprivate var phase: Phase = .wakeprivate var partialCount = 0+ private var maxWords = 0 // diagnostics only — never the words themselves+ private var nearWake = false // a partial had a "coucou"-like tokenprivate var gen = SpotterGeneration() // stale-callback filter+ /// What a wake window heard, without any text: lets the log tell "recognizer+ /// returned nothing" apart from "heard speech but not the wake phrase".+ struct WindowStats { let partials: Int; let maxWords: Int; let nearWake: Bool }+private enum Phase { case wake, command }// MARK: - Public API@@ -123,8 +129,12 @@ final class WakeSpotter: @unchecked Sendable {/// Close the window. Bumps the generation so any in-flight callbacks from the/// cancelled task are ignored even if they arrive after the next `beginWindow`.- func endWindow() {+ @discardableResult+ func endWindow() -> WindowStats {lock.withLock {+ let stats = WindowStats(partials: partialCount, maxWords: maxWords, nearWake: nearWake)+ maxWords = 0+ nearWake = falserequest?.endAudio()task?.cancel()request = nil@@ -134,6 +144,7 @@ final class WakeSpotter: @unchecked Sendable {phase = .wakepartialCount = 0gen.bump() // invalidate callbacks from the task we just cancelled+ return stats}}@@ -164,6 +175,11 @@ final class WakeSpotter: @unchecked Sendable {partialCount += 1switch phase {case .wake:+ let words = WakePhrase.normalise(transcript).split(separator: " ")+ maxWords = max(maxWords, words.count)+ if words.contains(where: { w in+ ["cou", "kou", "kuku", "cuck", "koukou", "coco"].contains { w.contains($0) }+ }) { nearWake = true }let r = WakePhrase.split(transcript)if r.matched {phase = .command@@ -185,7 +201,7 @@ final class WakeSpotter: @unchecked Sendable {recognizer = nilactive = falsephase = .wake- partialCount = 0+ // partialCount kept: endWindow() reports it (WindowStats)if let err = error as NSError? {logMsg = "[Voice] spotter task end: error \(err.domain)/\(err.code), partials \(n)"} else {