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: fixes from the first real transcript history
Claudef079e526de55
diff --git a/NotchBuddy/Sources/App/IslandWindowController.swift b/NotchBuddy/Sources/App/IslandWindowController.swiftindex ccfa64df..6e5c45db 100644--- a/NotchBuddy/Sources/App/IslandWindowController.swift+++ b/NotchBuddy/Sources/App/IslandWindowController.swift@@ -1476,6 +1476,21 @@ extension IslandWindowController {}}+ // Mid-conversation, a phrase with no command in it (talking to someone else,+ // "on s'en fout c'est"…) is dropped silently: no dizzy Mochi, no "pas compris".+ // Two in a row end the conversation.+ if isInConversation, case .unknown = effectiveIntent, result.outcome == .failure {+ consecutiveFailures += 1+ appendAppLog("nb.log", "[Voice] conversation: no command in phrase, ignored")+ if consecutiveFailures >= 2 {+ consecutiveFailures = 0+ endConversation(speaking: false)+ } else {+ scheduleConversationContinue(delay: 0.2)+ }+ return+ }+// Mochi reaction + consecutive failure trackingswitch result.outcome {case .success:diff --git a/NotchBuddy/Sources/App/Voice/IntentParser.swift b/NotchBuddy/Sources/App/Voice/IntentParser.swiftindex 9dd63d3f..7fb31941 100644--- a/NotchBuddy/Sources/App/Voice/IntentParser.swift+++ b/NotchBuddy/Sources/App/Voice/IntentParser.swift@@ -25,6 +25,13 @@ enum IntentParser {(fwords, frawWords) = stripTrailingLocation(fwords, rawWords: frawWords)guard !fwords.isEmpty else { return .unknown }+ // ── 0. Strip spoken interjections from the start ─────────────────────+ // "merci tu peux…", "ouais mets…", "bon alors ajoute…"+ while let first = fwords.first, interjections.contains(first), fwords.count > 1 {+ fwords.removeFirst()+ if !frawWords.isEmpty { frawWords.removeFirst() }+ }+// ── 0a. Strip politeness prefixes from the start ─────────────────────// "tu peux", "est-ce que tu peux", "peux-tu", "can you", etc.for prefix in politenessPrefixes {@@ -40,6 +47,12 @@ enum IntentParser {// "mettre" → "mets", "lancer" → "lance", "ajouter" → "ajoute", …fwords = fwords.map { infinitiveMap[$0] ?? $0 }+ // ── 0c. "mets GitHub à la place de Notion" → replace Notion by GitHub ─+ // Before the music rules, or "mets X …" becomes a song search.+ if let (old, new) = extractInsteadOf(fwords, pills: pills) {+ return .pillReplace(old: old, new: new)+ }+// ── 1. Explicit music-only patterns ──────────────────────────────────if matchesAny(fwords, in: pausePrefixes) { return .musicPause }if matchesAny(fwords, in: nextPrefixes) { return .musicNext }@@ -507,6 +520,26 @@ enum IntentParser {return nil}+ /// "mets (la pilule) X à la place de Y" / "X au lieu de Y" / "X instead of Y" → (Y, X).+ private static func extractInsteadOf(_ words: [String], pills: [PillDefinition]) -> (String, String)? {+ let markers: [[String]] = [["a", "la", "place", "de"], ["a", "la", "place", "du"],+ ["au", "lieu", "de"], ["au", "lieu", "du"], ["instead", "of"]]+ let leadVerbs: Set<String> = ["mets", "met", "remets", "ajoute", "rajoute", "active",+ "affiche", "put", "add", "use", "utilise", "prends"]+ let noise: Set<String> = ["la", "le", "les", "l", "pilule", "pilules", "the", "pill", "me", "moi"]+ for m in markers {+ guard let i = indexOfSequence(m, in: words), i > 0, i + m.count < words.count else { continue }+ let left = words[..<i].filter { !leadVerbs.contains($0) && !noise.contains($0) }+ let right = words[(i + m.count)...].filter { !noise.contains($0) }+ guard !left.isEmpty, !right.isEmpty,+ let new = EntityResolver.resolve(left.joined(separator: " "), from: pills),+ let old = EntityResolver.resolve(right.joined(separator: " "), from: pills),+ new != old else { continue }+ return (old, new)+ }+ return nil+ }+// MARK: - pillOnly extractionprivate static func extractOnly(_ words: [String], pills: [PillDefinition]) -> [String]? {@@ -547,6 +580,12 @@ enum IntentParser {["please"],]+ /// Spoken interjections dropped from the start of a phrase (normalised).+ private static let interjections: Set<String> = [+ "merci", "ouais", "oui", "ok", "okay", "bon", "alors", "euh", "bah", "ben", "hein",+ "voila", "donc", "hey", "yeah", "yes", "so", "well", "um", "uh", "thanks",+ ]+/// Maps normalised infinitive forms → imperative/trigger forms.private static let infinitiveMap: [String: String] = ["mettre": "mets",diff --git a/NotchBuddy/Sources/App/Voice/VoiceActionRunner.swift b/NotchBuddy/Sources/App/Voice/VoiceActionRunner.swiftindex 34aae75a..2e4bef9b 100644--- a/NotchBuddy/Sources/App/Voice/VoiceActionRunner.swift+++ b/NotchBuddy/Sources/App/Voice/VoiceActionRunner.swift@@ -272,8 +272,15 @@ final class VoiceActionRunner {return ok("voice.question-cancelled")}- let norm = IntentParser.normalise(transcript)- guard let entity = EntityResolver.resolve(norm, from: availablePills) else {+ guard let entity = Self.answerEntity(transcript, active: pills.activeIds(),+ availablePills: availablePills) else {+ // Not understood: ask once more, then give up.+ if !pending.askedAgain {+ var again = pending+ again.askedAgain = true+ pendingQuestion = again+ return .init(outcome: .question(text: pending.text), message: pending.text)+ }return fail("voice.unknown")}@@ -294,6 +301,33 @@ final class VoiceActionRunner {}}+ /// The pill named in an answer, whether it is a bare name ("Stripe") or a sentence+ /// ("je retire la pilule Stripe", "enlève GitHub", "plutôt Vercel").+ /// Active pills win when several names could match.+ static func answerEntity(_ transcript: String, active: Set<String>,+ availablePills: [PillDefinition]) -> String? {+ switch IntentParser.parse(transcript, pills: availablePills) {+ case .pillRemove(let id), .pillAdd(let id): return id+ case .pillRemoveMultiple(let ids) where !ids.isEmpty: return ids[0]+ default: break+ }+ let norm = IntentParser.normalise(transcript)+ if let id = EntityResolver.resolve(norm, from: availablePills) { return id }+ // Look for a pill name inside the sentence: 3-, 2- then 1-word windows.+ let words = norm.split(separator: " ").map(String.init)+ var found: [String] = []+ for size in stride(from: min(3, words.count), through: 1, by: -1) {+ for start in 0...(words.count - size) {+ let gram = words[start..<(start + size)].joined(separator: " ")+ guard gram.count >= 3,+ let id = EntityResolver.resolve(gram, from: availablePills) else { continue }+ if !found.contains(id) { found.append(id) }+ }+ if !found.isEmpty { break }+ }+ return found.first(where: { active.contains($0) }) ?? found.first+ }+// MARK: - Helpersprivate func ok(_ key: String) -> VoiceActionResult {diff --git a/NotchBuddy/Sources/App/Voice/VoiceIntent.swift b/NotchBuddy/Sources/App/Voice/VoiceIntent.swiftindex 82e996ce..b5610ed6 100644--- a/NotchBuddy/Sources/App/Voice/VoiceIntent.swift+++ b/NotchBuddy/Sources/App/Voice/VoiceIntent.swift@@ -64,5 +64,7 @@ struct PendingVoiceQuestion {}let kind: Kindlet text: String+ /// True once Coucou has asked the question a second time (it never asks a third time).+ var askedAgain: Bool = false}#endifdiff --git a/tests/IntentParserTests.swift b/tests/IntentParserTests.swiftindex 100d2064..3da4dd59 100644--- a/tests/IntentParserTests.swift+++ b/tests/IntentParserTests.swift@@ -284,6 +284,25 @@ enum IntentParserTests {check("mets Notion dans le notch",parse("mets Notion dans le notch", pills: pills), .pillAdd(id: "integration_notion"))+ // Real phrases from a test on the Mac (Settings → Voice history)+ check("Merci tu peux mettre la pilule GitHub à la place de notion",+ parse("Merci tu peux mettre la pilule GitHub à la place de notion", pills: pills),+ .pillReplace(old: "integration_notion", new: "integration_github"))+ check("mets GitHub à la place de Notion",+ parse("mets GitHub à la place de Notion", pills: pills),+ .pillReplace(old: "integration_notion", new: "integration_github"))+ check("GitHub au lieu de Notion",+ parse("GitHub au lieu de Notion", pills: pills),+ .pillReplace(old: "integration_notion", new: "integration_github"))+ check("put GitHub instead of Notion",+ parse("put GitHub instead of Notion", pills: pills),+ .pillReplace(old: "integration_notion", new: "integration_github"))+ check("Ouais tu peux me mettre la pilule Gemini",+ parse("Ouais tu peux me mettre la pilule Gemini", pills: pills), .pillAdd(id: "agent_gemini"))+ check("bon alors ajoute Notion",+ parse("bon alors ajoute Notion", pills: pills), .pillAdd(id: "integration_notion"))+ check("On s'en fout c'est", parse("On s'en fout c'est", pills: pills), .unknown)+// Single pill with conjunction → NOT multi-action (fallback to single-intent)checkNilMultiAction("mets Gemini et Cursor",parseMulti("mets Gemini et Cursor"))diff --git a/tests/VoiceActionRunnerTests.swift b/tests/VoiceActionRunnerTests.swiftindex d193a568..c5eaf6e4 100644--- a/tests/VoiceActionRunnerTests.swift+++ b/tests/VoiceActionRunnerTests.swift@@ -173,6 +173,26 @@ enum VoiceActionRunnerTests {check("question answer → cursor added", pills_.calls.contains("toggle:agent_cursor"), true)check("pending question cleared after answer", runner.pendingQuestion == nil, true)+ // Answer given as a sentence (real transcript from a test on the Mac)+ pills_.active = Set(["integration_github","integration_vercel","integration_stripe","integration_resend"])+ _ = await runner.run(.pillAdd(id: "agent_gemini"), availablePills: pills)+ pills_.calls = []+ let sentence = await runner.handleAnswer("Je retire la pilule Stripe", availablePills: pills)+ check("sentence answer → success", sentence.outcome, .success)+ check("sentence answer → stripe removed", pills_.calls.contains("toggle:integration_stripe"), true)+ check("sentence answer → gemini added", pills_.calls.contains("toggle:agent_gemini"), true)++ // Unclear answer → asked once more, then given up+ pills_.active = Set(["integration_github","integration_vercel","integration_stripe","integration_resend"])+ _ = await runner.run(.pillAdd(id: "agent_gemini"), availablePills: pills)+ let unclear1 = await runner.handleAnswer("on s en fout c est", availablePills: pills)+ if case .question = unclear1.outcome { print("✓ unclear answer → asked again"); pass += 1 }+ else { print("✗ unclear answer — got \(unclear1.outcome)"); fail += 1 }+ check("unclear answer keeps the question", runner.pendingQuestion != nil, true)+ let unclear2 = await runner.handleAnswer("bof", availablePills: pills)+ check("second unclear answer → failure", unclear2.outcome, .failure)+ check("question dropped after second miss", runner.pendingQuestion == nil, true)+// ── Pills: add multiple ───────────────────────────────────────────────pills_.active = ["integration_github"]pills_.calls = []