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(wake): don't deafen the wake for 3s after a user hard hangup + keep poll fast
Ruben Lütkeb2543c25918c
diff --git a/jarvis/speech/pipeline.py b/jarvis/speech/pipeline.pyindex ca282c4713..d8618170a7 100644--- a/jarvis/speech/pipeline.py+++ b/jarvis/speech/pipeline.py@@ -1366,6 +1366,16 @@ class SpeechPipeline:# selbst wieder als "Hey Jarvis" triggert (Speaker→Mic-Feedback-Loop).self._wake_lock_until: float = 0.0self._post_hangup_lock_s: float = 3.0+ # A user-initiated HARD hangup (JarvisBar close, hotkey, "auflegen")+ # stops the player, so there is NO TTS tail to echo — the long+ # post-hangup lock then only DEAFENS the wake to the user's very next+ # "Hey <wake>" ("say it twice", live log 2026-07-02 18:40/18:46). Such a+ # hangup uses this SHORT lock instead: just past the disconnect earcon,+ # not the 3 s speaker-tail guard. Set by ``_trigger_voice_hangup`` when+ # it stops the player; reset per session so a no-op hangup while idle+ # cannot shorten a later natural end's lock.+ self._explicit_hangup_lock_s: float = 0.4+ self._explicit_hard_hangup: bool = Falseself._last_wake_keyword: str = ""# 2026-05-26: timestamp of the last priority="interrupt"# announcement, used by ``_on_announcement`` to gate preamble-class@@ -3805,6 +3815,20 @@ class SpeechPipeline:self._call_event.set()return True+ def _post_hangup_lock_seconds(self) -> float:+ """Wake-lock duration for the session that just ended (one-shot).++ SHORT (`_explicit_hangup_lock_s`) after a user HARD hangup — the+ JarvisBar close / hotkey / "auflegen" stopped the player, so there is no+ TTS tail to echo and the long lock would only swallow the user's very+ next "Hey <wake>". Otherwise the FULL `_post_hangup_lock_s` guards the+ speaker tail of a natural end / farewell. Consumes the hard-hangup flag+ so it applies to exactly one session end.+ """+ hard = self._explicit_hard_hangup+ self._explicit_hard_hangup = False+ return self._explicit_hangup_lock_s if hard else self._post_hangup_lock_s+def request_hangup(self) -> None:"""End the live voice session from outside the audio path.@@ -3868,6 +3892,10 @@ class SpeechPipeline:self._player.stop()except Exception as exc: # noqa: BLE001log.warning("Player-Stop bei Hangup fehlgeschlagen: %s", exc)+ # Player stopped => no TTS tail => the next session end uses the+ # SHORT wake-lock so the user can re-wake immediately. A farewell+ # hangup (stop_player=False) keeps the full speaker-tail guard.+ self._explicit_hard_hangup = Trueself._session_end_reason = HANGUP_VOICE_PATTERNself._hangup_event.set()# BUG-CU-HANGUP (2026-05-28): "auflegen" must also STOP a running@@ -4403,6 +4431,9 @@ class SpeechPipeline:self._ptt_mode = Falsecontinueself._hangup_event.clear()+ # Fresh session: forget any hard-hangup flag left by a no-op hangup+ # while idle, so ONLY this session's own ending decides its lock.+ self._explicit_hard_hangup = Falseself._state = PipelineState.ACTIVE# Reset per-session completeness signal state: a new session# starts "fresh" so the first INCOMPLETE gets an earcon, not a@@ -4465,10 +4496,10 @@ class SpeechPipeline:# Disconnect-Sound als hörbares Hangup-Signal (earcon — gated# by the global "Sound effects" switch).await self._play_earcon(DISCONNECT_PCM)- # Cooldown setzen damit Speaker-Echo nicht sofort re-triggert- self._wake_lock_until = time.time() + self._post_hangup_lock_s- log.info("📵 AUFGELEGT — zurück zu IDLE (Wake-Lock %.1fs).",- self._post_hangup_lock_s)+ # Cooldown setzen damit Speaker-Echo nicht sofort re-triggert.+ lock_s = self._post_hangup_lock_seconds()+ self._wake_lock_until = time.time() + lock_s+ log.info("📵 AUFGELEGT — zurück zu IDLE (Wake-Lock %.1fs).", lock_s)def _earcons_enabled(self) -> bool:"""Whether synthesized UI earcons may play.diff --git a/jarvis/speech/wake_phrase.py b/jarvis/speech/wake_phrase.pyindex 8e8955ab49..2ca543e190 100644--- a/jarvis/speech/wake_phrase.py+++ b/jarvis/speech/wake_phrase.py@@ -70,17 +70,21 @@ def sensitivity_to_threshold(sensitivity: float) -> float:# a custom-phrase user moving the Sensitivity slider felt NOTHING. Map the same# 0..1 slider onto how OFTEN that path re-transcribes the rolling window: a# higher sensitivity polls more often, so a spoken wake is picked up sooner.-_POLL_INTERVAL_SLOW = 0.20 # sensitivity 0.0 — calmest, least CPU+# Both ends are deliberately FAST — the user's mandate is "always as low as+# possible" (2026-07-02). The slider still trims a little, but even its lowest+# position must not feel slow, so the slow end is 0.12 s, not a lazy 0.20 s.+_POLL_INTERVAL_SLOW = 0.12 # sensitivity 0.0 — still snappy_POLL_INTERVAL_FAST = 0.08 # sensitivity 1.0 — snappiest reactiondef sensitivity_to_poll_interval(sensitivity: float) -> float:"""Map a 0..1 sensitivity onto the stt_match wake poll interval (seconds).- Linear: 0.0 -> 0.20 s (calm), 1.0 -> 0.08 s (snappy). Higher sensitivity =>- shorter interval => the wake word is noticed sooner. This is the slider's- *felt* effect on the transcript-match path; the heavy latency win (skipping- the second confirming transcription on a clearly-loud wake) is unconditional.+ Linear: 0.0 -> 0.12 s, 1.0 -> 0.08 s. Both ends are fast on purpose (the+ "always as low as possible" mandate); higher sensitivity just trims a little+ more. The dominant latency floor is the ~0.5 s transcription itself, so the+ poll interval is a minor knob — the real win is skipping the second+ confirming transcription on a clearly-loud wake (unconditional)."""s = max(0.0, min(1.0, float(sensitivity)))return _POLL_INTERVAL_SLOW + (_POLL_INTERVAL_FAST - _POLL_INTERVAL_SLOW) * sdiff --git a/tests/unit/speech/test_wake_lock_hard_hangup.py b/tests/unit/speech/test_wake_lock_hard_hangup.pynew file mode 100644index 0000000000..eb9549dc7b--- /dev/null+++ b/tests/unit/speech/test_wake_lock_hard_hangup.py@@ -0,0 +1,84 @@+"""A user HARD hangup must not deafen the wake to the very next word.++Live bug (data/jarvis_desktop.log 2026-07-02 18:40 / 18:46): closing the+JarvisBar (or muting then hanging up) ended the session and armed the full 3 s+post-hangup wake-lock, so the user's immediate "Hey <wake>" was swallowed and+had to be said twice:++ 18:40:44.771 AUFGELEGT — Wake-Lock 3.0s+ 18:40:44.857 Wake-Lock aktiv — ignoriere (noch 2.9s) # the re-wake, eaten++A user hangup stops the player (`stop_player=True`), so there is NO TTS tail to+echo — the long lock is pointless there. It must use the SHORT lock instead. A+farewell hangup (`stop_player=False`) lets the goodbye play, so it keeps the+full speaker-tail guard.+"""+from __future__ import annotations++from collections.abc import AsyncIterator+from dataclasses import dataclass+from types import SimpleNamespace++from jarvis.core.config import STTConfig+from jarvis.speech.pipeline import SpeechPipeline+++@dataclass+class _FakeTTS:+ name: str = "fake-tts"+ supports_streaming: bool = True++ async def synthesize(+ self, text: str, voice: str | None = None, language_code: str | None = None+ ) -> AsyncIterator:+ if False: # pragma: no cover+ yield+++def _pipe() -> SpeechPipeline:+ # Lightweight, no local Whisper / detectors — we only exercise the hangup+ # → wake-lock decision, which is audio-engine-independent.+ return SpeechPipeline(+ tts=_FakeTTS(),+ bus=None,+ enable_openwakeword=False,+ enable_whisper_wake=False,+ enable_local_whisper=False,+ config=SimpleNamespace(stt=STTConfig(provider="groq-api")),+ )+++def test_hard_hangup_uses_the_short_lock() -> None:+ pipe = _pipe()+ pipe._trigger_voice_hangup(stop_player=True) # JarvisBar / hotkey / "auflegen"+ assert pipe._explicit_hard_hangup is True+ lock = pipe._post_hangup_lock_seconds()+ assert lock == pipe._explicit_hangup_lock_s+ assert lock < 1.0, "a hard hangup must not deafen the wake for ~1s+"+ # one-shot: the flag is consumed so the NEXT (natural) end keeps the guard+ assert pipe._explicit_hard_hangup is False+ assert pipe._post_hangup_lock_seconds() == pipe._post_hangup_lock_s+++def test_farewell_hangup_keeps_the_full_speaker_tail_guard() -> None:+ pipe = _pipe()+ pipe._trigger_voice_hangup(stop_player=False) # let the goodbye play out+ assert pipe._explicit_hard_hangup is False+ assert pipe._post_hangup_lock_seconds() == pipe._post_hangup_lock_s+++def test_natural_end_without_a_hangup_keeps_the_full_guard() -> None:+ pipe = _pipe()+ # No hangup call at all (e.g. an idle-timeout / single-turn end).+ assert pipe._post_hangup_lock_seconds() == pipe._post_hangup_lock_s+++def test_idle_noop_hangup_does_not_shorten_a_later_natural_end() -> None:+ # A hard hangup while idle sets the flag, but a session that later ends+ # naturally (reset at session start) must still get the full guard. We model+ # the per-session reset that _state_loop does at accept time.+ pipe = _pipe()+ pipe._trigger_voice_hangup(stop_player=True)+ assert pipe._explicit_hard_hangup is True+ pipe._explicit_hard_hangup = False # what _state_loop does on session start+ assert pipe._post_hangup_lock_seconds() == pipe._post_hangup_lock_sdiff --git a/tests/unit/speech/test_wake_phrase.py b/tests/unit/speech/test_wake_phrase.pyindex f83f9b35dd..9a33d1d4f9 100644--- a/tests/unit/speech/test_wake_phrase.py+++ b/tests/unit/speech/test_wake_phrase.py@@ -372,9 +372,10 @@ def test_sensitivity_to_poll_interval_makes_the_slider_control_speed() -> None:# it only fed the openWakeWord threshold, which that path never scores# against. It now drives the poll interval, so moving it changes how fast a# spoken wake is picked up. Higher sensitivity => shorter interval => snappier.- assert wp.sensitivity_to_poll_interval(0.0) == pytest.approx(0.20)+ # Both ends are fast ("always as low as possible"); the slider only trims.+ assert wp.sensitivity_to_poll_interval(0.0) == pytest.approx(0.12)assert wp.sensitivity_to_poll_interval(1.0) == pytest.approx(0.08)- assert wp.sensitivity_to_poll_interval(0.5) == pytest.approx(0.14)+ assert wp.sensitivity_to_poll_interval(0.5) == pytest.approx(0.10)# strictly monotonic decreasingassert wp.sensitivity_to_poll_interval(0.2) > wp.sensitivity_to_poll_interval(0.8)# clamps out-of-range input instead of producing absurd intervals