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): the microphone mute silences a live call the window owns

rubenluetke10-beep98dd52d199ca
diff --git a/jarvis/live/native.py b/jarvis/live/native.py
index 7dede0d313..f67a87da6a 100644
--- a/jarvis/live/native.py
+++ b/jarvis/live/native.py
@@ -116,6 +116,7 @@ class NativeLiveVoiceSession(LiveVoiceSession):
register(self)
self._pump_task = asyncio.create_task(self._pump(), name="native-live-events")
await self._take_startup_input(message)
+ self._watch_input_mute()
await self._send_json(
{
"type": "audio_ready",
@@ -125,6 +126,7 @@ class NativeLiveVoiceSession(LiveVoiceSession):
"output_sample_rate": self._provider.output_sample_rate,
"language": self._language,
"requires_webrtc_answer": False,
+ "input_muted": self._input_muted,
}
)
except BaseException:
@@ -132,7 +134,12 @@ class NativeLiveVoiceSession(LiveVoiceSession):
raise
async def handle_audio_frame(self, pcm: bytes) -> None:
- if self._connection is not None and not self._closing and not self._recovering:
+ if (
+ self._connection is not None
+ and not self._closing
+ and not self._recovering
+ and not self._input_muted
+ ):
audio = self._resampler.process(pcm)
if audio:
try:
@@ -410,6 +417,7 @@ class NativeLiveVoiceSession(LiveVoiceSession):
if self._ended:
return
self._ended = True
+ self._stop_watching_input_mute()
self._clear_media_levels()
self._closing = True
await self._publish_phase("idle")
diff --git a/jarvis/live/session.py b/jarvis/live/session.py
index 56d8ab51e1..32c7d7fe9d 100644
--- a/jarvis/live/session.py
+++ b/jarvis/live/session.py
@@ -30,6 +30,13 @@ REASONING_SNAPSHOT_INTERVAL_S = 0.3
_REASONING_ITEMS_MAX = 16
+def _pipeline_input_muted() -> bool:
+ """Jarvis's microphone mute. The speech pipeline is its only writer."""
+ from jarvis.core.runtime_refs import get_speech_pipeline
+
+ return bool(getattr(get_speech_pipeline(), "is_muted", False))
+
+
def _summary_index(event: dict) -> int:
"""The summary part a reasoning-summary event belongs to (0 when absent)."""
try:
@@ -104,6 +111,11 @@ class LiveVoiceSession:
self._mic_feedback_owned = False
self._mic_feedback_warning = False
self._input_active = False
+ # The mute on the pet strip, the Jarvis Bar or the orb. A browser call
+ # owns its microphone in the WebView, out of reach of the pipeline's own
+ # capture gate, so the session drops the frames and tells the page.
+ self._input_muted = False
+ self._watching_input_mute = False
self._media_timeout: asyncio.TimerHandle | None = None
self._active_model = ""
self._archive_turn_id = str(uuid4())
@@ -510,6 +522,7 @@ class LiveVoiceSession:
if self._closing:
return
await self._take_startup_input(message)
+ self._watch_input_mute()
await self._send_json(
{
"type": "audio_ready",
@@ -521,6 +534,7 @@ class LiveVoiceSession:
"requires_webrtc_answer": bool(offer),
"webrtc_answer_sdp": self._connection.answer_sdp,
"continuous": True,
+ "input_muted": self._input_muted,
}
)
except BaseException as exc:
@@ -594,11 +608,44 @@ class LiveVoiceSession:
if prefix is not None:
await self._send_json(prefix)
+ def _watch_input_mute(self) -> None:
+ """Adopt the current microphone mute and follow it until the call ends."""
+ self._input_muted = _pipeline_input_muted()
+ if self._bus is None or self._watching_input_mute:
+ return
+ from jarvis.core.events import VoiceMuteChanged
+
+ self._bus.subscribe(VoiceMuteChanged, self._on_input_mute_changed)
+ self._watching_input_mute = True
+
+ def _stop_watching_input_mute(self) -> None:
+ if not self._watching_input_mute or self._bus is None:
+ return
+ from jarvis.core.events import VoiceMuteChanged
+
+ self._bus.unsubscribe(VoiceMuteChanged, self._on_input_mute_changed)
+ self._watching_input_mute = False
+
+ async def _on_input_mute_changed(self, event: Any) -> None:
+ """Drop the user's audio from now on and let the page silence its track.
+
+ Dropping frames here covers the PCM socket. A WebRTC call sends its
+ audio straight to the provider, so only the page can silence that one.
+ """
+ self._input_muted = bool(event.muted)
+ if self._closing:
+ return
+ try:
+ await self._send_json({"type": "input_mute", "muted": self._input_muted})
+ except Exception: # noqa: BLE001 — the frames are dropped here regardless
+ log.warning("Voice page missed the microphone mute", exc_info=True)
+
async def handle_audio_frame(self, pcm: bytes) -> None:
if (
self._connection is None
or self._closing
or self._recovering
+ or self._input_muted
or self._connection.answer_sdp
):
return
@@ -1137,6 +1184,7 @@ class LiveVoiceSession:
if self._ended:
return
self._ended = True
+ self._stop_watching_input_mute()
self._clear_media_levels()
from jarvis.live.runtime import unregister
diff --git a/jarvis/ui/web/frontend/src/lib/realtimeAudio.test.ts b/jarvis/ui/web/frontend/src/lib/realtimeAudio.test.ts
index 0cc026cfb8..33b1dbf6d1 100644
--- a/jarvis/ui/web/frontend/src/lib/realtimeAudio.test.ts
+++ b/jarvis/ui/web/frontend/src/lib/realtimeAudio.test.ts
@@ -153,6 +153,36 @@ describe("realtime audio client", () => {
await client.disconnect();
});
+ it.each([true, false])("silences the microphone track while Jarvis's mute is on (WebRTC=%s)", async (webrtc) => {
+ const { track } = installVoiceBrowserFakes() as { track: { stop: () => void; enabled?: boolean } };
+ vi.stubGlobal("Audio", class { play = async () => undefined; pause = () => undefined; });
+ const client = new RealtimeAudioClient({}, { browserAudio: true, requiresWebRtcOffer: webrtc });
+ const connecting = client.connect();
+ await vi.waitFor(() => expect(FakeWebSocket.instances).toHaveLength(1));
+ const socket = FakeWebSocket.instances[0];
+ socket.open();
+ socket.receive({
+ type: "audio_ready",
+ requires_webrtc_answer: webrtc,
+ input_muted: true,
+ ...(webrtc ? { webrtc_answer_sdp: "answer" } : {}),
+ });
+ expect(track.enabled).toBe(false);
+ await connecting;
+ socket.receive({ type: "input_mute", muted: false });
+ expect(track.enabled).toBe(true);
+ socket.receive({ type: "input_mute", muted: true });
+ expect(track.enabled).toBe(false);
+ socket.receive({ type: "input_mute", muted: false });
+ socket.receive({ type: "audio_stopping" });
+ expect(track.enabled).toBe(false);
+ // An unmute after the call began closing never reopens the microphone.
+ socket.receive({ type: "input_mute", muted: false });
+ expect(track.enabled).toBe(false);
+ socket.receive({ type: "audio_closed" });
+ await client.disconnect();
+ });
+
it("precedes browser PCM with native wake audio on the local/Gemini path", async () => {
installVoiceBrowserFakes();
const client = new RealtimeAudioClient({}, { browserAudio: true });
diff --git a/jarvis/ui/web/frontend/src/lib/realtimeAudio.ts b/jarvis/ui/web/frontend/src/lib/realtimeAudio.ts
index f065da86ce..f23afed111 100644
--- a/jarvis/ui/web/frontend/src/lib/realtimeAudio.ts
+++ b/jarvis/ui/web/frontend/src/lib/realtimeAudio.ts
@@ -401,6 +401,11 @@ export class RealtimeAudioClient {
private finalized: (() => void) | null = null;
private serverClosed = false;
private reconnecting = false;
+ // Jarvis's microphone mute (pet strip, Jarvis Bar, orb), sent by the
+ // backend. A WebRTC call carries this track straight to the provider, so
+ // the backend cannot drop its audio; a disabled track sends silence.
+ private inputMuted = false;
+ private inputStopped = false;
constructor(
private cb: RealtimeCallbacks = {},
@@ -477,6 +482,22 @@ export class RealtimeAudioClient {
};
}
+ private syncInputTracks(): void {
+ const enabled = !this.inputMuted && !this.inputStopped;
+ this.stream?.getAudioTracks().forEach(track => { track.enabled = enabled; });
+ }
+
+ private applyInputMute(muted: unknown): void {
+ if (typeof muted !== "boolean") return;
+ this.inputMuted = muted;
+ this.syncInputTracks();
+ }
+
+ private stopInput(): void {
+ this.inputStopped = true;
+ this.syncInputTracks();
+ }
+
connect(): Promise<void> {
if (this.ready) return Promise.resolve();
if (this.connecting) return this.connecting;
@@ -490,6 +511,8 @@ export class RealtimeAudioClient {
this.intentionalClose = false;
this.serverClosed = false;
this.reconnecting = false;
+ this.inputMuted = false;
+ this.inputStopped = false;
try {
const supportIssue = browserRealtimeSupportIssue();
if (supportIssue) throw new RealtimeAudioSupportError(supportIssue);
@@ -723,7 +746,9 @@ export class RealtimeAudioClient {
} else if (type === "audio_stopping") {
this.startupNode?.port.postMessage({ type: "suspend" });
this.webRtcTransport.muteOutput();
- this.stream?.getAudioTracks().forEach(track => { track.enabled = false; });
+ this.stopInput();
+ } else if (type === "input_mute") {
+ this.applyInputMute(message.muted);
} else if (type === "audio_closed") {
this.serverClosed = true;
this.finalized?.();
@@ -748,6 +773,8 @@ export class RealtimeAudioClient {
// The local control channel can already relay levels while RTP
// finishes its handshake. Native and browser bars share this input.
this.controlReady = true;
+ // Before the retained opening is released below.
+ this.applyInputMute(message.input_muted);
this.sendMediaLevels(true);
this.setOutputRate(message.output_sample_rate);
void this.finishAudioReady(message)
@@ -926,7 +953,7 @@ export class RealtimeAudioClient {
if (this.options.browserAudio && this.ready && !this.serverClosed && this.ws?.readyState === WebSocket.OPEN) {
this.ready = false;
this.webRtcTransport.muteOutput();
- this.stream?.getAudioTracks().forEach(track => { track.enabled = false; });
+ this.stopInput();
await new Promise<void>(resolve => {
const timer = window.setTimeout(resolve, 16_000);
this.finalized = () => { window.clearTimeout(timer); resolve(); };
diff --git a/tests/contract/test_live_input_mute.py b/tests/contract/test_live_input_mute.py
new file mode 100644
index 0000000000..7e8f4c0bf4
--- /dev/null
+++ b/tests/contract/test_live_input_mute.py
@@ -0,0 +1,100 @@
+"""Jarvis's microphone mute reaches a live call whose microphone the page owns.
+
+Live 2026-10-01: the pet strip's microphone flipped the pipeline's mute, but a
+browser-owned GPT-Live call kept hearing the user, because the pipeline's
+capture gate never sees that audio.
+"""
+
+from types import SimpleNamespace
+
+import pytest
+
+from jarvis.core import runtime_refs
+from jarvis.core.bus import EventBus
+from jarvis.core.events import VoiceMuteChanged
+from jarvis.live.native import NativeLiveVoiceSession
+from jarvis.live.session import LiveVoiceSession
+
+
+class _Connection:
+ answer_sdp = ""
+
+ def __init__(self) -> None:
+ self.sent: list[object] = []
+
+ async def send(self, message: dict) -> None:
+ self.sent.append(message)
+
+ async def send_audio(self, chunk: object) -> None:
+ self.sent.append(chunk)
+
+ async def close(self) -> None:
+ return None
+
+
[email protected](params=[LiveVoiceSession, NativeLiveVoiceSession])
+def call(request, monkeypatch):
+ pipeline = SimpleNamespace(is_muted=False)
+ monkeypatch.setattr(runtime_refs, "get_speech_pipeline", lambda: pipeline)
+ bus = EventBus()
+ page: list[dict] = []
+
+ async def send_json(message: dict) -> None:
+ page.append(message)
+
+ async def send_binary(_data: bytes) -> None:
+ return None
+
+ session = request.param(
+ session_id="mute-test",
+ bus=bus,
+ send_json=send_json,
+ send_binary=send_binary,
+ config=SimpleNamespace(brain=SimpleNamespace(reply_language="en")),
+ providers=[
+ SimpleNamespace(name="test", input_sample_rate=24000, output_sample_rate=24000)
+ ],
+ )
+ connection = _Connection()
+ session._connection = connection
+ return SimpleNamespace(
+ session=session, bus=bus, page=page, connection=connection, pipeline=pipeline
+ )
+
+
+PCM = b"\x01\x00" * 4800
+
+
+async def test_a_mute_during_the_call_stops_the_audio_and_tells_the_page(call):
+ call.session._watch_input_mute()
+ await call.session.handle_audio_frame(PCM)
+ assert len(call.connection.sent) == 1
+
+ await call.bus.publish(VoiceMuteChanged(muted=True, source="pet_strip"))
+ assert call.page[-1] == {"type": "input_mute", "muted": True}
+ await call.session.handle_audio_frame(PCM)
+ assert len(call.connection.sent) == 1
+
+ await call.bus.publish(VoiceMuteChanged(muted=False, source="pet_strip"))
+ assert call.page[-1] == {"type": "input_mute", "muted": False}
+ await call.session.handle_audio_frame(PCM)
+ assert len(call.connection.sent) == 2
+
+
+async def test_a_call_that_starts_muted_adopts_the_mute(call):
+ call.pipeline.is_muted = True
+ call.session._watch_input_mute()
+ assert call.session._input_muted is True
+ await call.session.handle_audio_frame(PCM)
+ assert call.connection.sent == []
+
+
+async def test_an_ended_call_stops_following_the_mute(call):
+ call.session._watch_input_mute()
+ call.session._stop_watching_input_mute()
+ await call.bus.publish(VoiceMuteChanged(muted=True, source="pet_strip"))
+ assert call.page == []
+ assert call.session._input_muted is False