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(voice): a fallback to classic voice is not a hangup — keep the bar on the call

Ruben Lütkeaa5cf13b3d86
diff --git a/jarvis/realtime/session.py b/jarvis/realtime/session.py
index 319b3b2188..ab7aef5510 100644
--- a/jarvis/realtime/session.py
+++ b/jarvis/realtime/session.py
@@ -44,6 +44,7 @@ from jarvis.realtime.protocol import RealtimeSessionConfig
from jarvis.realtime.scrub_gate import ScrubHoldGate
from jarvis.sessions.constants import (
HANGUP_CLIENT_STOP,
+ HANGUP_DESKTOP_FALLBACK,
HANGUP_VOICE_PATTERN,
SPOKEN_KIND_PROGRESS,
SPOKEN_KIND_REPLY,
@@ -5348,8 +5349,32 @@ class RealtimeVoiceSession:
# the second event with the same session_id as a natural no-op, and
# the redundancy keeps the wiki completeness sweep alive even when
# one layer misses its teardown.
- if self._bus is not None and (
- self._surface != "browser" or self._browser_session_started
+ #
+ # ONE exception: a desktop engine handover is not an end at all. When
+ # no realtime provider can open a session (or the duplex stream dies
+ # before a turn is committed), the classic pipeline picks the SAME call
+ # up under the SAME session_id and publishes the one real end when it
+ # actually finishes. Announcing an end here told every subscriber that
+ # tracks session boundaries the call was over: the orb bridge armed its
+ # post-hangup latch and dropped every later LISTENING/THINKING/SPEAKING
+ # of the live call as a stray, so the JarvisBar froze mid-call until the
+ # next wake word, and the recorder closed the row with turns=0 (live
+ # 2026-07-26 — both providers out of credit, so EVERY session fell back
+ # and the bar was dead for the whole conversation). The browser keeps
+ # its fallback end: nothing else would ever close its row.
+ handover_to_classic = (
+ reason == HANGUP_DESKTOP_FALLBACK and self._surface != "browser"
+ )
+ if handover_to_classic:
+ log.info(
+ "realtime[%s] handing this call to the classic pipeline — "
+ "no session end published (the pipeline owns it).",
+ self.session_id,
+ )
+ if (
+ self._bus is not None
+ and not handover_to_classic
+ and (self._surface != "browser" or self._browser_session_started)
):
try:
from jarvis.core.events import VoiceSessionEnded
diff --git a/jarvis/sessions/constants.py b/jarvis/sessions/constants.py
index 9c5329ca1b..f2fedb5e83 100644
--- a/jarvis/sessions/constants.py
+++ b/jarvis/sessions/constants.py
@@ -64,12 +64,26 @@ HANGUP_ERROR: Final[str] = "error"
termination. The exact failure should be in the trace logs; this
string only marks the session row."""
+HANGUP_DESKTOP_FALLBACK: Final[str] = "desktop_fallback"
+"""The desktop realtime engine handed the SAME voice session over to the
+classic pipeline (no realtime provider could open a session, or the duplex
+stream died before any turn was committed).
+
+This marks a handover, NOT an end: the pipeline keeps the same ``session_id``
+running and publishes the one real ``VoiceSessionEnded`` when the call actually
+finishes. ``RealtimeVoiceSession.end`` therefore stops here without announcing a
+session end — treating the handover as one froze the JarvisBar mid-call and
+closed the recorder row with ``turns=0`` (live 2026-07-26). It stays in
+``HANGUP_REASONS`` because rows written before that fix still carry it, so the
+session list must keep a label for them."""
+
HANGUP_REASONS: Final[tuple[str, ...]] = (
HANGUP_VOICE_PATTERN,
HANGUP_HOTKEY,
HANGUP_CLIENT_STOP,
HANGUP_WS_CLOSED,
HANGUP_REALTIME_FALLBACK,
+ HANGUP_DESKTOP_FALLBACK,
HANGUP_IDLE_TIMEOUT,
HANGUP_TURN_COMPLETE,
HANGUP_SHUTDOWN,
@@ -186,6 +200,7 @@ SPOKEN_KINDS: Final[tuple[str, ...]] = (
__all__ = [
"HANGUP_CLIENT_STOP",
+ "HANGUP_DESKTOP_FALLBACK",
"HANGUP_ERROR",
"HANGUP_HOTKEY",
"HANGUP_IDLE_TIMEOUT",
diff --git a/jarvis/sessions/models.py b/jarvis/sessions/models.py
index 36cc7daac6..7f50c9cb44 100644
--- a/jarvis/sessions/models.py
+++ b/jarvis/sessions/models.py
@@ -37,6 +37,7 @@ KNOWN_HANGUP_REASONS: frozenset[str] = frozenset(
"client_stop", # browser client explicitly stopped microphone audio
"ws_closed", # browser voice WebSocket closed
"realtime_fallback", # browser switched to the classic voice pipeline
+ "desktop_fallback", # legacy rows: desktop handover to classic voice
"idle_timeout", # auto-hangup after inactivity
"shutdown", # app shutdown ends the running session
"error", # pipeline crash
diff --git a/jarvis/sessions/schema.sql b/jarvis/sessions/schema.sql
index c0014cb44a..79d8523e95 100644
--- a/jarvis/sessions/schema.sql
+++ b/jarvis/sessions/schema.sql
@@ -13,7 +13,7 @@ CREATE TABLE IF NOT EXISTS voice_sessions (
id TEXT PRIMARY KEY, -- session_id (UUIDv4 string)
started_ms INTEGER NOT NULL, -- wake timestamp
ended_ms INTEGER, -- NULL while the session is active
- hangup_reason TEXT, -- voice_pattern|hotkey|client_stop|ws_closed|realtime_fallback|idle_timeout|turn_complete|shutdown|error
+ hangup_reason TEXT, -- voice_pattern|hotkey|client_stop|ws_closed|realtime_fallback|desktop_fallback|idle_timeout|turn_complete|shutdown|error
turn_count INTEGER NOT NULL DEFAULT 0,
total_cost_usd REAL NOT NULL DEFAULT 0.0,
total_tokens_in INTEGER NOT NULL DEFAULT 0,
diff --git a/jarvis/speech/pipeline.py b/jarvis/speech/pipeline.py
index 535183948e..7cd661ee0f 100644
--- a/jarvis/speech/pipeline.py
+++ b/jarvis/speech/pipeline.py
@@ -79,6 +79,7 @@ from jarvis.plugins.wake.openwakeword_provider import (
OpenWakeWordProvider,
)
from jarvis.sessions.constants import (
+ HANGUP_DESKTOP_FALLBACK,
HANGUP_ERROR,
HANGUP_HOTKEY,
HANGUP_IDLE_TIMEOUT,
@@ -6627,7 +6628,11 @@ class SpeechPipeline:
preroll: deque[bytes] = deque()
preroll_bytes = 0
wait_tasks: set[asyncio.Task[Any]] = set()
- reason = "desktop_fallback"
+ # Default: this session ends by handing the SAME call to the classic
+ # pipeline. Every genuine hangup path below overwrites it. The marker
+ # keeps ``RealtimeVoiceSession.end`` from announcing a session end that
+ # never happened — the pipeline's own teardown owns that.
+ reason = HANGUP_DESKTOP_FALLBACK
session: Any | None = None
microphone_task: asyncio.Task[Any] | None = None
try:
diff --git a/jarvis/ui/web/frontend/src/components/sessions/SessionList.tsx b/jarvis/ui/web/frontend/src/components/sessions/SessionList.tsx
index 46bb82450e..26cb37aed2 100644
--- a/jarvis/ui/web/frontend/src/components/sessions/SessionList.tsx
+++ b/jarvis/ui/web/frontend/src/components/sessions/SessionList.tsx
@@ -151,6 +151,8 @@ function hangupLabel(reason: string): string {
return translate("session_list.hangup_ws_closed");
case "realtime_fallback":
return translate("session_list.hangup_realtime_fallback");
+ case "desktop_fallback":
+ return translate("session_list.hangup_desktop_fallback");
case "idle_timeout":
return translate("session_list.hangup_idle_timeout");
case "shutdown":
diff --git a/jarvis/ui/web/frontend/src/components/sessions/types.ts b/jarvis/ui/web/frontend/src/components/sessions/types.ts
index 50132459b4..3d21207868 100644
--- a/jarvis/ui/web/frontend/src/components/sessions/types.ts
+++ b/jarvis/ui/web/frontend/src/components/sessions/types.ts
@@ -13,6 +13,7 @@ export const KNOWN_HANGUP_REASONS = [
"client_stop",
"ws_closed",
"realtime_fallback",
+ "desktop_fallback",
"idle_timeout",
"shutdown",
"error",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.json
index 6ce6c2a361..9a82aa3f6a 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json
@@ -1991,6 +1991,7 @@
"hangup_client_stop": "Gestoppt",
"hangup_ws_closed": "Browser geschlossen",
"hangup_realtime_fallback": "Auf klassischen Modus gewechselt",
+ "hangup_desktop_fallback": "Auf klassischen Modus gewechselt",
"hangup_idle_timeout": "Timeout",
"hangup_shutdown": "Shutdown"
},
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.json
index 246a651997..e257a7c529 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json
@@ -1992,6 +1992,7 @@
"hangup_client_stop": "Stopped",
"hangup_ws_closed": "Browser closed",
"hangup_realtime_fallback": "Switched to classic",
+ "hangup_desktop_fallback": "Switched to classic",
"hangup_idle_timeout": "Timeout",
"hangup_shutdown": "Shutdown"
},
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.json
index e583c3ef00..9b2484f31d 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json
@@ -1991,6 +1991,7 @@
"hangup_client_stop": "Detenido",
"hangup_ws_closed": "Navegador cerrado",
"hangup_realtime_fallback": "Cambio al modo clásico",
+ "hangup_desktop_fallback": "Cambio al modo clásico",
"hangup_idle_timeout": "Tiempo de espera",
"hangup_shutdown": "Apagado"
},
diff --git a/tests/unit/realtime/test_engine_handover_keeps_session.py b/tests/unit/realtime/test_engine_handover_keeps_session.py
new file mode 100644
index 0000000000..5eabfa2097
--- /dev/null
+++ b/tests/unit/realtime/test_engine_handover_keeps_session.py
@@ -0,0 +1,102 @@
+"""An engine handover is not a hangup — surfaces must keep following the call.
+
+Live forensic 2026-07-26 (log 16:15 + 16:56): both realtime providers were out
+of credit, so EVERY voice session fell back to the classic pipeline seconds
+after the wake word. On its way out the realtime session published
+``VoiceSessionEnded(desktop_fallback)`` for a call that was still running under
+the SAME ``session_id``. The orb bridge armed its post-hangup suppression latch
+and dropped every later LISTENING/THINKING/SPEAKING of that call as a stray
+("stray THINKING outside live session suppressed"), so the JarvisBar froze the
+instant the handover happened and only came back on the next wake word. The
+session recorder closed the row with ``turns=0`` for the same reason.
+
+The desktop pipeline owns the real session bracket: it publishes
+``VoiceSessionStarted`` before the engine is chosen and the one real
+``VoiceSessionEnded`` in its session-loop teardown. The browser surface has no
+such second publisher, so its fallback end must survive.
+"""
+
+from __future__ import annotations
+
+import asyncio
+from types import SimpleNamespace
+
+import pytest
+
+from jarvis.core.bus import EventBus
+from jarvis.core.events import VoiceSessionEnded
+from jarvis.realtime.session import RealtimeVoiceSession
+from jarvis.sessions.constants import (
+ HANGUP_DESKTOP_FALLBACK,
+ HANGUP_REALTIME_FALLBACK,
+ HANGUP_VOICE_PATTERN,
+)
+
+
+class _IdleProvider:
+ """Provider that never opens a stream — the handover case under test."""
+
+ name = "fake-realtime"
+ input_sample_rate = 16_000
+
+ async def open(self, config): # pragma: no cover - never reached here
+ raise RuntimeError("provider unavailable")
+
+
+def _cfg() -> SimpleNamespace:
+ return SimpleNamespace(
+ brain=SimpleNamespace(reply_language="en", providers={}),
+ stt=SimpleNamespace(language="auto"),
+ voice=SimpleNamespace(mode="realtime"),
+ latency=SimpleNamespace(enabled=False),
+ )
+
+
+def _session(*, bus: EventBus, surface: str) -> RealtimeVoiceSession:
+ return RealtimeVoiceSession(
+ session_id="s-handover",
+ send_binary=lambda _b: asyncio.sleep(0),
+ send_json=lambda _m: asyncio.sleep(0),
+ provider=_IdleProvider(),
+ config=_cfg(),
+ bus=bus,
+ surface=surface,
+ )
+
+
+async def _ends_published(*, surface: str, reason: str) -> list[VoiceSessionEnded]:
+ bus = EventBus()
+ seen: list[VoiceSessionEnded] = []
+
+ async def _capture(event: VoiceSessionEnded) -> None:
+ seen.append(event)
+
+ bus.subscribe(VoiceSessionEnded, _capture)
+ session = _session(bus=bus, surface=surface)
+ if surface == "browser":
+ # The browser gate opens once its own session-started went out.
+ session._browser_session_started = True
+ await session.end(reason=reason)
+ return seen
+
+
+async def test_desktop_handover_to_classic_publishes_no_session_end() -> None:
+ """The call continues in the classic pipeline — nothing ended."""
+ assert await _ends_published(surface="desktop", reason=HANGUP_DESKTOP_FALLBACK) == []
+
+
+async def test_real_desktop_hangup_still_publishes_session_end() -> None:
+ """A genuine hangup must stay observable (the redundancy that keeps the
+ wiki completeness sweep alive when the pipeline misses its teardown)."""
+ ends = await _ends_published(surface="desktop", reason=HANGUP_VOICE_PATTERN)
+ assert [event.hangup_reason for event in ends] == [HANGUP_VOICE_PATTERN]
+
+
+async def test_browser_fallback_still_publishes_session_end() -> None:
+ """The browser's classic session publishes no end of its own — suppressing
+ this one would leave its recorder row open forever."""
+ ends = await _ends_published(surface="browser", reason=HANGUP_REALTIME_FALLBACK)
+ assert [event.hangup_reason for event in ends] == [HANGUP_REALTIME_FALLBACK]