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(realtime): make subscription status surfaces truthful

rubenluetke10-beep6a24b1b7929d
diff --git a/docs/codex-subscription-realtime-voice.md b/docs/codex-subscription-realtime-voice.md
index e6757ba750..773bfb16b2 100644
--- a/docs/codex-subscription-realtime-voice.md
+++ b/docs/codex-subscription-realtime-voice.md
@@ -483,11 +483,11 @@ them changes the trade-off above, which is a property of the wire.
requires every installed provider with `supports_direct_tools = False` to
resolve a callable brain to the delegate path and to decline an unavailable
handoff audibly without ending the call.
-3. **Wayland-only browser hand-off.** Establish whether `codex` can open a
- browser on a pure-Wayland session without XWayland. If it cannot, the
- printed device-code URL is the honest answer and the card should say so
- rather than leaving the user waiting for a window. Do not solve this by
- admitting `XDG_RUNTIME_DIR` back into the forced file-store environment.
+3. **Pure-Wayland login is explicit.** Without an X/XWayland `DISPLAY`, the
+ isolated file-credential environment cannot auto-open the browser. The card
+ keeps Connect available when a supported terminal exists and tells the user
+ before the click to follow the device-login URL printed there. It does not
+ admit `XDG_RUNTIME_DIR` back into the credential-isolated environment.
4. **Keep the CLI version pin current.** `_TRUSTED_CODEX_TARGETS` pins the six
SHA-256 hashes of `@openai/codex` 0.147.0; the previous audited 0.146.0 set
remains an explicit compatibility window. Every other build is disabled
@@ -495,18 +495,16 @@ them changes the trade-off above, which is a property of the wire.
That is deliberate — but verify the pin is still current before any release
claiming subscription voice works, and follow the five-step upgrade policy
above when moving it.
-5. **Retire or wire the dormant browser-offer stack.** No shipped provider
- sets `requires_webrtc_offer = True` since Jarvis took the WebRTC peer
- in-process, so `realtime/offer_broker.py`, `/ws/realtime-transport`,
- `lib/realtimeTransportBroker.ts`, `SubscriptionRealtimeTransportBroker.tsx`
- and the desktop broker-token plumbing are unreachable in production. Either
- delete them or mark them as a deliberately retained seam.
-6. **Reconcile `busy` between the probe and the card.**
- `external_login_ready()` fails **open** on a transient `busy` probe, while
- `_codex_subscription_status_payload` reports the same `busy` as
- `connected: false`. So `/voice-mode` can say `realtime_available: true`
- while the card says "not connected" and `PUT /voice-mode` answers 409. Both
- halves are individually right; the contradiction the user sees is not.
+5. **The browser-offer stack is a retained compatibility seam.** No built-in
+ provider currently sets `requires_webrtc_offer = True`; the broker,
+ `/ws/realtime-transport`, frontend broker, and desktop token plumbing remain
+ capability-gated for third-party entry-point providers. They are documented
+ as compatibility infrastructure, not a second Codex media path.
+6. **Transient status is reconciled.** Runtime discovery may still fail open
+ on `busy` so an authoritative opener protects a live/in-flight call. Status
+ surfaces do not: `/voice-mode` now reports availability as pending/false,
+ the card renders checking, and mode persistence returns 409. None calls an
+ unknown account state connected.
### Failure modes and where to look first
diff --git a/jarvis/codex_app_server.py b/jarvis/codex_app_server.py
index aaff0212b5..9e2445f9f8 100644
--- a/jarvis/codex_app_server.py
+++ b/jarvis/codex_app_server.py
@@ -1470,6 +1470,11 @@ _NO_LOGIN_TERMINAL_REASON: Final = (
"desktop does not provide. Install one (for example gnome-terminal, "
"konsole, xfce4-terminal, kitty or alacritty) and connect again."
)
+_PURE_WAYLAND_LOGIN_REASON: Final = (
+ "This pure-Wayland session has no XWayland display, so the isolated "
+ "subscription login cannot auto-open a browser. Connect opens a terminal; "
+ "follow the device-login URL printed there."
+)
def _headless_linux() -> bool:
@@ -1481,6 +1486,15 @@ def _headless_linux() -> bool:
)
+def _pure_wayland_linux() -> bool:
+ """A graphical Linux session with Wayland but no X/XWayland display."""
+ return bool(
+ sys.platform.startswith("linux")
+ and os.environ.get("WAYLAND_DISPLAY")
+ and not os.environ.get("DISPLAY")
+ )
+
+
def _linux_login_terminal_missing() -> bool:
"""True on a graphical Linux host with no terminal able to host the login.
@@ -1529,6 +1543,8 @@ def _login_required_state(reason: str) -> tuple[str, CodexSubscriptionReasonCode
if _headless_linux()
else _NO_LOGIN_TERMINAL_REASON
)
+ elif _pure_wayland_linux():
+ reason = _PURE_WAYLAND_LOGIN_REASON
return reason, code
diff --git a/jarvis/realtime/offer_broker.py b/jarvis/realtime/offer_broker.py
index 7f4245ccb2..3ffa3b6692 100644
--- a/jarvis/realtime/offer_broker.py
+++ b/jarvis/realtime/offer_broker.py
@@ -1,10 +1,16 @@
-"""In-process WebRTC offer handoff between UI and native voice surfaces.
+"""Retained WebRTC-offer compatibility seam for realtime plugins.
Some externally authenticated realtime transports need a genuine browser SDP
offer even when the microphone owner is the native desktop voice loop. The UI
keeps a recv-only peer ready and registers its offer here; a provider leases it
exactly once and returns the answer through the same registration. No audio,
credentials, or model content passes through this broker.
+
+No built-in provider currently declares ``requires_webrtc_offer = True``:
+Codex owns its media peer in-process and the API providers use their SDKs. The
+broker, websocket, and frontend component intentionally remain capability-
+gated for third-party entry-point providers that need browser-origin WebRTC.
+They are compatibility infrastructure, not an alternate Codex media path.
"""
from __future__ import annotations
diff --git a/jarvis/ui/web/settings_routes.py b/jarvis/ui/web/settings_routes.py
index 83a6f96f2c..e0b96b417a 100644
--- a/jarvis/ui/web/settings_routes.py
+++ b/jarvis/ui/web/settings_routes.py
@@ -272,6 +272,27 @@ async def get_voice_mode(request: Request) -> dict[str, object]:
# subprocess off the event loop so a settings poll cannot punch a hole in
# live Realtime audio playback.
prov = await asyncio.to_thread(_realtime_available_provider, cfg)
+ realtime_available = prov is not None
+ realtime_availability_pending = False
+ if prov == "codex-subscription-realtime":
+ # Runtime discovery deliberately fails open on ``busy`` because the
+ # authoritative session opener can protect an in-flight/live call.
+ # A STATUS surface must not convert that unknown answer into "ready":
+ # the provider card says checking and mode persistence returns 409, so
+ # this route reports the same pending truth while retaining the
+ # resolved provider/model labels for display.
+ from jarvis.ui.web.provider_routes import (
+ _codex_binary_path,
+ _codex_subscription_status_payload,
+ )
+
+ codex_status = await asyncio.to_thread(
+ _codex_subscription_status_payload,
+ _codex_binary_path(request),
+ )
+ if codex_status.get("reason_code") in {"busy", "login_in_progress"}:
+ realtime_available = False
+ realtime_availability_pending = True
requires_webrtc_offer = await asyncio.to_thread(
_realtime_requires_webrtc_offer, cfg
)
@@ -299,7 +320,8 @@ async def get_voice_mode(request: Request) -> dict[str, object]:
session_model = str(runtime.get("active_session_model", "") or "")
return {
"mode": mode,
- "realtime_available": prov is not None,
+ "realtime_available": realtime_available,
+ "realtime_availability_pending": realtime_availability_pending,
"requires_webrtc_offer": requires_webrtc_offer,
"handshake_budget_s": handshake_budget_s,
"transport_offer_ready": transport_offer_ready,
diff --git a/tests/unit/test_codex_auth.py b/tests/unit/test_codex_auth.py
index ed5a22fd70..200c6e0d86 100644
--- a/tests/unit/test_codex_auth.py
+++ b/tests/unit/test_codex_auth.py
@@ -844,6 +844,26 @@ def test_graphical_linux_without_a_terminal_does_not_invite_a_login(
assert "terminal emulator" in reason
+def test_pure_wayland_login_names_the_manual_browser_handoff(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ """The card must not leave a pure-Wayland user waiting for a window."""
+ import jarvis.codex_app_server as transport
+ import jarvis.codex_auth as codex_mod
+
+ monkeypatch.setattr(transport.sys, "platform", "linux")
+ monkeypatch.setenv("WAYLAND_DISPLAY", "wayland-0")
+ monkeypatch.delenv("DISPLAY", raising=False)
+ monkeypatch.setattr(codex_mod, "linux_login_terminal_available", lambda: True)
+
+ reason, code = transport._login_required_state("please log in")
+
+ assert code == "login_required"
+ assert "pure-Wayland" in reason
+ assert "device-login URL" in reason
+ assert "terminal" in reason
+
+
def test_every_login_terminal_records_why_its_flags_keep_it_in_the_foreground() -> None:
"""The reason column is the review gate for a new entry, not decoration.
diff --git a/tests/unit/web/test_voice_mode_route.py b/tests/unit/web/test_voice_mode_route.py
index 36f3d4acab..1a399572e3 100644
--- a/tests/unit/web/test_voice_mode_route.py
+++ b/tests/unit/web/test_voice_mode_route.py
@@ -210,6 +210,33 @@ def test_put_voice_mode_codex_busy_answers_409_and_persists_nothing(monkeypatch)
assert "being checked" in r.json()["detail"]
+def test_get_voice_mode_codex_busy_is_pending_not_ready(monkeypatch):
+ """Status surfaces agree: busy means checking, never connected/ready."""
+ from jarvis.ui.web import provider_routes, settings_routes
+
+ monkeypatch.setattr(
+ settings_routes,
+ "_realtime_available_provider",
+ lambda _cfg: "codex-subscription-realtime",
+ )
+ monkeypatch.setattr(
+ provider_routes,
+ "_codex_subscription_status_payload",
+ lambda _binary_path: {
+ "connected": False,
+ "reason_code": "busy",
+ },
+ )
+
+ body = TestClient(_app(mode="realtime")).get(
+ "/api/settings/voice-mode"
+ ).json()
+
+ assert body["active_provider"] == "codex-subscription-realtime"
+ assert body["realtime_available"] is False
+ assert body["realtime_availability_pending"] is True
+
+
def test_put_voice_mode_codex_logged_out_is_400(monkeypatch):
"""A pinned but logged-out provider must not be persisted as the mode."""
from jarvis.ui.web import provider_routes, settings_routes