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): say why a voice start was refused instead of guessing (#552)
Ruben Lütke7e8adfa6411e
diff --git a/dodaios/speech/pipeline.py b/dodaios/speech/pipeline.pyindex a043514453..b70d05bebb 100644--- a/dodaios/speech/pipeline.py+++ b/dodaios/speech/pipeline.py@@ -128,6 +128,7 @@ from dodaios.sessions.constants import (from dodaios.skills.schema import SkillDirectTriggeredfrom dodaios.skills.skill_context import try_get_skill_contextfrom dodaios.skills.trigger_matcher import TriggerMatcher+from dodaios.speech import start_refusalfrom dodaios.speech.completeness import (Completeness,classify_completeness,@@ -7624,6 +7625,20 @@ class SpeechPipeline:def request_voice_session(self, *, seed_messages: list[tuple[str, str]] | None = None) -> bool:+ """``start_voice_session`` for a caller that only needs armed / not armed."""+ return not self.start_voice_session(seed_messages=seed_messages)++ def _activation_state_refusal(self) -> str:+ """Which half of ``_activation_state_allows`` said no, as a refusal code."""+ if getattr(self, "_muted", False):+ return start_refusal.MUTED+ if self._dictation_blocks_activation():+ return start_refusal.DICTATION+ return start_refusal.MICROPHONE_IN_USE++ def start_voice_session(+ self, *, seed_messages: list[tuple[str, str]] | None = None+ ) -> str:"""Arm a wake-style voice session from outside the audio path.The "Speak in this conversation" button (``POST /api/chats/{kind}/@@ -7636,23 +7651,26 @@ class SpeechPipeline:``asyncio.Event`` directly from Tk can leave the selector asleep untilunrelated I/O happens to wake it.- Returns ``False`` (no-op) when a session is already active or arming,- or when the desktop app is not visible (``_activation_allowed``). The- brain is seeded ONLY when we actually arm, so a rejected request never- pollutes an unrelated in-flight session's history. Like PTT (an- explicit user action with no audio-echo path), the post-hangup- wake-lock is intentionally not consulted here.+ Returns ``""`` when the session was armed, otherwise the one reason it+ was not, from ``dodaios.speech.start_refusal`` (a no-op: a session is+ already active or arming, voice is muted, a dictation or a browser call+ holds the microphone, or the microphone is not granted). The caller+ shows that reason; it must never guess one. The brain is seeded ONLY+ when we actually arm, so a rejected request never pollutes an unrelated+ in-flight session's history. Like PTT (an explicit user action with no+ audio-echo path), the post-hangup wake-lock is intentionally not+ consulted here."""if self._ptt_mode or self._state != PipelineState.IDLE:log.info("request_voice_session ignored: pipeline not idle.")- return False+ return start_refusal.BUSYif not self._activation_state_allows():log.info("request_voice_session ignored: %s",self._activation_block_reason(explicit=True, include_permission=False)- or "activation not allowed",+ or "another call owns the microphone",)- return False+ return self._activation_state_refusal()# Gesture entry: the speak button / bar click may ask macOS for the# microphone. A first request raises the dialog and returns False (the UI# says "allowed - press again"); the session is never armed retroactively.@@ -7660,7 +7678,7 @@ class SpeechPipeline:refusal = self._ensure_microphone("voice")if refusal is not None:log.info("request_voice_session ignored: %s", refusal)- return False+ return start_refusal.MICROPHONEif seed_messages:brain = getattr(self, "_brain", None)seed = getattr(brain, "seed_history", None)@@ -7678,7 +7696,7 @@ class SpeechPipeline:len(seed_messages or []),)self._explicit_call_pending = True- return self._arm_call_event()+ return "" if self._arm_call_event() else start_refusal.UNAVAILABLEdef request_voice_hangup(self) -> bool:"""Hang up the voice channel from outside the audio path.diff --git a/dodaios/speech/start_refusal.py b/dodaios/speech/start_refusal.pynew file mode 100644index 0000000000..5f466b755d--- /dev/null+++ b/dodaios/speech/start_refusal.py@@ -0,0 +1,35 @@+"""Why a click-started voice conversation was refused.++One vocabulary for ``SpeechPipeline.start_voice_session``, the+``POST /api/voice/call`` answer and the sentence the voice controls show. The+empty string means "armed"; every other value names the one thing that stopped+the start, so the person is told that reason and never a guess.++Mirrored by ``VOICE_START_REFUSALS`` in+``dodaios/ui/web/frontend/src/lib/voiceStartRefusal.ts`` (parity:+``tests/unit/speech/test_voice_start_refusal_parity.py``).+"""++from __future__ import annotations++#: A voice session is already open, or push-to-talk is recording.+BUSY = "busy"+#: Voice is muted.+MUTED = "muted"+#: A dictation holds the microphone.+DICTATION = "dictation"+#: A browser-held call owns the microphone.+MICROPHONE_IN_USE = "microphone_in_use"+#: The operating system has not granted the microphone.+MICROPHONE = "microphone"+#: The pipeline could not take the request (its event loop is gone).+UNAVAILABLE = "unavailable"++VOICE_START_REFUSALS: tuple[str, ...] = (+ BUSY,+ MUTED,+ DICTATION,+ MICROPHONE_IN_USE,+ MICROPHONE,+ UNAVAILABLE,+)diff --git a/dodaios/ui/web/frontend/src/components/agentic/VoiceBubble.test.tsx b/dodaios/ui/web/frontend/src/components/agentic/VoiceBubble.test.tsxindex 3f31ee5cb3..dd2bea8c74 100644--- a/dodaios/ui/web/frontend/src/components/agentic/VoiceBubble.test.tsx+++ b/dodaios/ui/web/frontend/src/components/agentic/VoiceBubble.test.tsx@@ -355,7 +355,7 @@ describe("voice bubble", () => {await waitFor(() =>expect(pushToast).toHaveBeenCalledWith("warning",- expect.stringContaining("Could not start"),+ expect.stringContaining("could not be started"),),);});diff --git a/dodaios/ui/web/frontend/src/components/agentic/useVoiceCall.test.tsx b/dodaios/ui/web/frontend/src/components/agentic/useVoiceCall.test.tsxindex 1d2eb065df..9e619bc71d 100644--- a/dodaios/ui/web/frontend/src/components/agentic/useVoiceCall.test.tsx+++ b/dodaios/ui/web/frontend/src/components/agentic/useVoiceCall.test.tsx@@ -124,4 +124,42 @@ describe("useVoiceCall", () => {expect(fakes.requestVoiceHangup).toHaveBeenCalledTimes(1);});++ it("says why the host refused instead of guessing a running conversation", async () => {+ fakes.requestVoiceCall.mockResolvedValue({ armed: false, reason: "muted" });+ const { result } = renderHook(() => useVoiceCall());++ await act(() => result.current.toggleCall());++ expect(toast).toHaveBeenCalledTimes(1);+ expect(toast).toHaveBeenCalledWith(+ "warning",+ "agentic_grid.voice_bubble.start_refused.muted",+ );+ });++ it("names no cause when the host gives none", async () => {+ fakes.requestVoiceCall.mockResolvedValue({ armed: false });+ const { result } = renderHook(() => useVoiceCall());++ await act(() => result.current.toggleCall());++ expect(toast).toHaveBeenCalledWith("warning", "agentic_grid.voice_bubble.start_failed");+ });++ it("offers the hang-up for a session this window does not show", async () => {+ fakes.requestVoiceCall.mockResolvedValue({ armed: false, reason: "busy" });+ const { result } = renderHook(() => useVoiceCall());++ await act(() => result.current.toggleCall());++ const [kind, message, options] = toast.mock.calls[0];+ expect([kind, message]).toEqual([+ "warning",+ "agentic_grid.voice_bubble.start_refused.busy",+ ]);+ expect(options.action.label).toBe("agentic_grid.voice_bubble.hang_up");+ await options.action.onAction();+ expect(fakes.requestVoiceHangup).toHaveBeenCalledTimes(1);+ });});diff --git a/dodaios/ui/web/frontend/src/components/agentic/useVoiceCall.ts b/dodaios/ui/web/frontend/src/components/agentic/useVoiceCall.tsindex f0a967dbc3..981725be41 100644--- a/dodaios/ui/web/frontend/src/components/agentic/useVoiceCall.ts+++ b/dodaios/ui/web/frontend/src/components/agentic/useVoiceCall.ts@@ -6,6 +6,7 @@ import {requestVoiceCall,requestVoiceHangup,} from "@/lib/voiceApi";+import { voiceStartRefusalKey } from "@/lib/voiceStartRefusal";import { useEventStore, type VoiceState } from "@/store/events";import { useHomeStore } from "@/store/home";@@ -64,9 +65,23 @@ export function useVoiceCall() {if (!stopBrowserVoiceCall()) await requestVoiceHangup();} else {try {- const { armed } = await requestVoiceCall();+ const { armed, reason } = await requestVoiceCall();if (!armed) {- pushToast("warning", t("agentic_grid.voice_bubble.start_failed"));+ const message = t(voiceStartRefusalKey(reason));+ if (reason === "busy") {+ // A session this window does not show as running can only be+ // ended from here, so the refusal carries the way out.+ pushToast("warning", message, {+ action: {+ label: t("agentic_grid.voice_bubble.hang_up"),+ onAction: async () => {+ if (!stopBrowserVoiceCall()) await requestVoiceHangup();+ },+ },+ });+ } else {+ pushToast("warning", message);+ }}} catch (error) {if (diff --git a/dodaios/ui/web/frontend/src/i18n/locales/de.json b/dodaios/ui/web/frontend/src/i18n/locales/de.jsonindex ac01140c5d..a2c1d200c4 100644--- a/dodaios/ui/web/frontend/src/i18n/locales/de.json+++ b/dodaios/ui/web/frontend/src/i18n/locales/de.json@@ -5731,7 +5731,15 @@"close": "Sprach-Bubble schließen","mute": "Stimme von {0} für diese Sitzung stummschalten","unmute": "Stummschaltung von {0} aufheben",- "start_failed": "Das Zuhören konnte nicht gestartet werden — möglicherweise läuft bereits ein Gespräch.",+ "start_failed": "Die Sprachfunktion konnte nicht gestartet werden. Bitte versuche es erneut.",+ "start_refused": {+ "busy": "Es ist bereits ein Sprachgespräch offen. Lege zuerst auf und starte dann neu.",+ "muted": "Die Sprachfunktion ist stummgeschaltet. Hebe die Stummschaltung auf, um ein Gespräch zu starten.",+ "dictation": "Ein Diktat nutzt gerade das Mikrofon. Beende es und starte dann neu.",+ "microphone_in_use": "Ein anderer Sprachanruf nutzt gerade das Mikrofon. Beende ihn und starte dann neu.",+ "microphone": "Das Mikrofon ist nicht verfügbar. Erlaube den Mikrofonzugriff in den Systemeinstellungen und versuche es erneut.",+ "unavailable": "Die Sprachfunktion ist gerade nicht bereit. Starte die App neu und versuche es erneut."+ },"notice_jump": "Zu {0} springen","notice_dismiss": "Diese Meldung ausblenden"},diff --git a/dodaios/ui/web/frontend/src/i18n/locales/en.json b/dodaios/ui/web/frontend/src/i18n/locales/en.jsonindex 9eddf08fa8..6cd2208ceb 100644--- a/dodaios/ui/web/frontend/src/i18n/locales/en.json+++ b/dodaios/ui/web/frontend/src/i18n/locales/en.json@@ -5731,7 +5731,15 @@"close": "Close the voice bubble","mute": "Mute {0}'s voice for this session","unmute": "Unmute {0}'s voice",- "start_failed": "Could not start listening — a conversation may already be running.",+ "start_failed": "Voice could not be started. Please try again.",+ "start_refused": {+ "busy": "A voice conversation is already open. Hang up first, then start again.",+ "muted": "Voice is muted. Unmute it to start a conversation.",+ "dictation": "A dictation is using the microphone. Finish it, then start again.",+ "microphone_in_use": "Another voice call is using the microphone. End it, then start again.",+ "microphone": "The microphone is not available. Allow microphone access in your system settings, then try again.",+ "unavailable": "Voice is not ready right now. Restart the app and try again."+ },"notice_jump": "Go to {0}","notice_dismiss": "Hide this update"},diff --git a/dodaios/ui/web/frontend/src/i18n/locales/es.json b/dodaios/ui/web/frontend/src/i18n/locales/es.jsonindex 117baade53..7690101430 100644--- a/dodaios/ui/web/frontend/src/i18n/locales/es.json+++ b/dodaios/ui/web/frontend/src/i18n/locales/es.json@@ -5731,7 +5731,15 @@"close": "Cerrar la burbuja de voz","mute": "Silenciar la voz de {0} en esta sesión","unmute": "Reactivar la voz de {0}",- "start_failed": "No se pudo empezar a escuchar — puede que ya haya una conversación en curso.",+ "start_failed": "No se pudo iniciar la voz. Inténtalo de nuevo.",+ "start_refused": {+ "busy": "Ya hay una conversación de voz abierta. Cuelga primero y vuelve a empezar.",+ "muted": "La voz está silenciada. Actívala para iniciar una conversación.",+ "dictation": "Un dictado está usando el micrófono. Termínalo y vuelve a empezar.",+ "microphone_in_use": "Otra llamada de voz está usando el micrófono. Termínala y vuelve a empezar.",+ "microphone": "El micrófono no está disponible. Permite el acceso al micrófono en los ajustes del sistema e inténtalo de nuevo.",+ "unavailable": "La voz no está lista en este momento. Reinicia la aplicación e inténtalo de nuevo."+ },"notice_jump": "Ir a {0}","notice_dismiss": "Ocultar este aviso"},diff --git a/dodaios/ui/web/frontend/src/i18n/locales/pt.json b/dodaios/ui/web/frontend/src/i18n/locales/pt.jsonindex 9de537e2eb..063421704d 100644--- a/dodaios/ui/web/frontend/src/i18n/locales/pt.json+++ b/dodaios/ui/web/frontend/src/i18n/locales/pt.json@@ -5731,7 +5731,15 @@"close": "Fechar a bolha de voz","mute": "Silenciar a voz de {0} nesta sessão","unmute": "Reativar a voz de {0}",- "start_failed": "Não foi possível começar a ouvir — talvez já esteja uma conversa a decorrer.",+ "start_failed": "Não foi possível iniciar a voz. Tente novamente.",+ "start_refused": {+ "busy": "Já está aberta uma conversa de voz. Desligue primeiro e depois comece de novo.",+ "muted": "A voz está silenciada. Reative-a para iniciar uma conversa.",+ "dictation": "Um ditado está a usar o microfone. Termine-o e depois comece de novo.",+ "microphone_in_use": "Outra chamada de voz está a usar o microfone. Termine-a e depois comece de novo.",+ "microphone": "O microfone não está disponível. Permita o acesso ao microfone nas definições do sistema e tente novamente.",+ "unavailable": "A voz não está pronta neste momento. Reinicie a aplicação e tente novamente."+ },"notice_jump": "Ir para {0}","notice_dismiss": "Ocultar esta atualização"},diff --git a/dodaios/ui/web/frontend/src/i18n/locales/zh.json b/dodaios/ui/web/frontend/src/i18n/locales/zh.jsonindex 6c45a4de97..64beef1c46 100644--- a/dodaios/ui/web/frontend/src/i18n/locales/zh.json+++ b/dodaios/ui/web/frontend/src/i18n/locales/zh.json@@ -5731,7 +5731,15 @@"close": "关闭语音气泡","mute": "在本次会话中静音 {0} 的声音","unmute": "取消静音 {0} 的声音",- "start_failed": "无法开始聆听——可能已有对话在进行。",+ "start_failed": "无法启动语音。请重试。",+ "start_refused": {+ "busy": "已有语音对话在进行。请先挂断,然后重新开始。",+ "muted": "语音已静音。取消静音后即可开始对话。",+ "dictation": "听写正在使用麦克风。请先结束听写,然后重新开始。",+ "microphone_in_use": "另一个语音通话正在使用麦克风。请先结束它,然后重新开始。",+ "microphone": "麦克风不可用。请在系统设置中允许访问麦克风,然后重试。",+ "unavailable": "语音暂时未就绪。请重启应用后重试。"+ },"notice_jump": "前往 {0}","notice_dismiss": "隐藏此更新"},diff --git a/dodaios/ui/web/frontend/src/lib/voiceApi.ts b/dodaios/ui/web/frontend/src/lib/voiceApi.tsindex 8ea1308394..81b38660f3 100644--- a/dodaios/ui/web/frontend/src/lib/voiceApi.ts+++ b/dodaios/ui/web/frontend/src/lib/voiceApi.ts@@ -4,6 +4,11 @@ import { fill, translate } from "@/i18n";export interface VoiceCallAnswer {armed: boolean;+ /**+ * Why the host refused, when `armed` is false (`lib/voiceStartRefusal.ts`).+ * Absent on a host from before the field existed.+ */+ reason?: string;}export interface VoiceHangupAnswer {diff --git a/dodaios/ui/web/frontend/src/lib/voiceStartRefusal.ts b/dodaios/ui/web/frontend/src/lib/voiceStartRefusal.tsnew file mode 100644index 0000000000..fb6c7c7a81--- /dev/null+++ b/dodaios/ui/web/frontend/src/lib/voiceStartRefusal.ts@@ -0,0 +1,27 @@+/**+ * Why the host refused to start a voice conversation, and the sentence for it.+ *+ * Mirrors `VOICE_START_REFUSALS` in `dodaios/speech/start_refusal.py` (parity:+ * `tests/unit/speech/test_voice_start_refusal_parity.py`).+ */+export const VOICE_START_REFUSALS = [+ "busy",+ "muted",+ "dictation",+ "microphone_in_use",+ "microphone",+ "unavailable",+] as const;++export type VoiceStartRefusal = (typeof VOICE_START_REFUSALS)[number];++/**+ * The i18n key of the sentence for a refused start. A reason this build does+ * not know (or none, from an older host) gets the plain "could not start"+ * sentence: the control never names a cause it was not given.+ */+export function voiceStartRefusalKey(reason: string | undefined): string {+ return (VOICE_START_REFUSALS as readonly string[]).includes(reason ?? "")+ ? `agentic_grid.voice_bubble.start_refused.${reason}`+ : "agentic_grid.voice_bubble.start_failed";+}diff --git a/dodaios/ui/web/voice_call_routes.py b/dodaios/ui/web/voice_call_routes.pyindex f947823093..2f796e5df5 100644--- a/dodaios/ui/web/voice_call_routes.py+++ b/dodaios/ui/web/voice_call_routes.py@@ -143,13 +143,16 @@ async def voice_state(request: Request) -> dict[str, Any]:async def voice_call() -> dict[str, Any]:"""Start a voice conversation — functionally the wake word, by click.- ``armed`` is ``False`` when the pipeline refused (a session already runs,- or activation is blocked) — that is an answer, not an error.+ ``armed`` is ``False`` when the pipeline refused — that is an answer, not+ an error — and ``reason`` then names why, from+ ``dodaios.speech.start_refusal``, so the control can say what actually+ stopped the start. ``reason`` is ``""`` when the call was armed."""pipeline = _pipeline()- if pipeline is None or not hasattr(pipeline, "request_voice_session"):+ if pipeline is None or not hasattr(pipeline, "start_voice_session"):raise HTTPException(status_code=503, detail="voice-pipeline-unavailable")- return {"armed": bool(pipeline.request_voice_session())}+ reason = str(pipeline.start_voice_session() or "")+ return {"armed": not reason, "reason": reason}@router.post("/hangup")diff --git a/tests/unit/speech/test_request_voice_session.py b/tests/unit/speech/test_request_voice_session.pyindex beb978858d..4bef928f3a 100644--- a/tests/unit/speech/test_request_voice_session.py+++ b/tests/unit/speech/test_request_voice_session.py@@ -15,6 +15,7 @@ import pytestfrom dodaios.platform.permission_service import PermissionOutcomefrom dodaios.platform.permissions import PermissionId+from dodaios.speech import start_refusalfrom dodaios.speech.pipeline import PipelineState, SpeechPipeline, TurnTakingStatefrom tests.fakes.fake_permission_service import FakePermissionService@@ -164,3 +165,52 @@ async def test_taskbar_thread_wakes_owner_loop_immediately() -> None:"taskbar request did not wake the owner loop promptly; it likely set ""asyncio.Event directly from the Tk thread")+++# --- start_voice_session: every refusal names its own reason -----------------+++def test_start_answers_empty_when_armed() -> None:+ p = _pipe()+ assert p.start_voice_session() == ""+ assert p._call_event.is_set()+++def test_start_names_a_running_session() -> None:+ assert _pipe(state=PipelineState.ACTIVE).start_voice_session() == start_refusal.BUSY+ assert _pipe(ptt=True).start_voice_session() == start_refusal.BUSY+++def test_start_names_mute_instead_of_a_running_session() -> None:+ p = _pipe()+ p._muted = True+ assert p.start_voice_session() == start_refusal.MUTED+ assert not p._call_event.is_set()+++def test_start_names_a_dictation_that_holds_the_microphone() -> None:+ p = _pipe()+ p._dictation_blocks_activation = lambda: True+ assert p.start_voice_session() == start_refusal.DICTATION+++def test_start_names_a_browser_call_that_owns_the_microphone(monkeypatch) -> None:+ from dodaios.live import runtime++ monkeypatch.setattr(runtime, "owns_microphone", lambda **_: True)+ assert _pipe().start_voice_session() == start_refusal.MICROPHONE_IN_USE+++def test_start_names_a_refused_microphone() -> None:+ p = _pipe(gate=False)+ gate = FakePermissionService()+ gate.script(PermissionId.MICROPHONE, PermissionOutcome.DENIED)+ p._permission_gate = gate+ assert p.start_voice_session() == start_refusal.MICROPHONE+++def test_every_refusal_is_part_of_the_shared_vocabulary() -> None:+ assert len(set(start_refusal.VOICE_START_REFUSALS)) == len(+ start_refusal.VOICE_START_REFUSALS+ )+ assert "" not in start_refusal.VOICE_START_REFUSALSdiff --git a/tests/unit/speech/test_voice_start_refusal_parity.py b/tests/unit/speech/test_voice_start_refusal_parity.pynew file mode 100644index 0000000000..ed15c412f4--- /dev/null+++ b/tests/unit/speech/test_voice_start_refusal_parity.py@@ -0,0 +1,45 @@+"""Parity for the layers that share the voice start-refusal vocabulary.++``POST /api/voice/call`` answers a refused start with a reason code, and the+voice controls turn that code into the sentence the person reads. A code the+frontend does not know falls back to a sentence without a cause, and a code+without a sentence in one language shows a raw key. Both ship silently, so the+layers are held together here:++1. ``dodaios/speech/start_refusal.py`` - the Python tuple (source of truth)+2. ``dodaios/ui/web/frontend/src/lib/voiceStartRefusal.ts`` - ``VOICE_START_REFUSALS``+3. ``dodaios/ui/web/frontend/src/i18n/locales/*.json`` - one sentence per code and language+"""+from __future__ import annotations++import json+import re+from pathlib import Path++import pytest++from dodaios.speech.start_refusal import VOICE_START_REFUSALS++REPO_ROOT = Path(__file__).resolve().parents[3]+FRONTEND_SRC = REPO_ROOT / "dodaios/ui/web/frontend/src"+REFUSAL_TS = FRONTEND_SRC / "lib/voiceStartRefusal.ts"+LOCALES = sorted((FRONTEND_SRC / "i18n/locales").glob("*.json"))+++def test_the_frontend_lists_the_same_codes() -> None:+ source = REFUSAL_TS.read_text(encoding="utf-8")+ block = re.search(+ r"export const VOICE_START_REFUSALS = \[(.*?)\] as const", source, re.DOTALL+ )+ assert block, "VOICE_START_REFUSALS not found in voiceStartRefusal.ts"+ assert tuple(re.findall(r'"([a-z_]+)"', block.group(1))) == VOICE_START_REFUSALS++[email protected]("locale", LOCALES, ids=lambda path: path.stem)+def test_every_language_has_one_sentence_per_code(locale: Path) -> None:+ bubble = json.loads(locale.read_text(encoding="utf-8"))["agentic_grid"]["voice_bubble"]+ sentences = bubble["start_refused"]+ assert set(sentences) == set(VOICE_START_REFUSALS)+ assert all(str(text).strip() for text in sentences.values())+ # The fallback names no cause: it is shown when the reason is unknown.+ assert bubble["start_failed"].strip()diff --git a/tests/unit/ui/test_voice_call_routes.py b/tests/unit/ui/test_voice_call_routes.pyindex 7150b533a2..ecbcdc7276 100644--- a/tests/unit/ui/test_voice_call_routes.py+++ b/tests/unit/ui/test_voice_call_routes.py@@ -1,8 +1,8 @@"""GET /api/voice/state + POST /api/voice/call + /hangup — the voice orb's click.-The click must take the SAME path as the call hotkey (``request_voice_session``-/ ``request_voice_hangup``), report a pipeline refusal as an answer rather than-an error, and degrade honestly on a headless install (503 / available=false)+The click must take the SAME path as the call hotkey (``start_voice_session``+/ ``request_voice_hangup``), report a pipeline refusal as an answer that names+its reason rather than an error, and degrade honestly on a headless install (503 / available=false)instead of 500-ing."""from __future__ import annotations@@ -21,21 +21,21 @@ class _Pipeline:def __init__(self,- armed: bool = True,+ refusal: str = "",stopped: bool = True,*,state: str = "IDLE",supervisor_state: str = "IDLE",) -> None:- self._armed = armed+ self._refusal = refusalself._stopped = stoppedself.calls: list[str] = []self._state = SimpleNamespace(name=state)self._supervisor = SimpleNamespace(state=supervisor_state)- def request_voice_session(self) -> bool:+ def start_voice_session(self) -> str:self.calls.append("call")- return self._armed+ return self._refusaldef request_voice_hangup(self) -> bool:self.calls.append("hangup")@@ -66,16 +66,17 @@ def test_call_arms_a_wake_style_session(monkeypatch):client = _client(monkeypatch, pipeline)answer = client.post("/api/voice/call")assert answer.status_code == 200- assert answer.json() == {"armed": True}+ assert answer.json() == {"armed": True, "reason": ""}assert pipeline.calls == ["call"]def test_call_reports_a_refusal_as_an_answer(monkeypatch):- # A session already running (or a hidden window) is a refusal, not an error.- client = _client(monkeypatch, _Pipeline(armed=False))+ # A refusal is an answer, not an error, and it says which refusal it was:+ # the control must never guess "a conversation is already running".+ client = _client(monkeypatch, _Pipeline(refusal="muted"))answer = client.post("/api/voice/call")assert answer.status_code == 200- assert answer.json() == {"armed": False}+ assert answer.json() == {"armed": False, "reason": "muted"}def test_hangup_takes_the_hangup_contract(monkeypatch):