Skip to content

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.

fix(overlay): drive the whisper-bar listen look from VoiceSessionStarted

Ruben Lütkeb39ff560496b
diff --git a/tests/unit/ui/test_orb_bus_bridge.py b/tests/unit/ui/test_orb_bus_bridge.py
index 691f6ee85f..5468afff4c 100644
--- a/tests/unit/ui/test_orb_bus_bridge.py
+++ b/tests/unit/ui/test_orb_bus_bridge.py
@@ -52,6 +52,9 @@ class _FakeOrb:
def show(self, mode: str = "listen") -> None:
self.calls.append(("show", mode))
+ def set_level(self, level: float) -> None:
+ self.calls.append(("set_level", level))
+
def hide(self) -> None:
self.calls.append(("hide", None))
@@ -734,6 +737,71 @@ async def test_orb_shows_again_after_genuine_wake_following_hangup() -> None:
assert ("show", "listen") in orb.calls
+async def test_session_start_shows_listening_when_listening_state_is_deduped() -> None:
+ """Live forensic (2026-06-21, session 1a3df62a): the bar only "woke up" at
+ THINKING, never while the user spoke into it.
+
+ Root cause: the supervisor's high-level state was already ``LISTENING`` when
+ the new session started (a stale prior teardown left it there), so
+ ``set_state("LISTENING")`` was a no-op and NO ``SystemStateChanged(LISTENING)``
+ reached the bridge. The bridge then saw nothing until ``THINKING`` and only
+ revealed/activated the bar there.
+
+ ``VoiceSessionStarted`` is the authoritative "the user is being listened to
+ now" signal — the bar must enter its listening look from THAT, never depend
+ on a derived ``LISTENING`` state event that can be deduplicated upstream.
+ """
+ orb = _FakeOrb()
+ bridge = OrbBusBridge(bus=_FakeBus(), orb=orb, idle_animations_enabled=False) # type: ignore[arg-type]
+
+ # A genuine wake starts a session, but the supervisor was already LISTENING,
+ # so NO SystemStateChanged(LISTENING) follows — the next state the bridge
+ # would see is THINKING.
+ await bridge._on_session_started( # noqa: SLF001
+ VoiceSessionStarted(session_id="s1", wake_keyword="hey_jarvis")
+ )
+
+ # The bar must already be in its listening look — before any THINKING.
+ assert ("show", "listen") in orb.calls
+ # A fresh turn opens an empty transcript bubble.
+ assert ("show_listening_transcript", "") in orb.calls
+
+
+async def test_session_start_drives_mic_equalizer_immediately() -> None:
+ """The bar's equalizer reacts to mic loudness only while the bridge
+ considers the state LISTENING. After a session starts (even when the
+ LISTENING state event is deduped upstream), mic loudness must drive the
+ bars from the very first word — otherwise the bar looks dead while the user
+ is talking."""
+ orb = _FakeOrb()
+ bridge = OrbBusBridge(bus=_FakeBus(), orb=orb, idle_animations_enabled=False) # type: ignore[arg-type]
+
+ await bridge._on_session_started( # noqa: SLF001
+ VoiceSessionStarted(session_id="s1", wake_keyword="hey_jarvis")
+ )
+ orb.calls.clear()
+
+ bridge._on_mic_level(0.5) # noqa: SLF001
+ assert ("set_level", 0.5) in orb.calls
+
+
+async def test_session_start_then_real_listening_does_not_double_show() -> None:
+ """The normal flow (session start FOLLOWED by a genuine
+ SystemStateChanged(LISTENING)) must enter the listening look exactly once —
+ the genuine event is a clean same-state no-op, not a second show."""
+ orb = _FakeOrb()
+ bridge = OrbBusBridge(bus=_FakeBus(), orb=orb, idle_animations_enabled=False) # type: ignore[arg-type]
+
+ await bridge._on_session_started( # noqa: SLF001
+ VoiceSessionStarted(session_id="s1", wake_keyword="hey_jarvis")
+ )
+ await bridge._on_state( # noqa: SLF001
+ SystemStateChanged(new_state="LISTENING", previous="IDLE")
+ )
+
+ assert orb.calls.count(("show", "listen")) == 1
+
+
async def test_active_state_shows_orb_before_any_session_event() -> None:
"""Backward-compat: with no VoiceSession lifecycle events seen yet, the
bridge behaves exactly as before — an active state shows the orb. The
diff --git a/ui/orb/bus_bridge.py b/ui/orb/bus_bridge.py
index f67cab40e5..4cb512caf2 100644
--- a/ui/orb/bus_bridge.py
+++ b/ui/orb/bus_bridge.py
@@ -372,17 +372,46 @@ class OrbBusBridge:
async def _on_session_started(self, event: VoiceSessionStarted) -> None:
"""A genuine new voice session began (wake-word / hotkey / call).
- Releases the post-hangup suppression latch so the orb shows normally
- for this session's states. ``_last_state`` is reset to IDLE as a
- defensive measure: a session always begins from idle, so even if the
- previous session somehow left ``_last_state`` on a non-IDLE value (a
- raced or missed IDLE transition), the first LISTENING of the new
- session is still treated as a real change rather than a same-state
- no-op — otherwise the show + wave would be skipped.
+ Releases the post-hangup suppression latch AND drives the surface into
+ its listening look immediately — from THIS authoritative signal, not
+ from the ``SystemStateChanged(IDLE→LISTENING)`` the pipeline emits right
+ after.
+
+ Why not rely on that state event: it is *derived* and lossy. When the
+ supervisor's high-level state was already ``LISTENING`` (a stale prior
+ teardown left it there, or the turn-state cycles LISTENING↔USER_SPEAKING
+ without ever re-entering IDLE), ``set_state("LISTENING")`` is a no-op and
+ NO ``SystemStateChanged`` is published. The bridge then saw nothing until
+ ``THINKING`` and the bar only "woke up" once Jarvis started thinking —
+ never while the user was speaking into it (live forensic 2026-06-21,
+ session 1a3df62a: ``_on_session_started`` → the next bridge state was
+ ``IDLE → THINKING`` with no LISTENING in between).
+
+ ``VoiceSessionStarted`` is the authoritative "the user is being listened
+ to now" signal (the pipeline opens the mic + sets LISTENING immediately
+ after publishing it), so the listening visual is driven from here.
+ ``_last_state`` is set to ``LISTENING`` (not ``IDLE``) so the genuine
+ ``SystemStateChanged(LISTENING)`` that normally follows is a clean
+ same-state no-op rather than a second show, and so mic loudness is
+ forwarded to the equalizer (gated on ``_last_state == "LISTENING"``) from
+ the very first word.
"""
log.info("OrbBridge._on_session_started: session=%s", event.session_id)
+ prev_state = self._last_state
self._suppress_show_until_session = False
- self._last_state = "IDLE"
+ self._last_state = "LISTENING"
+ # Enter the listening look now — robust to a deduplicated LISTENING state.
+ self._orb.show(mode="listen")
+ if prev_state in ("IDLE", "ERROR", "PAUSED"):
+ self._orb.play_animation("wave")
+ # Fresh turn: clear any transcript/reply left over from a prior session
+ # and open an empty live-transcript bubble, mirroring the LISTENING
+ # branch of ``_on_state`` (a session never resumes a paused completion).
+ self._listening_transcript_text = ""
+ self._last_response_text = ""
+ self._show_listening_transcript("")
+ self._completion_continuation = False
+ self._cancel_idle_scheduler()
async def _on_session_ended(self, event: VoiceSessionEnded) -> None:
"""A voice session ended (hangup / idle-timeout / shutdown / error).