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): close round-5 findings — every surface speaks the same state

Ruben Lütke4605cab33698
diff --git a/jarvis/codex_app_server.py b/jarvis/codex_app_server.py
index 1a796074d4..05b10dfdc4 100644
--- a/jarvis/codex_app_server.py
+++ b/jarvis/codex_app_server.py
@@ -1033,6 +1033,23 @@ _CLI_VERSION_RE: Final = re.compile(
)
+def _login_required_reason_code() -> CodexSubscriptionReasonCode:
+ """The honest "please log in" state for THIS host.
+
+ On a headless Linux host the interactive browser login is impossible, so
+ inviting it would only produce an error toast after the click — the
+ pre-click truth there is ``lifecycle_unavailable`` (visible degradation,
+ CLAUDE.md §3). An EXISTING login still reports ready on such hosts.
+ """
+ if (
+ sys.platform.startswith("linux")
+ and not os.environ.get("DISPLAY")
+ and not os.environ.get("WAYLAND_DISPLAY")
+ ):
+ return "lifecycle_unavailable"
+ return "login_required"
+
+
def _displayable_cli_version(raw: str | None) -> str | None:
"""Return the probe output only when it is an actual version string.
@@ -1124,7 +1141,7 @@ def _read_codex_capability(binary_path: str | None) -> CodexAppServerCapability:
binary_path=resolved_binary,
version=version,
reason=str(exc),
- reason_code="login_required",
+ reason_code=_login_required_reason_code(),
)
except CodexSubscriptionUnavailable as exc: # Unsafe profile state becomes a status snapshot.
return CodexAppServerCapability(
@@ -1163,7 +1180,7 @@ def _read_codex_capability(binary_path: str | None) -> CodexAppServerCapability:
binary_path=resolved_binary,
version=version,
reason=str(exc),
- reason_code="login_required",
+ reason_code=_login_required_reason_code(),
)
except CodexSubscriptionUnavailable as exc: # Profile validation failure is returned to the UI.
return CodexAppServerCapability(
@@ -1199,7 +1216,7 @@ def _read_codex_capability(binary_path: str | None) -> CodexAppServerCapability:
if chatgpt_login
else "Use Jarvis's subscription-voice login to connect ChatGPT."
),
- reason_code="ready" if chatgpt_login else "login_required",
+ reason_code="ready" if chatgpt_login else _login_required_reason_code(),
)
@@ -1845,7 +1862,13 @@ class CodexAppServerClient:
await self.ensure_started()
try:
await self._verify_live_chatgpt_account()
- except CodexSubscriptionUnavailable:
+ except CodexSubscriptionUnavailable as exc:
+ if isinstance(exc, CodexSubscriptionPlanUnsupported):
+ # Recorded where the truth is discovered — this gate is also
+ # the LIVE call path, so a plan that turns unsupported after
+ # activation still flips every status surface to the sticky
+ # diagnosis instead of leaving them all claiming "ready".
+ set_codex_subscription_activation_block(str(exc))
await self._close_process(
CodexAppServerDisconnected(
"Codex app-server authentication is not ChatGPT."
@@ -3904,7 +3927,11 @@ __all__ = [
"CodexRealtimeStartResult",
"CodexSubscriptionProfileMissing",
"CodexSubscriptionContainmentUnavailable",
+ "CodexSubscriptionBinaryUnsupported",
+ "CodexSubscriptionPlanUnsupported",
"CodexSubscriptionUnavailable",
+ "codex_subscription_activation_block",
+ "set_codex_subscription_activation_block",
"codex_subscription_auth_snapshot",
"codex_subscription_home",
"codex_subscription_login_ready",
diff --git a/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.test.tsx b/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.test.tsx
index 2b3c372d3f..7ab8ae0a7a 100644
--- a/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.test.tsx
@@ -590,6 +590,10 @@ describe("ProviderCard: ChatGPT subscription Realtime", () => {
name: "Connect with ChatGPT",
}) as HTMLButtonElement;
expect(connect.disabled).toBe(true);
+ // The state chip stays neutral — nothing is "missing" on an OS the
+ // feature does not support.
+ expect(screen.queryByText("missing")).toBeNull();
+ expect(screen.getByText("unavailable")).toBeTruthy();
});
it("shows the sticky plan diagnosis after a refused activation", () => {
diff --git a/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.tsx b/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.tsx
index 49c7db8f9b..2beff53036 100644
--- a/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.tsx
+++ b/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.tsx
@@ -768,18 +768,28 @@ export function ProviderCard({
return;
}
if (!assumeConfigured && !descriptor.configured) {
- // A transient busy probe means "state unknown for a moment" — telling
- // the user to redo a working ChatGPT login here would contradict the
- // card's own "checking" line (and the backend's 409 for this case).
- if (descriptor.codex_status?.reason_code === "busy") {
- pushToast("info", t("apikeys_codex.status_busy"));
+ const codexReason = descriptor.codex_status?.reason_code;
+ // Transient/in-flight states are notes, not faults — and telling the
+ // user to redo a working ChatGPT login would contradict the card's own
+ // "checking" / "finish the login" line (and the backend's 409s).
+ if (codexReason === "busy" || codexReason === "login_in_progress") {
+ pushToast("info", t(CODEX_STATUS_KEY_BY_REASON[codexReason]));
return;
}
pushToast(
"warning",
descriptor.auth_mode === "codex"
? isSubscriptionLoginOnly
- ? t("apikeys_codex.subscription_login_required")
+ ? // The reason-specific line names the actual remedy (install the
+ // pinned release, unsupported OS, unsupported plan…) — a blank
+ // "connect first" would be wrong for most of those states.
+ t(
+ (codexReason &&
+ (CODEX_STATUS_KEY_BY_REASON as Record<string, string>)[
+ codexReason
+ ]) ||
+ "apikeys_codex.subscription_login_required",
+ )
: t("apikeys_codex.needs_codex_full").replace("{0}", descriptor.label)
: descriptor.auth_mode === "antigravity"
? t("apikeys_antigravity.needs_login_full").replace("{0}", descriptor.label)
@@ -1310,8 +1320,14 @@ export function ActiveControl({
? disabledReason ?? "Provider cannot be activated"
: descriptor.configured
? "Activate this provider"
- : descriptor.codex_status?.reason_code === "busy"
- ? t("apikeys_codex.status_busy")
+ : descriptor.codex_status?.reason_code
+ ? // The reason-specific line names the actual remedy; a generic
+ // "connect first" is wrong for most non-ready codex states.
+ t(
+ (CODEX_STATUS_KEY_BY_REASON as Record<string, string>)[
+ descriptor.codex_status.reason_code
+ ] ?? "apikeys_view.needs_credentials",
+ )
: t("apikeys_view.needs_credentials");
return (
@@ -2014,6 +2030,9 @@ export function StatusBadge({ descriptor }: { descriptor: ProviderDescriptor })
// exactly the bug this state exists to prevent.
if (status?.reason_code === "busy")
return <StateChip tone="neutral">checking</StateChip>;
+ // Nothing is "missing" on an OS the feature does not support at all.
+ if (status?.reason_code === "lifecycle_unavailable")
+ return <StateChip tone="neutral">unavailable</StateChip>;
if (!status?.installed) return <StateChip tone="missing">missing</StateChip>;
if (descriptor.configured) return <StateChip tone="ready">ready</StateChip>;
return <StateChip tone="neutral">not connected</StateChip>;
diff --git a/jarvis/ui/web/provider_routes.py b/jarvis/ui/web/provider_routes.py
index 6ec36cdbd1..337e50401e 100644
--- a/jarvis/ui/web/provider_routes.py
+++ b/jarvis/ui/web/provider_routes.py
@@ -1138,16 +1138,19 @@ async def _run_tier_test(
_codex_subscription_status_payload,
getattr(getattr(cfg, "codex", None), "binary_path", "") or None,
)
- if payload.get("reason_code") == "busy":
- # Transient — the same instant renders "checking" on the card and
- # unknown on the tab dot; a not_configured verdict here would be
- # the one dissenting surface. rate_limited is the existing
- # "transient, integration fine" status in the test vocabulary.
+ if payload.get("reason_code") in {"busy", "login_in_progress"}:
+ # Transient — the same instant renders "checking" (or "finish the
+ # login") on the card and unknown on the tab dot; a not_configured
+ # verdict here would be the one dissenting surface. rate_limited
+ # is the existing "transient, integration fine" status in the
+ # test vocabulary, and the payload message carries the honest
+ # wording for whichever transient state this is.
return _provider_test.ProviderTestResult(
spec.id,
_provider_test.RATE_LIMITED,
- "The ChatGPT voice status is still being checked — try again "
- "in a moment.",
+ str(payload.get("message") or "")
+ or "The ChatGPT voice status is still being checked — try "
+ "again in a moment.",
)
isolated_status = SimpleNamespace(
connected=bool(payload.get("connected")),
@@ -1361,6 +1364,18 @@ async def _tier_section_health(
detail=f"{spec.label}: login in progress",
subject_id=spec.id,
)
+ if codex_payload.get("reason_code") == "plan_unsupported":
+ # Connected but permanently refused: "not connected or
+ # configured" would name the wrong remedy in the hover text.
+ return SectionHealth(
+ status=_section_health.NEEDS_SETUP,
+ reason="plan_unsupported",
+ detail=(
+ f"{spec.label}: "
+ f"{codex_payload.get('message') or 'ChatGPT plan not supported'}"
+ ),
+ subject_id=spec.id,
+ )
configured = bool(codex_payload.get("connected"))
else:
configured = await _provider_credential_present_for_binary_async(
@@ -3843,17 +3858,8 @@ async def realtime_switch(body: SwitchBody, request: Request) -> dict[str, Any]:
),
) from exc
except Exception as exc: # noqa: BLE001 - provider gate returns a safe 409
- if spec.id == "codex-subscription-realtime":
- from jarvis.codex_app_server import (
- CodexSubscriptionPlanUnsupported,
- set_codex_subscription_activation_block,
- )
-
- if isinstance(exc, CodexSubscriptionPlanUnsupported):
- # Sticky: the one honest toast fades in seconds, but this
- # account can never activate — every surface must stop
- # claiming "ready" until a different login exists.
- set_codex_subscription_activation_block(str(exc))
+ # A refused plan already recorded its sticky diagnosis where it was
+ # discovered (require_chatgpt_login) — the live call path shares it.
raise HTTPException(status_code=409, detail=str(exc)) from exc
if spec.id == "codex-subscription-realtime":
from jarvis.codex_app_server import set_codex_subscription_activation_block
diff --git a/tests/unit/codex_app_server/test_transport.py b/tests/unit/codex_app_server/test_transport.py
index 84fc703cce..e455f10b3b 100644
--- a/tests/unit/codex_app_server/test_transport.py
+++ b/tests/unit/codex_app_server/test_transport.py
@@ -2378,6 +2378,38 @@ def test_failure_memo_is_not_served_on_the_stale_path(
assert "owned elsewhere" in snapshot.reason
+async def test_live_account_gate_records_the_plan_block(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ """The sticky diagnosis is written where the truth is discovered — the
+ live account gate — so a plan that turns unsupported AFTER activation
+ still flips every status surface, not just the activation route."""
+ client = CodexAppServerClient("codex-test")
+
+ async def no_start() -> None:
+ return None
+
+ async def refuse() -> None:
+ raise transport.CodexSubscriptionPlanUnsupported(
+ "Subscription voice permits only personal ChatGPT accounts."
+ )
+
+ async def no_close(*_args: object, **_kwargs: object) -> None:
+ return None
+
+ monkeypatch.setattr(client, "ensure_started", no_start)
+ monkeypatch.setattr(client, "_verify_live_chatgpt_account", refuse)
+ monkeypatch.setattr(client, "_close_process", no_close)
+
+ with pytest.raises(transport.CodexSubscriptionPlanUnsupported):
+ await client.require_chatgpt_login()
+
+ assert transport.codex_subscription_activation_block() == (
+ "Subscription voice permits only personal ChatGPT accounts."
+ )
+
+
def test_activation_block_sticks_until_invalidated() -> None:
transport.set_codex_subscription_activation_block(
"Subscription voice permits only personal ChatGPT accounts."
diff --git a/tests/unit/ui/test_provider_spec_codex_subscription_realtime.py b/tests/unit/ui/test_provider_spec_codex_subscription_realtime.py
index 649fc1b118..8c2ed8d000 100644
--- a/tests/unit/ui/test_provider_spec_codex_subscription_realtime.py
+++ b/tests/unit/ui/test_provider_spec_codex_subscription_realtime.py
@@ -581,6 +581,116 @@ async def test_tier_test_reports_busy_as_transient_not_as_unconfigured(
assert "being checked" in result.detail
+async def test_tier_test_reports_login_in_progress_as_transient(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ """During a running login the Test button must not dissent from the card."""
+ spec = get_spec("codex-subscription-realtime")
+ assert spec is not None
+ monkeypatch.setattr(
+ routes,
+ "_codex_subscription_status_payload",
+ lambda _binary_path: {
+ "installed": True,
+ "connected": False,
+ "mode": "not_connected",
+ "message": "Dedicated ChatGPT subscription login is in progress.",
+ "reason_code": "login_in_progress",
+ },
+ )
+
+ result = await routes._run_tier_test(spec, SimpleNamespace())
+
+ assert result.status == "rate_limited"
+ assert "login is in progress" in result.detail
+
+
+async def test_section_health_reports_login_in_progress_as_unknown(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ spec = get_spec("codex-subscription-realtime")
+ assert spec is not None
+ monkeypatch.setattr(
+ routes,
+ "_codex_subscription_status_payload",
+ lambda _binary_path: {
+ "installed": True,
+ "connected": False,
+ "mode": "not_connected",
+ "message": "Dedicated ChatGPT subscription login is in progress.",
+ "reason_code": "login_in_progress",
+ },
+ )
+
+ health = await routes._tier_section_health(
+ SimpleNamespace(), spec, binary_path="codex-custom"
+ )
+
+ assert health.status == "unknown"
+ assert health.reason == "login_in_progress"
+
+
+async def test_section_health_names_the_plan_as_the_blocker(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ spec = get_spec("codex-subscription-realtime")
+ assert spec is not None
+ monkeypatch.setattr(
+ routes,
+ "_codex_subscription_status_payload",
+ lambda _binary_path: {
+ "installed": True,
+ "connected": False,
+ "mode": "not_connected",
+ "message": "Subscription voice permits only personal ChatGPT accounts.",
+ "reason_code": "plan_unsupported",
+ },
+ )
+
+ health = await routes._tier_section_health(
+ SimpleNamespace(), spec, binary_path="codex-custom"
+ )
+
+ assert health.status == "needs_setup"
+ assert health.reason == "plan_unsupported"
+ # The hover detail names the actual blocker, not "not connected".
+ assert "personal ChatGPT accounts" in health.detail
+
+
+async def test_realtime_activation_asks_to_finish_a_running_login(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ monkeypatch.setattr(routes, "_codex_binary_path", lambda *_args: "codex")
+ monkeypatch.setattr(
+ routes,
+ "_codex_subscription_status_payload",
+ lambda _binary_path: {
+ "installed": True,
+ "connected": False,
+ "mode": "not_connected",
+ "message": "Dedicated ChatGPT subscription login is in progress.",
+ "reason_code": "login_in_progress",
+ },
+ )
+
+ with pytest.raises(HTTPException) as caught:
+ await routes.realtime_switch(
+ routes.SwitchBody(
+ provider="codex-subscription-realtime",
+ persist=False,
+ accept_experimental=True,
+ ),
+ object(),
+ )
+
+ assert caught.value.status_code == 409
+ assert "Finish" in str(caught.value.detail)
+
+
def test_install_hint_pins_the_supported_release() -> None:
"""The card's install command must name the pinned release — a silent
unpin would send users to a version the trust gate rejects."""