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(realtime): show the experimental notice once, and report a stuck mute
Ruben Lütkedbb31f42bcae
diff --git a/jarvis/realtime/session.py b/jarvis/realtime/session.pyindex 68ac68d112..f452b47201 100644--- a/jarvis/realtime/session.py+++ b/jarvis/realtime/session.py@@ -65,6 +65,11 @@ log = logging.getLogger(__name__)_MAX_UNSCRUBBED_AUDIO_MS = 15_000_PROVIDER_HANDSHAKE_TOTAL_TIMEOUT_S = 12.0_AUDIO_SEND_TIMEOUT_S = 2.0+# A reply lasts seconds; a half-duplex mute that outlives one is a stuck turn,+# not normal speaking. Report it, then keep reporting at this interval so a+# call that went deaf is visible for its whole duration, not only at onset.+_HALF_DUPLEX_MUTE_ALERT_S = 6.0+_HALF_DUPLEX_MUTE_REPEAT_S = 10.0_TOOL_TRANSCRIPT_WAIT_S = 3.0# Grace window for the model to finish its goodbye after an end_call tool# call; if the provider never sends turn_complete, hang up anyway.@@ -976,6 +981,13 @@ class RealtimeVoiceSession:self.allow_classic_fallback = bool(allow_classic_fallback)self._transport_offer_sdp = ""self._output_active = False+ # Half-duplex mutes the microphone while the assistant speaks. If that+ # state is ever left standing, the user talks and NOTHING reaches the+ # session — and the drop is silent by construction, so the call just+ # looks like it stopped listening. Track how long it has been muted so+ # the condition is visible instead of invisible (AP-30).+ self._half_duplex_muted_since: float | None = None+ self._half_duplex_mute_reported = 0.0brain_config = getattr(self._config, "brain", None)reply_language = str(@@ -1712,13 +1724,41 @@ class RealtimeVoiceSession:self._pump(), name=f"rt-pump-{self.session_id}")+ def _note_half_duplex_mute(self) -> None:+ """Report a microphone that half-duplex has been holding shut too long.++ A reply lasts seconds; a mute that outlives one is a stuck turn, and+ the user experiences it as "it just stopped listening to me" with+ nothing anywhere to say why.+ """+ now = time.monotonic()+ if self._half_duplex_muted_since is None:+ self._half_duplex_muted_since = now+ return+ muted_s = now - self._half_duplex_muted_since+ if muted_s < _HALF_DUPLEX_MUTE_ALERT_S:+ return+ if now - self._half_duplex_mute_reported < _HALF_DUPLEX_MUTE_REPEAT_S:+ return+ self._half_duplex_mute_reported = now+ log.warning(+ "realtime[%s] microphone has been muted by half-duplex for %.1fs — "+ "the assistant is still marked as speaking, so nothing the user "+ "says is reaching the provider",+ self.session_id,+ muted_s,+ )+async def handle_audio_frame(self, pcm_native: bytes) -> None:if self._ended or self._session is None or not pcm_native:returnif self._session is self._transport_rebuild_pending:returnif self._half_duplex and self._output_active:+ self._note_half_duplex_mute()return+ self._half_duplex_muted_since = None+ self._half_duplex_mute_reported = 0.0try:if self.browser_sample_rate == self._input_sample_rate:pcm16 = bytes(pcm_native)diff --git a/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.test.tsx b/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.test.tsxindex 2674f0969e..fc013d082b 100644--- a/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.test.tsx+++ b/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.test.tsx@@ -20,6 +20,10 @@ import { act, cleanup, fireEvent, render, screen, waitFor } from "@testing-libraimport { ProviderCard } from "@/components/providers/ProviderTierSection";import type { ProviderDescriptor, ProviderTestResult } from "@/hooks/useProviders";import { useI18nStore, type UiLanguage } from "@/i18n";++const EXPERIMENTAL_CONSENT_KEY =+ "jarvis.experimentalConsent.codex-subscription-realtime";+import { useEventStore } from "@/store/events";interface Call {@@ -151,6 +155,7 @@ function polishPin(calls: Call[]): Record<string, unknown> {describe("ProviderCard — dictation polish activation", () => {beforeEach(() => {+ window.localStorage.clear();vi.restoreAllMocks();});@@ -211,6 +216,7 @@ describe("ProviderCard — dictation polish activation", () => {describe("ProviderCard — a switched-to polish provider proves it works", () => {beforeEach(() => {+ window.localStorage.clear();vi.restoreAllMocks();useI18nStore.getState().setUi("en", { push: false });useEventStore.setState({ toasts: [] });@@ -311,6 +317,7 @@ describe("ProviderCard — a switched-to polish provider proves it works", () =>describe("ProviderCard: ChatGPT subscription Realtime", () => {beforeEach(() => {+ window.localStorage.clear();vi.restoreAllMocks();useEventStore.setState({ toasts: [] });useI18nStore.getState().setUi("en", { push: false });@@ -626,8 +633,9 @@ describe("ProviderCard: ChatGPT subscription Realtime", () => {it("lets a plan-blocked card retry activation through the backend", async () => {const calls = installFetchMock();- // The experimental-provider acknowledgement dialog (jsdom cannot show it).- vi.spyOn(window, "confirm").mockReturnValue(true);+ // Not this test's subject: the route was acknowledged earlier, so the+ // dialog stays away (it asks once per provider, never on every switch).+ window.localStorage.setItem(EXPERIMENTAL_CONSENT_KEY, "1");renderCard(codexRealtimeCard({configured: false,@@ -738,7 +746,7 @@ describe("ProviderCard: ChatGPT subscription Realtime", () => {it("activates through the Realtime switch without the Brain API-key guard", async () => {const calls = installFetchMock();- vi.spyOn(window, "confirm").mockReturnValue(true);+ window.localStorage.setItem(EXPERIMENTAL_CONSENT_KEY, "1");renderCard(codexRealtimeCard());fireEvent.click(screen.getByText("ChatGPT subscription (Codex)"));@@ -759,13 +767,15 @@ describe("ProviderCard: ChatGPT subscription Realtime", () => {it("does not activate until the user accepts the experimental boundary", async () => {const calls = installFetchMock();- vi.spyOn(window, "confirm").mockReturnValue(false);const optimistic = vi.fn();renderCard(codexRealtimeCard(), () => {}, optimistic);fireEvent.click(screen.getByText("ChatGPT subscription (Codex)"));- await waitFor(() => expect(window.confirm).toHaveBeenCalledOnce());+ // An in-app dialog, not window.confirm: the desktop shell renders that as+ // a raw "127.0.0.1 says" box and it blocks the whole window.+ const cancel = await screen.findByText("Cancel");+ fireEvent.click(cancel);expect(calls.some((candidate) =>@@ -780,17 +790,39 @@ describe("ProviderCard: ChatGPT subscription Realtime", () => {it("flips the radio optimistically only after the consent is accepted", async () => {installFetchMock();- vi.spyOn(window, "confirm").mockReturnValue(true);const optimistic = vi.fn();renderCard(codexRealtimeCard(), () => {}, optimistic);fireEvent.click(screen.getByText("ChatGPT subscription (Codex)"));+ const accept = await screen.findByText("Yes");+ expect(optimistic).not.toHaveBeenCalled();+ fireEvent.click(accept);++ await waitFor(() =>+ expect(optimistic).toHaveBeenCalledWith(+ "realtime",+ "codex-subscription-realtime",+ ),+ );+ });++ it("asks for the experimental acknowledgement once, not on every switch", async () => {+ installFetchMock();+ window.localStorage.setItem(EXPERIMENTAL_CONSENT_KEY, "1");+ const optimistic = vi.fn();+ renderCard(codexRealtimeCard(), () => {}, optimistic);++ fireEvent.click(screen.getByText("ChatGPT subscription (Codex)"));++ // Straight through: re-asking every time taught the user to click the+ // notice away unread, which defeats the point of showing it at all.await waitFor(() =>expect(optimistic).toHaveBeenCalledWith("realtime","codex-subscription-realtime",),);+ expect(screen.queryByText("Yes")).toBeNull();});});diff --git a/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.tsx b/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.tsxindex d12b588e76..c0f59d6ac6 100644--- a/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.tsx+++ b/jarvis/ui/web/frontend/src/components/providers/ProviderTierSection.tsx@@ -70,6 +70,34 @@ export interface CategoryMeta {// Realtime only when a realtime provider actually has a key// (`realtimeAvailable`), so the switch can never pin the boot default to an// unreachable engine. See `EngineModeSwitch` below for the exact rule.+/** Remembered acknowledgement of an experimental provider route.+ *+ * The notice is worth showing once — it explains whose plan pays and that the+ * route can change without notice. Showing it on EVERY switch is the+ * confirmation fatigue this project rejects, and it taught the user to click+ * it away unread, which defeats the point of having it. */+function experimentalConsentKey(providerId: string): string {+ return `jarvis.experimentalConsent.${providerId}`;+}++function hasExperimentalConsent(providerId: string): boolean {+ try {+ return window.localStorage.getItem(experimentalConsentKey(providerId)) === "1";+ } catch {+ // A WebView with storage disabled simply asks again next time: annoying,+ // never broken, and never silently skipping the notice.+ return false;+ }+}++function rememberExperimentalConsent(providerId: string): void {+ try {+ window.localStorage.setItem(experimentalConsentKey(providerId), "1");+ } catch {+ // Same trade-off as above — the dialog reappears, nothing else breaks.+ }+}+export type VoiceEngineMode = "pipeline" | "realtime";// The three provider slots the maintainer's setup recommendation speaks about@@ -696,6 +724,12 @@ export function ProviderCard({}) {const t = useT();const [activating, setActivating] = useState(false);+ // The experimental-route acknowledgement. It used to be a window.confirm,+ // which the desktop WebView renders as a raw "127.0.0.1 says" box that also+ // blocks the whole window — and it reappeared on EVERY switch, which is the+ // confirmation fatigue this project explicitly rejects. Now it is an in-app+ // dialog shown once per provider.+ const [consentPending, setConsentPending] = useState(false);const pushToast = useEventStore((s) => s.pushToast);const assistantName = useEventStore((s) => s.assistantName);// The card only escalates to red for a real "set up but failing" error — the@@ -814,8 +848,9 @@ export function ProviderCard({if (isRealtimeSwitch &&descriptor.experimental &&- !window.confirm(t("apikeys_view.experimental_subscription_consent"))+ !hasExperimentalConsent(descriptor.id)) {+ setConsentPending(true);return;}// Flip the highlight immediately so the switch feels instant — the backend@@ -931,7 +966,53 @@ export function ProviderCard({await activate(true);}+ const consentDialog = consentPending ? (+ <div+ className="fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4"+ onClick={(event) => {+ event.stopPropagation();+ setConsentPending(false);+ }}+ >+ <div+ className="card-outline max-w-lg space-y-4 bg-background p-5 shadow-xl"+ onClick={(event) => event.stopPropagation()}+ >+ <div className="text-sm font-semibold">{descriptor.label}</div>+ <p className="text-sm leading-relaxed text-muted-foreground">+ {t("apikeys_view.experimental_subscription_consent")}+ </p>+ <div className="flex justify-end gap-2">+ <button+ type="button"+ className="btn-outline px-3 py-1.5 text-sm"+ onClick={(event) => {+ event.stopPropagation();+ setConsentPending(false);+ }}+ >+ {t("common.cancel")}+ </button>+ <button+ type="button"+ className="btn-primary px-3 py-1.5 text-sm"+ onClick={(event) => {+ event.stopPropagation();+ rememberExperimentalConsent(descriptor.id);+ setConsentPending(false);+ void activate();+ }}+ >+ {t("common.yes")}+ </button>+ </div>+ </div>+ </div>+ ) : null;+return (+ <>+ {consentDialog}<divonClick={handleCardActivate}onDoubleClick={handleCardActivate}@@ -1167,6 +1248,7 @@ export function ProviderCard({/></div></div>+ </>);}@@ -1355,13 +1437,13 @@ export function ActiveControl({e.stopPropagation();}}className={cn(- "inline-flex shrink-0 select-none items-center gap-1.5 text-xs",+ "inline-flex shrink-0 select-none items-center gap-1.5 rounded-full border px-2.5 py-1.5 text-xs transition-colors focus-within:ring-2 focus-within:ring-primary focus-within:ring-offset-2 focus-within:ring-offset-background",disabled ? "cursor-not-allowed" : "cursor-pointer",descriptor.active- ? "font-medium text-primary"+ ? "border-primary/40 bg-primary/10 font-semibold text-primary": descriptor.configured- ? "text-muted-foreground hover:text-foreground"- : "text-muted-foreground/70",+ ? "border-border bg-background text-muted-foreground hover:border-primary/40 hover:text-foreground"+ : "border-border/60 text-muted-foreground/70",)}title={labelTitle}>@@ -1373,7 +1455,11 @@ export function ActiveControl({disabled={activating || disabled}className="accent-primary"/>- {activating ? "Activating…" : descriptor.active ? "Active" : "Set active"}+ {activating+ ? t("apikeys_view.provider_activating")+ : descriptor.active+ ? t("apikeys_view.provider_active")+ : t("apikeys_view.provider_set_active")}</label>);}@@ -1573,11 +1659,11 @@ export function AuthWidget({{descriptor.experimental && (<divdata-testid={`provider-experimental-note-${descriptor.id}`}- className="rounded-md border border-violet-500/30 bg-violet-500/[0.06] px-3 py-2 text-xs leading-relaxed text-muted-foreground"+ className="rounded-md border border-violet-500/30 bg-violet-500/[0.06] px-2.5 py-1.5 text-[11px] leading-snug text-muted-foreground">- <p>{t("apikeys_view.subscription_realtime_description")}</p>- <p className="mt-1">- {t("apikeys_view.experimental_subscription_fallback")}+ <p>+ <span>{t("apikeys_view.subscription_realtime_description")}</span>{" "}+ <span>{t("apikeys_view.experimental_subscription_fallback")}</span></p></div>)}