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(orb): give the desktop sphere the energy its in-app twin has
rubenluetke10-beepe98291cc3045
diff --git a/tests/unit/ui/test_orb_style_surface_parity.py b/tests/unit/ui/test_orb_style_surface_parity.pyindex 3fa6869800..9b6bb3b793 100644--- a/tests/unit/ui/test_orb_style_surface_parity.py+++ b/tests/unit/ui/test_orb_style_surface_parity.py@@ -60,12 +60,18 @@ def test_the_mascot_still_gets_both_bubble_variants() -> None:def test_the_sphere_is_half_again_the_mascots_size() -> None:+ from ui.orb.voice_orb import _BASE_SCALE+assert overlay.window_size_for_style("voice_orb") == (overlay.VOICE_ORB_WIN_W,overlay.VOICE_ORB_WIN_H,)assert overlay.window_size_for_style("mascot") == (overlay.WIN_W, overlay.WIN_H)- assert overlay.VOICE_ORB_WIN_W == round(overlay.WIN_W * 1.5)+ # The SPHERE is 1.5x the mascot; the window is larger still because the+ # aura has to be drawn inside it.+ sphere = overlay.VOICE_ORB_WIN_W * _BASE_SCALE+ assert sphere == pytest.approx(overlay.WIN_W * 1.5, abs=6)+ assert overlay.VOICE_ORB_WIN_W > spheredef test_a_new_orb_adopts_its_styles_window_size() -> None:diff --git a/tests/unit/ui/test_voice_orb_renderer.py b/tests/unit/ui/test_voice_orb_renderer.pyindex 355592fdd8..cda8a0dfb3 100644--- a/tests/unit/ui/test_voice_orb_renderer.py+++ b/tests/unit/ui/test_voice_orb_renderer.py@@ -89,10 +89,20 @@ def test_only_modes_with_a_live_feed_react_to_the_level() -> None:def _lit_radius(frame: np.ndarray) -> float:- """Half the width of the painted sphere in a rendered frame."""+ """Half the width of the SPHERE — measured as the longest unbroken run of+ painted pixels across the middle row.++ Not "leftmost to rightmost painted pixel": the aura is painted too, and it+ is deliberately full of gaps (its falloff is density, not alpha), so an+ extent measure would report the corona instead of the sphere.+ """lit = np.any(frame != np.asarray(KEY, dtype=np.int16), axis=-1)- columns = np.nonzero(lit.any(axis=0))[0]- return 0.0 if columns.size == 0 else (columns.max() - columns.min() + 1) / 2.0+ row = lit[frame.shape[0] // 2]+ best = run = 0+ for painted in row:+ run = run + 1 if painted else 0+ best = max(best, run)+ return best / 2.0def test_a_loud_voice_visibly_swells_the_sphere() -> None:@@ -117,6 +127,55 @@ def test_the_resting_sphere_leaves_room_to_grow() -> None:assert _lit_radius(frame) < 54.0 # strictly inside the window+def _outside_sphere(frame: np.ndarray, renderer: VoiceOrbRenderer) -> np.ndarray:+ """Mask of pixels beyond the sphere but inside the window."""+ radius = renderer._pixel_radius+ sphere_edge = _lit_radius(frame) / (frame.shape[0] / 2.0)+ return (radius > sphere_edge + 0.04) & (radius < 0.95)+++def test_a_resting_orb_throws_off_no_aura() -> None:+ """Idle has to stay exactly as calm as it was — no glow, no cost."""+ renderer = VoiceOrbRenderer(size=108, color_key=KEY)+ for step in range(30):+ frame = _frame(renderer, step / 30.0, "idle", None)+ outside = _outside_sphere(frame, renderer)+ painted = np.any(frame != np.asarray(KEY, dtype=np.int16), axis=-1)+ assert not (painted & outside).any()+++def test_a_loud_voice_lights_an_aura_around_the_sphere() -> None:+ renderer = VoiceOrbRenderer(size=108, color_key=KEY)+ for step in range(30):+ frame = _frame(renderer, step / 30.0, "speak", 1.0)+ outside = _outside_sphere(frame, renderer)+ painted = np.any(frame != np.asarray(KEY, dtype=np.int16), axis=-1)+ assert (painted & outside).sum() > 40+++def test_the_aura_is_density_not_a_solid_band() -> None:+ """Its falloff has to come from GAPS: a colour-keyed window has no alpha,+ and a solid ring read as machined brass rather than as energy."""+ renderer = VoiceOrbRenderer(size=108, color_key=KEY)+ for step in range(30):+ frame = _frame(renderer, step / 30.0, "speak", 1.0)+ outside = _outside_sphere(frame, renderer)+ painted = np.any(frame != np.asarray(KEY, dtype=np.int16), axis=-1)+ lit = (painted & outside).sum()+ dark = (~painted & outside).sum()+ assert lit > 0 and dark > 0, "the corona is either absent or completely solid"+++def test_the_aura_never_reaches_the_window_corners() -> None:+ """A pixel in the corner would put a stray ember at the window edge, and+ the surface's transparency contract expects the corners keyed out."""+ renderer = VoiceOrbRenderer(size=108, color_key=KEY)+ for step in range(30):+ frame = _frame(renderer, step / 30.0, "speak", 1.0)+ for y, x in ((0, 0), (0, 107), (107, 0), (107, 107)):+ assert tuple(frame[y, x]) == KEY++def test_thinking_churns_the_palette_harder_than_resting() -> None:"""Thinking has nothing to hear, so it says so with colour, not with text."""assert MOTIONS["think"].color_churn > MOTIONS["idle"].color_churn * 2diff --git a/ui/orb/overlay.py b/ui/orb/overlay.pyindex 07a025001c..bdb5c987a3 100644--- a/ui/orb/overlay.py+++ b/ui/orb/overlay.py@@ -119,13 +119,15 @@ class _DragState:WIN_W = 108WIN_H = 108-#: The voice orb's window, 50 % larger than the mascot's (maintainer, 2026-08-06).-#: The sphere now carries the whole conversation state on its own — no speech-#: bubble, no text — so it has to be big enough to read a swell and a colour-#: churn at a glance. The mascot keeps 108: its artwork, taskbar anchor and-#: animations are all drawn for that size.-VOICE_ORB_WIN_W = 162-VOICE_ORB_WIN_H = 162+#: The voice orb's window. Twice the mascot's edge, which is NOT the same as+#: twice the sphere: the sphere rests at 70 % of the window (162 px — the 50 %+#: larger sphere the maintainer asked for on 2026-08-06), and the margin that+#: leaves is where the aura lives. The corona and its outgoing waves have to be+#: drawn INSIDE this window like everything else, so the window has to be+#: bigger than the thing it draws. The mascot keeps 108: its artwork, taskbar+#: anchor and animations are all drawn for that size.+VOICE_ORB_WIN_W = 216+VOICE_ORB_WIN_H = 216def window_size_for_style(style: str) -> tuple[int, int]:diff --git a/ui/orb/voice_orb.py b/ui/orb/voice_orb.pyindex b1c3e32b72..4ebdc758a6 100644--- a/ui/orb/voice_orb.py+++ b/ui/orb/voice_orb.py@@ -143,14 +143,42 @@ _LEVEL_REACTIVE = frozenset({"listen", "dictate", "speak"})#: read as "I am listening", never as a dead orb._DICTATE_LEVEL_FLOOR = 0.18-#: Resting size as a fraction of the window. Below 1.0 ON PURPOSE: the swell-#: has to have somewhere to go. With the old value the sphere already filled-#: its window at rest, every beat hit the ``min(1.0, ...)`` ceiling, and the-#: result was a bump nobody could see.-_BASE_SCALE = 0.86+#: Resting size as a fraction of the window. Well below 1.0 ON PURPOSE, for two+#: reasons: the swell has to have somewhere to go (at 1.0 every beat hit the+#: ``min(1.0, ...)`` ceiling and the bump was invisible), and the aura needs the+#: margin outside the sphere to live in.+_BASE_SCALE = 0.75#: How much of the remaining headroom a full-volume moment claims.-_LEVEL_SWELL = 0.12+_LEVEL_SWELL = 0.10++# --- Aura -------------------------------------------------------------------+# The energy the sphere throws off: a warm corona that widens with loudness,+# plus waves that leave it and fade outward. What the in-app orb does with two+# CSS rings and an opacity animation — but the desktop window keys ONE exact+# colour out to become transparent, so a partly-transparent pixel is impossible.+#+# So the falloff is carried by DENSITY, not by alpha: each pixel is tested+# against a fine ordered-dither pattern, and the fraction that survives is the+# intensity. Half-strength paints half the pixels; from a step back the eye+# integrates that into a soft glow. A solid band with only its colour dimming+# was tried first and read as a machined brass ring around the sphere — the+# eye needs the AIR between the pixels to see gas rather than metal.++#: Widest the corona reaches, as a fraction of the half-window.+_AURA_REACH = 0.99+#: How quickly the corona thins with distance. Higher = tighter to the sphere.+_AURA_FALLOFF = 4.2+#: Corona density right at the sphere's edge, at full energy.+_AURA_MAX = 1.05+#: A wave leaves the sphere this often (seconds) and travels for this long.+_WAVE_PERIOD_S = 1.35+_WAVE_TRAVEL_S = 1.05+#: Wave ring thickness, as a fraction of the half-window.+_WAVE_WIDTH = 0.055+#: Ordered-dither cell. 8x8 is fine enough that the pattern reads as texture+#: rather than as a grid, and cheap enough to tile across a 216² window.+_DITHER_N = 8def _mix(a, b, amount):@@ -185,6 +213,38 @@ def speaking_onset(age: float) -> float:return math.sin((age / 0.24) * math.pi) * math.exp(-age * 2.4)+def _dither_tile(size: int) -> np.ndarray:+ """The aura's threshold field (values 0..1) — its stand-in for alpha.++ A pixel is painted when its strength beats the threshold under it, so+ strength becomes DENSITY. The field is FIXED, never regenerated per frame:+ a field that changed every frame would make the corona boil.++ Ordered dither alone (a plain Bayer matrix) laid visible diagonals across+ the glow — the eye finds the grid instantly. Mixing it with a fixed random+ field breaks the lattice while keeping the even coverage a pure random+ field lacks, and the result reads as embers instead of as a screen door.+ """+ base = np.array(+ [+ [0, 32, 8, 40, 2, 34, 10, 42],+ [48, 16, 56, 24, 50, 18, 58, 26],+ [12, 44, 4, 36, 14, 46, 6, 38],+ [60, 28, 52, 20, 62, 30, 54, 22],+ [3, 35, 11, 43, 1, 33, 9, 41],+ [51, 19, 59, 27, 49, 17, 57, 25],+ [15, 47, 7, 39, 13, 45, 5, 37],+ [63, 31, 55, 23, 61, 29, 53, 21],+ ],+ dtype=np.float32,+ )+ normalized = (base + 0.5) / 64.0+ repeats = int(np.ceil(size / _DITHER_N))+ ordered = np.tile(normalized, (repeats, repeats))[:size, :size]+ scatter = np.random.default_rng(0x0A11A).random((size, size)).astype(np.float32)+ return np.clip(ordered * 0.45 + scatter * 0.55, 0.0, 1.0)++def _build_noise_grid() -> np.ndarray:"""A stable tile of pseudo-random values (same LCG stream as the web orb)."""grid = np.empty(NOISE_SIZE * NOISE_SIZE, dtype=np.float64)@@ -270,6 +330,19 @@ class VoiceOrbRenderer:self._texture: Image.Image | None = Noneself._masks: dict[int, Image.Image] = {}+ # Distance of every window pixel from the centre, in half-window units+ # (1.0 = the window edge). Built once; the aura is a handful of numpy+ # comparisons against it per frame.+ half = max(1.0, self._size / 2.0)+ span = (np.arange(self._size, dtype=np.float32) + 0.5) - half+ yy, xx = np.meshgrid(span, span, indexing="ij")+ self._pixel_radius = np.sqrt(xx * xx + yy * yy) / half+ # Angle of every pixel, so the corona can breathe unevenly instead of+ # sitting around the sphere as a perfect ring.+ self._pixel_angle = np.arctan2(yy, xx).astype(np.float32)+ self._dither_field = _dither_tile(self._size)+ self._aura_elapsed = 0.0+# -- public seam ---------------------------------------------------def render(self, t: float, mode: str, ext_level: float | None) -> Image.Image:@@ -332,7 +405,18 @@ class VoiceOrbRenderer:)half = self._size / 2.0radius = (half - 1.0) * min(1.0, breath)- return self._compose(self._texture, radius)++ # How much energy the orb is throwing off right now (0..1). The live+ # level dominates when there is one — that is the honest signal — and+ # thinking keeps a steady work pulse of its own, because it has no+ # sound to ride and still has to look busy.+ self._aura_elapsed += dt+ energy = self._live_input+ if mode in ("think", "dictate_transcribing"):+ energy = max(energy, 0.42 + 0.30 * math.sin(self._aura_elapsed * 3.1))+ elif mode == "speak":+ energy = max(energy, self._live_impact * 6.0)+ return self._compose(self._texture, radius, min(1.0, max(0.0, energy)))# Compatibility no-ops: the overlay drives mascot-only expressions through# these. Answering them here (instead of leaving them to fail) keeps the@@ -461,9 +545,77 @@ class VoiceOrbRenderer:self._masks[diameter] = maskreturn mask- def _compose(self, texture: Image.Image, radius: float) -> Image.Image:+ def _aura_layer(self, radius: float, energy: float) -> np.ndarray | None:+ """The corona + travelling waves, as an RGB array over the key colour.++ Returns ``None`` when there is nothing to draw, so an idle orb costs+ exactly what it did before this existed.++ Every pixel returned is FULLY opaque — the falloff lives in the colour,+ not in an alpha channel the window cannot carry. See the module notes+ on ``_AURA_REACH``.+ """+ if energy <= 0.01:+ return None+ half = max(1.0, self._size / 2.0)+ inner = radius / half+ if inner >= _AURA_REACH:+ return None++ field = self._pixel_radius+ band = (field > inner) & (field <= _AURA_REACH)+ if not band.any():+ return None++ # Corona: densest against the sphere, thinning outward. An exponential+ # falloff, so it reads as gas leaving a surface rather than as a band+ # with an edge.+ distance_out = np.clip((field - inner) / max(1e-6, _AURA_REACH - inner), 0.0, 1.0)+ strength = np.exp(-distance_out * _AURA_FALLOFF) * _AURA_MAX * energy+ # Three slow lobes turning around the sphere: without this the corona is+ # a geometrically perfect annulus, which reads as a drawn ring rather+ # than as something the sphere is giving off.+ lobes = 1.0 + 0.34 * np.sin(self._pixel_angle * 3.0 - self._aura_elapsed * 1.15) * np.sin(+ self._pixel_angle * 2.0 + self._aura_elapsed * 0.7+ )+ strength = strength * lobes++ # Waves: rings that leave the sphere and thin as they travel, which is+ # what the in-app orb animates with two expanding CSS circles.+ phase = (self._aura_elapsed % _WAVE_PERIOD_S) / _WAVE_TRAVEL_S+ for offset in (0.0, 0.5):+ travel = phase - offset+ if not 0.0 <= travel <= 1.0:+ continue+ ring_r = inner + (_AURA_REACH - inner) * travel+ ring = np.clip(1.0 - np.abs(field - ring_r) / _WAVE_WIDTH, 0.0, 1.0)+ strength = np.maximum(strength, ring * (1.0 - travel) * energy * 0.9)++ # Density, not alpha: the dither decides which pixels survive, so a+ # half-strength glow paints half of them and the eye fills in the rest.+ visible = band & (strength > self._dither_field)+ if not visible.any():+ return None++ layer = np.empty((self._size, self._size, 3), dtype=np.uint8)+ layer[..., 0] = self._color_key[0]+ layer[..., 1] = self._color_key[1]+ layer[..., 2] = self._color_key[2]+ # Surviving pixels still carry a little of the falloff in their colour,+ # so the thin outer reaches read as embers rather than as gold confetti.+ amount = np.clip(strength[visible] / max(_AURA_MAX, 1e-6), 0.35, 1.0)+ layer[visible, 0] = (AMBER[0] + (SIGNAL_GOLD[0] - AMBER[0]) * amount).astype(np.uint8)+ layer[visible, 1] = (AMBER[1] + (SIGNAL_GOLD[1] - AMBER[1]) * amount).astype(np.uint8)+ layer[visible, 2] = (AMBER[2] + (SIGNAL_GOLD[2] - AMBER[2]) * amount).astype(np.uint8)+ return layer++ def _compose(self, texture: Image.Image, radius: float, energy: float = 0.0) -> Image.Image:diameter = max(2, int(round(radius * 2.0)))- frame = Image.new("RGB", (self._size, self._size), self._color_key)+ aura = self._aura_layer(radius, energy)+ if aura is None:+ frame = Image.new("RGB", (self._size, self._size), self._color_key)+ else:+ frame = Image.fromarray(aura, "RGB")scaled = texture.resize((diameter, diameter), Image.Resampling.BICUBIC)offset = (self._size - diameter) // 2frame.paste(scaled, (offset, offset), self._circle_mask(diameter))