@@ -175,9 +175,49 @@ async def _trigger_custom_event_subscribers(
175175 }
176176 assert emitted ["event_type" ] == "voice_bridge_result"
177177 assert emitted ["payload" ]["event_id" ] == "voice-2"
178- assert emitted ["payload" ]["result" ] == {
179- "action" : "prime_context" ,
180- "context" : "screen context" ,
181- "source_plugin" : "study_companion" ,
182- "source_event_id" : "handle_transcript" ,
183- }
178+ result = emitted ["payload" ]["result" ]
179+ assert result ["action" ] == "prime_context"
180+ assert result ["context" ] == "screen context"
181+ assert result ["source_plugin" ] == "study_companion"
182+ assert result ["source_event_id" ] == "handle_transcript"
183+
184+
185+ def test_voice_bridge_dispatch_results_are_arbitrated () -> None :
186+ from app import agent_server as srv
187+
188+ result = srv ._voice_bridge_action_from_dispatch_results (
189+ [
190+ {
191+ "plugin_id" : "context_plugin" ,
192+ "event_id" : "prime" ,
193+ "success" : True ,
194+ "result" : {
195+ "action" : "prime_context" ,
196+ "context" : "screen context" ,
197+ "priority" : 100 ,
198+ },
199+ },
200+ {
201+ "plugin_id" : "study_companion" ,
202+ "event_id" : "handle_transcript" ,
203+ "success" : True ,
204+ "result" : {
205+ "action" : "cancel_response" ,
206+ "reason" : "ocr_overlap" ,
207+ "priority" : - 10 ,
208+ },
209+ },
210+ {
211+ "plugin_id" : "broken" ,
212+ "event_id" : "voice" ,
213+ "success" : False ,
214+ "error" : "timeout" ,
215+ },
216+ ]
217+ )
218+
219+ assert result ["action" ] == "cancel_response"
220+ assert result ["reason" ] == "ocr_overlap"
221+ assert result ["source_plugin" ] == "study_companion"
222+ assert result ["source_event_id" ] == "handle_transcript"
223+ assert result ["failures" ] == 1
0 commit comments