Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
fix(voice): close remaining wake handoff races
Ruben Lütke3b66be9d77ef
diff --git a/jarvis/speech/pipeline.py b/jarvis/speech/pipeline.pyindex 042b03591c..bfbd7224c7 100644--- a/jarvis/speech/pipeline.py+++ b/jarvis/speech/pipeline.py@@ -1037,10 +1037,10 @@ def _looks_like_complete_smalltalk(text: str) -> bool:async def _queue_iter(q: asyncio.Queue) -> AsyncIterator[AudioChunk]:- """Hilfs-Adapter: Queue → AsyncIterator (für die Wake-Detektoren)."""+ """Adapt a queue into an async iterator for wake detectors."""while True:chunk = await q.get()- if chunk is None: # Poison-Pill+ if chunk is None: # Sentinelreturnyield chunk@@ -3738,7 +3738,7 @@ class SpeechPipeline:hotkey_bindings["ptt"] = list(self._ptt_hotkeys)ptt_events.add("ptt")log.info(- "Pipeline bereit. CALL=[%s] PTT=[%s] HANGUP=[%s] OWW=%s WAKE=%s (threshold=%.2f) "+ "Pipeline ready. CALL=[%s] PTT=[%s] HANGUP=[%s] OWW=%s WAKE=%s (threshold=%.2f) ""WHISPER-WAKE=%s TURN-MODE=%s",", ".join(self._call_hotkeys),", ".join(self._ptt_hotkeys) or "off",@@ -3788,7 +3788,9 @@ class SpeechPipeline:if wake_task is not None:wake_task.add_done_callback(_log_task_exit)else:- log.info("Wake-Listener deaktiviert; Mikrofon bleibt bis zum Hotkey-Call geschlossen.")+ log.info(+ "Wake listener disabled; microphone stays closed until a hotkey call."+ )main_task = asyncio.create_task(self._state_loop(), name="state")main_task.add_done_callback(_log_task_exit)@@ -4427,11 +4429,20 @@ class SpeechPipeline:and getattr(self, "_wake_handoff_ready", None)and self._wake_handoff_ready.is_set())+ candidate_active = bool(+ getattr(self, "_state", PipelineState.IDLE) is PipelineState.IDLE+ and getattr(self, "_wake_preroll_active", False)+ )if handoff_ready and handoff_close is not None:# Set synchronously on the caller thread. The owner-loop callback# can otherwise lose a race with the already-armed state task.handoff_close.set()- if pending is not None and pending.is_set() and not handoff_ready:+ if (+ pending is not None+ and pending.is_set()+ and not handoff_ready+ and not candidate_active+ ):log.debug("request_hangup ignored: external hangup already pending")returnif pending is not None:diff --git a/tests/unit/speech/test_request_hangup_threadsafe.py b/tests/unit/speech/test_request_hangup_threadsafe.pyindex 84579e5765..a6d2e06e1a 100644--- a/tests/unit/speech/test_request_hangup_threadsafe.py+++ b/tests/unit/speech/test_request_hangup_threadsafe.py@@ -69,6 +69,24 @@ async def test_visible_wake_candidate_close_cancels_without_starting_session() -assert pipeline._external_hangup_pending.is_set() is False+async def test_stale_idle_hangup_does_not_block_later_candidate_close() -> None:+ loop = asyncio.get_running_loop()+ pipeline = _pipeline(loop)+ pipeline._state = PipelineState.IDLE+ pipeline._wake_preroll_active = True+ pipeline._wake_cancel_event = asyncio.Event()+ pipeline._external_hangup_pending.set()+ pipeline._trigger_voice_hangup = lambda: pytest.fail(+ "candidate close must supersede the stale idle edge"+ )++ pipeline.request_hangup()++ assert pipeline._wake_cancel_event.is_set()+ assert pipeline._external_hangup_pending.is_set() is False++class _QueuedLoop:def __init__(self) -> None:self.callbacks = []diff --git a/ui/orb/bus_bridge.py b/ui/orb/bus_bridge.pyindex 79bef32bdc..3fced3706d 100644--- a/ui/orb/bus_bridge.py+++ b/ui/orb/bus_bridge.py@@ -620,6 +620,12 @@ class OrbBusBridge:# orb is clickable, so the loop is always captured in time.self._remember_loop()state = event.new_state+ if state == "LISTENING":+ # An authoritative supervisor edge can arrive after a late bridge+ # attach even if VoiceSessionStarted itself was missed.+ self._voice_session_active = True+ elif state in {"IDLE", "ERROR", "PAUSED"}:+ self._voice_session_active = Falseif state != "IDLE":# Any authoritative non-idle state supersedes a visual-only wake# preview. Keeping the latch beyond this edge could let a late mic