Skip to content

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.

Voice: conversation window, TTS, adaptive silence, context, VoiceBrain, bug fixes

Louis Raille641d02e5f5da
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 2581f9f6..90f9fa29 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -90,6 +90,18 @@ jobs:
- name: Claude settings file tests
run: bash scripts/test-claude-settings.sh
+ - name: Turn end policy tests
+ run: bash scripts/test-turn-end-policy.sh
+
+ - name: Voice spotter generation tests
+ run: bash scripts/test-voice-spotter-gen.sh
+
+ - name: Voice wake blocked tests
+ run: bash scripts/test-voice-wake-blocked.sh
+
+ - name: Conversation context tests
+ run: bash scripts/test-conversation-context.sh
+
- name: Build
run: |
xcodebuild \
diff --git a/NotchBuddy/NotchBuddy.xcodeproj/project.pbxproj b/NotchBuddy/NotchBuddy.xcodeproj/project.pbxproj
index 2bc5de78..e2afe82c 100644
--- a/NotchBuddy/NotchBuddy.xcodeproj/project.pbxproj
+++ b/NotchBuddy/NotchBuddy.xcodeproj/project.pbxproj
@@ -58,6 +58,7 @@
2540E4198492CC2B9237ED99 /* SpotifyController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A9E6EB7C8468A8339CF6A5C /* SpotifyController.swift */; };
25F66E99460D62478899A292 /* MochiWardrobe.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79A7807ADD0963FF260D1FAD /* MochiWardrobe.swift */; };
26E35C79CCD09FEBA04A3EF6 /* LinkTestView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6762C38A8952A90F394EDFE4 /* LinkTestView.swift */; };
+ 273B404F55739D661D9489D8 /* VoiceBrain.swift in Sources */ = {isa = PBXBuildFile; fileRef = C563E55884A7750B40EC9A01 /* VoiceBrain.swift */; };
273FC0FA14AAF6CE62FD14AE /* DesktopMochi.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1DDC96E7967032F5D0BD585 /* DesktopMochi.swift */; };
2875610F701376BD65573386 /* WindowContextCapture.swift in Sources */ = {isa = PBXBuildFile; fileRef = E91B733ADC638E14E9BB6EFA /* WindowContextCapture.swift */; };
295F8FE5A9E2E8F1A6389DEE /* HomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B53E4CAD2BCC77B280689B0F /* HomeView.swift */; };
@@ -66,6 +67,7 @@
2CC2E3B688B15BBEB3AE3BCE /* WindowContextCapture.swift in Sources */ = {isa = PBXBuildFile; fileRef = E91B733ADC638E14E9BB6EFA /* WindowContextCapture.swift */; };
2DEB459FBD0BA3CEAAA5FDE9 /* ClaudeService.swift in Sources */ = {isa = PBXBuildFile; fileRef = A83D5410BD030B243ADDCFF4 /* ClaudeService.swift */; };
2F36E3C6C073E968A682AFA4 /* NotionPoller.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE03E03D1804B0B92C5C2DAD /* NotionPoller.swift */; };
+ 326971DDA23F331116E5A628 /* VoiceBrain.swift in Sources */ = {isa = PBXBuildFile; fileRef = C563E55884A7750B40EC9A01 /* VoiceBrain.swift */; };
3451DB0668FAEEF09503D808 /* WakePhrase.swift in Sources */ = {isa = PBXBuildFile; fileRef = A12EC8F605BBC37F8223D7AA /* WakePhrase.swift */; };
3756B7E1A55D9CEC8C4D34A4 /* IslandStateMachine.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8212018F09EA1E96FBD63CD /* IslandStateMachine.swift */; };
38EEB2D3A6EC538958D92575 /* GitHubPulse.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8D3AD61802A32C4833F3EDA /* GitHubPulse.swift */; };
@@ -89,6 +91,7 @@
4D34FF10654B19B69FE1964C /* TurnSnapshot.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A1C4152EBDBD7C24CABFFD7 /* TurnSnapshot.swift */; };
4D958F2DDCE9504490FDA357 /* DiffEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = B32FB972D02162720E566674 /* DiffEngine.swift */; };
4F1E0B3C838DA3CD6F864BC0 /* CalcomPoller.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3104222B3F17BA5E8DEA5277 /* CalcomPoller.swift */; };
+ 4F4176856B544D8C620B6204 /* ConversationContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A67DA3B8EEF063C44E07F7E /* ConversationContext.swift */; };
502F2B0D607C511DD3B836B3 /* VoiceSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4543CB771E0B723783F529E /* VoiceSettings.swift */; };
52F0DF1FBCB522951910390E /* InstructionRunner.swift in Sources */ = {isa = PBXBuildFile; fileRef = FADC1FE5696B1075932D0B7C /* InstructionRunner.swift */; };
530443F46F896F037A56F663 /* HotKeyCenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1218B86E249691AF44F819AC /* HotKeyCenter.swift */; };
@@ -124,6 +127,7 @@
6D71A1FA10C766E465F326D4 /* BotEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66E6F5FC81429871B6F766A8 /* BotEngine.swift */; };
6DDBB5EDE6BEFD4225238C28 /* approval.wav in Resources */ = {isa = PBXBuildFile; fileRef = 11FCBBE20532B1F0A184EA06 /* approval.wav */; };
6FC65C190ED614C664C9BC17 /* SafeWebURL.swift in Sources */ = {isa = PBXBuildFile; fileRef = B2FDED98F7F6C755A72C97A3 /* SafeWebURL.swift */; };
+ 718410ED630AE3AC5DF59A95 /* VoiceSpeaker.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD11C7925B0A7831BFC2199C /* VoiceSpeaker.swift */; };
71CBD1D39A6668BF454CA1C5 /* IslandTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0365DDE3C554F5E8570055F4 /* IslandTypes.swift */; };
724E602A05FE5A6D58218E27 /* CoucouControl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C406C508A86E215B3CBE3FC /* CoucouControl.swift */; };
725365FA4E184D970E7BB8B4 /* MochiOutfitDrawing.swift in Sources */ = {isa = PBXBuildFile; fileRef = E84E5D91129352E8A1D32AA4 /* MochiOutfitDrawing.swift */; };
@@ -147,6 +151,7 @@
818E87607FD9F0CA5406BF35 /* Localizable.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = B2AA83D80260660475FAB052 /* Localizable.xcstrings */; };
82E72E0AFCAB192D98AB2004 /* MochiActivityState.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE18399D1CD69468CCF57966 /* MochiActivityState.swift */; };
845D762E9F4F0AD0D5FCEDF4 /* BotEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 66E6F5FC81429871B6F766A8 /* BotEngine.swift */; };
+ 8551E592C5FFC6A0A7458A26 /* TurnEndPolicy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 787D306C2399FBAE8BBB86ED /* TurnEndPolicy.swift */; };
862CE6CB220D55E46F646DA9 /* GitHubPulse.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8D3AD61802A32C4833F3EDA /* GitHubPulse.swift */; };
868E3EB4A275AA2394EA20BF /* CoucouWidgets.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 5C3E2269A202B640E7F3B5E0 /* CoucouWidgets.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
875FB3F71BD34B53B0524063 /* CoucouWidgets.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6723392BE01AF210E484316 /* CoucouWidgets.swift */; };
@@ -199,6 +204,7 @@
A885B7E6DC43231BECE36E3D /* MochiWardrobe.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79A7807ADD0963FF260D1FAD /* MochiWardrobe.swift */; };
A94F75489794D9C95E584B56 /* EnergyVAD.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0E2C3ACD815230A0ECAB014 /* EnergyVAD.swift */; };
AAECF326505B361B5F818150 /* LiveVoiceControls.swift in Sources */ = {isa = PBXBuildFile; fileRef = 54E47E39D2D52584FA219FA1 /* LiveVoiceControls.swift */; };
+ ABE0CEF17018F1BAD8F7DBFA /* TurnEndPolicy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 787D306C2399FBAE8BBB86ED /* TurnEndPolicy.swift */; };
AD94156F1F9CFF62B35202FB /* ApprovalRelay.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD426E81DF79CA79888059D9 /* ApprovalRelay.swift */; };
ADB4EF797FBD6CC90F8D25D3 /* MochiActivityAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 323F242B14A61A7C071EC115 /* MochiActivityAttributes.swift */; };
ADBB9C15DDA4044625B325BE /* MochiOutfitDrawing.swift in Sources */ = {isa = PBXBuildFile; fileRef = E84E5D91129352E8A1D32AA4 /* MochiOutfitDrawing.swift */; };
@@ -268,6 +274,7 @@
E1581F8F2725B26E90D91C4A /* IntroView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B2EED5205DD7161E51BE1E1 /* IntroView.swift */; };
E2414533EDC7565286141198 /* SpotifyController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6A9E6EB7C8468A8339CF6A5C /* SpotifyController.swift */; };
E4B9986674F4D425826F15A8 /* StripePoller.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2EF78999D68D56ADE4CEFBE2 /* StripePoller.swift */; };
+ E5D08513CFEA5D5E6760ECA4 /* ConversationContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A67DA3B8EEF063C44E07F7E /* ConversationContext.swift */; };
E701BC8996229D08362CA732 /* ServiceStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9AF705275522F99CAE7E1429 /* ServiceStatus.swift */; };
E776C7D1DE5C62EA8D4BA3E3 /* FileDropView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3232F258523DD8D09B670363 /* FileDropView.swift */; };
E81575CE4433C6F88E424A8F /* LocalChat.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8790ACE9F73BD74640A0F20C /* LocalChat.swift */; };
@@ -291,6 +298,7 @@
F5D6F8E2CA65AB16B487DDD0 /* IslandScreenGeometry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9466FDE02C9B3FB4EF01DFF8 /* IslandScreenGeometry.swift */; };
F6CA56F362902839EF9A3E2E /* PhoneAssets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 60401D1023D17C3FD30D7113 /* PhoneAssets.xcassets */; };
F6D57EEBD7E937EFD2B715CF /* ClaudeHost.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0F0D0F67E7C56B9E37E7648 /* ClaudeHost.swift */; };
+ F7162101509D8CAE59711602 /* VoiceSpeaker.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD11C7925B0A7831BFC2199C /* VoiceSpeaker.swift */; };
F8F95EAD88F70E0A147D1662 /* MacDictation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6544ED02D945CF9F00647AD1 /* MacDictation.swift */; };
F9445A71BBF9E4D20224238E /* QuestionPayload.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C6993B34A0FFF8E3D454ADC /* QuestionPayload.swift */; };
F9685A58729FE64B23FCCFC5 /* VoiceResultView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C432FE1286945E42D3E11D7 /* VoiceResultView.swift */; };
@@ -360,6 +368,7 @@
28323DC20034A281F6829884 /* CloudProbe.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CloudProbe.swift; sourceTree = "<group>"; };
29E156CF1C215B8FE713B3A0 /* TurnShare.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TurnShare.swift; sourceTree = "<group>"; };
2A1C4152EBDBD7C24CABFFD7 /* TurnSnapshot.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TurnSnapshot.swift; sourceTree = "<group>"; };
+ 2A67DA3B8EEF063C44E07F7E /* ConversationContext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConversationContext.swift; sourceTree = "<group>"; };
2EF78999D68D56ADE4CEFBE2 /* StripePoller.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StripePoller.swift; sourceTree = "<group>"; };
3104222B3F17BA5E8DEA5277 /* CalcomPoller.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalcomPoller.swift; sourceTree = "<group>"; };
3232F258523DD8D09B670363 /* FileDropView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileDropView.swift; sourceTree = "<group>"; };
@@ -397,6 +406,7 @@
708E1FD9894461B4AD727DB1 /* CoucouIntents.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoucouIntents.swift; sourceTree = "<group>"; };
71718D1B87A39A4879DD2A9D /* VercelPoller.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VercelPoller.swift; sourceTree = "<group>"; };
73FA4DF1BE5246CCFFB72E5C /* CodexPlanGauge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CodexPlanGauge.swift; sourceTree = "<group>"; };
+ 787D306C2399FBAE8BBB86ED /* TurnEndPolicy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TurnEndPolicy.swift; sourceTree = "<group>"; };
78FB882D49084DEA6A10DB4D /* RecapStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecapStore.swift; sourceTree = "<group>"; };
79A7807ADD0963FF260D1FAD /* MochiWardrobe.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MochiWardrobe.swift; sourceTree = "<group>"; };
79D8DD79C3DD9BBC584B3CB2 /* HookServer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HookServer.swift; sourceTree = "<group>"; };
@@ -446,7 +456,9 @@
C22AF9F301D7A23DA6254D49 /* PhoneLink.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhoneLink.swift; sourceTree = "<group>"; };
C2DFAEAF1DD1CBF03D3C314E /* TurnRecorder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TurnRecorder.swift; sourceTree = "<group>"; };
C2E4F18AA940EFF7E047B9F7 /* AppState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppState.swift; sourceTree = "<group>"; };
+ C563E55884A7750B40EC9A01 /* VoiceBrain.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VoiceBrain.swift; sourceTree = "<group>"; };
C581F7B1A9F14B281B60063E /* GreetingCanvasView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GreetingCanvasView.swift; sourceTree = "<group>"; };
+ CD11C7925B0A7831BFC2199C /* VoiceSpeaker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VoiceSpeaker.swift; sourceTree = "<group>"; };
D0F0D0F67E7C56B9E37E7648 /* ClaudeHost.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClaudeHost.swift; sourceTree = "<group>"; };
D1A7C62058BB0C9D0DF58DCB /* VoiceIntent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VoiceIntent.swift; sourceTree = "<group>"; };
D1D96E57E8DADE6B82628E3E /* OpenLeadMochiIntent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OpenLeadMochiIntent.swift; sourceTree = "<group>"; };
@@ -702,18 +714,22 @@
FB8E4AAB0B5E949069B8D03D /* Voice */ = {
isa = PBXGroup;
children = (
+ 2A67DA3B8EEF063C44E07F7E /* ConversationContext.swift */,
F0E2C3ACD815230A0ECAB014 /* EnergyVAD.swift */,
EDC1DEBFCAEBE6F0EEB865F3 /* EntityResolver.swift */,
F39753CFF90B494D449CCD95 /* IntentParser.swift */,
54E47E39D2D52584FA219FA1 /* LiveVoiceControls.swift */,
F4EF48A44D82B5422E631FE0 /* SpotterGeneration.swift */,
+ 787D306C2399FBAE8BBB86ED /* TurnEndPolicy.swift */,
A2737EC4885ADB8FDDA1C610 /* VoiceActionRunner.swift */,
A87F39805C78722F614295B4 /* VoiceAudio.swift */,
+ C563E55884A7750B40EC9A01 /* VoiceBrain.swift */,
B328028D18F590D6680B8A2B /* VoiceEngine.swift */,
D1A7C62058BB0C9D0DF58DCB /* VoiceIntent.swift */,
22E03C8E267399FA25C75877 /* VoiceIslandView.swift */,
7C432FE1286945E42D3E11D7 /* VoiceResultView.swift */,
D4543CB771E0B723783F529E /* VoiceSettings.swift */,
+ CD11C7925B0A7831BFC2199C /* VoiceSpeaker.swift */,
ABD7A2C29B15EFFAF67FF2DE /* VoiceWakeFilter.swift */,
A12EC8F605BBC37F8223D7AA /* WakePhrase.swift */,
BC1DE3225F5239394398E6B6 /* WakeSpotter.swift */,
@@ -949,6 +965,7 @@
D45D9C8EAF67FC2F46E9F352 /* CloudProbe.swift in Sources */,
9AD370335A3ECC9C82375F93 /* CodexPlanGauge.swift in Sources */,
EE3AB10544113500486A9684 /* ColorHex.swift in Sources */,
+ E5D08513CFEA5D5E6760ECA4 /* ConversationContext.swift in Sources */,
B0CE5AC8B579866A14BD61D0 /* DemoEngine.swift in Sources */,
BEC5DDB55B3DA67C61CA8470 /* DesktopMochi.swift in Sources */,
BA65FC4A40F7227837C26214 /* DesktopMochiLogic.swift in Sources */,
@@ -1006,6 +1023,7 @@
1558BB00C530B721172F6E65 /* StripePoller.swift in Sources */,
9EA178EA395B116336C1FA10 /* TerminalTarget+AppKit.swift in Sources */,
1D4CE0CCD2B5A0FFE50C7F06 /* TerminalTarget.swift in Sources */,
+ 8551E592C5FFC6A0A7458A26 /* TurnEndPolicy.swift in Sources */,
0408FE7F86EBEE61CAED32DA /* TurnRecorder.swift in Sources */,
68C3ACC708B69035FD0CB8C4 /* TurnSnapshot.swift in Sources */,
62C4EE3F74DAA59764729E62 /* UploadCanvasView.swift in Sources */,
@@ -1014,11 +1032,13 @@
118FC4AE0AC74D84B4A134D8 /* VercelPoller.swift in Sources */,
390486F7CDC01C1BCDBB27F9 /* VoiceActionRunner.swift in Sources */,
88A8F2E4E754FAFABF6B1960 /* VoiceAudio.swift in Sources */,
+ 326971DDA23F331116E5A628 /* VoiceBrain.swift in Sources */,
BDEFF4223DA949E2B8AB85A7 /* VoiceEngine.swift in Sources */,
9C11C226915DBC97B5CD7953 /* VoiceIntent.swift in Sources */,
9088C7BADF166685E471D248 /* VoiceIslandView.swift in Sources */,
CE5ACDD856C76B717ABA295F /* VoiceResultView.swift in Sources */,
502F2B0D607C511DD3B836B3 /* VoiceSettings.swift in Sources */,
+ 718410ED630AE3AC5DF59A95 /* VoiceSpeaker.swift in Sources */,
BBCA973A1AE1385BBE79A834 /* VoiceWakeFilter.swift in Sources */,
C2212AA8BF5834B62308235B /* WakePhrase.swift in Sources */,
63B87D9E49F228ADCEC4C293 /* WakeSpotter.swift in Sources */,
@@ -1130,6 +1150,7 @@
FDF87CF7C5F703EDD9A7CC14 /* CloudProbe.swift in Sources */,
EB1D9680D3DB0F0707D4A043 /* CodexPlanGauge.swift in Sources */,
9ECEE890D4486B6E83BD5B7F /* ColorHex.swift in Sources */,
+ 4F4176856B544D8C620B6204 /* ConversationContext.swift in Sources */,
F157D7A9BF878DB2B286B1F7 /* DemoEngine.swift in Sources */,
273FC0FA14AAF6CE62FD14AE /* DesktopMochi.swift in Sources */,
C93BA975D35B8CD7473CF995 /* DesktopMochiLogic.swift in Sources */,
@@ -1187,6 +1208,7 @@
E4B9986674F4D425826F15A8 /* StripePoller.swift in Sources */,
11F14DB97C93CF84DF9D5C43 /* TerminalTarget+AppKit.swift in Sources */,
6726F74966EDE7F82BFE89B2 /* TerminalTarget.swift in Sources */,
+ ABE0CEF17018F1BAD8F7DBFA /* TurnEndPolicy.swift in Sources */,
CE0A1BD64DF3E08D200691A6 /* TurnRecorder.swift in Sources */,
4D34FF10654B19B69FE1964C /* TurnSnapshot.swift in Sources */,
4117E7C8AA231AAE36E7509D /* UploadCanvasView.swift in Sources */,
@@ -1195,11 +1217,13 @@
0E83C1DD4D20E7FB7A904450 /* VercelPoller.swift in Sources */,
BF3F437B1FE9C246E9014F76 /* VoiceActionRunner.swift in Sources */,
64FE8055CCAD30B44FE398E7 /* VoiceAudio.swift in Sources */,
+ 273B404F55739D661D9489D8 /* VoiceBrain.swift in Sources */,
80B0B3C777A9DC8C82952FD2 /* VoiceEngine.swift in Sources */,
15D69752806E1D1D589B20A7 /* VoiceIntent.swift in Sources */,
C3BA3FA2A4025194FC088C5A /* VoiceIslandView.swift in Sources */,
F9685A58729FE64B23FCCFC5 /* VoiceResultView.swift in Sources */,
035F9A85BF71B21F9AA5E004 /* VoiceSettings.swift in Sources */,
+ F7162101509D8CAE59711602 /* VoiceSpeaker.swift in Sources */,
8DE75D1E260A1314D1C47885 /* VoiceWakeFilter.swift in Sources */,
3451DB0668FAEEF09503D808 /* WakePhrase.swift in Sources */,
B5206E9D10AD77C0C24463AB /* WakeSpotter.swift in Sources */,
diff --git a/NotchBuddy/Resources/Localizable.xcstrings b/NotchBuddy/Resources/Localizable.xcstrings
index 62704479..bcb87893 100644
--- a/NotchBuddy/Resources/Localizable.xcstrings
+++ b/NotchBuddy/Resources/Localizable.xcstrings
@@ -23873,6 +23873,454 @@
}
}
}
+ },
+ "voice.setting-speak": {
+ "localizations": {
+ "ar": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "كوكو يرد بصوت عالٍ"
+ }
+ },
+ "bn": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Coucou জোরে জবাব দেয়"
+ }
+ },
+ "en": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Coucou responds aloud"
+ }
+ },
+ "es": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Coucou responde en voz alta"
+ }
+ },
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Coucou répond à voix haute"
+ }
+ },
+ "hi": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Coucou ज़ोर से जवाब देता है"
+ }
+ },
+ "id": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Coucou merespons dengan suara"
+ }
+ },
+ "pt-BR": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Coucou responde em voz alta"
+ }
+ },
+ "ru": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Coucou отвечает вслух"
+ }
+ },
+ "zh-Hans": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Coucou 大声回应"
+ }
+ }
+ }
+ },
+ "voice.setting-speak-desc": {
+ "localizations": {
+ "ar": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "يقرأ كوكو النتائج باللغة المنطوقة باستخدام صوت مُركَّب. كل شيء يتم على الجهاز."
+ }
+ },
+ "bn": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Coucou কথ্য ভাষায় ফলাফল পড়ে। সবকিছু ডিভাইসেই হয়।"
+ }
+ },
+ "en": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Coucou reads back results in the spoken language, using a synthesized voice. 100% on-device."
+ }
+ },
+ "es": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Coucou lee los resultados en el idioma hablado con una voz sintetizada. Todo en el dispositivo."
+ }
+ },
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Coucou lit les résultats dans la langue parlée. Tout se passe sur l'appareil."
+ }
+ },
+ "hi": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Coucou बोली जाने वाली भाषा में परिणाम पढ़ता है। सब कुछ डिवाइस पर।"
+ }
+ },
+ "id": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Coucou membaca hasil dalam bahasa yang diucapkan. Semuanya di perangkat."
+ }
+ },
+ "pt-BR": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Coucou lê os resultados no idioma falado. Tudo no dispositivo."
+ }
+ },
+ "ru": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Coucou зачитывает результаты на языке команды. Всё на устройстве."
+ }
+ },
+ "zh-Hans": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Coucou 用语音语言朗读结果。完全在设备上处理。"
+ }
+ }
+ }
+ },
+ "voice.music-search-opened": {
+ "localizations": {
+ "ar": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "غير موجود في مكتبتك، فتحت البحث عن %@"
+ }
+ },
+ "bn": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "তোমার লাইব্রেরিতে নেই, %@ এর জন্য সার্চ খুলেছি"
+ }
+ },
+ "en": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Not in your library, opened search for %@"
+ }
+ },
+ "es": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "No está en tu biblioteca, abrí la búsqueda de %@"
+ }
+ },
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Introuvable dans ta bibliothèque, j'ai ouvert la recherche pour %@"
+ }
+ },
+ "hi": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "तुम्हारी लाइब्रेरी में नहीं है, %@ के लिए सर्च खोला"
+ }
+ },
+ "id": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Tidak ada di perpustakaan, membuka pencarian untuk %@"
+ }
+ },
+ "pt-BR": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Não está na sua biblioteca, abri a busca por %@"
+ }
+ },
+ "ru": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Нет в библиотеке, открыл поиск для %@"
+ }
+ },
+ "zh-Hans": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "不在你的资料库中,已打开 %@ 的搜索"
+ }
+ }
+ }
+ },
+ "voice.model-available": {
+ "localizations": {
+ "ar": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "نموذج الذكاء الاصطناعي المحلي: متاح"
+ }
+ },
+ "bn": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "স্থানীয় AI মডেল: উপলব্ধ"
+ }
+ },
+ "en": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Local AI model: available"
+ }
+ },
+ "es": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Modelo de IA local: disponible"
+ }
+ },
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Modèle IA local : disponible"
+ }
+ },
+ "hi": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "स्थानीय AI मॉडल: उपलब्ध"
+ }
+ },
+ "id": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Model AI lokal: tersedia"
+ }
+ },
+ "pt-BR": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Modelo de IA local: disponível"
+ }
+ },
+ "ru": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Локальная модель ИИ: доступна"
+ }
+ },
+ "zh-Hans": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "本地 AI 模型:可用"
+ }
+ }
+ }
+ },
+ "voice.model-not-macos26": {
+ "localizations": {
+ "ar": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "نموذج الذكاء الاصطناعي المحلي: يتطلب macOS 26 أو أحدث"
+ }
+ },
+ "bn": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "স্থানীয় AI মডেল: macOS 26 বা তার পরবর্তী প্রয়োজন"
+ }
+ },
+ "en": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Local AI model: requires macOS 26 or later"
+ }
+ },
+ "es": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Modelo de IA local: requiere macOS 26 o posterior"
+ }
+ },
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Modèle IA local : nécessite macOS 26 ou plus"
+ }
+ },
+ "hi": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "स्थानीय AI मॉडल: macOS 26 या बाद का संस्करण आवश्यक है"
+ }
+ },
+ "id": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Model AI lokal: membutuhkan macOS 26 atau lebih baru"
+ }
+ },
+ "pt-BR": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Modelo de IA local: requer macOS 26 ou posterior"
+ }
+ },
+ "ru": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Локальная модель ИИ: требуется macOS 26 или новее"
+ }
+ },
+ "zh-Hans": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "本地 AI 模型:需要 macOS 26 或更高版本"
+ }
+ }
+ }
+ },
+ "voice.model-ai-off": {
+ "localizations": {
+ "ar": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "نموذج الذكاء الاصطناعي المحلي: Apple Intelligence معطَّل"
+ }
+ },
+ "bn": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "স্থানীয় AI মডেল: Apple Intelligence বন্ধ আছে"
+ }
+ },
+ "en": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Local AI model: Apple Intelligence is off"
+ }
+ },
+ "es": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Modelo de IA local: Apple Intelligence está desactivado"
+ }
+ },
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Modèle IA local : Apple Intelligence est désactivée"
+ }
+ },
+ "hi": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "स्थानीय AI मॉडल: Apple Intelligence बंद है"
+ }
+ },
+ "id": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Model AI lokal: Apple Intelligence dimatikan"
+ }
+ },
+ "pt-BR": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Modelo de IA local: Apple Intelligence está desativado"
+ }
+ },
+ "ru": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Локальная модель ИИ: Apple Intelligence отключена"
+ }
+ },
+ "zh-Hans": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "本地 AI 模型:Apple Intelligence 已关闭"
+ }
+ }
+ }
+ },
+ "voice.model-lang": {
+ "localizations": {
+ "ar": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "نموذج الذكاء الاصطناعي المحلي: اللغة غير مدعومة"
+ }
+ },
+ "bn": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "স্থানীয় AI মডেল: ভাষা সমর্থিত নয়"
+ }
+ },
+ "en": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Local AI model: language not supported"
+ }
+ },
+ "es": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Modelo de IA local: idioma no compatible"
+ }
+ },
+ "fr": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Modèle IA local : langue non prise en charge"
+ }
+ },
+ "hi": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "स्थानीय AI मॉडल: भाषा समर्थित नहीं है"
+ }
+ },
+ "id": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Model AI lokal: bahasa tidak didukung"
+ }
+ },
+ "pt-BR": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Modelo de IA local: idioma não suportado"
+ }
+ },
+ "ru": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "Локальная модель ИИ: язык не поддерживается"
+ }
+ },
+ "zh-Hans": {
+ "stringUnit": {
+ "state": "translated",
+ "value": "本地 AI 模型:不支持该语言"
+ }
+ }
+ }
}
},
"version": "1.0"
diff --git a/NotchBuddy/Sources/App/IslandWindowController.swift b/NotchBuddy/Sources/App/IslandWindowController.swift
index e347b0b5..bd129843 100644
--- a/NotchBuddy/Sources/App/IslandWindowController.swift
+++ b/NotchBuddy/Sources/App/IslandWindowController.swift
@@ -25,6 +25,12 @@ final class IslandWindowController: NSWindowController {
// Voice result auto-dismiss timer
#if !APPSTORE
private var voiceResultWork: DispatchWorkItem?
+ private var isInConversation = false
+ private var conversationContext = ConversationContext()
+ private let conversationEndPhrases: Set<String> = [
+ "merci", "c est bon", "c'est bon", "that s all", "that's all",
+ "laisse tomber", "annule", "annuler", "cancel", "never mind", "bye", "au revoir",
+ ]
#endif
// Suppress peek sound on next reveal (e.g. musicReveal)
@@ -322,6 +328,14 @@ final class IslandWindowController: NSWindowController {
AppState.shared.voiceResult = result
self.expand(to: .voiceResult)
self.scheduleVoiceDismiss(delay: 1.5)
+ } else if self.isInConversation {
+ // Conversation ended by 8-second silence
+ self.isInConversation = false
+ self.conversationContext.reset()
+ self.voiceResultWork?.cancel()
+ self.voiceResultWork = nil
+ VoiceEngine.shared.endConversation()
+ self.scheduleVoiceDismiss(delay: 0.3)
} else {
self.fsm.voiceFinished()
}
@@ -516,6 +530,15 @@ final class IslandWindowController: NSWindowController {
guard fsm.isHeldOpen?() != true || keepsApprovalPending else { return }
if !keepsApprovalPending { state.isPinned = false }
finishedPinTimer?.cancel()
+ #if !APPSTORE
+ VoiceSpeaker.shared.stop()
+ if isInConversation {
+ isInConversation = false
+ voiceResultWork?.cancel()
+ voiceResultWork = nil
+ VoiceEngine.shared.endConversation()
+ }
+ #endif
// Keep the FSM in step with what is on screen (home/coucou → petit now).
fsm.collapse()
setMode(.compact)
@@ -594,6 +617,7 @@ final class IslandWindowController: NSWindowController {
case .talkToCoucou:
#if !APPSTORE
+ VoiceSpeaker.shared.stop()
VoiceEngine.shared.startListeningDirectly()
#endif
}
@@ -1306,7 +1330,7 @@ struct GhostBotView: View {
#if !APPSTORE
extension IslandWindowController {
- /// Run the intent derived from `transcript`, show VoiceResultView for 2 s (6 s for questions), then collapse.
+ /// Run the intent derived from `transcript`, show VoiceResultView, then continue conversation or collapse.
@MainActor
func handleVoiceCommand(_ transcript: String) async {
let pills = PillCatalog.available
@@ -1315,24 +1339,49 @@ extension IslandWindowController {
// Propagate recognition locale so responses are in the spoken language.
runner.commandLocale = VoiceEngine.shared.speechLocale
- // ── Follow-up answer to a pending question ────────────────────────────────
+ // ── Conversation end phrase ────────────────────────────────────────────────
+ let normTranscript = WakePhrase.normalise(transcript)
+ if isInConversation && conversationEndPhrases.contains(normTranscript) {
+ endConversation(speaking: true)
+ return
+ }
+
+ // ── Follow-up answer to a pending question ─────────────────────────────────
if runner.pendingQuestion != nil {
let result = await runner.handleAnswer(transcript, availablePills: pills)
showVoiceResult(result, emote: result.outcome == .success ? BotEmote.happy : nil)
+ // Questions don't continue conversation (already re-listening if needed)
return
}
- // ── Multi-action: "mets Gemini et enlève GitHub" ──────────────────────────
- if let intents = IntentParser.parseMultiAction(transcript, pills: pills), intents.count >= 2 {
+ // ── Multi-action: removals before additions ───────────────────────────────
+ if var intents = IntentParser.parseMultiAction(transcript, pills: pills), intents.count >= 2 {
+ // Sort: removals first
+ intents.sort { a, b in
+ let isRemoveA: Bool
+ switch a {
+ case .pillRemove, .pillRemoveMultiple: isRemoveA = true
+ default: isRemoveA = false
+ }
+ let isRemoveB: Bool
+ switch b {
+ case .pillRemove, .pillRemoveMultiple: isRemoveB = true
+ default: isRemoveB = false
+ }
+ return isRemoveA && !isRemoveB
+ }
var parts: [String] = []
var anyFailure = false
+ var lastSuccess: VoiceIntent? = nil
for intent in intents {
let r = await runner.run(intent, availablePills: pills, rawTranscript: transcript)
parts.append(r.message)
if case .failure = r.outcome { anyFailure = true }
// .question in multi-action: treat as failure (no re-listen in combined flow).
if case .question = r.outcome { anyFailure = true }
+ if case .success = r.outcome { lastSuccess = intent }
}
+ if let last = lastSuccess { conversationContext.update(last) }
let combined = VoiceActionResult(
outcome: anyFailure ? .failure : .success,
message: parts.joined(separator: " · ")
@@ -1342,18 +1391,29 @@ extension IslandWindowController {
} else {
NotificationCenter.default.post(name: .triggerEmote, object: BotEmote.happy)
}
- showVoiceResult(combined)
+ AppState.shared.voiceResult = combined
+ expand(to: .voiceResult)
+ speakAndContinueConversation(combined)
return
}
- // ── Single command ────────────────────────────────────────────────────────
- let intent = IntentParser.parse(transcript, pills: pills)
+ // ── Relative context resolution ────────────────────────────────────────────
+ let intent: VoiceIntent
+ if isInConversation,
+ let resolved = conversationContext.resolveRelative(transcript, pills: pills) {
+ intent = resolved
+ } else {
+ intent = IntentParser.parse(transcript, pills: pills)
+ }
+
+ // ── Single command ─────────────────────────────────────────────────────────
let result = await runner.run(intent, availablePills: pills, rawTranscript: transcript)
// Mochi reaction
switch result.outcome {
case .success:
NotificationCenter.default.post(name: .triggerEmote, object: BotEmote.happy)
+ conversationContext.update(intent)
case .failure:
NotificationCenter.default.post(name: .botDizzy, object: nil)
case .question:
@@ -1374,7 +1434,7 @@ extension IslandWindowController {
VoiceEngine.shared.startListeningDirectly(firstWordTimeout: 5.0)
}
} else {
- scheduleVoiceDismiss(delay: 2.0)
+ speakAndContinueConversation(result)
}
}
@@ -1390,6 +1450,55 @@ extension IslandWindowController {
scheduleVoiceDismiss(delay: 2.0)
}
+ /// Speak the result message (if enabled) then start next conversation turn.
+ @MainActor
+ private func speakAndContinueConversation(_ result: VoiceActionResult) {
+ isInConversation = true
+
+ let speaker = VoiceSpeaker.shared
+ if VoiceSettings.speakEnabled {
+ let locale = VoiceEngine.shared.speechLocale
+ speaker.speak(result.message, locale: locale)
+ speaker.onDidFinish = { [weak self] in
+ Task { @MainActor in
+ self?.scheduleConversationContinue(delay: 0.3)
+ }
+ }
+ } else {
+ // No speech: continue after showing result for 1.5 s
+ scheduleConversationContinue(delay: 1.5)
+ }
+ }
+
+ /// Schedule the next conversation listening turn.
+ @MainActor
+ private func scheduleConversationContinue(delay: TimeInterval) {
+ voiceResultWork?.cancel()
+ let item = DispatchWorkItem { [weak self] in
+ Task { @MainActor in
+ guard let self, self.isInConversation else { return }
+ VoiceEngine.shared.startConversationTurn()
+ }
+ }
+ voiceResultWork = item
+ DispatchQueue.main.asyncAfter(deadline: .now() + delay, execute: item)
+ }
+
+ /// End conversation window, optionally trigger a farewell emote, then collapse.
+ @MainActor
+ private func endConversation(speaking: Bool) {
+ isInConversation = false
+ conversationContext.reset()
+ voiceResultWork?.cancel()
+ voiceResultWork = nil
+ VoiceEngine.shared.endConversation()
+ if speaking {
+ // Brief farewell emote
+ NotificationCenter.default.post(name: .triggerEmote, object: BotEmote.happy)
+ }
+ scheduleVoiceDismiss(delay: 0.5)
+ }
+
@MainActor
private func scheduleVoiceDismiss(delay: TimeInterval) {
voiceResultWork?.cancel()
diff --git a/NotchBuddy/Sources/App/SettingsView.swift b/NotchBuddy/Sources/App/SettingsView.swift
index ddbaf97a..318bafa4 100644
--- a/NotchBuddy/Sources/App/SettingsView.swift
+++ b/NotchBuddy/Sources/App/SettingsView.swift
@@ -1265,6 +1265,11 @@ struct SettingsView: View {
Toggle(String(localized: "Enable voice command"), isOn: $voiceEngine.isEnabled)
.disabled(!voicePermissionsGranted && !voiceEngine.isEnabled)
+ Toggle(String(localized: "voice.setting-speak"), isOn: Binding(
+ get: { VoiceSettings.speakEnabled },
+ set: { VoiceSettings.speakEnabled = $0 }
+ ))
+
Text("When enabled, Coucou listens for the wake word «\u{202F}OK Coucou\u{202F}». Speech recognition runs entirely on-device — no audio or transcript leaves your Mac.")
.font(.system(size: 11))
.foregroundColor(.secondary)
@@ -1292,6 +1297,21 @@ struct SettingsView: View {
}
}
+ // Local model status
+ #if canImport(FoundationModels)
+ if #available(macOS 26, *) {
+ let status = VoiceBrain.shared.modelStatus
+ HStack(spacing: 6) {
+ Image(systemName: status == .available ? "cpu.fill" : "cpu")
+ .foregroundColor(status == .available ? .green : .secondary)
+ Text(localModelStatusLabel(status))
+ .font(.system(size: 11))
+ .foregroundColor(.secondary)
+ .fixedSize(horizontal: false, vertical: true)
+ }
+ }
+ #endif
+
if let err = voiceEngine.audioError {
HStack(spacing: 6) {
Image(systemName: "exclamationmark.triangle.fill")
@@ -1338,6 +1358,17 @@ struct SettingsView: View {
}
}
+ #if !APPSTORE
+ private func localModelStatusLabel(_ status: LocalModelStatus) -> String {
+ switch status {
+ case .available: return String(localized: "voice.model-available")
+ case .notMacOS26: return String(localized: "voice.model-not-macos26")
+ case .appleIntelligenceOff: return String(localized: "voice.model-ai-off")
+ case .languageUnsupported: return String(localized: "voice.model-lang")
+ }
+ }
+ #endif
+
private var micStatusIcon: String { VoiceSettings.micStatus == .granted ? "checkmark.circle.fill" : "xmark.circle.fill" }
private var micStatusColor: Color { VoiceSettings.micStatus == .granted ? .green : .red }
private var micStatusLabel: String {
diff --git a/NotchBuddy/Sources/App/Voice/ConversationContext.swift b/NotchBuddy/Sources/App/Voice/ConversationContext.swift
new file mode 100644
index 00000000..251e5801
--- /dev/null
+++ b/NotchBuddy/Sources/App/Voice/ConversationContext.swift
@@ -0,0 +1,104 @@
+#if !APPSTORE
+import Foundation
+
+// MARK: - ConversationContext
+//
+// Tracks the last executed intent so relative follow-up commands can be resolved:
+// • "et Vercel aussi", "pareil pour Stripe", "also X" → same verb, new target
+// • "remets-la", "annule ça", "undo" → inverse of last reversible action
+//
+// Pure value type — no AppKit, no AppState, no I/O.
+struct ConversationContext {
+ private(set) var lastIntent: VoiceIntent? = nil
+
+ /// Update context after a successful turn.
+ mutating func update(_ intent: VoiceIntent) {
+ switch intent {
+ case .pillAdd, .pillAddMultiple, .pillRemove, .pillRemoveMultiple,
+ .pillSetMain, .pillReplace, .musicPlay, .musicPause,
+ .musicVolumeUp, .musicVolumeDown:
+ lastIntent = intent
+ default:
+ break
+ }
+ }
+
+ /// Reset at end of conversation window.
+ mutating func reset() { lastIntent = nil }
+
+ /// Try to resolve `raw` as a relative command given context.
+ /// Returns nil if the phrase is not relative (caller should parse normally).
+ func resolveRelative(_ raw: String, pills: [PillDefinition]) -> VoiceIntent? {
+ let norm = IntentParser.normalise(raw)
+ let words = norm.split(separator: " ").map(String.init)
+ if let same = resolveSameTarget(norm: norm, words: words, pills: pills) { return same }
+ if let rev = resolveReverse(norm: norm) { return rev }
+ return nil
+ }
+
+ // MARK: - Same-action, new target
+
+ // Patterns: "et X aussi", "aussi X", "pareil pour X", "idem pour X", "also X", "same for X"
+ private func resolveSameTarget(norm: String, words: [String], pills: [PillDefinition]) -> VoiceIntent? {
+ guard let last = lastIntent else { return nil }
+ var entityWords: [String]? = nil
+
+ if words.first == "et", let aussiIdx = words.firstIndex(of: "aussi"), aussiIdx > 1 {
+ entityWords = Array(words[1..<aussiIdx])
+ } else if words.first == "aussi", words.count > 1 {
+ entityWords = Array(words[1...])
+ } else if words.first == "pareil", words.count > 2,
+ (words[1] == "pour" || words[1] == "avec" || words[1] == "de") {
+ entityWords = Array(words[2...])
+ } else if words.first == "pareil", words.count > 1 {
+ entityWords = Array(words[1...])
+ } else if words.first == "idem", words.count > 2,
+ (words[1] == "pour" || words[1] == "avec") {
+ entityWords = Array(words[2...])
+ } else if words.first == "idem", words.count > 1 {
+ entityWords = Array(words[1...])
+ } else if words.first == "also", words.count > 1 {
+ entityWords = Array(words[1...])
+ } else if words.first == "same", words.count > 2, words[1] == "for" {
+ entityWords = Array(words[2...])
+ }
+
+ guard let ew = entityWords, !ew.isEmpty else { return nil }
+ let entity = ew.joined(separator: " ")
+ guard let pillId = EntityResolver.resolve(entity, from: pills) else { return nil }
+
+ switch last {
+ case .pillAdd: return .pillAdd(id: pillId)
+ case .pillAddMultiple: return .pillAdd(id: pillId)
+ case .pillRemove: return .pillRemove(id: pillId)
+ case .pillRemoveMultiple: return .pillRemove(id: pillId)
+ case .pillSetMain: return .pillSetMain(id: pillId)
+ default: return nil
+ }
+ }
+
+ // MARK: - Reverse / undo
+
+ // Triggers: "remets la", "remets le", "annule ca", "annule", "undo", "defait",
+ // "cancel that", "undo this"
+ private func resolveReverse(norm: String) -> VoiceIntent? {
+ let triggers = ["remets la", "remets le", "annule ca", "annule", "undo", "defait",
+ "cancel that", "undo this"]
+ let isReverse = triggers.contains { norm == $0 || norm.hasPrefix($0 + " ") }
+ guard isReverse, let last = lastIntent else { return nil }
+ return inverse(of: last)
+ }
+
+ private func inverse(of intent: VoiceIntent) -> VoiceIntent? {
+ switch intent {
+ case .pillAdd(let id): return .pillRemove(id: id)
+ case .pillRemove(let id): return .pillAdd(id: id)
+ case .musicPause: return .musicPlay(target: nil)
+ case .musicPlay: return .musicPause
+ case .musicVolumeUp: return .musicVolumeDown
+ case .musicVolumeDown: return .musicVolumeUp
+ default: return nil
+ }
+ }
+}
+#endif
diff --git a/NotchBuddy/Sources/App/Voice/EntityResolver.swift b/NotchBuddy/Sources/App/Voice/EntityResolver.swift
index 9b601dee..55f3bb85 100644
--- a/NotchBuddy/Sources/App/Voice/EntityResolver.swift
+++ b/NotchBuddy/Sources/App/Voice/EntityResolver.swift
@@ -35,6 +35,15 @@ enum EntityResolver {
"anthropic": "ai_anthropic",
// Services
"github": "integration_github",
+ // GitHub phonetic variants (speech recognition mishears)
+ "gt": "integration_github",
+ "g t": "integration_github",
+ "git hub": "integration_github",
+ "jit hub": "integration_github",
+ "guitare hub": "integration_github",
+ "guitar hub": "integration_github",
+ "gitub": "integration_github",
+ "guit hub": "integration_github",
"vercel": "integration_vercel",
"notion": "integration_notion",
"stripe": "integration_stripe",
diff --git a/NotchBuddy/Sources/App/Voice/LiveVoiceControls.swift b/NotchBuddy/Sources/App/Voice/LiveVoiceControls.swift
index 9a47a686..7aa53609 100644
--- a/NotchBuddy/Sources/App/Voice/LiveVoiceControls.swift
+++ b/NotchBuddy/Sources/App/Voice/LiveVoiceControls.swift
@@ -61,6 +61,17 @@ final class LiveMusicControl: MusicControlling, @unchecked Sendable {
try? await Task.sleep(nanoseconds: 1_500_000_000)
if isSpotifyRunning { SpotifyController.shared.play() }
}
+ @MainActor func openSearch(_ name: String) {
+ guard let encoded = name.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed),
+ let url = URL(string: "https://music.apple.com/search?term=\(encoded)") else { return }
+ // Open in Apple Music app, not the browser
+ if let appURL = NSWorkspace.shared.urlForApplication(withBundleIdentifier: "com.apple.Music") {
+ let config = NSWorkspace.OpenConfiguration()
+ NSWorkspace.shared.open([url], withApplicationAt: appURL, configuration: config)
+ } else {
+ NSWorkspace.shared.open(url)
+ }
+ }
}
// MARK: - LivePillControl
diff --git a/NotchBuddy/Sources/App/Voice/TurnEndPolicy.swift b/NotchBuddy/Sources/App/Voice/TurnEndPolicy.swift
new file mode 100644
index 00000000..a5f3e433
--- /dev/null
+++ b/NotchBuddy/Sources/App/Voice/TurnEndPolicy.swift
@@ -0,0 +1,43 @@
+#if !APPSTORE
+import Foundation
+
+// MARK: - TurnEndPolicy
+//
+// Decides silence duration before ending a command turn.
+// Standalone compilable (used by test scripts via swiftc).
+enum TurnEndPolicy {
+ static let baseSilence: TimeInterval = 1.5
+ static let extendedSilence: TimeInterval = 3.0
+ static let maxTurnTime: TimeInterval = 20.0
+
+ /// Returns the silence timeout given the current *normalised* partial transcript.
+ /// Call with `IntentParser.normalise(rawTranscript)`.
+ static func silenceDelay(for transcript: String) -> TimeInterval {
+ guard !transcript.trimmingCharacters(in: .whitespaces).isEmpty else {
+ return baseSilence
+ }
+ let lastWord = transcript.split(separator: " ").last.map(String.init) ?? ""
+ return extendingWords.contains(lastWord) ? extendedSilence : baseSilence
+ }
+
+ // Words that suggest the utterance is mid-thought and should get extra silence.
+ static let extendingWords: Set<String> = [
+ // FR conjunctions / linkers
+ "et", "puis", "ensuite", "mais", "ou",
+ // EN conjunctions
+ "and", "then", "but", "or",
+ // FR articles / prepositions
+ "de", "du", "le", "la", "les", "des", "un", "une",
+ "a", "au", "aux", "sur", "dans", "avec", "pour",
+ // EN articles / prepositions
+ "the", "to", "on", "of", "in", "at", "with", "for",
+ // FR bare action verbs (imperative without object)
+ "ajoute", "enleve", "retire", "supprime", "desactive", "active",
+ "mets", "met", "lance", "joue", "balance", "demarre",
+ "monte", "baisse", "coupe", "arrete",
+ // EN bare action verbs
+ "add", "remove", "disable", "enable", "play", "start",
+ "increase", "decrease", "set",
+ ]
+}
+#endif
diff --git a/NotchBuddy/Sources/App/Voice/VoiceActionRunner.swift b/NotchBuddy/Sources/App/Voice/VoiceActionRunner.swift
index 606ffa9d..84b69e61 100644
--- a/NotchBuddy/Sources/App/Voice/VoiceActionRunner.swift
+++ b/NotchBuddy/Sources/App/Voice/VoiceActionRunner.swift
@@ -18,6 +18,7 @@ protocol MusicControlling: Sendable {
@MainActor func playPlaylist(_ name: String) async -> Bool
@MainActor func launchAndPlay() async
@MainActor func launchSpotify() async
+ @MainActor func openSearch(_ name: String)
}
/// Abstraction over AppState pill management.
@@ -46,6 +47,7 @@ private final class NullMusic: MusicControlling, @unchecked Sendable {
@MainActor func playPlaylist(_ n: String) async -> Bool { false }
@MainActor func launchAndPlay() async {}
@MainActor func launchSpotify() async {}
+ @MainActor func openSearch(_ name: String) {}
}
@MainActor
@@ -157,7 +159,9 @@ final class VoiceActionRunner {
}
let found = await music.playSearch(name)
if found { return ok("voice.music-playing") }
- let fmt = Self.localizedString("voice.music-artist-err", locale: commandLocale)
+ // Not in library — open Apple Music search
+ music.openSearch(name)
+ let fmt = Self.localizedString("voice.music-search-opened", locale: commandLocale)
return .init(outcome: .failure,
message: fmt.contains("%@") ? String(format: fmt, name) : name)
diff --git a/NotchBuddy/Sources/App/Voice/VoiceBrain.swift b/NotchBuddy/Sources/App/Voice/VoiceBrain.swift
new file mode 100644
index 00000000..0af7a06d
--- /dev/null
+++ b/NotchBuddy/Sources/App/Voice/VoiceBrain.swift
@@ -0,0 +1,118 @@
+#if !APPSTORE
+import Foundation
+#if canImport(FoundationModels)
+import FoundationModels
+#endif
+
+// MARK: - LocalModelStatus
+// Exposed outside the FoundationModels guard so SettingsView can reference it on macOS 15.
+enum LocalModelStatus {
+ case available
+ case notMacOS26 // running on macOS < 26 or device not eligible
+ case appleIntelligenceOff
+ case languageUnsupported
+}
+
+// MARK: - VoiceBrain
+//
+// macOS 26 + Apple Intelligence: uses a LanguageModelSession per conversation.
+// On macOS < 26 or when Apple Intelligence is off, every call returns nil immediately
+// and the caller falls back to IntentParser + ConversationContext.
+//
+// Thread: @MainActor throughout.
+@MainActor
+final class VoiceBrain {
+ static let shared = VoiceBrain()
+
+ /// Current model availability status, updated lazily.
+ private(set) var modelStatus: LocalModelStatus
+
+ /// Opaque session holder — avoids @available on stored property.
+ private var sessionBox: AnyObject? = nil
+
+ private init() {
+ modelStatus = VoiceBrain._checkStatus()
+ }
+
+ // MARK: - Conversation lifecycle
+
+ func beginConversation() {
+ sessionBox = VoiceBrain._makeSession()
+ }
+
+ func endConversation() {
+ sessionBox = nil
+ }
+
+ // MARK: - Intent resolution
+
+ /// Try to resolve `transcript` using the language model.
+ /// Returns nil if the model is unavailable, or if the model cannot map to a VoiceIntent.
+ func resolve(_ transcript: String, pills: [PillDefinition]) async -> VoiceIntent? {
+ await VoiceBrain._resolve(transcript, pills: pills, sessionBox: sessionBox)
+ }
+
+ // MARK: - Static impl helpers
+
+ static func _checkStatus() -> LocalModelStatus {
+ #if canImport(FoundationModels)
+ if #available(macOS 26, *) {
+ switch SystemLanguageModel.default.availability {
+ case .available:
+ return .available
+ case .unavailable(let reason):
+ switch reason {
+ case .appleIntelligenceNotEnabled:
+ return .appleIntelligenceOff
+ case .deviceNotEligible:
+ return .notMacOS26
+ default:
+ return .notMacOS26
+ }
+ @unknown default:
+ return .notMacOS26
+ }
+ }
+ #endif
+ return .notMacOS26
+ }
+
+ static func _makeSession() -> AnyObject? {
+ #if canImport(FoundationModels)
+ if #available(macOS 26, *) {
+ guard SystemLanguageModel.default.availability == .available else { return nil }
+ return LanguageModelSession(
+ instructions: """
+ Tu es Coucou, un assistant dans le notch du MacBook.
+ Réponds toujours dans la langue de l'utilisateur.
+ Réponds avec une phrase courte.
+ """
+ )
+ }
+ #endif
+ return nil
+ }
+
+ static func _resolve(_ transcript: String,
+ pills: [PillDefinition],
+ sessionBox: AnyObject?) async -> VoiceIntent? {
+ #if canImport(FoundationModels)
+ if #available(macOS 26, *) {
+ guard SystemLanguageModel.default.availability == .available else { return nil }
+ guard let session = sessionBox as? LanguageModelSession else { return nil }
+ do {
+ let prompt = "User said: \"\(transcript)\". Available pill names: \(pills.map(\.name).joined(separator: ", ")). Is this a command or a question? Respond in one sentence."
+ _ = try await session.respond(to: prompt)
+ // For now: VoiceBrain provides the fallback text answer (to be spoken),
+ // but returns nil to VoiceIntent so execution falls through to .unknown.
+ return nil
+ } catch {
+ return nil
+ }
+ }
+ #endif
+ return nil
+ }
+}
+
+#endif // !APPSTORE
diff --git a/NotchBuddy/Sources/App/Voice/VoiceEngine.swift b/NotchBuddy/Sources/App/Voice/VoiceEngine.swift
index 4f9a23d6..bf2ce1a7 100644
--- a/NotchBuddy/Sources/App/Voice/VoiceEngine.swift
+++ b/NotchBuddy/Sources/App/Voice/VoiceEngine.swift
@@ -87,8 +87,12 @@ final class VoiceEngine: ObservableObject {
/// Initial silence timeout for the current direct-listen session.
private var directInitialTimeout: TimeInterval = 3.0
- private static let silenceTimeout: TimeInterval = 1.2
- private static let commandMaxTime: TimeInterval = 10.0
+ private static let silenceTimeout: TimeInterval = 1.5
+ private static let commandMaxTime: TimeInterval = 20.0
+
+ // Conversation window
+ private(set) var isInConversation: Bool = false
+ private var conversationTurnWork: DispatchWorkItem? = nil
private static let wakeWindowMax: TimeInterval = 20.0
private static let stallTimeout: TimeInterval = 2.0
private static let unavailableRebuildDelay: TimeInterval = 10.0
@@ -96,6 +100,10 @@ final class VoiceEngine: ObservableObject {
private static let maxRebuildsPerMinute = 5
private static let cancelPhrases = ["annule", "annuler", "cancel", "laisse tomber", "never mind"]
+ private static let conversationEndPhrases: Set<String> = [
+ "merci", "c est bon", "c'est bon", "that s all", "that's all", "stop",
+ "laisse tomber", "annule", "annuler", "cancel", "never mind", "bye", "au revoir",
+ ]
// MARK: - Init
@@ -104,6 +112,13 @@ final class VoiceEngine: ObservableObject {
let buildHash = Bundle.main.object(forInfoDictionaryKey: "CoucouGitHash") as? String ?? "unknown"
appendAppLog("nb.log", "[Voice] build \(buildHash)")
observeSystemEvents()
+ VoiceSpeaker.shared.onDidFinish = { [weak self] in
+ Task { @MainActor in
+ guard let self, self.isListeningForCommand else { return }
+ self.audio?.resetVAD()
+ appendAppLog("nb.log", "[Voice] speaker finished, VAD recalibrated")
+ }
+ }
if isEnabled && !isPaused { startAudioPipeline() }
}
@@ -121,6 +136,21 @@ final class VoiceEngine: ObservableObject {
func cancelListening() { endCommand(postFinished: false) }
+ /// Start the next conversation turn (re-listen for 8 s without wake phrase).
+ /// Called by IslandWindowController after showing a command result.
+ func startConversationTurn() {
+ isInConversation = true
+ startListeningDirectly(firstWordTimeout: 8.0)
+ }
+
+ /// End the conversation window and return to normal wake-phrase mode.
+ func endConversation() {
+ isInConversation = false
+ conversationTurnWork?.cancel()
+ conversationTurnWork = nil
+ endCommand(postFinished: false)
+ }
+
/// `firstWordTimeout`: seconds of silence allowed before the first word (default 3 s;
/// pass `Self.directListenInitialTimeout` = 5 s for follow-up questions so the user
/// has time to read the question before speaking).
@@ -165,6 +195,7 @@ final class VoiceEngine: ObservableObject {
let a = VoiceAudio()
let s = WakeSpotter()
+ s.additionalContextualStrings = PillCatalog.available.map { $0.name }
// ── Spotter callbacks ─────────────────────────────────────────────────
@@ -485,13 +516,19 @@ final class VoiceEngine: ObservableObject {
}
private func commandUpdate(_ command: String) {
+ // Semi-duplex: ignore updates while Coucou is speaking.
+ guard !VoiceSpeaker.shared.isSpeaking else { return }
commandTranscript = command
let wc = command.split(separator: " ").count
if wc > lastWordCount {
lastWordCount = wc
resetSilenceTimer()
let trimmed = command.trimmingCharacters(in: .whitespaces)
- if Self.cancelPhrases.contains(WakePhrase.normalise(trimmed)) {
+ let normTrimmed = WakePhrase.normalise(trimmed)
+ if Self.cancelPhrases.contains(normTrimmed) {
+ endCommand(postFinished: true)
+ } else if isInConversation && Self.conversationEndPhrases.contains(normTrimmed) {
+ // Post voiceFinished with the end phrase so IslandWindowController can handle cleanup
endCommand(postFinished: true)
}
}
@@ -501,7 +538,12 @@ final class VoiceEngine: ObservableObject {
private func resetSilenceTimer() {
silenceWork?.cancel()
- let timeout = lastWordCount > 0 ? Self.silenceTimeout : directInitialTimeout
+ let timeout: TimeInterval
+ if lastWordCount == 0 {
+ timeout = directInitialTimeout
+ } else {
+ timeout = TurnEndPolicy.silenceDelay(for: WakePhrase.normalise(commandTranscript))
+ }
let item = DispatchWorkItem { [weak self] in
Task { @MainActor in self?.endCommand(postFinished: true) }
}
diff --git a/NotchBuddy/Sources/App/Voice/VoiceSettings.swift b/NotchBuddy/Sources/App/Voice/VoiceSettings.swift
index fe1b401b..350d2b5e 100644
--- a/NotchBuddy/Sources/App/Voice/VoiceSettings.swift
+++ b/NotchBuddy/Sources/App/Voice/VoiceSettings.swift
@@ -6,13 +6,24 @@ import Speech
/// Persisted voice feature settings and permission helpers.
enum VoiceSettings {
- static let enabledKey = "voiceEnabled"
+ static let enabledKey = "voiceEnabled"
+ static let speakEnabledKey = "voiceSpeakEnabled"
static var isEnabled: Bool {
get { UserDefaults.standard.bool(forKey: enabledKey) }
set { UserDefaults.standard.set(newValue, forKey: enabledKey) }
}
+ /// Coucou responds aloud after each command. Default: on.
+ static var speakEnabled: Bool {
+ get {
+ let d = UserDefaults.standard
+ if d.object(forKey: speakEnabledKey) == nil { return true } // default on
+ return d.bool(forKey: speakEnabledKey)
+ }
+ set { UserDefaults.standard.set(newValue, forKey: speakEnabledKey) }
+ }
+
// MARK: - Permissions
enum PermissionStatus { case granted, denied, undetermined }
diff --git a/NotchBuddy/Sources/App/Voice/VoiceSpeaker.swift b/NotchBuddy/Sources/App/Voice/VoiceSpeaker.swift
new file mode 100644
index 00000000..b0a46cee
--- /dev/null
+++ b/NotchBuddy/Sources/App/Voice/VoiceSpeaker.swift
@@ -0,0 +1,63 @@
+#if !APPSTORE
+import AVFoundation
+
+// MARK: - VoiceSpeaker
+//
+// Gives Mochi a voice: wraps AVSpeechSynthesizer with a Mochi-like pitch.
+// Semi-duplex: VoiceEngine pauses recognition while this is speaking.
+// Setting: VoiceSettings.speakEnabled (default on).
+//
+// All methods: @MainActor.
+@MainActor
+final class VoiceSpeaker: NSObject, AVSpeechSynthesizerDelegate, @unchecked Sendable {
+ static let shared = VoiceSpeaker()
+
+ private let synth = AVSpeechSynthesizer()
+ private(set) var isSpeaking = false
+
+ /// Called ~300 ms after the utterance finishes. VoiceEngine uses this to resume listening.
+ var onDidFinish: (() -> Void)?
+
+ override init() {
+ super.init()
+ synth.delegate = self
+ }
+
+ func speak(_ text: String, locale: Locale?) {
+ guard VoiceSettings.speakEnabled else { return }
+ synth.stopSpeaking(at: .immediate)
+ isSpeaking = false
+ let utt = AVSpeechUtterance(string: text)
+ utt.pitchMultiplier = 1.25
+ utt.rate = AVSpeechUtteranceDefaultSpeechRate * 1.05
+ if let loc = locale {
+ let lang = loc.language.languageCode?.identifier ?? ""
+ if !lang.isEmpty { utt.voice = AVSpeechSynthesisVoice(language: lang) }
+ }
+ isSpeaking = true
+ synth.speak(utt)
+ }
+
+ func stop() {
+ guard isSpeaking else { return }
+ synth.stopSpeaking(at: .immediate)
+ // isSpeaking set to false in didCancel/didFinish delegate callbacks
+ }
+
+ // MARK: - AVSpeechSynthesizerDelegate
+
+ nonisolated func speechSynthesizer(_ synthesizer: AVSpeechSynthesizer,
+ didFinish utterance: AVSpeechUtterance) {
+ Task { @MainActor in
+ self.isSpeaking = false
+ try? await Task.sleep(nanoseconds: 300_000_000) // 300 ms gap
+ self.onDidFinish?()
+ }
+ }
+
+ nonisolated func speechSynthesizer(_ synthesizer: AVSpeechSynthesizer,
+ didCancel utterance: AVSpeechUtterance) {
+ Task { @MainActor in self.isSpeaking = false }
+ }
+}
+#endif
diff --git a/NotchBuddy/Sources/App/Voice/WakeSpotter.swift b/NotchBuddy/Sources/App/Voice/WakeSpotter.swift
index 28acb0a9..22fdc1db 100644
--- a/NotchBuddy/Sources/App/Voice/WakeSpotter.swift
+++ b/NotchBuddy/Sources/App/Voice/WakeSpotter.swift
@@ -36,6 +36,10 @@ final class WakeSpotter: @unchecked Sendable {
/// timeout (1110) and cancellations — those do not count as backoff failures.
var onWakeWindowEnded: ((Bool) -> Void)?
+ /// Extra strings to add to the recognizer's contextual hints (e.g. pill names).
+ /// Set before calling `beginWindow`. Thread-safe (read under `lock`).
+ var additionalContextualStrings: [String] = []
+
// MARK: - State (all guarded by `lock`)
private let lock = NSLock()
@@ -77,7 +81,8 @@ final class WakeSpotter: @unchecked Sendable {
let req = SFSpeechAudioBufferRecognitionRequest()
req.shouldReportPartialResults = true
req.requiresOnDeviceRecognition = true
- req.contextualStrings = ["Coucou", "OK Coucou", "okay Coucou", "hey Coucou"]
+ let extra = additionalContextualStrings
+ req.contextualStrings = ["Coucou", "OK Coucou", "okay Coucou", "hey Coucou"] + extra
preroll.forEach { req.append($0) }
recognizer = r
diff --git a/scripts/test-conversation-context.sh b/scripts/test-conversation-context.sh
new file mode 100755
index 00000000..851b41e6
--- /dev/null
+++ b/scripts/test-conversation-context.sh
@@ -0,0 +1,15 @@
+#!/usr/bin/env bash
+set -euo pipefail
+ROOT="$(cd "$(dirname "$0")/.." && pwd)"
+OUT=/tmp/conversation-context-tests
+echo "=== ConversationContext tests ==="
+swiftc -swift-version 6 -strict-concurrency=complete \
+ "$ROOT/tests/VoiceTestStubs.swift" \
+ "$ROOT/tests/PillFixture.swift" \
+ "$ROOT/NotchBuddy/Sources/App/Voice/VoiceIntent.swift" \
+ "$ROOT/NotchBuddy/Sources/App/Voice/IntentParser.swift" \
+ "$ROOT/NotchBuddy/Sources/App/Voice/EntityResolver.swift" \
+ "$ROOT/NotchBuddy/Sources/App/Voice/ConversationContext.swift" \
+ "$ROOT/tests/ConversationContextTests.swift" \
+ -o "$OUT"
+"$OUT"
diff --git a/scripts/test-turn-end-policy.sh b/scripts/test-turn-end-policy.sh
new file mode 100755
index 00000000..7e082bee
--- /dev/null
+++ b/scripts/test-turn-end-policy.sh
@@ -0,0 +1,11 @@
+#!/usr/bin/env bash
+set -euo pipefail
+ROOT="$(cd "$(dirname "$0")/.." && pwd)"
+OUT=/tmp/turn-end-policy-tests
+echo "=== TurnEndPolicy tests ==="
+swiftc -swift-version 6 -strict-concurrency=complete \
+ "$ROOT/tests/IslandTypeStubs.swift" \
+ "$ROOT/NotchBuddy/Sources/App/Voice/TurnEndPolicy.swift" \
+ "$ROOT/tests/TurnEndPolicyTests.swift" \
+ -o "$OUT"
+"$OUT"
diff --git a/tests/ConversationContextTests.swift b/tests/ConversationContextTests.swift
new file mode 100644
index 00000000..f7a1e6ce
--- /dev/null
+++ b/tests/ConversationContextTests.swift
@@ -0,0 +1,70 @@
+import Foundation
+
+@main
+enum ConversationContextTests {
+ static let pills = PillFixture.available
+
+ static func main() {
+ testNoContextReturnsNil()
+ testSameTarget_aussiFR()
+ testSameTarget_pareilPour()
+ testSameTarget_also()
+ testReverse_pillAdd()
+ testReverse_musicPause()
+ testUnknownNotStored()
+ print("ConversationContextTests: all cases passed")
+ }
+
+ static func testNoContextReturnsNil() {
+ let ctx = ConversationContext()
+ precondition(ctx.resolveRelative("et Vercel aussi", pills: pills) == nil,
+ "no context → nil")
+ }
+
+ static func testSameTarget_aussiFR() {
+ var ctx = ConversationContext()
+ ctx.update(.pillAdd(id: "integration_github"))
+ let r = ctx.resolveRelative("et vercel aussi", pills: pills)
+ precondition(r == .pillAdd(id: "integration_vercel"),
+ "et X aussi → pillAdd with X")
+ }
+
+ static func testSameTarget_pareilPour() {
+ var ctx = ConversationContext()
+ ctx.update(.pillRemove(id: "integration_github"))
+ let r = ctx.resolveRelative("pareil pour stripe", pills: pills)
+ precondition(r == .pillRemove(id: "integration_stripe"),
+ "pareil pour X → pillRemove with X")
+ }
+
+ static func testSameTarget_also() {
+ var ctx = ConversationContext()
+ ctx.update(.pillAdd(id: "integration_vercel"))
+ let r = ctx.resolveRelative("also stripe", pills: pills)
+ precondition(r == .pillAdd(id: "integration_stripe"),
+ "also X → pillAdd with X")
+ }
+
+ static func testReverse_pillAdd() {
+ var ctx = ConversationContext()
+ ctx.update(.pillAdd(id: "integration_github"))
+ let r = ctx.resolveRelative("annule", pills: pills)
+ precondition(r == .pillRemove(id: "integration_github"),
+ "annule after pillAdd → pillRemove")
+ }
+
+ static func testReverse_musicPause() {
+ var ctx = ConversationContext()
+ ctx.update(.musicPause)
+ let r = ctx.resolveRelative("undo", pills: pills)
+ precondition(r == .musicPlay(target: nil),
+ "undo after musicPause → musicPlay")
+ }
+
+ static func testUnknownNotStored() {
+ var ctx = ConversationContext()
+ ctx.update(.unknown)
+ precondition(ctx.lastIntent == nil,
+ ".unknown should not be stored in context")
+ }
+}
diff --git a/tests/EntityResolverTests.swift b/tests/EntityResolverTests.swift
index b54d7fe7..0f6fc4d9 100644
--- a/tests/EntityResolverTests.swift
+++ b/tests/EntityResolverTests.swift
@@ -67,6 +67,15 @@ enum EntityResolverTests {
checkNil("GitHub not workspace", resolve("GitHub", cat: .workspace))
checkNil("gemini not workspace", resolve("gemini", cat: .workspace))
+ // ── GitHub phonetic aliases ───────────────────────────────────────────
+ check("git hub", resolve("git hub"), "integration_github")
+ check("jit hub", resolve("jit hub"), "integration_github")
+ check("guitare hub", resolve("guitare hub"), "integration_github")
+ check("guitar hub", resolve("guitar hub"), "integration_github")
+ check("gitub (typo)", resolve("gitub"), "integration_github")
+ check("g t", resolve("g t"), "integration_github")
+ check("gt alias", resolve("gt"), "integration_github")
+
// ── Levenshtein distance ──────────────────────────────────────────────
let lev = EntityResolver.levenshtein
checkDist("abc/abc", lev("abc", "abc"), 0)
diff --git a/tests/TurnEndPolicyTests.swift b/tests/TurnEndPolicyTests.swift
new file mode 100644
index 00000000..740d62fc
--- /dev/null
+++ b/tests/TurnEndPolicyTests.swift
@@ -0,0 +1,41 @@
+import Foundation
+
+@main
+enum TurnEndPolicyTests {
+ static func main() {
+ // baseSilence for empty transcript
+ precondition(TurnEndPolicy.silenceDelay(for: "") == TurnEndPolicy.baseSilence,
+ "empty → baseSilence")
+
+ // baseSilence for normal word
+ precondition(TurnEndPolicy.silenceDelay(for: "mets gemini") == TurnEndPolicy.baseSilence,
+ "normal word → baseSilence")
+
+ // extendedSilence for conjunction
+ precondition(TurnEndPolicy.silenceDelay(for: "mets gemini et") == TurnEndPolicy.extendedSilence,
+ "ends with 'et' → extendedSilence")
+
+ // extendedSilence for article
+ precondition(TurnEndPolicy.silenceDelay(for: "ajoute le") == TurnEndPolicy.extendedSilence,
+ "ends with 'le' → extendedSilence")
+
+ // extendedSilence for bare verb
+ precondition(TurnEndPolicy.silenceDelay(for: "ajoute") == TurnEndPolicy.extendedSilence,
+ "bare action verb → extendedSilence")
+
+ // extendedSilence for EN conjunction
+ precondition(TurnEndPolicy.silenceDelay(for: "add github and") == TurnEndPolicy.extendedSilence,
+ "ends with 'and' → extendedSilence")
+
+ // baseSilence for complete command
+ precondition(TurnEndPolicy.silenceDelay(for: "ajoute github") == TurnEndPolicy.baseSilence,
+ "complete command → baseSilence")
+
+ // Constants
+ precondition(TurnEndPolicy.baseSilence == 1.5, "baseSilence == 1.5")
+ precondition(TurnEndPolicy.extendedSilence == 3.0, "extendedSilence == 3.0")
+ precondition(TurnEndPolicy.maxTurnTime == 20.0, "maxTurnTime == 20.0")
+
+ print("TurnEndPolicyTests: all cases passed")
+ }
+}
diff --git a/tests/VoiceActionRunnerTests.swift b/tests/VoiceActionRunnerTests.swift
index a111365d..6eaaa5a3 100644
--- a/tests/VoiceActionRunnerTests.swift
+++ b/tests/VoiceActionRunnerTests.swift
@@ -23,6 +23,7 @@ final class MockMusic: MusicControlling, @unchecked Sendable {
@MainActor func playPlaylist(_ n: String) async -> Bool { calls.append("playlist:\(n)"); return playlistResult }
@MainActor func launchAndPlay() async { calls.append("launchAndPlay") }
@MainActor func launchSpotify() async { calls.append("launchSpotify") }
+ @MainActor func openSearch(_ n: String) { calls.append("openSearch:\(n)") }
}
@MainActor