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(jarvisbar): steady the speaking equalizer instead of stepping and shimmering

rubenluetke10-beep5b908692154b
diff --git a/jarvis/ui/jarvisbar/renderer.py b/jarvis/ui/jarvisbar/renderer.py
index 756800aa08..2ec5064e7c 100644
--- a/jarvis/ui/jarvisbar/renderer.py
+++ b/jarvis/ui/jarvisbar/renderer.py
@@ -655,6 +655,57 @@ def visual_mode(
return "speak"
+#: Release time constant (seconds) while the voice is still sounding but got
+#: quieter. The level feeds arrive in steps — ~60 ms native TTS blocks, ~100 ms
+#: browser realtime snapshots — against a 25-60 fps frame loop, so a per-frame
+#: fall snapped the whole row down at every sample and held it flat until the
+#: next one: the equalizer stepped instead of moving. A short glide between
+#: samples keeps it fluid. Rises stay instant (onset sync) and a drop to
+#: silence keeps the fast fall + snap to zero, so neither the "reacts late"
+#: nor the "keeps moving after I stopped" defect can come back.
+LEVEL_RELEASE_TAU_S = 0.12
+
+
+def smooth_level(current: float, target: float, dt: float) -> float:
+ """One frame of the equalizer's level envelope. Pure, frame-rate aware.
+
+ - ``target > current`` → rise almost instantly (0.8 per frame);
+ - ``target <= 0`` (silence) → fall fast (0.5 per frame) and snap to an
+ exact zero once sub-visible;
+ - otherwise (quieter, still sounding) → glide down with
+ ``LEVEL_RELEASE_TAU_S``, measured in seconds so 25 fps (Tk) and 60 fps
+ (Qt) surfaces move alike.
+ """
+ if target > current:
+ return ease(current, target, 0.8)
+ if target <= 0.0:
+ nxt = ease(current, 0.0, 0.5)
+ return 0.0 if nxt < 0.02 else nxt
+ dt = 0.0 if dt < 0.0 else 0.25 if dt > 0.25 else dt
+ return ease(current, target, 1.0 - math.exp(-dt / LEVEL_RELEASE_TAU_S))
+
+
+def pixel_bar_box(
+ x: float, cy: float, half_w: float, h: float
+) -> tuple[int, int, int, int]:
+ """Whole-pixel box for one equalizer/sweep stroke.
+
+ Handing ImageDraw float edges let it round the top and the bottom edge
+ independently (and half-to-even), so as a level changed by a fraction of a
+ pixel a stroke grew on one side only, its centre hopped by a pixel, and
+ near the resting height it flipped between Pillow's circle and capsule
+ paths — a shimmer on top of the real motion. Here the width is fixed, the
+ stroke grows in whole pixel PAIRS around one fixed centre row, and it is
+ never shorter than its own width (a round dot at rest).
+ """
+ w = max(2, math.floor(2.0 * half_w + 0.5))
+ extra = max(0, math.floor((h - w) / 2.0 + 0.5))
+ hh = w + 2 * extra
+ x0 = math.floor(x - w / 2.0 + 0.5)
+ y0 = math.floor(cy - hh / 2.0 + 0.5)
+ return x0, y0, x0 + w, y0 + hh
+
+
def bar_heights(
t: float, level: float, n: int, *, max_h: float, min_h: float
) -> list[float]:
@@ -772,6 +823,8 @@ class _RenderState:
# at INSTANTIATION time, after apply_display_scale() may have rescaled
# the module geometry — a plain default would freeze the import-time value.
display_level: float = 0.0
+ # ``t`` of the previous frame, for the time-based level release.
+ last_t: float | None = None
# live pill width/height, eased toward the target
pw: float = field(default_factory=lambda: float(COLLAPSED_W))
ph: float = field(default_factory=lambda: float(COLLAPSED_H))
@@ -822,18 +875,14 @@ 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
+ # Asymmetric level envelope (``smooth_level``): rise almost instantly so
+ # the bars move in sync with the voice, glide between quieter samples,
+ # and fall fast + snap to dead zero on silence — a lingering
# sub-visible tail otherwise keeps the equalizer wiggling in silence.
- # 0.8 reaches ~96% of a rising target within two 16 ms frames; the
- # onset of a word registers the same tick its level sample arrives.
level_target = ext_level if active else 0.0
- rising = level_target > self._st.display_level
- self._st.display_level = ease(
- self._st.display_level, level_target, 0.8 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.0
+ dt = 0.0 if self._st.last_t is None else t - self._st.last_t
+ self._st.last_t = t
+ self._st.display_level = smooth_level(self._st.display_level, level_target, dt)
pw, ph = self._st.pw, self._st.ph
frame = np.empty((WIN_H, WIN_W, 3), dtype=np.uint8)
@@ -1150,11 +1199,8 @@ class JarvisBarRenderer:
t, self._st.display_level, n, max_h=bar_max_for(ph), min_h=bar_min_for(ph)
)
for x, h in zip(evenly_spaced(cx, span, n), hs, strict=True):
- d.rounded_rectangle(
- [x - half_w, cy - h / 2, x + half_w, cy + h / 2],
- radius=half_w,
- fill=self._accent,
- )
+ box = pixel_bar_box(x, cy, half_w, h)
+ d.rounded_rectangle(box, radius=(box[2] - box[0]) / 2.0, fill=self._accent)
def _draw_thinking(
self,
@@ -1191,8 +1237,5 @@ class JarvisBarRenderer:
# to fade with: mixing toward the pill's own background is what an
# opacity would look like over it anyway, and it costs one lerp.
color = _lerp_rgb(PILL_BG, self._accent, THINK_DIM + (1.0 - THINK_DIM) * g)
- d.rounded_rectangle(
- [x - half_w, cy - h / 2, x + half_w, cy + h / 2],
- radius=half_w,
- fill=color,
- )
+ box = pixel_bar_box(x, cy, half_w, h)
+ d.rounded_rectangle(box, radius=(box[2] - box[0]) / 2.0, fill=color)
diff --git a/jarvis/ui/web/frontend/src/components/home/VoiceGlow.tsx b/jarvis/ui/web/frontend/src/components/home/VoiceGlow.tsx
index ee4f704665..2eae67d073 100644
--- a/jarvis/ui/web/frontend/src/components/home/VoiceGlow.tsx
+++ b/jarvis/ui/web/frontend/src/components/home/VoiceGlow.tsx
@@ -1,5 +1,6 @@
import { useEffect, useRef } from "react";
+import { cn } from "@/lib/utils";
import { readVoiceInputLevel } from "@/lib/voiceInputLevel";
import { voiceOutputLevelRef } from "@/lib/voiceOutputLevel";
@@ -67,7 +68,11 @@ export function VoiceGlow({ active }: { active: boolean }) {
ref={(el) => {
blobRefs.current[i] = el;
}}
- className="absolute bottom-0 origin-bottom transition-opacity duration-500"
+ // The fade only eases the rest <-> call hand-over. While a call runs
+ // the frame loop writes opacity every frame, and a transition there
+ // restarted a 500 ms fade per frame — the light lagged the voice and
+ // the browser re-planned a transition 60 times a second.
+ className={cn("absolute bottom-0 origin-bottom", !active && "transition-opacity duration-500")}
style={{
left: `${b.x}%`,
width: b.width,
diff --git a/tests/unit/ui/jarvisbar/test_renderer.py b/tests/unit/ui/jarvisbar/test_renderer.py
index 15bcdc10cf..7f24e9dfbc 100644
--- a/tests/unit/ui/jarvisbar/test_renderer.py
+++ b/tests/unit/ui/jarvisbar/test_renderer.py
@@ -49,6 +49,40 @@ def test_display_level_snaps_to_exact_zero_after_silence():
assert k <= 8 # ≤ ~150 ms at 60 fps
+def test_quieter_sample_glides_instead_of_snapping_the_row_down():
+ """While Jarvis is still speaking, a quieter level sample must not drop the
+ whole row in one frame — at 25 fps against ~60-100 ms level samples that
+ made the equalizer step and hold instead of move (2026-10-01)."""
+ r = R.JarvisBarRenderer()
+ for k in range(5):
+ r.render(k * 0.04, "speak", 0.8)
+ r.render(0.20, "speak", 0.3)
+ assert r._st.display_level > 0.55 # noqa: SLF001
+ for k in range(1, 15):
+ r.render(0.20 + k * 0.04, "speak", 0.3)
+ assert abs(r._st.display_level - 0.3) < 0.01 # noqa: SLF001
+
+
+def test_level_release_is_frame_rate_independent():
+ one = R.smooth_level(0.8, 0.3, 0.04)
+ two = R.smooth_level(R.smooth_level(0.8, 0.3, 0.02), 0.3, 0.02)
+ assert abs(one - two) < 1e-9
+
+
+def test_pixel_bar_box_grows_symmetrically_around_a_fixed_centre():
+ """Float edges rounded independently made a stroke grow on one side and
+ its centre hop a pixel as the level moved — a visible shimmer."""
+ boxes = [R.pixel_bar_box(37.37, 41.6, 2.35, h / 10.0) for h in range(30, 400)]
+ widths = {b[2] - b[0] for b in boxes}
+ lefts = {b[0] for b in boxes}
+ centres = {b[1] + b[3] for b in boxes}
+ assert len(widths) == 1 and len(lefts) == 1
+ assert len(centres) == 1
+ for x0, y0, x1, y1 in boxes:
+ assert all(isinstance(v, int) for v in (x0, y0, x1, y1))
+ assert y1 - y0 >= x1 - x0 # never shorter than its own width
+
+
# --- thinking: the travelling sweep ------------------------------------------
# The look the mission deck's header bar uses for "working", brought onto the
# desktop bar (maintainer, 2026-08-20). It replaced the "orbital core", which