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): stop the post-hangup wake lock from swallowing explicit key presses
Ruben Lütke7ae46d516ce7
diff --git a/jarvis/speech/pipeline.py b/jarvis/speech/pipeline.pyindex e82cc35e98..b792c7920a 100644--- a/jarvis/speech/pipeline.py+++ b/jarvis/speech/pipeline.py@@ -1874,6 +1874,16 @@ class SpeechPipeline:self._ptt_mode = Falseself._ptt_release_event = asyncio.Event()self._ptt_max_hold_s = 60.0+ # A DELIBERATE user activation edge (PTT down, CALL hotkey, the+ # "Speak in this conversation" button) is pending in ``_call_event``.+ # The state loop consumes this to exempt exactly that call from the+ # post-hangup wake lock: the lock exists so Jarvis' own speaker tail+ # cannot re-trigger the WAKE WORD (audio echo), and a key press has no+ # echo path. Dropping explicit presses under the lock made recording+ # start only after the lock expired — the user was already talking and+ # the opening 1-3 s of every quick follow-up were missing (live+ # 2026-07-31).+ self._explicit_call_pending = False# While the key is held, re-transcribe the growing buffer every N# seconds and publish it as a non-final TranscriptionUpdate so the orb# bubble shows the live transcript (parity with the wake-word path,@@ -5567,6 +5577,9 @@ class SpeechPipeline:async for event_name in trigger.events():if event_name == "call":log.info("📞 CALL via Hotkey")+ # A deliberate key press — exempt from the post-hangup wake+ # lock (no speaker-echo path), same contract as PTT below.+ self._explicit_call_pending = Trueself._call_event.set()elif event_name == "ptt_press":self._on_ptt_press()@@ -5774,6 +5787,7 @@ class SpeechPipeline:log.info("🎙 PTT DOWN — recording (hold to talk, release to send)")self._ptt_mode = Trueself._ptt_release_event.clear()+ self._explicit_call_pending = Trueself._arm_call_event()def _on_ptt_release(self) -> None:@@ -5834,6 +5848,7 @@ class SpeechPipeline:"Voice session requested (wake-style, seeded=%d turns).",len(seed_messages or []),)+ self._explicit_call_pending = Truereturn self._arm_call_event()def _arm_call_event(self) -> bool:@@ -6711,9 +6726,14 @@ class SpeechPipeline:# needs to re-arm fanout.ring_bytes = bytearray()RING_MAX = 16_000 * 2 * 3 # ~3 s+ # Rolling overlap for the EXPLICIT (hotkey/PTT) handoff seed: it must+ # cover the whole press-to-claim latency — key poll (~20 ms), the+ # cross-thread call edge, one state-loop turn and the stop-event round+ # trip — or the user's first syllables land in the wake detectors+ # instead of the session.recent_chunks: deque[AudioChunk] = deque(- maxlen=capture_chunks_for_duration(0.2)- ) # ~200 ms overlap+ maxlen=capture_chunks_for_duration(0.5)+ ) # ~500 ms overlapwake_confirmed = Falsehandoff_buffer: _SessionInputBuffer | None = None@@ -6787,11 +6807,15 @@ class SpeechPipeline:else:# An explicit click/hotkey may arrive while a wake candidate is# still being verified. Preserve that already-visible interval;- # otherwise keep only one block around the explicit edge.+ # otherwise seed the full rolling overlap. The user starts+ # talking AT the press, and the press precedes this claim by+ # the key-poll + call-edge + state-loop latency — seeding only+ # the last block (the old behaviour) cut the first syllables+ # off every "press and talk" capture.initial = (tuple(self._pending_session_preroll)if self._wake_preroll_active- else tuple(recent_chunks)[-1:]+ else tuple(recent_chunks))self._discard_wake_preroll()handoff_buffer = _SessionInputBuffer(initial=initial)@@ -7156,8 +7180,15 @@ class SpeechPipeline:while True:await self._call_event.wait()self._call_event.clear()- # Ignore activation edges that arrive inside the speaker-echo lock.now = time.time()+ # Consume the explicit-edge marker for THIS call before any gate+ # decides. ``_ptt_mode`` is included defensively: it is only ever+ # armed by a genuine press from IDLE, so it carries the same+ # deliberate-user-action meaning even if the marker was lost.+ explicit_call = bool(+ getattr(self, "_explicit_call_pending", False)+ ) or bool(getattr(self, "_ptt_mode", False))+ self._explicit_call_pending = Falseif not self._activation_allowed():# Resolved, never guessed: this backstop closes for a mute and# for a running dictation too, and a log line that names the@@ -7172,7 +7203,12 @@ class SpeechPipeline:self._ptt_mode = Falseawait self._abort_pending_wake_handoff()continue- if now < self._wake_lock_until:+ if now < self._wake_lock_until and not explicit_call:+ # The speaker-echo lock gates only WAKE-WORD calls: the tail of+ # Jarvis' own TTS can re-trigger the wake word, but it cannot+ # press a key. Dropping explicit presses here made a quick+ # follow-up ("press and talk") record nothing until the lock+ # expired — the opening words of the capture were missing.remaining = self._wake_lock_until - nowlog.info("Wake lock active; ignoring call for %.1fs.", remaining)self._ptt_mode = Falsediff --git a/tests/unit/speech/test_pipeline_push_to_talk.py b/tests/unit/speech/test_pipeline_push_to_talk.pyindex 0dab6dfcb7..e819e61310 100644--- a/tests/unit/speech/test_pipeline_push_to_talk.py+++ b/tests/unit/speech/test_pipeline_push_to_talk.py@@ -21,6 +21,7 @@ import asyncioimport threadingimport timefrom collections.abc import AsyncIterator+from contextlib import asynccontextmanagerfrom types import SimpleNamespacefrom jarvis.core.events import TranscriptionUpdate@@ -242,18 +243,79 @@ async def _pump_state_loop_once(pipe: SpeechPipeline) -> None:pass-async def test_wake_lock_discards_call_and_clears_ptt_mode():- """A PTT press whose call lands during the post-hangup wake-lock is- dropped by the state loop — and must NOT leave ``_ptt_mode`` armed, or the- next wake-word call would wrongly enter the keyless raw-recording path."""+async def test_wake_lock_discards_wake_word_call():+ """A WAKE-WORD call landing inside the post-hangup wake-lock is dropped:+ the lock exists precisely so Jarvis' own speaker tail cannot re-trigger+ the wake word. No explicit edge → the lock applies."""pipe = _make_pipeline()pipe._wake_lock_until = time.time() + 100.0 # lock wide open- pipe._ptt_mode = Truepipe._call_event.set()+ ran = {"session": False}++ async def fake_active_session(*, input_buffer=None): # noqa: ANN001+ ran["session"] = True+ return HANGUP_TURN_COMPLETE++ pipe._active_session = fake_active_session # type: ignore[method-assign]await _pump_state_loop_once(pipe)- assert pipe._ptt_mode is False+ assert ran["session"] is False+ assert pipe._state == PipelineState.IDLE+++def _accepting_session_stub(pipe: SpeechPipeline) -> dict[str, bool]:+ """Stub the capture + session so the state loop can ACCEPT a call without+ real audio hardware; returns the record of whether the session ran."""+ _silence_side_effects(pipe)+ pipe._player = _RecordingPlayer() # type: ignore[assignment]+ ran = {"session": False}++ @asynccontextmanager+ async def fake_capture():+ yield None++ async def fake_active_session(*, input_buffer=None): # noqa: ANN001+ ran["session"] = True+ return HANGUP_TURN_COMPLETE++ pipe._capture_first_session_input = fake_capture # type: ignore[method-assign]+ pipe._active_session = fake_active_session # type: ignore[method-assign]+ return ran+++async def test_ptt_press_bypasses_post_hangup_wake_lock():+ """REGRESSION (live 2026-07-31): a PTT press inside the post-hangup+ wake-lock was silently dropped by the state loop; key-repeat then re-armed+ it until the lock expired, so recording started 1-3 s AFTER the user began+ talking and the opening words of the capture were missing. A deliberate+ key press has no speaker-echo path — the lock must not gate it."""+ pipe = _make_pipeline()+ ran = _accepting_session_stub(pipe)+ pipe._wake_lock_until = time.time() + 100.0 # lock wide open+ pipe._on_ptt_press()++ await _pump_state_loop_once(pipe)++ assert ran["session"] is True, "explicit PTT press must open a session"+ assert pipe._ptt_mode is False # one-shot, disarmed by session teardown+ assert pipe._state == PipelineState.IDLE+++async def test_call_hotkey_bypasses_post_hangup_wake_lock():+ """The CALL hotkey is the same deliberate-press contract as PTT: what the+ ``_hotkey_loop`` arms (explicit marker + call event) must survive the+ wake lock."""+ pipe = _make_pipeline()+ ran = _accepting_session_stub(pipe)+ pipe._wake_lock_until = time.time() + 100.0+ pipe._explicit_call_pending = True # what _hotkey_loop sets on "call"+ pipe._call_event.set()++ await _pump_state_loop_once(pipe)++ assert ran["session"] is True, "explicit CALL press must open a session"+ assert pipe._explicit_call_pending is False, "marker is one-shot"assert pipe._state == PipelineState.IDLE