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): draw the assistant's own voice, and calm the bar down
rubenluetke10-beep555e94a07dee
diff --git a/jarvis/ui/web/frontend/src/components/home/JarvisBar.tsx b/jarvis/ui/web/frontend/src/components/home/JarvisBar.tsxindex 953db42c9d..2c3be3150b 100644--- a/jarvis/ui/web/frontend/src/components/home/JarvisBar.tsx+++ b/jarvis/ui/web/frontend/src/components/home/JarvisBar.tsx@@ -5,6 +5,7 @@ import { useEventStore, type VoiceState } from "@/store/events";import type { WaveformPhase } from "@/components/overlay/VoiceWaveform";import { StageWaveform } from "@/components/home/StageWaveform";import { voiceInputLevelRef } from "@/lib/voiceInputLevel";+import { voiceOutputLevelRef } from "@/lib/voiceOutputLevel";import { useVoiceCall } from "@/components/agentic/useVoiceCall";import { useVoiceReadiness } from "@/hooks/useVoiceReadiness";import { useVoiceEngineDisplay } from "@/hooks/useVoiceEngineDisplay";@@ -112,14 +113,18 @@ export function JarvisBar({ phase, hint }: { phase: WaveformPhase; hint: stringdata-active={callActive || undefined}className={cn("group flex w-full cursor-pointer select-none flex-col gap-2 rounded-2xl border border-border bg-card px-4 pb-2.5 pt-4 text-left",- "shadow-[0_1px_2px_rgb(var(--scrim-rgb)/0.05),0_8px_24px_rgb(var(--scrim-rgb)/0.06)] transition-[border-color,box-shadow]",+ "transition-[border-color,box-shadow]","hover:border-primary/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-disabled:cursor-default aria-disabled:opacity-80 aria-disabled:hover:border-border",callActive && "border-primary/50",)}><div className="h-14 w-full">- <StageWaveform levelRef={voiceInputLevelRef} phase={phase} />+ <StageWaveform+ levelRef={voiceInputLevelRef}+ outputLevelRef={voiceOutputLevelRef}+ phase={phase}+ /></div><div className="flex items-center gap-2"><spandiff --git a/jarvis/ui/web/frontend/src/components/home/StageWaveform.tsx b/jarvis/ui/web/frontend/src/components/home/StageWaveform.tsxindex 94ebc013d2..dc62dad3dd 100644--- a/jarvis/ui/web/frontend/src/components/home/StageWaveform.tsx+++ b/jarvis/ui/web/frontend/src/components/home/StageWaveform.tsx@@ -26,9 +26,12 @@ import { cn } from "@/lib/utils";* sees most of the time);* - while listening it is a TAPE: the newest microphone sample enters at* the right edge and the whole row travels left, on the overlay's own- * attack/release and column cadence;- * - thinking and speaking are a sweep, connecting a pulse, error a- * still red row.+ * attack/release and its own slower column cadence;+ * - while the assistant SPEAKS it is the same tape, fed by the level of+ * the audio actually leaving for the speaker — but only where this+ * device can measure that (see `outputLevelRef`);+ * - thinking, connecting, and speaking we cannot hear are a sweep; error+ * is a still red row.** ## Why it scrolls (maintainer, 2026-08-28)*@@ -72,17 +75,26 @@ import { cn } from "@/lib/utils";*/export function StageWaveform({levelRef,+ outputLevelRef,phase,className,}: {/** Normalised 0..1 microphone level, written by the audio callback. */levelRef: MutableRefObject<number>;+ /**+ * Normalised 0..1 level of the ASSISTANT's voice, or `null` where this+ * device cannot observe it (lib/voiceOutputLevel). Absent and `null` both+ * mean the same thing to the drawing: fall back to the sweep.+ */+ outputLevelRef?: { current: number | null };phase: WaveformPhase;className?: string;}) {const canvasRef = useRef<HTMLCanvasElement | null>(null);const phaseRef = useRef<WaveformPhase>(phase);phaseRef.current = phase;+ const outRef = useRef<{ current: number | null } | undefined>(outputLevelRef);+ outRef.current = outputLevelRef;useEffect(() => {const canvas = canvasRef.current;@@ -112,6 +124,7 @@ export function StageWaveform({let head = 0;let level = 0;let carryMs = 0;+ let peak = 0;let sweep = 0;let breath = 0;let last = performance.now();@@ -170,6 +183,51 @@ export function StageWaveform({/** How present a column is: a quiet floor that the activity lifts. */const presence = (v: number) => DOT_ALPHA + (1 - DOT_ALPHA) * v;+ /**+ * Advance and draw the measured tape from one 0..1 level.+ *+ * Called for the microphone while listening and for the assistant's own+ * voice while it speaks, so the row stays ONE instrument reading whoever+ * currently holds the conversation — both are real measurements, which+ * is the only thing that entitles this drawing to look like a waveform.+ *+ * A column is a WINDOW, not an instant: it banks the loudest level seen+ * since the last one. Sampling the level at the column boundary instead+ * would drop a short consonant that happened to fall between two ticks.+ */+ const tape = (target: number, dt: number) => {+ const tau = target > level ? ATTACK_TAU_S : RELEASE_TAU_S;+ level += (target - level) * (1 - Math.exp(-dt / tau));+ peak = Math.max(peak, level);+ carryMs += dt * 1000;+ while (carryMs >= STAGE_COLUMN_MS) {+ carryMs -= STAGE_COLUMN_MS;+ history[head] = peak;+ head = (head + 1) % count;+ peak = level;+ }+ const shaped: number[] = new Array<number>(count);+ const alphas: number[] = new Array<number>(count);+ for (let i = 0; i < count; i += 1) {+ // `ringValue` reads the history oldest-first, so column 0 is the far+ // left and the last column is this instant: a syllable appears at+ // the right edge and walks out of the left. Reduced motion holds the+ // plain level instead — a meter, no travel.+ const raw = reduced ? level : clamp01(ringValue(history, head, i));+ // `LOUDNESS` is a DISPLAY curve, applied here and never to the+ // stored history: the meter behind it (lib/levelMeter) deliberately+ // spends most of its range on ordinary speech, so feeding it+ // straight into the height made every word slam the ceiling+ // (maintainer, 2026-08-28: it deflects far too much). Bending it+ // keeps the ORDER — louder is still taller — and gives a shout+ // somewhere left to go.+ const v = raw <= 0 ? 0 : raw ** LOUDNESS;+ shaped[i] = v;+ alphas[i] = presence(v);+ }+ paint(shaped, alphas, fills.primary);+ };+const frame = (now: number) => {raf = requestAnimationFrame(frame);const dt = Math.min((now - last) / 1000, 0.1);@@ -223,6 +281,20 @@ export function StageWaveform({return;}+ if (p === "speaking") {+ // The assistant's own voice, when this device can actually hear it:+ // the browser realtime surface plays the reply itself, so the+ // playback worklet measures the very samples going to the speaker.+ // When the backend speaks through the OS device the page sees+ // nothing, `out` is null, and the sweep below takes over rather than+ // inventing a waveform.+ const out = outRef.current?.current;+ if (typeof out === "number") {+ tape(clamp01(out), dt);+ return;+ }+ }+if (p === "working" || p === "speaking") {// A sweep: a bright band travelling the row right to left, the// same direction the measured tape runs, faster when speaking.@@ -241,26 +313,9 @@ export function StageWaveform({return;}- // listening: the microphone as a tape running right to left.- const target = clamp01(levelRef.current);- const tau = target > level ? ATTACK_TAU_S : RELEASE_TAU_S;- level += (target - level) * (1 - Math.exp(-dt / tau));- carryMs += dt * 1000;- while (carryMs >= COLUMN_MS) {- carryMs -= COLUMN_MS;- history[head] = level;- head = (head + 1) % count;- }- for (let i = 0; i < count; i += 1) {- // `ringValue` reads the history oldest-first, so column 0 is the- // far left and the last column is the sample from this instant:- // a syllable appears at the right edge and walks out of the left.- // Reduced motion holds the plain level instead — a meter, no travel.- const v = reduced ? level : clamp01(ringValue(history, head, i));- shaped[i] = v;- alphas[i] = presence(v);- }- paint(shaped, alphas, fills.primary);+ // listening, and speaking wherever the assistant's voice is observable:+ // a measured tape running right to left.+ tape(clamp01(levelRef.current), dt);};measure();@@ -295,8 +350,26 @@ const ROW_PITCH = BAR_W + BAR_GAP;* rest state is a round dot rather than a dash. */const BAR_MIN = 5;-/** Fraction of the box the loudest capsule may take. */-const TALLEST = 0.8;+/** Fraction of the box the loudest capsule may take. Leaves real headroom+ * on purpose: a bar that a normal sentence already fills has nothing left+ * to say when somebody raises their voice. */+const TALLEST = 0.62;++/** Display exponent on the measured level (see `tape`). Above 1, so an+ * ordinary word sits around half the box and the top belongs to a shout. */+const LOUDNESS = 1.6;++/** How much time one column of the tape covers.+ *+ * Twice the overlay pill's cadence, and derived from it so the relationship+ * stays visible: the small pill is a glance, this row is meant to be READ,+ * and at 33 ms the whole width held barely a second and a half — a single+ * word smeared across a third of the bar and left again before you had+ * looked at it (maintainer, 2026-08-28: run it a little slower). At 66 ms+ * a word is a compact group of capsules and the row holds a whole sentence.+ * Nothing is thrown away to get there: each column banks the PEAK of its+ * window. */+const STAGE_COLUMN_MS = COLUMN_MS * 2;/** How present a resting dot is at the centre of the row. Visible as a row,* quiet enough that the measured part of the drawing is the part thatdiff --git a/jarvis/ui/web/frontend/src/components/voice/BrowserRealtimeControl.tsx b/jarvis/ui/web/frontend/src/components/voice/BrowserRealtimeControl.tsxindex 3d7f02a8a1..ec1c40e46d 100644--- a/jarvis/ui/web/frontend/src/components/voice/BrowserRealtimeControl.tsx+++ b/jarvis/ui/web/frontend/src/components/voice/BrowserRealtimeControl.tsx@@ -18,6 +18,7 @@ import {setBrowserVoiceInputOwnership,setVoiceInputLevel,} from "@/lib/voiceInputLevel";+import { clearVoiceOutputLevel, setVoiceOutputLevel } from "@/lib/voiceOutputLevel";type ConnectionState = "idle" | "connecting" | "connected" | "error";@@ -134,6 +135,7 @@ export function BrowserRealtimeControl() {setSpokenText("");levelRef.current = 0;clearVoiceInputLevel("browser");+ clearVoiceOutputLevel();setBrowserVoiceInputOwnership(false);setVoice("idle");await client?.disconnect();@@ -150,6 +152,7 @@ export function BrowserRealtimeControl() {setEffectiveProvider("");levelRef.current = 0;clearVoiceInputLevel("browser");+ clearVoiceOutputLevel();await previousClient?.disconnect();if (connectionGenerationRef.current !== generation) return;@@ -173,6 +176,11 @@ export function BrowserRealtimeControl() {levelRef.current = value;setVoiceInputLevel(value, "browser");},+ onOutputLevel: (value) => {+ if (!isCurrent()) return;+ if (value === null) clearVoiceOutputLevel();+ else setVoiceOutputLevel(value);+ },onStatus: (status, payload) => {if (!isCurrent()) return;// The backend authors one precise English sentence per failure —diff --git a/jarvis/ui/web/frontend/src/lib/pcm-worklet.ts b/jarvis/ui/web/frontend/src/lib/pcm-worklet.tsindex 93be08933c..ce20af4ca2 100644--- a/jarvis/ui/web/frontend/src/lib/pcm-worklet.ts+++ b/jarvis/ui/web/frontend/src/lib/pcm-worklet.ts@@ -50,6 +50,8 @@ class PcmCapture extends AudioWorkletProcessor {class PcmPlayback extends AudioWorkletProcessor {private readonly queue = new JitterBufferedPcm16Queue(sampleRate);+ private levelSum = 0;+ private levelCount = 0;constructor() {super();@@ -72,6 +74,22 @@ class PcmPlayback extends AudioWorkletProcessor {// streams at wall clock. Zero-filling a starved quantum instead is what// chopped the voice on this surface.this.queue.render(out);+ // Throttled (~30 Hz) OUTPUT-level messages, the mirror of PcmCapture's.+ // Measured on the samples this processor just wrote, so the number is the+ // audio actually leaving for the speaker at that instant — the only+ // honest source for a "Jarvis is speaking" waveform, and the reason the+ // front-page bar can draw a real tape there instead of a stand-in sweep.+ // A silent quantum reports 0 rather than nothing: "the tap is alive and+ // there is nothing to hear" and "there is no tap here" must stay+ // distinguishable on the other end.+ for (let i = 0; i < out.length; i++) this.levelSum += out[i] * out[i];+ this.levelCount += out.length;+ if (this.levelCount >= sampleRate / 30) {+ const rms = Math.sqrt(this.levelSum / this.levelCount);+ this.port.postMessage({ type: "level", rms });+ this.levelSum = 0;+ this.levelCount = 0;+ }return true;}}diff --git a/jarvis/ui/web/frontend/src/lib/realtimeAudio.ts b/jarvis/ui/web/frontend/src/lib/realtimeAudio.tsindex 10f0f04e51..0e2fd6db96 100644--- a/jarvis/ui/web/frontend/src/lib/realtimeAudio.ts+++ b/jarvis/ui/web/frontend/src/lib/realtimeAudio.ts@@ -20,6 +20,13 @@ export type RealtimeCallbacks = {onAudio?: () => void;/** Normalized 0..1 microphone input level, ~30 Hz while capturing. */onInputLevel?: (level: number) => void;+ /**+ * Normalized 0..1 level of the ASSISTANT's voice, ~30 Hz while a session+ * is open, measured on the samples the playback worklet writes. `null`+ * when the tap goes away, so a renderer can tell "silent" from "not+ * observable here" (see lib/voiceOutputLevel).+ */+ onOutputLevel?: (level: number | null) => void;};export type RealtimeAudioOptions = {@@ -35,6 +42,14 @@ export type RealtimeAudioOptions = {startBudgetMs?: number;};+/**+ * How long after the last PCM packet the playback tap still counts as the+ * source of what is audible. Comfortably longer than the worklet's jitter+ * reserve, so the tail of a sentence keeps its levels, and far shorter than+ * a turn, so the browser-speech fallback never inherits them.+ */+const OUTPUT_TAP_TTL_MS = 600;+/** Historical fixed budget for one realtime start attempt. */const DEFAULT_START_BUDGET_MS = 20_000;@@ -304,6 +319,17 @@ export class RealtimeAudioClient {private ready = false;private intentionalClose = false;private inputMeter = new LevelMeter();+ // Its own normalizer: the assistant's voice and the room's microphone have+ // different noise floors and dynamics, and one shared adaptive floor would+ // let whichever is louder decide the other one's scale.+ private outputMeter = new LevelMeter();+ // When PCM last reached the playback worklet. The worklet renders (and so+ // measures) whatever is in its queue, which is silence whenever the reply+ // is NOT coming through it — most importantly during the SpeechSynthesis+ // fallback, where the voice is audible but never passes this graph.+ // Reporting that silence would be a lie in the other direction, so the tap+ // only speaks while it is the thing making the sound.+ private lastPcmAt = Number.NEGATIVE_INFINITY;private browserSpeech = new BrowserSpeechFallback();private webRtcTransport: RealtimeWebRtcTransport;private webRtcOfferSdp: string | null = null;@@ -362,6 +388,13 @@ export class RealtimeAudioClient {const source = this.ctx.createMediaStreamSource(this.stream);this.captureNode = new AudioWorkletNode(this.ctx, "pcm-capture");this.playbackNode = new AudioWorkletNode(this.ctx, "pcm-playback");+ this.playbackNode.port.onmessage = (event: MessageEvent) => {+ const data = event.data as { type?: string; rms?: number } | null;+ if (data && data.type === "level" && typeof data.rms === "number") {+ const live = performance.now() - this.lastPcmAt <= OUTPUT_TAP_TTL_MS;+ this.cb.onOutputLevel?.(live ? this.outputMeter.push(data.rms) : null);+ }+ };// Keep the capture worklet in the active audio graph without feeding the// microphone back to the user. Browser AEC still sees the real playback// node connected below and can remove it from captured audio.@@ -602,6 +635,7 @@ export class RealtimeAudioClient {const converted = this.playbackResampler?.process(pcm) ?? pcm;if (converted.byteLength === 0) return;this.playbackNode?.port.postMessage({ type: "pcm", data: converted }, [converted]);+ this.lastPcmAt = performance.now();this.cb.onAudio?.();}@@ -670,6 +704,9 @@ export class RealtimeAudioClient {this.stream = null;this.ctx = null;this.inputMeter.reset();+ this.outputMeter.reset();this.cb.onInputLevel?.(0);+ // null, not 0: playback is gone, so nothing may keep drawing a voice.+ this.cb.onOutputLevel?.(null);}}diff --git a/jarvis/ui/web/frontend/src/lib/voiceOutputLevel.ts b/jarvis/ui/web/frontend/src/lib/voiceOutputLevel.tsnew file mode 100644index 0000000000..eadd9f243c--- /dev/null+++ b/jarvis/ui/web/frontend/src/lib/voiceOutputLevel.ts@@ -0,0 +1,28 @@+/**+ * Shared real level of the ASSISTANT's voice, for animation loops.+ *+ * The mirror of `voiceInputLevel`, with one difference that is the whole+ * point of the module: `null` and `0` mean different things here.+ *+ * - a number (0 included) — a tap is running and this is what is currently+ * leaving for the speaker. `0` is the honest "Jarvis is between words";+ * - `null` — there is NO tap on this device, so nothing may claim to draw+ * the assistant's voice.+ *+ * That distinction exists because only the browser realtime surface plays+ * the reply itself (components/voice/BrowserRealtimeControl → the+ * `pcm-playback` worklet, which measures the samples it writes). When the+ * backend speaks through the OS audio device instead, the page never sees a+ * sample, and a waveform drawn there would be an invention. Renderers fall+ * back to a sweep on `null`: motion, promising nothing.+ */+export const voiceOutputLevelRef: { current: number | null } = { current: null };++export function setVoiceOutputLevel(value: number): void {+ voiceOutputLevelRef.current = Number.isFinite(value) ? Math.min(1, Math.max(0, value)) : 0;+}++/** Give up the tap — the surface that owned playback has stopped. */+export function clearVoiceOutputLevel(): void {+ voiceOutputLevelRef.current = null;+}