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
feat(voice): acknowledge listening readiness with a cue and pet nod
rubenluetke10-beep8e0937662802
diff --git a/jarvis/live/native.py b/jarvis/live/native.pyindex 20c7277b53..b31da0a2ae 100644--- a/jarvis/live/native.py+++ b/jarvis/live/native.py@@ -212,6 +212,9 @@ class NativeLiveVoiceSession(LiveVoiceSession):await self._send_json({"type": "audio_ready",+ "sound_effects": bool(+ getattr(getattr(self._config, "ui", None), "sound_effects", True)+ ),"provider": self.active_provider,"model": model,"input_sample_rate": rate,diff --git a/jarvis/live/session.py b/jarvis/live/session.pyindex 5432012b33..65b8882b23 100644--- a/jarvis/live/session.py+++ b/jarvis/live/session.py@@ -795,6 +795,9 @@ class LiveVoiceSession:await self._send_json({"type": "audio_ready",+ "sound_effects": bool(+ getattr(getattr(self._config, "ui", None), "sound_effects", True)+ ),"provider": self.active_provider,"model": profile.model,"language": self._language,diff --git a/jarvis/realtime/session.py b/jarvis/realtime/session.pyindex aae291ef66..9c19b9a7f6 100644--- a/jarvis/realtime/session.py+++ b/jarvis/realtime/session.py@@ -3658,6 +3658,9 @@ class RealtimeVoiceSession:)ready = {"type": "audio_ready",+ "sound_effects": bool(+ getattr(getattr(self._config, "ui", None), "sound_effects", True)+ ),"provider": self.active_provider,"model": self._active_model,# The call's output language, from the ONE resolverdiff --git a/jarvis/speech/pipeline.py b/jarvis/speech/pipeline.pyindex fe0edd6688..f6e84454b0 100644--- a/jarvis/speech/pipeline.py+++ b/jarvis/speech/pipeline.py@@ -9083,6 +9083,8 @@ class SpeechPipeline:# starts "fresh" so the first INCOMPLETE gets an earcon, not a# spoken cue. (The spoken-cue path is for mid-conversation use.)self._session_has_assistant_spoken = False+ self._listening_cue_started = False+ self._listening_cue_task: asyncio.Task[None] | None = Nonesession_id = str(uuid4())self._termination_producer = ""self._termination_detail = {}@@ -9136,11 +9138,9 @@ class SpeechPipeline:self._active_voice_mode,)await self._set_turn_state(TurnTakingState.LISTENING)- # Activation feedback is now visual-only. Playing a- # chime or spoken ACK while a portable desktop mic is- # live forces an impossible choice: discard simultaneous- # user speech or feed speaker echo into STT. The visible- # bar is the truthful zero-loss acknowledgement.+ # The selected engine confirms readiness with a brief+ # non-speech cue. Never play the legacy spoken ACK or+ # pause capture: the opening words are already buffered.hangup_reason = await self._active_session(input_buffer=input_buffer)@@ -9152,6 +9152,14 @@ class SpeechPipeline:self._termination_producer = "speech.pipeline._state_loop.error"log.exception("Voice session failed: %s", exc)finally:+ cue = getattr(self, "_listening_cue_task", None)+ if cue is not None:+ await cancel_and_reap(+ cue,+ budget_s=_SESSION_TASK_REAP_BUDGET_S,+ heartbeat_s=_SESSION_TASK_REAP_HEARTBEAT_S,+ )+ self._listening_cue_task = Nonetermination = self._termination_snapshot(hangup_reason)reopen_after_engine_change = bool(getattr(self, "_reopen_after_engine_change", False)@@ -9270,6 +9278,23 @@ class SpeechPipeline:except Exception as exc: # noqa: BLE001log.debug("Earcon playback skipped (%s).", exc)+ def _start_listening_cue(self) -> None:+ """Confirm native capture once, without blocking or suppressing input."""+ if getattr(self, "_listening_cue_started", False):+ return+ self._listening_cue_started = True+ if (+ not self._earcons_enabled()+ or self.is_speaker_muted+ or getattr(self, "_muted", False)+ or self._hangup_event.is_set()+ or self._external_hangup_pending.is_set()+ ):+ return+ self._listening_cue_task = asyncio.create_task(+ self._play_earcon(CHIME_PCM), name="voice-listening-cue"+ )+async def _play_ack(self, *, ptt: bool = False) -> None:"""Play the legacy chime and optional pre-rendered acknowledgement.@@ -9394,6 +9419,7 @@ class SpeechPipeline:async with self._session_input_source(input_buffer, discard_suppressed=True) as input_chunks:+ self._start_listening_cue()vad_iter = self._vad.utterances(self._session_input_stream(input_chunks)).__aiter__()@@ -9933,6 +9959,7 @@ class SpeechPipeline:# already listening (field report 2026-08-06). Say the true# state now: from here the session hears the user.await self._transition("LISTENING")+ self._start_listening_cue()elif kind == "transcript":role = str(message.get("role", ""))if role == "user" and bool(message.get("is_final", False)):diff --git a/jarvis/ui/web/frontend/src/lib/listeningCue.ts b/jarvis/ui/web/frontend/src/lib/listeningCue.tsnew file mode 100644index 0000000000..bb0659c741--- /dev/null+++ b/jarvis/ui/web/frontend/src/lib/listeningCue.ts@@ -0,0 +1,40 @@+/** A local, non-speech acknowledgement on the call's existing audio context. */+export function playListeningCue(ctx: AudioContext, volume: number): () => void {+ const voices: OscillatorNode[] = [];+ let gain: GainNode | undefined;+ let stopped = false;+ const stop = () => {+ if (stopped) return;+ stopped = true;+ for (const voice of voices) {+ voice.onended = null;+ voice.disconnect();+ try { voice.stop(); }+ catch { /* A partially constructed oscillator may not have started. */ }+ }+ gain?.disconnect();+ };+ try {+ if (ctx.state !== "running" || !Number.isFinite(volume) || volume <= 0) return stop;+ gain = ctx.createGain();+ const now = ctx.currentTime;+ gain.gain.setValueAtTime(0, now);+ gain.gain.linearRampToValueAtTime(0.09 * Math.min(1, volume), now + 0.01);+ gain.gain.exponentialRampToValueAtTime(0.0001, now + 0.18);+ gain.connect(ctx.destination);+ for (const frequency of [880, 1320]) {+ const voice = ctx.createOscillator();+ voices.push(voice);+ voice.frequency.value = frequency;+ voice.connect(gain);+ voice.start(now);+ voice.stop(now + 0.18);+ }+ voices[voices.length - 1].onended = stop;+ } catch (error) {+ // Readiness feedback must never fail a working microphone connection.+ console.debug("Listening cue unavailable", error);+ stop();+ }+ return stop;+}diff --git a/jarvis/ui/web/frontend/src/lib/realtimeAudio.test.ts b/jarvis/ui/web/frontend/src/lib/realtimeAudio.test.tsindex 4109db1d7f..32c1b52be0 100644--- a/jarvis/ui/web/frontend/src/lib/realtimeAudio.test.ts+++ b/jarvis/ui/web/frontend/src/lib/realtimeAudio.test.ts@@ -28,13 +28,24 @@ class FakeAudioNode {}class FakeAudioContext {+ static voices: Array<{ start: ReturnType<typeof vi.fn>; stop: ReturnType<typeof vi.fn>; disconnect: ReturnType<typeof vi.fn> }> = [];+ state = "running";+ currentTime = 0;sampleRate = 48_000;destination = {} as AudioDestinationNode;audioWorklet = { addModule: vi.fn(async () => undefined) };resume = vi.fn(async () => undefined);close = vi.fn(async () => undefined);createMediaStreamSource = vi.fn(() => new FakeAudioNode());- createGain = vi.fn(() => Object.assign(new FakeAudioNode(), { gain: { value: 1 } }));+ createGain = vi.fn(() => Object.assign(new FakeAudioNode(), { gain: {+ value: 1, setValueAtTime: vi.fn(), linearRampToValueAtTime: vi.fn(), exponentialRampToValueAtTime: vi.fn(),+ } }));+ createOscillator = vi.fn(() => {+ const voice = { frequency: { value: 0 }, connect: vi.fn(), disconnect: vi.fn(),+ start: vi.fn(), stop: vi.fn(), onended: null };+ FakeAudioContext.voices.push(voice);+ return voice;+ });createMediaStreamDestination = vi.fn(() => Object.assign(new FakeAudioNode(), {stream: { getAudioTracks: () => ["buffered-track"], getTracks: () => [] },}));@@ -126,6 +137,42 @@ function installVoiceBrowserFakes() {}describe("realtime audio client", () => {+ it.each([+ { sound_effects: false }, { input_muted: true }, { output_muted: true }, { output_volume: 0 },+ ])("respects readiness cue mute %j", async (state) => {+ installVoiceBrowserFakes();+ const client = new RealtimeAudioClient();+ const connecting = client.connect();+ await vi.waitFor(() => expect(FakeWebSocket.instances).toHaveLength(1));+ const socket = FakeWebSocket.instances[0];+ socket.open();+ socket.receive({ type: "audio_ready", ...state });+ await connecting;+ expect(FakeAudioContext.voices).toHaveLength(0);+ await client.disconnect();+ });++ it("plays once and cancels the cue on output mute without stopping the microphone", async () => {+ const { track } = installVoiceBrowserFakes();+ const client = new RealtimeAudioClient();+ const connecting = client.connect();+ await vi.waitFor(() => expect(FakeWebSocket.instances).toHaveLength(1));+ const socket = FakeWebSocket.instances[0];+ socket.open();+ socket.receive({ type: "audio_ready" });+ await connecting;+ expect(FakeAudioContext.voices).toHaveLength(2);+ socket.receive({ type: "output_state", muted: true, revision: 1 });+ expect(FakeAudioContext.voices.every(voice => voice.disconnect.mock.calls.length === 1)).toBe(true);+ expect(track.stop).not.toHaveBeenCalled();+ socket.receive({ type: "reconnecting" });+ socket.receive({ type: "audio_ready", output_muted: false, output_revision: 2 });+ await Promise.resolve();+ await Promise.resolve();+ expect(FakeAudioContext.voices).toHaveLength(2);+ await client.disconnect();+ });+it("does not consume the media deadline while microphone permission is pending", async () => {vi.useFakeTimers();vi.stubGlobal("RTCPeerConnection", FakePeerConnection);@@ -159,10 +206,12 @@ describe("realtime audio client", () => {socket.receive({ type: "audio_ready", requires_webrtc_answer: true, webrtc_answer_sdp: "answer" });await Promise.resolve();expect(gate.port.postMessage.mock.calls.some(([message]) => message.type === "start")).toBe(false);+ expect(FakeAudioContext.voices).toHaveLength(0);peer.connectionState = "connected";peer.events.dispatchEvent(new Event("connectionstatechange"));await connecting;expect(gate.port.postMessage.mock.calls.filter(([message]) => message.type === "start")).toHaveLength(1);+ expect(FakeAudioContext.voices).toHaveLength(2);socket.receive({ type: "audio_closed" });await client.disconnect();});@@ -449,6 +498,7 @@ describe("realtime audio client", () => {});beforeEach(() => {+ FakeAudioContext.voices = [];vi.stubGlobal("window", {location: { protocol: "https:", host: "app.example", hostname: "app.example" },__JARVIS_TOKEN: "tok",diff --git a/jarvis/ui/web/frontend/src/lib/realtimeAudio.ts b/jarvis/ui/web/frontend/src/lib/realtimeAudio.tsindex c47e3e1607..988ad9083f 100644--- a/jarvis/ui/web/frontend/src/lib/realtimeAudio.ts+++ b/jarvis/ui/web/frontend/src/lib/realtimeAudio.ts@@ -2,6 +2,7 @@// JSON-only WSClient: this socket carries raw mono PCM16 in both directions.import { LevelMeter } from "./levelMeter";+import { playListeningCue } from "./listeningCue";import { MediaActivity, type MediaLevels } from "./mediaLevels";import { requestConnect } from "./connectBudget";import { mintWsTicket } from "./ws";@@ -464,6 +465,8 @@ export class RealtimeAudioClient {private outputMuted = true;private outputVolume = 1;private outputRevision = -1;+ private listeningCueConsumed = false;+ private stopListeningCue: (() => void) | null = null;private applyOutputState(muted: unknown, volume: unknown, revision: unknown): void {if (typeof muted !== "boolean") return;@@ -472,6 +475,7 @@ export class RealtimeAudioClient {if (typeof revision === "number") this.outputRevision = revision;const changed = this.outputMuted !== effectiveMuted;this.outputMuted = effectiveMuted;+ if (effectiveMuted || volume === 0) this.stopListeningCue?.();if (typeof volume === "number" && Number.isFinite(volume)) {this.outputVolume = Math.max(0, Math.min(1, volume));}@@ -583,6 +587,7 @@ export class RealtimeAudioClient {this.inputMuted = muted;this.syncInputTracks();if (muted) {+ this.stopListeningCue?.();this.startupNode?.port.postMessage({ type: "suspend" });this.startupPreroll = [];this.startupPrerollBytes = 0;@@ -592,6 +597,7 @@ export class RealtimeAudioClient {}private stopInput(): void {+ this.stopListeningCue?.();this.inputStopped = true;this.syncInputTracks();}@@ -609,6 +615,7 @@ export class RealtimeAudioClient {this.startupAt = performance.now();this.startupMarks = {};this.intentionalClose = false;+ this.listeningCueConsumed = false;this.serverClosed = false;this.reconnecting = false;this.inputMuted = false;@@ -928,6 +935,13 @@ export class RealtimeAudioClient {this.reconnecting = false;this.sendMediaLevels(true);this.flushStartupPreroll();+ if (!this.listeningCueConsumed) {+ this.listeningCueConsumed = true;+ if (this.ctx && message.sound_effects !== false && !this.inputMuted &&+ !this.inputStopped && !this.outputMuted) {+ this.stopListeningCue = playListeningCue(this.ctx, this.outputVolume);+ }+ }if (!settled) {settled = true;window.clearTimeout(timeout);@@ -1125,6 +1139,8 @@ export class RealtimeAudioClient {}private async teardown(sendStop: boolean): Promise<void> {+ this.stopListeningCue?.();+ this.stopListeningCue = null;if (this.remoteMeter) this.remoteMeter.port.onmessage = null;this.remoteMeter?.disconnect();this.remoteMeter = null;diff --git a/tests/unit/live/test_native_live_fixes.py b/tests/unit/live/test_native_live_fixes.pyindex 9ecb2f7b5d..11410f674b 100644--- a/tests/unit/live/test_native_live_fixes.py+++ b/tests/unit/live/test_native_live_fixes.py@@ -167,6 +167,20 @@ async def test_ready_provider_opens_after_one_probe(call, make_provider):assert len(live.provider.opened_with) == 1assert live.sent("error_spoken") == []assert len(live.sent("audio_ready")) == 1+ assert live.sent("audio_ready")[0]["sound_effects"] is True+ finally:+ await live.session.end()+++@both_providers+async def test_readiness_cue_respects_the_shared_sound_effects_switch(call, make_provider):+ config = _config()+ config.ui = SimpleNamespace(sound_effects=False)+ live = call(make_provider(), config)+ await live.start()+ try:+ assert live.sent("audio_ready")[0]["sound_effects"] is Falsefinally:await live.session.end()diff --git a/tests/unit/speech/test_pipeline_sound_effects.py b/tests/unit/speech/test_pipeline_sound_effects.pyindex f625b71cf6..c5328a69be 100644--- a/tests/unit/speech/test_pipeline_sound_effects.py+++ b/tests/unit/speech/test_pipeline_sound_effects.py@@ -8,6 +8,7 @@ must never silence tones."""from __future__ import annotations+import asynciofrom collections.abc import AsyncIteratorfrom types import SimpleNamespace@@ -86,3 +87,26 @@ async def test_wake_chime_muted_but_spoken_ack_still_plays(monkeypatch):monkeypatch.setattr("jarvis.speech.pipeline.asyncio.sleep", _fast_sleep)await pipe._play_ack(ptt=False)assert pipe._player.plays == [pipe._ack_pcm] # type: ignore[attr-defined]+++async def test_listening_cue_is_once_per_session_and_preserves_input():+ pipe = _make_pipeline(True)+ pipe._input_suppressed_until_ns = 0+ pipe._start_listening_cue()+ task = pipe._listening_cue_task+ pipe._start_listening_cue()+ assert pipe._listening_cue_task is task+ await task+ assert pipe._player.plays == [CHIME_PCM]+ assert pipe._input_suppressed_until_ns == 0+++async def test_listening_cue_obeys_mutes_and_hangup():+ for condition in ("effects", "speaker", "hangup"):+ pipe = _make_pipeline(condition != "effects")+ pipe._speaker_muted = condition == "speaker"+ if condition == "hangup":+ pipe._hangup_event.set()+ pipe._start_listening_cue()+ await asyncio.sleep(0)+ assert pipe._player.plays == []diff --git a/tests/unit/ui/test_pet_overlay_renderer.py b/tests/unit/ui/test_pet_overlay_renderer.pyindex c72b7185d2..fb06d584e2 100644--- a/tests/unit/ui/test_pet_overlay_renderer.py+++ b/tests/unit/ui/test_pet_overlay_renderer.py@@ -533,3 +533,39 @@ def test_a_pet_without_acts_just_idles() -> None:renderer, _ = _renderer(clock)clock.now += 120.0assert renderer.frame_key()[2] == "idle"+++def test_activation_nod_is_visible_bounded_and_does_not_mutate_cached_frames() -> None:+ clock = _Clock()+ renderer, _ = _renderer(clock)+ renderer.on_mode("listen")+ original = renderer.render().copy()+ renderer.greet()+ assert renderer.next_frame_delay_ms() <= 36+ clock.now += 0.35+ assert renderer.frame_key()[-1] > 0+ nodded = renderer.render()+ assert nodded.size == renderer.size+ assert nodded.getpixel((0, 0)) == (255, 0, 255)+ clock.now += 0.36+ assert len(renderer.frame_key()) == 4+ assert renderer._frames["listening"][0].tobytes() == original.tobytes()++[email protected]("mode", ["idle", "think", "speak", "dictate"])+def test_activation_nod_stops_when_listening_ends(mode: str) -> None:+ clock = _Clock()+ renderer, _ = _renderer(clock)+ renderer.on_mode("listen")+ renderer.greet()+ clock.now += 0.2+ renderer.on_mode(mode)+ assert len(renderer.frame_key()) == 4+++def test_no_figure_never_starts_an_activation_animation() -> None:+ clock = _Clock()+ renderer, _ = _renderer(clock, pet_id="none", loader=_Loader({"none": None}))+ renderer.on_mode("listen")+ renderer.greet()+ assert renderer.next_frame_delay_ms() == pr.MAX_FRAME_DELAY_MSdiff --git a/tests/unit/ui/test_pet_overlay_surface.py b/tests/unit/ui/test_pet_overlay_surface.pyindex 1e2bf9f886..5d17ed6449 100644--- a/tests/unit/ui/test_pet_overlay_surface.py+++ b/tests/unit/ui/test_pet_overlay_surface.py@@ -20,10 +20,23 @@ from jarvis.ui.jarvisbar.null_overlay import NullOverlayfrom jarvis.ui.jarvisbar.subprocess_overlay import SubprocessMascotOverlayfrom ui.orb import controlsfrom ui.orb.overlay import OrbOverlay+from ui.orb.pet_renderer import PetRenderer# --- OrbOverlay (never started: no Tk root under pytest) --------------------------+def test_wake_wave_reaches_the_pet_renderer(monkeypatch: pytest.MonkeyPatch) -> None:+ pet = OrbOverlay(style="pet")+ pet._renderer = PetRenderer("gigi")+ pet._renderer.on_mode("listen")+ calls: list[str] = []+ monkeypatch.setattr(pet, "_enqueue_ui", lambda fn: fn())+ monkeypatch.setattr(pet, "_kick_frame", lambda: calls.append("frame"))+ pet.play_animation("wave")+ assert pet._renderer._greet_until > 0+ assert calls == ["frame"]++def test_only_the_pet_stays_visible_while_idle_and_wants_status_lines() -> None:pet = OrbOverlay(style="pet")assert pet.keeps_visible_when_idle is Truediff --git a/ui/orb/overlay.py b/ui/orb/overlay.pyindex 4a73e83fcd..1387def9fa 100644--- a/ui/orb/overlay.py+++ b/ui/orb/overlay.py@@ -4219,13 +4219,21 @@ class OrbOverlay:"""Starts a named animation (e.g. 'wave', 'salute', 'think').Thread-safe: queued via ``root.after(0, ...)`` onto the Tk mainloop.- Only works with the MascotRenderer.+ The pet handles the activation wave as a short listening nod.Stacking behavior: several animations can run at the same time.Calling play_animation('wave') again while a 'wave' is still activeadds a second instance — this is intentional (multiple waves).To "replace" it, call stop_animation('wave') first."""+ if isinstance(self._renderer, PetRenderer):+ if name == "wave":+ def _greet() -> None:+ if isinstance(self._renderer, PetRenderer):+ self._renderer.greet()+ self._kick_frame()+ self._enqueue_ui(_greet)+ returnif not isinstance(self._renderer, MascotRenderer):returnif name not in ANIMATION_REGISTRY:diff --git a/ui/orb/pet_renderer.py b/ui/orb/pet_renderer.pyindex f8b6668a31..b3ccb2942f 100644--- a/ui/orb/pet_renderer.py+++ b/ui/orb/pet_renderer.py@@ -308,6 +308,7 @@ class PetRenderer:self._level = 0.0self._level_at = -math.infself._smoothed = 0.0+ self._greet_until = 0.0self.load(pet_id)# -- pack ------------------------------------------------------------@@ -431,8 +432,23 @@ class PetRenderer:# -- state feed ------------------------------------------------------def on_mode(self, mode: str) -> None:+ if mode != "listen":+ self._greet_until = 0.0self._machine.on_mode(mode)+ def greet(self) -> None:+ """Briefly nod on activation, using the selected pet's listening row."""+ if self.has_figure and self.state() == "listening":+ self._greet_until = float(self._clock()) + 0.7++ def _greet_inset(self) -> int:+ remaining = self._greet_until - float(self._clock())+ if remaining <= 0 or self.state() != "listening":+ return 0+ # A small squash and rise stays inside the existing window bounds.+ phase = (0.7 - remaining) / 0.7+ return max(0, round(self._size[1] * 0.10 * math.sin(math.pi * phase) ** 2))+def on_outcome(self, kind: str) -> None:self._machine.on_outcome(kind)@@ -542,12 +558,16 @@ class PetRenderer:if self._pack is None:return ("none", self._size)resolved, _spec, index, _elapsed, _driven = self._current()- return (self._pet_id, self._factor, resolved, index)+ key = (self._pet_id, self._factor, resolved, index)+ inset = self._greet_inset()+ return (*key, inset) if inset else keydef next_frame_delay_ms(self, t: float = 0.0) -> int:"""How long the overlay may sleep before the next repaint is due."""_ = twaits: list[float] = []+ if self._greet_until > float(self._clock()) and self.state() == "listening":+ waits.append(1 / 30)change = self._machine.next_change_in()if change is not None:waits.append(max(0.0, float(change)))@@ -588,4 +608,14 @@ class PetRenderer:if self._blank is None:self._blank = Image.new("RGB", self._size, self._color_key)return self._blank- return sequence[min(index, len(sequence) - 1)]+ frame = sequence[min(index, len(sequence) - 1)]+ inset = self._greet_inset()+ if not inset:+ return frame+ result = Image.new("RGB", self._size, self._color_key)+ # Preserve pixel edges; never crop the sprite or change host geometry.+ nodded = frame.resize(+ (frame.width, max(1, frame.height - inset)), Image.Resampling.NEAREST+ )+ result.paste(nodded, (0, inset))+ return result