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(jarvisbar): voice bars move in sync with the voice — no lag, no silence swings, no wake-word phantom
Personal Jarvis Maintainer41e4b3cbd27b
diff --git a/jarvis/audio/mic_level.py b/jarvis/audio/mic_level.pyindex a1b5267144..516a66c234 100644--- a/jarvis/audio/mic_level.py+++ b/jarvis/audio/mic_level.py@@ -33,11 +33,19 @@ _subscribers: list[Callable[[float], None]] = []# range is wide enough for a quiet laptop mic (speech around 0.002-0.006 RMS)# and a high-gain headset without making either device load-bearing. Unlike an# adaptive peak, it preserves the difference between quiet and loud speech.-_MIN_NOISE_FLOOR = 0.0002+_MIN_NOISE_FLOOR = 0.0004_METER_FLOOR_RMS = 0.00025_METER_CEILING_RMS = 0.25_METER_LOG_SPAN = math.log(_METER_CEILING_RMS / _METER_FLOOR_RMS)_METER_CURVE = 1.15+# Display squelch: mapped levels below this render as dead zero. Breaths, chair+# creaks and room murmur that sneak past the adaptive gate land in this band and+# used to keep the bars twitching while the user was silent. Real speech — even+# on a quiet laptop mic (~0.004 RMS → ~0.28 mapped) — sits well above it.+_DISPLAY_SQUELCH = 0.10+# Once the input is squelched, snap the decaying envelope straight to zero below+# this remainder instead of letting an invisible tail keep the bars animating.+_RELEASE_SNAP = 0.04class LevelNormalizer:@@ -73,13 +81,24 @@ class LevelNormalizer:else:position = math.log(gated / _METER_FLOOR_RMS) / _METER_LOG_SPANraw = position**_METER_CURVE+ if raw < _DISPLAY_SQUELCH:+ raw = 0.0- if raw > self._smoothed: # attack fast- self._smoothed = 0.4 * self._smoothed + 0.6 * raw- else: # release slow- self._smoothed = 0.75 * self._smoothed + 0.25 * raw+ # The bars must move IN SYNC with the voice: near-instant attack, a+ # fast release that bridges syllable gaps, and a hard snap to zero so+ # silence reads as silence immediately instead of a ~300 ms wiggle-out.+ if raw > self._smoothed:+ self._smoothed = 0.15 * self._smoothed + 0.85 * raw+ else:+ self._smoothed = 0.45 * self._smoothed + 0.55 * raw+ if raw == 0.0 and self._smoothed < _RELEASE_SNAP:+ self._smoothed = 0.0return self._smoothed+ def clear(self) -> None:+ """Zero the display envelope, keeping the adapted noise floor."""+ self._smoothed = 0.0+def reset(self) -> None:self._noise_floor = 0.005self._smoothed = 0.0@@ -122,6 +141,16 @@ def feed(rms: float) -> None:_log.debug("mic_level sink failed", exc_info=True)+def clear() -> None:+ """Drop the current level envelope, keeping the adapted noise floor.++ Called when the listening bar is revealed (wake candidate / wake word /+ session start): the wake word itself was loud, and its decaying envelope+ would otherwise render as a phantom swing the moment the bar appears —+ the user never sees the wake word, only their command."""+ _norm.clear()++def reset() -> None:"""Reset the adaptive normalizer (e.g. at the start of a fresh session)."""_norm.reset()diff --git a/jarvis/ui/jarvisbar/renderer.py b/jarvis/ui/jarvisbar/renderer.pyindex 095f286983..5ce11e628c 100644--- a/jarvis/ui/jarvisbar/renderer.py+++ b/jarvis/ui/jarvisbar/renderer.py@@ -490,9 +490,16 @@ class JarvisBarRenderer:# crawling there over a third of a second.self._st.pw = ease(self._st.pw, tw, 0.5)self._st.ph = ease(self._st.ph, th, 0.5)+ # Asymmetric level easing: rise almost instantly so the bars move in+ # sync with the voice, fall fast and snap to dead zero — a lingering+ # sub-visible tail otherwise keeps the equalizer wiggling in silence.+ level_target = ext_level if active else 0.0+ rising = level_target > self._st.display_levelself._st.display_level = ease(- self._st.display_level, ext_level if active else 0.0, 0.35+ self._st.display_level, level_target, 0.6 if rising else 0.5)+ if not rising and level_target <= 0.0 and self._st.display_level < 0.02:+ self._st.display_level = 0.0pw, ph = self._st.pw, self._st.phframe = np.empty((WIN_H, WIN_W, 3), dtype=np.uint8)diff --git a/tests/unit/audio/test_mic_level.py b/tests/unit/audio/test_mic_level.pyindex 72ec95ac6e..07d05c15f5 100644--- a/tests/unit/audio/test_mic_level.py+++ b/tests/unit/audio/test_mic_level.py@@ -59,6 +59,46 @@ def test_release_smoothing_decays_after_speech_stops():mic_level.reset_for_tests()+def test_release_snaps_to_dead_zero_within_a_quarter_second():+ """User report 2026-07-21: after you stop talking the bars keep moving for+ a moment. The release must reach EXACT zero (not an invisible-but-animated+ tail) within a few frames (~32 ms each) of true silence."""+ meter = LevelNormalizer()+ _push_frames(meter, 0.0008, 60)+ _push_frames(meter, 0.2, 12) # loud speech++ levels = [meter.push(0.0008) for _ in range(8)] # ≤ ~256 ms of audio frames+ assert 0.0 in levels, f"release never snapped to zero: {levels[-1]:.3f}"+++def test_clear_drops_envelope_but_keeps_adapted_floor():+ """clear() kills the wake word's leftover swing without re-arming the+ conservative default noise floor (which would deafen a quiet mic for the+ first second of the session)."""+ meter = LevelNormalizer()+ _push_frames(meter, 0.0005, 80) # quiet-mic floor adapts down+ _push_frames(meter, 0.2, 12) # the "wake word"++ meter.clear()+ assert meter.push(0.0005) == 0.0 # no phantom tail on the fresh bar++ # Quiet-mic speech right after clear() must still be visible immediately —+ # proof the adapted floor survived (reset() would gate it out).+ assert _push_frames(meter, 0.004, 4) > 0.25+++def test_breath_and_room_murmur_after_speech_stay_dark():+ """User report 2026-07-21: the bars swing although 'nothing' is there.+ Low-level noise just above the adaptive gate (breathing, chair creaks)+ lands in the squelch band and must render as dead zero."""+ meter = LevelNormalizer()+ _push_frames(meter, 0.0005, 80)+ _push_frames(meter, 0.05, 12) # normal speech+ _push_frames(meter, 0.0005, 10) # silence — envelope drains++ assert _push_frames(meter, 0.002, 10) == 0.0++def test_quiet_laptop_mic_speech_is_clearly_visible():"""Fresh-machine forensics Bug 17: on a quiet laptop input path (hiss~0.0005, speech ~0.004 rms) STT/wake work fine but the bars sat at zero —diff --git a/tests/unit/ui/jarvisbar/test_renderer.py b/tests/unit/ui/jarvisbar/test_renderer.pyindex 8d67496a88..1b55a7ffb6 100644--- a/tests/unit/ui/jarvisbar/test_renderer.py+++ b/tests/unit/ui/jarvisbar/test_renderer.py@@ -25,6 +25,30 @@ def test_bar_heights_grow_with_level():assert 4.0 <= h <= 40.0 + 1e-6+def test_display_level_rises_nearly_instantly():+ """The bars must move IN SYNC with the voice: from silence, one frame at+ full input already produces a clearly moving bar (user report 2026-07-21:+ the indicator reacted with a visible delay)."""+ r = R.JarvisBarRenderer()+ r.render(0.0, "listen", 0.0)+ r.render(0.016, "listen", 1.0)+ assert r._st.display_level > 0.5 # noqa: SLF001+++def test_display_level_snaps_to_exact_zero_after_silence():+ """After the input level drops to 0 the eased display must reach EXACT 0.0+ within a few 60 fps frames — a sub-visible tail still animates the bars."""+ r = R.JarvisBarRenderer()+ for k in range(10):+ r.render(k * 0.016, "listen", 0.9)+ for k in range(10):+ r.render((10 + k) * 0.016, "listen", 0.0)+ if r._st.display_level == 0.0: # noqa: SLF001+ break+ assert r._st.display_level == 0.0 # noqa: SLF001+ assert k <= 8 # ≤ ~150 ms at 60 fps++# --- thinking: "orbital core" (replaces the old generic sine wave) -----------diff --git a/tests/unit/ui/test_orb_bus_bridge_wake_candidate.py b/tests/unit/ui/test_orb_bus_bridge_wake_candidate.pyindex 0f12934fdc..2ea2127d7e 100644--- a/tests/unit/ui/test_orb_bus_bridge_wake_candidate.py+++ b/tests/unit/ui/test_orb_bus_bridge_wake_candidate.py@@ -180,6 +180,55 @@ async def test_rejected_candidate_stops_forwarding_wake_mic_level() -> None:assert ("set_level", 0.5) not in orb.calls+async def test_candidate_reveal_clears_wake_word_envelope() -> None:+ """The wake word itself is loud; its decaying level envelope must not render+ as a phantom swing the instant the bar appears (user report 2026-07-21)."""+ from jarvis.audio import mic_level++ mic_level.reset_for_tests()+ try:+ for _ in range(12):+ mic_level.feed(0.2) # the spoken wake word+ orb = _FakeOrb()+ bridge = _bridge(orb, hide_on_idle=True)++ await bridge._on_wake_candidate(WakeCandidateDetected(active=True)) # noqa: SLF001++ assert ("set_level", 0.0) in orb.calls # surface bars zeroed on reveal+ got: list[float] = []+ mic_level.subscribe(got.append)+ mic_level.feed(0.0005) # silence after the wake word+ assert got[-1] == 0.0 # envelope cleared — no decaying tail+ finally:+ mic_level.reset_for_tests()+++async def test_confirmed_wake_after_preview_does_not_re_zero_live_bars() -> None:+ """After the candidate preview the user may already be speaking the command;+ the authoritative WakeWordDetected/VoiceSessionStarted that follow must not+ dip the live bars by clearing again."""+ orb = _FakeOrb()+ bridge = _bridge(orb, hide_on_idle=True)++ await bridge._on_wake_candidate(WakeCandidateDetected(active=True)) # noqa: SLF001+ orb.calls.clear()+ await bridge._on_wake_word_detected(WakeWordDetected(keyword="jarvis")) # noqa: SLF001+ await bridge._on_session_started(VoiceSessionStarted(session_id="s1")) # noqa: SLF001++ assert ("set_level", 0.0) not in orb.calls+++async def test_sessionless_reveal_still_clears_envelope() -> None:+ """A session revealed WITHOUT a candidate preview (hotkey / call) clears+ the leftover envelope itself."""+ orb = _FakeOrb()+ bridge = _bridge(orb, hide_on_idle=True)++ await bridge._on_session_started(VoiceSessionStarted(session_id="s2")) # noqa: SLF001++ assert ("set_level", 0.0) in orb.calls++@pytest.mark.parametrize("state", ["THINKING", "SPEAKING"])async def test_stale_candidate_never_overrides_active_output_bars(state: str) -> None:"""A defensive stale latch must not clobber thinking or TTS animation."""diff --git a/ui/orb/bus_bridge.py b/ui/orb/bus_bridge.pyindex 9e88e2e50c..c06b09fd44 100644--- a/ui/orb/bus_bridge.py+++ b/ui/orb/bus_bridge.py@@ -458,6 +458,9 @@ class OrbBusBridge:# the bar. _last_state untouched (see docstring).if not self._wake_candidate_active:self._wake_preview_origin_state = self._last_state+ # Only on the reveal edge — a repeated candidate while the user+ # is already speaking must not re-zero the live envelope.+ self._clear_input_level()self._wake_candidate_active = True# A fresh input affordance supersedes stale output recency from the# preceding turn. Startup no longer plays an ACK, so retaining the@@ -486,9 +489,15 @@ class OrbBusBridge:self._wake_preview_origin_state = prev_stateself._last_state_trace_id = str(event.trace_id)self._suppress_show_until_session = False+ was_preview = self._wake_candidate_activeself._wake_candidate_active = Falseself._last_tts_level_t = 0.0self._last_state = "LISTENING"+ if not was_preview and prev_state != "LISTENING":+ # Fresh reveal (no candidate preview preceded it): drop the wake+ # word's leftover envelope. After a preview the user may already be+ # mid-command — re-zeroing would dip the live bars.+ self._clear_input_level()self._orb.show(mode="listen")if prev_state in ("IDLE", "ERROR", "PAUSED"):self._orb.play_animation("wave")@@ -525,9 +534,15 @@ class OrbBusBridge:self._voice_session_active = Trueprev_state = self._last_stateself._suppress_show_until_session = False+ was_preview = self._wake_candidate_activeself._wake_candidate_active = Falseself._last_tts_level_t = 0.0self._last_state = "LISTENING"+ if not was_preview and prev_state != "LISTENING":+ # Fresh reveal only (hotkey / call): after a wake preview or the+ # confirmed wake the envelope was already cleared and the user may+ # be mid-command — re-zeroing would dip the live bars.+ self._clear_input_level()# Enter the listening look now — robust to a deduplicated LISTENING state.self._orb.show(mode="listen")if prev_state in ("IDLE", "ERROR", "PAUSED"):@@ -973,6 +988,23 @@ class OrbBusBridge:_TTS_OWNS_BARS_S = 0.5 # mic is muted this long after the last TTS level+ def _clear_input_level(self) -> None:+ """Zero the mic-level envelope AND the surface bars on a listening+ reveal. The wake word itself was loud enough to leave a decaying+ envelope in the normalizer; without this it renders as a phantom+ swing the instant the bar appears — the bar must only ever show what+ the user says AFTER it is visible."""+ try:+ from jarvis.audio import mic_level++ mic_level.clear()+ except Exception: # noqa: BLE001 — visual hygiene must never break the bus+ log.debug("mic_level clear failed", exc_info=True)+ try:+ self._orb.set_level(0.0)+ except Exception: # noqa: BLE001+ log.debug("surface level clear failed", exc_info=True)+def _note_tts_level(self, level: float) -> None:"""Forward live TTS loudness and remember that Jarvis owns the bars.