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.

test(ui): cover the bar notice, orb dictation look and mode parity

Ruben Lütkeba1b67316344
diff --git a/desktop-ttu-latest.json b/desktop-ttu-latest.json
index b769b3114a..33d127f972 100644
--- a/desktop-ttu-latest.json
+++ b/desktop-ttu-latest.json
@@ -3,31 +3,31 @@
"runs": 1,
"python": "C:\\Program Files\\Python311\\python.exe",
"vault_pages": 84,
- "median_wall_ms": 6857.5,
- "median_boot_ready_ms": 249.0,
- "median_bind_wall_ms": 3142.3,
- "median_voice_ready_wall_ms": 16015.5,
+ "median_wall_ms": 1191.9,
+ "median_boot_ready_ms": 136.7,
+ "median_bind_wall_ms": 649.7,
+ "median_voice_ready_wall_ms": 6931.8,
"voice_ready_wall_ms_runs": [
- 16015.5
+ 6931.8
],
- "median_voice_usable_wall_ms": 17045.7,
+ "median_voice_usable_wall_ms": 7890.5,
"voice_usable_wall_ms_runs": [
- 17045.7
+ 7890.5
],
- "median_app_interactive_wall_ms": 17045.8,
+ "median_app_interactive_wall_ms": 8050.6,
"app_interactive_wall_ms_runs": [
- 17045.8
+ 8050.6
],
"wall_ms_runs": [
- 6857.5
+ 1191.9
],
"boot_ready_ms_runs": [
- 249.0
+ 136.7
],
"phase_medians_ms": {
- "db_app_interactive": 4145.8,
- "db_pre_webserver": 5771.6,
- "db_webserver_ctor": 4235.1
+ "db_app_interactive": 3227.4,
+ "db_pre_webserver": 1806.9,
+ "db_webserver_ctor": 2503.1
},
"anchor": "spawn -> /api/health responds 200 (= DesktopApp._wait_for_backend success = window creation point)",
"secondary_anchor": "median_bind_wall_ms = spawn -> BOOT_READY print (bootstrap bind; may precede a responsive health endpoint)",
diff --git a/scripts/config-soll.json b/scripts/config-soll.json
index bd7fe87bd2..4d0e848a91 100644
--- a/scripts/config-soll.json
+++ b/scripts/config-soll.json
@@ -64,10 +64,10 @@
"fallback_model_2": "gemini-3-pro-preview"
},
"stt": {
- "provider": "groq-api",
- "model": "whisper-large-v3",
+ "provider": "openrouter-stt",
+ "model": "openai/whisper-large-v3",
"bias_prompt": "Jarvis, OpenClaw, Codex, Gemini, Grok, Claude, Anthropic, OpenAI, OpenRouter, Whisper, Subagent, Sub-Agent, Mission-Manager, Critic-Loop, Critic, Worker, Router-Brain, Router, Kontrollierer, Voice-Pipeline, Wake-Word, Silero, VAD, TTS, STT, Telemetry, Transkript, Token, Provider, Plugin, Sprechblase, Orb, Mascot, Quip, Browser, Terminal, Repository, Branch, Commit, Push, Pull-Request, Issue, Merge, Refactor, Deployment, Screenshot, Debuggen, Workflow, Microservice, Container, Docker, Kubernetes, FastAPI, React, TypeScript, Python, JSON, Markdown, Logfile, Konfiguration, Endpoint, Webhook, API-Key, Service-Account, Cloud, Google Cloud, Vertex AI, BigQuery, GitHub, Twilio, ElevenLabs, OAuth, Credential Manager, Frontend, Backend, Skript, Daemon, Hangup, Auflegen, Denkpause, submitted, distanziert, erkennt",
- "language": "en"
+ "language": "auto"
},
"ack_brain": {
"enabled": true,
diff --git a/tests/unit/ui/jarvisbar/test_mode_parity.py b/tests/unit/ui/jarvisbar/test_mode_parity.py
index 6f2a347310..7a04ca4e30 100644
--- a/tests/unit/ui/jarvisbar/test_mode_parity.py
+++ b/tests/unit/ui/jarvisbar/test_mode_parity.py
@@ -36,8 +36,10 @@ def test_the_vocabulary_has_exactly_one_definition() -> None:
"""Nothing may restate the tuple — every layer imports the same object."""
assert renderer.MODES is modes.MODES
assert renderer.DICTATION_MODES is modes.DICTATION_MODES
+ assert renderer.NOTICE_MODES is modes.NOTICE_MODES
assert subprocess_mod._MODES is modes.MODES
assert interaction.DICTATION_MODES is modes.DICTATION_MODES
+ assert interaction.NOTICE_MODES is modes.NOTICE_MODES
def test_no_module_hardcodes_a_mode_tuple() -> None:
@@ -68,6 +70,19 @@ def test_dictation_modes_are_part_of_the_vocabulary() -> None:
assert modes.DICTATION_MODES == ("dictate", "dictate_transcribing")
+def test_a_notice_is_not_a_dictation_mode() -> None:
+ """A refusal must never borrow a dictation mode.
+
+ The dictation modes assert the microphone is open; a notice is raised
+ precisely when it is not. Sharing a mode would make a declined keypress look
+ exactly like an accepted one — the failure the notice exists to end.
+ """
+ for mode in modes.NOTICE_MODES:
+ assert mode in modes.MODES
+ assert mode not in modes.DICTATION_MODES
+ assert mode not in modes.VOICE_MODES
+
+
# --------------------------------------------------------------------------
# Every surface accepts every mode
# --------------------------------------------------------------------------
@@ -130,6 +145,12 @@ def test_the_null_surface_swallows_every_mode(mode: str) -> None:
# --------------------------------------------------------------------------
# Every mode has a defined look and a defined click behaviour
# --------------------------------------------------------------------------
+#: Every look ``renderer.render`` knows how to draw. Derived from the mode
+#: vocabulary so a new mode either resolves to an existing look or brings its
+#: own — it can never resolve to a look nothing draws.
+_RENDERABLE_LOOKS = ("idle", "speak", "think") + modes.NOTICE_MODES
+
+
@pytest.mark.parametrize("mode", modes.MODES)
def test_every_mode_resolves_to_a_renderable_look(mode: str) -> None:
for seconds_since_audible in (0.0, 99.0):
@@ -137,7 +158,48 @@ def test_every_mode_resolves_to_a_renderable_look(mode: str) -> None:
look = renderer.visual_mode(
mode, seconds_since_audible, hold_s=0.4, playback_active=playback
)
- assert look in ("idle", "speak", "think")
+ assert look in _RENDERABLE_LOOKS
+
+
[email protected]("mode", modes.NOTICE_MODES)
+def test_no_audio_signal_can_repaint_a_notice(mode: str) -> None:
+ """A notice survives live playback and a fresh level sample.
+
+ ``visual_mode`` normally lets real audio override the coarse mode. A notice
+ is raised when something did NOT happen, so letting a stale level or an
+ in-flight TTS buffer turn it into the listening/speaking look would replace
+ the answer to the user's keypress with a claim about the microphone that is
+ false.
+ """
+ for playback in (False, True):
+ for seconds_since_audible in (0.0, 0.1, 99.0):
+ assert (
+ renderer.visual_mode(
+ mode, seconds_since_audible, hold_s=0.4, playback_active=playback
+ )
+ == mode
+ )
+
+
+def test_a_notice_is_always_legible_never_fully_faded() -> None:
+ """The breath may dim the glyph, never erase it.
+
+ An invisible "your key press did nothing" message is the bug, not a style.
+ """
+ values = [renderer.notice_alpha(t / 50.0) for t in range(400)]
+ assert min(values) >= renderer.NOTICE_ALPHA_MIN
+ assert max(values) <= 1.0
+ # It genuinely moves — a constant alpha would read as a frozen bar.
+ assert max(values) - min(values) > 0.2
+
+
[email protected]("mode", modes.NOTICE_MODES)
+def test_a_notice_opens_the_pill_without_faking_a_session(mode: str) -> None:
+ """Big enough to draw a legible mark in, small enough not to claim a turn."""
+ w, h = renderer.target_pill_size(mode, hovered=False)
+ assert (w, h) == (renderer.OPEN_W, renderer.OPEN_H)
+ assert (w, h) != (renderer.ACTIVE_W, renderer.ACTIVE_H)
+ assert w > renderer.COLLAPSED_W
@pytest.mark.parametrize("mode", modes.MODES)
@@ -150,3 +212,19 @@ def test_every_mode_has_a_pill_size(mode: str) -> None:
def test_every_mode_resolves_a_click(mode: str) -> None:
action = interaction.resolve_click(400, 800, mode, hovered=True, pill_w=400)
assert action in ("hangup", "mute", "talk", "none")
+
+
[email protected]("mode", modes.NOTICE_MODES)
+def test_a_notice_is_inert_everywhere_on_the_bar(mode: str) -> None:
+ """A transient message is not a control.
+
+ It appears unrequested under wherever the pointer happens to be and clears
+ itself again, so ANY click it resolved would be one the user aimed at
+ something else — starting a session or toggling the mic by accident.
+ """
+ for x in (0, 40, 200, 400, 600, 799):
+ for hovered in (False, True):
+ assert (
+ interaction.resolve_click(x, 800, mode, hovered=hovered, pill_w=400)
+ == "none"
+ )
diff --git a/tests/unit/ui/jarvisbar/test_renderer_notice.py b/tests/unit/ui/jarvisbar/test_renderer_notice.py
new file mode 100644
index 0000000000..8afdd456bd
--- /dev/null
+++ b/tests/unit/ui/jarvisbar/test_renderer_notice.py
@@ -0,0 +1,87 @@
+"""A refused request must be VISIBLE on a bar that carries no text.
+
+The bar has no bubble, no label and no toast. So when the pipeline declines
+something the user asked for — pressing the dictation shortcut while a voice
+conversation owns the microphone — the only place the reason can land on this
+surface is the pill itself. Before the ``notice`` look existed the refusal went
+to a log file the desktop app cannot open, and the shortcut was
+indistinguishable from a dead key.
+
+These pin the four properties that make the look trustworthy: it draws
+something, it is unmistakably not a session, no audio signal can repaint it, and
+it changes nothing about a frame that has no notice in flight.
+"""
+
+from __future__ import annotations
+
+import numpy as np
+import pytest
+
+from jarvis.ui.jarvisbar import modes, renderer
+
+
[email protected](autouse=True)
+def _reset_geometry() -> None:
+ renderer.apply_display_scale(1.0, renderer.USER_SIZE_DEFAULT)
+
+
+def _settled(mode: str, t: float = 0.0, **kw) -> np.ndarray:
+ """Render ``mode`` after the pill easing has converged on its target size."""
+ r = renderer.JarvisBarRenderer(accent="#e7c46e")
+ for _ in range(60):
+ r.render(0.0, mode, 0.0, **kw)
+ return np.asarray(r.render(t, mode, 0.0, **kw))
+
+
[email protected]("mode", modes.NOTICE_MODES)
+def test_a_notice_draws_something_the_resting_pill_does_not(mode: str) -> None:
+ """The whole point: the user can SEE that the key press was answered."""
+ assert not np.array_equal(_settled(mode), _settled("idle"))
+
+
[email protected]("mode", modes.NOTICE_MODES)
+def test_a_notice_is_red_not_gold(mode: str) -> None:
+ """Red is this surface's existing "no" (the muted rim, the rejected drop).
+
+ Gold means activity here — a gold refusal would read as something starting.
+ """
+ frame = _settled(mode)
+ reds = frame[:, :, 0].astype(int)
+ greens = frame[:, :, 1].astype(int)
+ blues = frame[:, :, 2].astype(int)
+ # Ignore the magenta color key (R and B both maxed), which is the
+ # transparent background rather than drawn content.
+ drawn = ~((reds >= 250) & (blues >= 250))
+ warm = drawn & (reds > greens + 40) & (reds > blues + 40)
+ assert warm.sum() > 0, "no red content in the notice frame"
+
+
[email protected]("mode", modes.NOTICE_MODES)
+def test_a_notice_survives_hover(mode: str) -> None:
+ """Hovering must not swap the answer for the mic and close-X controls.
+
+ A notice can be raised while a conversation is live, so the hover branch
+ would otherwise offer a hang-up X on top of a message the user has not read
+ — and hide the reason they pressed the key in the first place.
+ """
+ assert np.array_equal(_settled(mode, hovered=False), _settled(mode, hovered=True))
+
+
[email protected]("mode", modes.NOTICE_MODES)
+def test_a_notice_breathes_so_it_never_reads_as_a_frozen_bar(mode: str) -> None:
+ r = renderer.JarvisBarRenderer()
+ for _ in range(60):
+ r.render(0.0, mode, 0.0)
+ early = np.asarray(r.render(0.0, mode, 0.0))
+ later = np.asarray(r.render(0.45, mode, 0.0))
+ assert not np.array_equal(early, later)
+
+
+def test_frames_without_a_notice_are_byte_identical_to_before() -> None:
+ """Adding the look may not perturb any existing mode's pixels."""
+ for mode in ("idle", "listen", "speak", "think", "dictate"):
+ a = _settled(mode, t=0.3)
+ b = _settled(mode, t=0.3)
+ assert np.array_equal(a, b)
+ # And nothing in a non-notice frame turns the rim into the refusal red.
+ assert not np.array_equal(a, _settled("notice", t=0.3))
diff --git a/tests/unit/ui/jarvisbar/test_show_makes_the_window_visible.py b/tests/unit/ui/jarvisbar/test_show_makes_the_window_visible.py
new file mode 100644
index 0000000000..7240250958
--- /dev/null
+++ b/tests/unit/ui/jarvisbar/test_show_makes_the_window_visible.py
@@ -0,0 +1,124 @@
+"""``show(mode)`` must MAP the window, not merely remember a mode string.
+
+The dictation lane shipped broken once already in exactly this gap: every layer
+agreed on the mode, every test asserted the mode, and the surface still put
+nothing on screen. A mode is an intention; ``_do_show`` is the only thing that
+turns it into pixels.
+
+These tests drive the REAL ``JarvisBarOverlay`` with a stand-in root, so the
+visibility decision is read out of the production code path rather than
+restated. Everything below the queue (deiconify, layered attributes, z-order)
+needs a live Tk window and is covered by ``test_show_lifts_topmost.py``; what is
+pinned here is WHICH of the two terminal operations each call ends up choosing.
+
+The fake surfaces used by the bridge's lifecycle tests model the same three
+rules — mode vocabulary, startup gate, persistence — so this file is what keeps
+those fakes honest about the surface they stand in for.
+"""
+
+from __future__ import annotations
+
+import queue
+
+import pytest
+
+from jarvis.ui.jarvisbar import modes
+from jarvis.ui.jarvisbar.overlay import JarvisBarOverlay
+
+
+def _headless_bar(*, persistent: bool, startup_gated: bool = False) -> JarvisBarOverlay:
+ """A real bar with a stand-in root, so ``show`` reaches the UI queue.
+
+ ``_tk_thread_id`` stays ``None`` so ``_enqueue_ui`` never mistakes the test
+ thread for the Tk thread and runs the operation inline against a root that
+ cannot service it.
+ """
+ bar = JarvisBarOverlay(
+ persistent=persistent, accent="#e7c46e", startup_gated=startup_gated
+ )
+ bar._root = object()
+ bar._tk_thread_id = None
+ bar._ui_queue = queue.Queue()
+ return bar
+
+
+def _drain(bar: JarvisBarOverlay) -> list[object]:
+ out: list[object] = []
+ while True:
+ try:
+ out.append(bar._ui_queue.get_nowait())
+ except queue.Empty:
+ return out
+
+
[email protected]("mode", modes.MODES)
+def test_a_persistent_bar_maps_the_window_for_every_mode(mode: str) -> None:
+ """The always-on bar is never withdrawn — not even by ``idle``."""
+ bar = _headless_bar(persistent=True)
+
+ bar.show(mode)
+
+ assert _drain(bar) == [bar._do_show]
+ assert bar._mode == mode
+
+
[email protected]("mode", [m for m in modes.MODES if m != "idle"])
+def test_a_non_persistent_bar_maps_the_window_for_every_active_mode(mode: str) -> None:
+ """Dictation and notice modes reveal a hidden bar exactly like a wake word.
+
+ This is the property the maintainer actually feels: press the shortcut and
+ the bar is THERE. A mode that only updated ``_mode`` would leave a
+ non-persistent bar withdrawn with a perfectly correct internal state.
+ """
+ bar = _headless_bar(persistent=False)
+
+ bar.show(mode)
+
+ assert _drain(bar) == [bar._do_show]
+
+
+def test_a_non_persistent_bar_withdraws_on_idle() -> None:
+ bar = _headless_bar(persistent=False)
+
+ bar.show("idle")
+
+ assert _drain(bar) == [bar._do_hide]
+
+
[email protected]("mode", modes.MODES)
+def test_a_startup_gated_bar_stores_the_mode_and_stays_off_screen(mode: str) -> None:
+ """AP-26: nothing may advertise a voice stack that is still warming.
+
+ The mode is still tracked so the release shows the CURRENT one — a bar that
+ reset itself to idle on release would drop a dictation that began during
+ warm-up.
+ """
+ bar = _headless_bar(persistent=True, startup_gated=True)
+
+ bar.show(mode)
+
+ assert _drain(bar) == []
+ assert bar._mode == mode
+
+
[email protected]("mode", [m for m in modes.MODES if m != "idle"])
+def test_releasing_the_gate_maps_the_window_in_the_stored_mode(mode: str) -> None:
+ bar = _headless_bar(persistent=True, startup_gated=True)
+ bar.show(mode)
+ _drain(bar)
+
+ assert bar.release_startup_gate() is True
+
+ assert _drain(bar) == [bar._do_show]
+ assert bar._mode == mode
+
+
+def test_an_unknown_mode_neither_maps_nor_overwrites_the_current_one() -> None:
+ bar = _headless_bar(persistent=True)
+ bar.show("listen")
+ _drain(bar)
+
+ bar.show("bogus")
+
+ assert _drain(bar) == []
+ assert bar._mode == "listen"
diff --git a/tests/unit/ui/test_orb_bus_bridge_dictation_visibility.py b/tests/unit/ui/test_orb_bus_bridge_dictation_visibility.py
new file mode 100644
index 0000000000..7fe376f923
--- /dev/null
+++ b/tests/unit/ui/test_orb_bus_bridge_dictation_visibility.py
@@ -0,0 +1,458 @@
+"""A dictation must reach the SCREEN — and so must a refused one.
+
+Why this file exists next to ``test_orb_bus_bridge_dictation.py``: that suite
+asserts the surface was handed the right mode string, and a mode string is what
+the whole feature already had while the maintainer reported "pressing the
+shortcut does nothing at all". A mode is an intention. Visibility is the
+product. Every assertion here is about whether the surface was actually asked to
+become visible, and about what happens when the answer is "no, and here is why".
+
+``_Surface`` therefore models the three gates the real ``JarvisBarOverlay.show``
+applies — the mode vocabulary, the AP-26 startup gate, and persistence — instead
+of recording calls blindly. Those three rules are read straight out of the
+production surface by ``tests/unit/ui/jarvisbar/test_show_makes_the_window_visible.py``,
+which is what stops this model from drifting into wishful thinking.
+
+The refusal path is the reported bug itself. On the maintainer's configuration
+(``session_idle_timeout_s = 0``, no hangup key, conversation mode) one wake word
+leaves a voice session open indefinitely, and the pipeline then declines every
+dictation with ``voice_session_active``. That refusal used to end in a log file
+the desktop app cannot display, so the key was indistinguishable from a dead
+one. It must now be visible — including, and especially, while a voice session
+owns the surface.
+"""
+
+from __future__ import annotations
+
+import asyncio
+import sys
+from pathlib import Path
+
+import pytest
+
+_REPO_ROOT = Path(__file__).resolve().parents[3]
+if str(_REPO_ROOT) in sys.path:
+ sys.path.remove(str(_REPO_ROOT))
+sys.path.insert(0, str(_REPO_ROOT))
+sys.modules.pop("ui", None)
+
+try: # noqa: SIM105 — deliberate try-import (top-level `ui` discovery quirk)
+ from ui.orb.bus_bridge import OrbBusBridge # type: ignore[import-not-found]
+except ModuleNotFoundError: # pragma: no cover
+ pytest.skip(
+ "ui.orb not importable in this pytest pythonpath — run from repo root.",
+ allow_module_level=True,
+ )
+
+from jarvis.core.events import ( # noqa: E402
+ DictationCompleted,
+ DictationRefused,
+ DictationStarted,
+ DictationTranscribing,
+ DictationTranscript,
+ SystemStateChanged,
+ VoiceSessionEnded,
+ VoiceSessionStarted,
+)
+from jarvis.ui.jarvisbar.modes import MODES # noqa: E402
+
+
+class _FakeBus:
+ def subscribe(self, *_a, **_k) -> None:
+ pass
+
+
+class _Surface:
+ """A surface that models WHETHER IT IS ON SCREEN, not just its mode.
+
+ Mirrors ``JarvisBarOverlay.show`` gate for gate:
+
+ * a mode outside the shared vocabulary is dropped whole — neither the mode
+ nor the visibility changes (the real surface returns before both);
+ * while the AP-26 startup gate is closed the mode is still tracked but the
+ window is never mapped, so ``release_startup_gate`` can reveal the
+ CURRENT mode rather than resetting to idle;
+ * a non-persistent surface withdraws on ``idle`` and maps on anything else;
+ a persistent one maps on everything and is never withdrawn by ``show``.
+ """
+
+ def __init__(self, *, persistent: bool = True, startup_gated: bool = False) -> None:
+ self.persistent = persistent
+ self.startup_gated = startup_gated
+ self.mode = "idle"
+ self.visible = False
+ self.transcripts: list[str] = []
+ self.levels: list[float] = []
+ #: Every (mode, visible) pair the surface actually ended up in, in order.
+ #: A reveal is a transition INTO ``visible=True`` — the thing the user
+ #: sees, and the thing a mode-only assertion cannot tell apart from
+ #: nothing happening at all.
+ self.frames: list[tuple[str, bool]] = []
+
+ # -- the surface API the bridge drives ------------------------------
+ def show(self, mode: str = "listen") -> None:
+ if mode not in MODES:
+ return
+ self.mode = mode
+ if self.startup_gated:
+ self._record()
+ return
+ self.visible = self.persistent or mode != "idle"
+ self._record()
+
+ def hide(self) -> None:
+ self.visible = False
+ self._record()
+
+ def release_startup_gate(self) -> bool:
+ if not self.startup_gated:
+ return False
+ self.startup_gated = False
+ if not self.persistent and self.mode == "idle":
+ return True
+ self.visible = True
+ self._record()
+ return True
+
+ def set_level(self, level: float) -> None:
+ self.levels.append(level)
+
+ def show_listening_transcript(self, text: str = "", duration_ms: int = 0) -> None:
+ self.transcripts.append(text)
+
+ def play_animation(self, name: str, **_kw) -> None: ...
+ def stop_animation(self, name: str) -> None: ...
+
+ # -- readouts -------------------------------------------------------
+ def _record(self) -> None:
+ self.frames.append((self.mode, self.visible))
+
+ @property
+ def visible_modes(self) -> list[str]:
+ """The modes the user could actually SEE, in order."""
+ return [mode for mode, visible in self.frames if visible]
+
+ @property
+ def reveals(self) -> list[str]:
+ """Modes the surface transitioned from hidden to visible in."""
+ out: list[str] = []
+ was_visible = False
+ for mode, visible in self.frames:
+ if visible and not was_visible:
+ out.append(mode)
+ was_visible = visible
+ return out
+
+
+class _VoiceOnlySurface(_Surface):
+ """A surface that predates the shared vocabulary: it knows the four voice
+ modes and raises on everything else (the mascot orb's contract)."""
+
+ def show(self, mode: str = "listen") -> None:
+ if mode not in ("idle", "listen", "speak", "think"):
+ raise ValueError(f"Unknown mode: {mode}")
+ super().show(mode)
+
+
+def _bridge(surface: _Surface, *, persistent: bool = True) -> OrbBusBridge:
+ """A bridge wired the way the desktop app wires it for this surface.
+
+ ``hide_on_idle`` is the inverse of the bar's "keep it visible at all times"
+ setting, exactly as ``DesktopApp._start_speech_and_orb`` computes it.
+ """
+ return OrbBusBridge( # type: ignore[arg-type]
+ bus=_FakeBus(),
+ orb=surface,
+ hide_on_idle=not persistent,
+ idle_animations_enabled=False,
+ )
+
+
+async def _run_standdown(bridge: OrbBusBridge) -> None:
+ """Run the pending stand-down immediately instead of waiting out its dwell."""
+ task = bridge._dictation_standdown_task
+ assert task is not None, "no stand-down was scheduled"
+ task.cancel()
+ await asyncio.sleep(0)
+ bridge._schedule_notice_standdown(0.0)
+ for _ in range(4):
+ await asyncio.sleep(0)
+
+
+async def _quiesce(bridge: OrbBusBridge) -> None:
+ for attr in ("_dictation_standdown_task", "_dictation_failsafe_task", "_hangup_task"):
+ task = getattr(bridge, attr, None)
+ if task is not None and not task.done():
+ task.cancel()
+ await asyncio.sleep(0)
+
+
+# --------------------------------------------------------------------------
+# The happy path, asserted on VISIBILITY
+# --------------------------------------------------------------------------
+async def test_the_whole_dictation_lifecycle_is_actually_on_screen() -> None:
+ """started → transcript → transcribing → completed, all of it visible.
+
+ A non-persistent surface starts withdrawn, so every step here is a claim
+ about pixels: the reveal happens at key-down, it does not blink out when the
+ key is released, and it closes itself afterwards.
+ """
+ surface = _Surface(persistent=False)
+ bridge = _bridge(surface, persistent=False)
+ assert surface.visible is False
+
+ await bridge._on_dictation_started(DictationStarted(target="insert"))
+ assert surface.visible is True
+ assert surface.reveals == ["dictate"]
+
+ await bridge._on_dictation_transcript(
+ DictationTranscript(text="hello there", is_final=False)
+ )
+ assert surface.visible is True
+ assert "hello there" in surface.transcripts
+
+ await bridge._on_dictation_transcribing(DictationTranscribing())
+ assert surface.visible is True
+ assert surface.mode == "dictate_transcribing"
+
+ await bridge._on_dictation_completed(
+ DictationCompleted(text="hello there", outcome="inserted")
+ )
+ assert surface.visible is True, "the outcome must be readable before it closes"
+
+ await _run_standdown(bridge)
+ assert surface.visible is False
+ await _quiesce(bridge)
+
+
+async def test_a_persistent_bar_is_never_withdrawn_by_a_dictation() -> None:
+ """The always-on bar returns to its idle look instead of vanishing."""
+ surface = _Surface(persistent=True)
+ surface.show("idle") # the resting state the maintainer actually sees
+ bridge = _bridge(surface, persistent=True)
+
+ await bridge._on_dictation_started(DictationStarted(target="insert"))
+ await bridge._on_dictation_completed(DictationCompleted(text="hi", outcome="inserted"))
+ await _run_standdown(bridge)
+
+ assert surface.visible is True
+ assert surface.mode == "idle"
+ await _quiesce(bridge)
+
+
+async def test_a_warming_surface_stays_off_screen_and_reveals_on_release() -> None:
+ """AP-26: a dictation may not advertise a voice stack that is still warming.
+
+ The mode is still tracked while gated, so releasing the gate shows the
+ dictation that began during warm-up rather than a stale idle pill.
+ """
+ surface = _Surface(persistent=False, startup_gated=True)
+ bridge = _bridge(surface, persistent=False)
+
+ await bridge._on_dictation_started(DictationStarted(target="insert"))
+ assert surface.visible is False
+ assert surface.mode == "dictate"
+
+ assert surface.release_startup_gate() is True
+ assert surface.visible is True
+ assert surface.mode == "dictate"
+ await _quiesce(bridge)
+
+
+# --------------------------------------------------------------------------
+# The refusal path — the reported bug
+# --------------------------------------------------------------------------
+async def test_a_refusal_is_shown_instead_of_disappearing_into_a_log() -> None:
+ surface = _Surface(persistent=False)
+ bridge = _bridge(surface, persistent=False)
+
+ await bridge._on_dictation_refused(
+ DictationRefused(
+ reason="no_stt",
+ detail="No speech-to-text provider is configured.",
+ )
+ )
+
+ assert surface.visible is True
+ assert surface.reveals == ["notice"]
+ assert "No speech-to-text provider is configured." in surface.transcripts
+ await _quiesce(bridge)
+
+
+async def test_a_refusal_during_a_live_voice_session_is_still_shown() -> None:
+ """The exact configuration in the report.
+
+ ``voice_session_active`` is the most common refusal reason there is — one
+ wake word with no auto-hangup keeps a conversation open all day. Gating the
+ notice on the bridge's own live-session flag, the way the rest of the
+ dictation lane is gated, would swallow precisely the message the user is
+ owed and put the shortcut back to doing nothing visible at all.
+ """
+ surface = _Surface(persistent=True)
+ bridge = _bridge(surface, persistent=True)
+ await bridge._on_session_started(VoiceSessionStarted(session_id="s1"))
+ assert bridge._voice_session_active is True
+ surface.frames.clear()
+
+ await bridge._on_dictation_refused(
+ DictationRefused(
+ reason="voice_session_active",
+ detail="A voice conversation is running and is using the microphone.",
+ )
+ )
+
+ assert surface.mode == "notice"
+ assert surface.visible is True
+ assert (
+ "A voice conversation is running and is using the microphone."
+ in surface.transcripts
+ )
+ await _quiesce(bridge)
+
+
+async def test_a_refusal_hands_a_live_session_back_instead_of_closing_it() -> None:
+ """Reporting a declined keypress must not take the conversation off screen."""
+ surface = _Surface(persistent=False)
+ bridge = _bridge(surface, persistent=False)
+ await bridge._on_session_started(VoiceSessionStarted(session_id="s1"))
+
+ await bridge._on_dictation_refused(
+ DictationRefused(reason="voice_session_active", detail="Hang up first.")
+ )
+ await _run_standdown(bridge)
+
+ assert surface.visible is True, "the live session must still be on screen"
+ assert surface.mode == "listen"
+ assert surface.transcripts[-1] == ""
+ await _quiesce(bridge)
+
+
+async def test_a_refusal_with_no_session_stands_the_surface_down() -> None:
+ surface = _Surface(persistent=False)
+ bridge = _bridge(surface, persistent=False)
+
+ await bridge._on_dictation_refused(
+ DictationRefused(reason="no_stt", detail="No provider.")
+ )
+ await _run_standdown(bridge)
+
+ assert surface.visible is False
+ await _quiesce(bridge)
+
+
+async def test_a_refusal_without_a_sentence_still_says_something() -> None:
+ """An empty ``detail`` is an upstream contract violation, not a reason to go
+ back to silence — the user still pressed a key."""
+ surface = _Surface(persistent=False)
+ bridge = _bridge(surface, persistent=False)
+
+ await bridge._on_dictation_refused(DictationRefused(reason="", detail=""))
+
+ assert surface.visible is True
+ assert surface.transcripts[-1].strip() != ""
+ await _quiesce(bridge)
+
+
+async def test_a_refusal_never_claims_the_microphone_is_recording() -> None:
+ """A surface that cannot render the notice is left alone rather than
+ degraded to its listening look.
+
+ The dictation lane degrades to ``listen`` on such a surface, and that is
+ honest there — something IS recording. On a refusal the same fallback would
+ be the opposite of the truth, so the message goes out through the transcript
+ line only.
+ """
+ surface = _VoiceOnlySurface(persistent=False)
+ bridge = _bridge(surface, persistent=False)
+
+ await bridge._on_dictation_refused(
+ DictationRefused(reason="no_stt", detail="No provider is configured.")
+ )
+
+ assert surface.visible_modes == []
+ assert "No provider is configured." in surface.transcripts
+ await _quiesce(bridge)
+
+
+async def test_a_refusal_clears_a_stale_dictation_lane() -> None:
+ """Nothing is recording after a refusal, so no timer may outlive it."""
+ surface = _Surface(persistent=False)
+ bridge = _bridge(surface, persistent=False)
+ await bridge._on_dictation_started(DictationStarted(target="insert"))
+ assert bridge._dictation_failsafe_task is not None
+
+ await bridge._on_dictation_refused(
+ DictationRefused(reason="already_running", detail="Already recording.")
+ )
+
+ assert bridge._dictation_active is False
+ assert bridge._dictation_transcribing is False
+ assert bridge._dictation_failsafe_task is None
+ await _quiesce(bridge)
+
+
+async def test_a_real_dictation_started_inside_the_dwell_keeps_the_surface() -> None:
+ """Refuse, then succeed a moment later: the notice's timer must not close a
+ dictation that is genuinely recording."""
+ surface = _Surface(persistent=False)
+ bridge = _bridge(surface, persistent=False)
+ await bridge._on_dictation_refused(
+ DictationRefused(reason="already_running", detail="Already recording.")
+ )
+ await bridge._on_dictation_started(DictationStarted(target="insert"))
+ surface.frames.clear()
+
+ bridge._schedule_notice_standdown(0.0)
+ for _ in range(4):
+ await asyncio.sleep(0)
+
+ assert surface.visible is True
+ assert surface.mode == "dictate"
+ await _quiesce(bridge)
+
+
+# --------------------------------------------------------------------------
+# The stale live-session mirror (why the lane went deaf for a whole day)
+# --------------------------------------------------------------------------
+async def test_a_stray_state_after_a_hangup_cannot_deafen_the_dictation_lane() -> None:
+ """The bridge's own version of the reported failure.
+
+ ``_on_session_ended`` documents that an in-flight turn can still emit an
+ active state AFTER the session is over, and suppresses the repaint. The
+ live-session MIRROR used to be set from those same suppressed transitions
+ and had no way back on a configuration whose state machine never returns to
+ IDLE on its own — after which the mirror silently outranked every dictation
+ reveal, with only a ``log.debug`` behind it. A state the handler itself
+ calls stray must not resurrect the mirror either.
+ """
+ surface = _Surface(persistent=False)
+ bridge = _bridge(surface, persistent=False)
+ await bridge._on_session_started(VoiceSessionStarted(session_id="s1"))
+ await bridge._on_session_ended(VoiceSessionEnded(session_id="s1", hangup_reason="user"))
+ assert bridge._voice_session_active is False
+
+ # The late in-flight turn finishing after the hangup.
+ await bridge._on_state(SystemStateChanged(previous="IDLE", new_state="LISTENING"))
+ assert bridge._voice_session_active is False, "a suppressed state is not a session"
+ surface.frames.clear()
+
+ await bridge._on_dictation_started(DictationStarted(target="insert"))
+
+ assert surface.visible is True
+ assert surface.reveals == ["dictate"]
+ await _quiesce(bridge)
+
+
+async def test_a_genuine_listening_edge_still_marks_the_session_live() -> None:
+ """The late-attach path is untouched: an authoritative LISTENING with no
+ hangup behind it still sets the mirror, so a stray dictation event cannot
+ repaint a real turn."""
+ surface = _Surface(persistent=False)
+ bridge = _bridge(surface, persistent=False)
+
+ await bridge._on_state(SystemStateChanged(previous="IDLE", new_state="LISTENING"))
+
+ assert bridge._voice_session_active is True
+ await bridge._on_state(SystemStateChanged(previous="LISTENING", new_state="IDLE"))
+ assert bridge._voice_session_active is False
+ await _quiesce(bridge)
diff --git a/tests/unit/ui/test_orb_mascot_dictation_look.py b/tests/unit/ui/test_orb_mascot_dictation_look.py
index 1bd771106f..9e517d4aa1 100644
--- a/tests/unit/ui/test_orb_mascot_dictation_look.py
+++ b/tests/unit/ui/test_orb_mascot_dictation_look.py
@@ -57,6 +57,7 @@ except ModuleNotFoundError: # pragma: no cover
from jarvis.core.events import ( # noqa: E402
DictationCompleted,
+ DictationRefused,
DictationStarted,
DictationTranscribing,
)
@@ -268,6 +269,55 @@ def test_every_energy_value_stays_in_range() -> None:
assert 0.0 <= mode_energy(mode, t, level) <= 1.0
+# --------------------------------------------------------------------------
+# The refusal look
+# --------------------------------------------------------------------------
+def test_a_refusal_never_shimmers_along_with_a_microphone_it_is_not_using() -> None:
+ """``notice`` ignores the live level outright.
+
+ The mascot shows the refusal SENTENCE in its bubble ("a voice conversation
+ is using the microphone"). A halo driven by that very microphone next to
+ that very sentence would contradict it — the same reason
+ ``dictate_transcribing`` drops its stale sample, one step further.
+ """
+ for t in (0.0, 1.1, 2.4, 5.0):
+ for level in (0.0, 0.5, 1.0):
+ assert mode_energy("notice", t, level) == pytest.approx(
+ mode_energy("notice", t, None)
+ )
+
+
+def test_a_refusal_still_looks_awake() -> None:
+ """Low, but never flat: a dead-still mascot reads as a crashed app, which is
+ exactly the impression a refused shortcut must stop giving."""
+ samples = [mode_energy("notice", t, None) for t in (0.0, 0.5, 1.0, 1.5, 2.0, 2.5)]
+ assert all(0.05 < v < 0.35 for v in samples)
+ assert len(set(round(v, 4) for v in samples)) > 1
+
+
+async def test_the_mascot_shows_a_refusal_and_says_why() -> None:
+ """The reported bug on the mascot surface: the key press must produce BOTH
+ something on screen and the reason for it."""
+ orb, root = _headless_mascot()
+ bridge = OrbBusBridge( # type: ignore[arg-type]
+ bus=_FakeBus(),
+ orb=orb,
+ hide_on_idle=True,
+ idle_animations_enabled=False,
+ )
+
+ await bridge._on_dictation_refused(
+ DictationRefused(
+ reason="voice_session_active",
+ detail="A voice conversation is running and is using the microphone.",
+ )
+ )
+
+ assert root.deiconify.called, "the mascot never came up for a refused dictation"
+ assert orb._mode == "notice"
+ await _drain(bridge)
+
+
# --------------------------------------------------------------------------
# Zero-regression budget on the voice modes
# --------------------------------------------------------------------------