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
revert(pets): bring back the smooth control strip
rubenluetke10-beep726558c6c274
diff --git a/docs/pets.md b/docs/pets.mdindex 7cccb49abe..390b36b87b 100644--- a/docs/pets.md+++ b/docs/pets.md@@ -22,11 +22,7 @@ one click.strip appears while Jarvis listens, thinks or talks, while notification cardsare up, and while the pointer is on the pet. With the pet "None", or with**Always show the buttons** on (My Pets → Customize, `[ui] pet_strip_always`),- it always shows. It is drawn in the pets' pixel art (`ui/orb/pixel_strip.py`,- at the sprite's own pixel size): chunky cream buttons with the sprites' dark- outline and a thick bottom edge, hand-placed pixel glyphs in dark ink, red- when muted, and three sky-blue pixel bars for the talk indicator; the- geometry and hit areas are `controls.pet_strip_layout`'s. From left to right:+ it always shows. From left to right:- bell: done cards on or off for this run (see *Cards*). Offshows a red, struck-through bell and sends the cards on screen away; onrings the bell. Like the speaker mute it never survives a restart, so adiff --git a/tests/unit/ui/test_pixel_strip.py b/tests/unit/ui/test_pixel_strip.pydeleted file mode 100644index 5c8bda4ea7..0000000000--- a/tests/unit/ui/test_pixel_strip.py+++ /dev/null@@ -1,71 +0,0 @@-"""The pet strip in pixel art (``ui.orb.pixel_strip``).--Pins: the frame keeps the original strip's size, so the original hit test-still fits it; every control's centre is paint, not key; only the pixel kit's-colours and the key appear (hard edges, no fringe); mutes turn red; the phone-turns green to call and red to hang up under the pointer; the voice moves the-bars; the art is whole blocks of ``art_px``.-"""--from __future__ import annotations--import pytest--from ui.orb import controls-from ui.orb import pixel_strip as ps--KEY = (255, 0, 255)-S = controls.PetStripState---def _colours(image) -> set[tuple[int, int, int]]:- return {c for _n, c in image.getcolors(image.width * image.height)}--[email protected]("scale", [1.0, 1.25, 2.0])-def test_the_pixel_strip_keeps_the_strips_size_and_controls(scale: float) -> None:- frame = ps.render_pet_strip_pixel(S(), scale, 3, KEY)- layout = controls.pet_strip_layout(scale)- assert frame.size == (layout.width, layout.height)- centres = [layout.pen[:2], layout.call[:2]]- centres += [- ((x0 + x1) / 2, (layout.pill[1] + layout.pill[3]) / 2) for _a, x0, x1 in layout.slots- ]- for x, y in centres:- assert frame.getpixel((int(x), int(y))) != KEY---def test_only_the_kits_colours_and_the_key_appear() -> None:- frame = ps.render_pet_strip_pixel(S(motion="voice", level=4, phase=3), 1.25, 4, KEY)- allowed = {- KEY,- ps.OUTLINE,- ps.PAPER,- ps.PAPER_HOVER,- ps.HIGHLIGHT,- ps.SHADE,- ps.DIVIDER,- ps.INK,- ps.SKY_HIGHLIGHT,- }- stray = {c for c in _colours(frame) - allowed if c[2] < 140 or c[0] > 140}- assert not stray # the bars' sky shades are the only other colours---def test_mutes_turn_red_and_the_phone_shows_its_action() -> None:- muted = ps.render_pet_strip_pixel(S(mic_muted=True), 1.0, 3, KEY)- assert ps.MUTED in _colours(muted)- call = ps.render_pet_strip_pixel(S(hovered="call"), 1.0, 3, KEY)- hang = ps.render_pet_strip_pixel(S(hovered="call", active=True), 1.0, 3, KEY)- assert ps.CALL_GO in _colours(call) and ps.CALL_STOP in _colours(hang)---def test_the_voice_moves_the_bars_and_art_pixels_are_whole_blocks() -> None:- rest = ps.render_pet_strip_pixel(S(), 1.0, 3, KEY)- loud = ps.render_pet_strip_pixel(S(motion="voice", level=6, phase=1), 1.0, 3, KEY)- assert rest.tobytes() != loud.tobytes()- big = ps.render_pet_strip_pixel(S(), 2.0, 4, KEY)- # Nearest-neighbour blocks: every 4 x 4 block inside the frame is one colour.- for bx in range(0, big.width - 4, 4):- block = big.crop((bx, 8, bx + 4, 12))- assert len(_colours(block)) == 1diff --git a/ui/orb/overlay.py b/ui/orb/overlay.pyindex b79828bd3d..13a5bed47b 100644--- a/ui/orb/overlay.py+++ b/ui/orb/overlay.py@@ -92,7 +92,6 @@ from ui.orb.drag_persistence import ()from ui.orb.notice_stack import PetNoticeStackfrom ui.orb.pet_renderer import PET_TARGET_EDGE_PX, PetRenderer, dpi_ratio_for-from ui.orb.pixel_strip import render_pet_strip_pixelfrom ui.orb.taskbar import (MascotAnchor,compute_mascot_position,@@ -2039,8 +2038,6 @@ class PetControlStrip(OrbControlRow):keep_visible: Callable[[], bool] | None = None,) -> None:self._scale = float(scale)- #: Screen pixels per art pixel: the strip is pixel art at the sprite's size.- self._art_px = max(1, int(round(3 * self._scale)))self._keep_visible = keep_visibleself._on_drag_press = on_drag_pressself._on_drag_motion = on_drag_motion@@ -2062,18 +2059,10 @@ class PetControlStrip(OrbControlRow):return orb_controls.pet_strip_size(self._scale)def _render_frame(self) -> Image.Image:- return render_pet_strip_pixel(- self._state, self._scale, self._art_px, tuple(int(c) for c in COLOR_KEY_RGB)+ return orb_controls.render_pet_strip(+ self._state, self._scale, tuple(int(c) for c in COLOR_KEY_RGB))- def set_art_px(self, art_px: int) -> None:- """Draw the strip's pixel art at the pet sprite's pixel size."""- art_px = max(1, int(art_px))- if art_px == self._art_px:- return- self._art_px = art_px- self._repaint()-def _hit(self, x: float, y: float) -> str | None:return orb_controls.pet_hit_test(x, y, self._scale)@@ -2704,7 +2693,6 @@ class OrbOverlay:row = self._controlsif isinstance(row, PetControlStrip):row.set_scale(scale)- row.set_art_px(self._thought_art_px())notices = self._noticesif notices is not None:strip_w, _strip_h = orb_controls.pet_strip_size(scale)@@ -3002,7 +2990,6 @@ class OrbOverlay:)if isinstance(row, PetControlStrip):row.set_state(mic_muted=self._mic_muted, notify_off=not self._notify_enabled)- row.set_art_px(self._thought_art_px())self._controls = rowdef _on_orb_pointer_enter(self, _event: tk.Event | None = None) -> None:diff --git a/ui/orb/pixel_strip.py b/ui/orb/pixel_strip.pydeleted file mode 100644index a23cb56260..0000000000--- a/ui/orb/pixel_strip.py+++ /dev/null@@ -1,286 +0,0 @@-"""The pet's control strip in pixel art — the pets' own retro look.--Same controls, same places, same hit areas as :func:`ui.orb.controls.render_pet_strip`-(the geometry is :func:`ui.orb.controls.pet_strip_layout`); only the drawing-changes. Every control is a chunky pixel button in the material the thought-bubble and the done letters use: cream paper with the sprites' dark outline, a-highlight row on top, a shaded row underneath and a thick dark bottom edge, so-each button looks pressable. The glyphs are hand-placed pixel sprites in the-pets' dark ink — a bell, a microphone, a speaker, a handset — and the talk-indicator is three sky-blue pixel bars that follow the voice.--Drawn at art resolution (one art pixel = ``art_px`` screen pixels, the pet-sprite's own size) and scaled up nearest-neighbour, so every edge is a hard-step. That also suits the strip's colour-keyed window: no pixel is ever a-blend of a button and the key.-"""--from __future__ import annotations--import functools-import math--from PIL import Image, ImageChops, ImageDraw, ImageFilter--from ui.orb import controls-from ui.orb.controls import PetStripState--_Rgb = tuple[int, int, int]--#: The pixel UI kit's palette (shared with ``pet_cards`` and ``thought_bubble``).-OUTLINE: _Rgb = (27, 22, 34)-PAPER: _Rgb = (252, 248, 237)-PAPER_HOVER: _Rgb = (255, 255, 250)-HIGHLIGHT: _Rgb = (255, 255, 255)-SHADE: _Rgb = (226, 218, 199)-DIVIDER: _Rgb = (214, 205, 184)-INK: _Rgb = (46, 36, 58)-MUTED: _Rgb = (206, 64, 72)-CALL_GO: _Rgb = (126, 214, 120)-CALL_STOP: _Rgb = (236, 104, 104)-SKY: _Rgb = (126, 186, 255)-SKY_HIGHLIGHT: _Rgb = (214, 234, 255)-NIGHT: _Rgb = (78, 98, 150)--#: Hand-placed glyphs, 11 x 11 art pixels, ``#`` is ink.-_BELL = (- ".....#.....",- "....###....",- "...#####...",- "..#######..",- "..#######..",- "..#######..",- "..#######..",- ".#########.",- "###########",- "...........",- "....###....",-)-_MIC = (- "....###....",- "...#####...",- "...#####...",- "...#####...",- ".#.#####.#.",- ".#..###..#.",- "..#.....#..",- "...#####...",- ".....#.....",- ".....#.....",- "...#####...",-)-_SPEAKER = (- "....#......",- "...##...#..",- "..###....#.",- "#####.#..#.",- "#####..#.#.",- "#####..#.#.",- "#####.#..#.",- "..###....#.",- "...##...#..",- "....#......",- "...........",-)-_SPEAKER_QUIET = (- "....#......",- "...##......",- "..###......",- "#####......",- "#####......",- "#####......",- "#####......",- "..###......",- "...##......",- "....#......",- "...........",-)-_PHONE = (- ".##........",- "####.......",- "####.......",- ".###.......",- "..##.......",- "..###......",- "...###..##.",- "....######.",- ".....#####.",- "......###..",- "...........",-)-_HANGUP = (- "...........",- "...........",- "...........",- "...#####...",- ".#########.",- "###.....###",- "###.....###",- "...........",- "...........",- "...........",- "...........",-)-GLYPH = 11---def _stamp(d: ImageDraw.ImageDraw, rows: tuple[str, ...], x0: int, y0: int, color: _Rgb) -> None:- for y, row in enumerate(rows):- for x, cell in enumerate(row):- if cell == "#":- d.point((x0 + x, y0 + y), fill=color)---def _slash(d: ImageDraw.ImageDraw, x0: int, y0: int, color: _Rgb) -> None:- """A two-pixel diagonal strike from top left to bottom right."""- for i in range(GLYPH):- d.point((x0 + i, y0 + i), fill=color)- if i + 1 < GLYPH:- d.point((x0 + i + 1, y0 + i), fill=color)---def _ring(mask: Image.Image) -> Image.Image:- return ImageChops.subtract(mask.filter(ImageFilter.MaxFilter(3)), mask)---def _button(canvas: Image.Image, shape: Image.Image, fill: _Rgb, origin: tuple[int, int]) -> None:- """One pixel button: dark bottom edge, fill, highlight and shade rows, outline."""- w, h = shape.size- ox, oy = origin- whole = Image.new("L", canvas.size, 0)- whole.paste(shape, (ox, oy))- # The thick bottom edge: the shape again, one art pixel lower, in ink.- depth = Image.new("L", canvas.size, 0)- depth.paste(shape, (ox, oy + 1))- canvas.paste(OUTLINE, (0, 0), ImageChops.lighter(depth, _ring(depth)))- canvas.paste(fill, (0, 0), whole)- up = Image.new("L", canvas.size, 0)- up.paste(shape, (ox, oy - 1))- down = Image.new("L", canvas.size, 0)- down.paste(shape, (ox, oy + 1))- canvas.paste(SHADE, (0, 0), ImageChops.subtract(whole, up))- canvas.paste(HIGHLIGHT, (0, 0), ImageChops.subtract(whole, down))- canvas.paste(OUTLINE, (0, 0), _ring(whole))- _ = (w, h)---def _disc(diameter: int) -> Image.Image:- mask = Image.new("L", (diameter, diameter), 0)- ImageDraw.Draw(mask).ellipse([0, 0, diameter - 1, diameter - 1], fill=255)- return mask---def _stadium(width: int, height: int) -> Image.Image:- mask = Image.new("L", (width, height), 0)- ImageDraw.Draw(mask).rounded_rectangle(- [0, 0, width - 1, height - 1], radius=height // 2, fill=255- )- return mask---def _wobble(angle: float) -> int:- """A ringing glyph shakes by one art pixel toward its swing."""- if abs(angle) < 2.0:- return 0- return 1 if angle > 0 else -1--[email protected]_cache(maxsize=256)-def render_pet_strip_pixel(- state: PetStripState,- scale: float = 1.0,- art_px: int = 3,- color_key: tuple[int, int, int] = (255, 0, 255),-) -> Image.Image:- """The pet strip as a colour-keyed RGB frame, in pixel art.-- Same size and the same control places as ``controls.render_pet_strip``,- so ``controls.pet_hit_test`` stays right. Cached per state like the- original: a strip at rest costs one render per look.- """- layout = controls.pet_strip_layout(scale)- u = max(1, int(art_px))- aw, ah = math.ceil(layout.width / u), math.ceil(layout.height / u)- art = Image.new("RGB", (aw, ah), color_key)- d = ImageDraw.Draw(art)-- def a(value: float) -> int:- return int(round(value / u))-- # Room for the outline above and the bottom edge below every button.- top = 1- body_h = max(GLYPH + 4, ah - 3)-- def disc_at(cx: float, action: str, fill: _Rgb) -> tuple[int, int]:- size = body_h- x0 = a(cx) - size // 2- _button(art, _disc(size), fill, (x0, top))- return x0 + (size - GLYPH) // 2, top + (size - GLYPH) // 2-- hovered = state.hovered- # The bell.- bx, by = disc_at(layout.pen[0], "bell", PAPER_HOVER if hovered == "bell" else PAPER)- bell_ink = MUTED if state.notify_off else INK- _stamp(d, _BELL, bx + _wobble(controls.ring_angle(state.ring)), by, bell_ink)- if state.notify_off:- _slash(d, bx, by, MUTED)-- # The pill: microphone, talk bars, speaker.- px0, _py0, px1, _py1 = layout.pill- pill_w = a(px1) - a(px0)- _button(art, _stadium(pill_w, body_h), PAPER, (a(px0), top))- for action, sx0, sx1 in layout.slots:- if hovered == action:- hx0, hx1 = a(sx0) + 1, a(sx1) - 1- d.rectangle([hx0, top + 2, hx1, top + body_h - 3], fill=PAPER_HOVER)- for dx in layout.dividers:- x = a(dx)- for y in range(top + 3, top + body_h - 3, 2): # a dotted seam- d.point((x, y), fill=DIVIDER)- gy = top + (body_h - GLYPH) // 2- for action, sx0, sx1 in layout.slots:- gx = (a(sx0) + a(sx1)) // 2 - GLYPH // 2- if action == "mic_mute":- ink = MUTED if state.mic_muted else INK- _stamp(d, _MIC, gx, gy, ink)- if state.mic_muted:- _slash(d, gx, gy, MUTED)- elif action == "speaker":- ink = MUTED if state.speaker_muted else INK- _stamp(d, _SPEAKER_QUIET if state.speaker_muted else _SPEAKER, gx, gy, ink)- if state.speaker_muted:- _slash(d, gx, gy, MUTED)- elif action == "orb":- _bars(d, (a(sx0) + a(sx1)) // 2, top + body_h // 2, body_h, state)-- # The phone: green to call, red to hang up, under the pointer.- if hovered == "call":- call_fill = CALL_STOP if state.active else CALL_GO- else:- call_fill = PAPER- cx, cy = disc_at(layout.call[0], "call", call_fill)- shake = _wobble(controls.call_ring_angle(state.call_ring))- _stamp(d, _HANGUP if state.active else _PHONE, cx + shake, cy, INK)-- big = art.resize((aw * u, ah * u), Image.Resampling.NEAREST)- return big.crop((0, 0, layout.width, layout.height))---def _bars(d: ImageDraw.ImageDraw, cx: int, cy: int, body_h: int, state: PetStripState) -> None:- """The talk indicator: three pixel bars of sky, as tall as the voice."""- tallest = max(3, body_h - 6)- for i, (share, glow) in enumerate(controls.indicator_bars(state)):- h = max(2, int(round(tallest * share / controls.PET_INDICATOR_MAX_H)))- h = min(tallest, h)- # Two art pixels wide, five apart: each bar keeps its own outline.- x = cx - 6 + i * 5- y0 = cy - h // 2- y1 = y0 + h - 1- t = max(0.0, min(1.0, glow))- body = tuple(int(round(n + (s - n) * t)) for n, s in zip(NIGHT, SKY, strict=True))- d.rectangle([x - 1, y0 - 1, x + 2, y1 + 1], fill=OUTLINE)- d.rectangle([x, y0, x + 1, y1], fill=body)- d.point((x, y0), fill=SKY_HIGHLIGHT if t > 0.7 else body)---__all__ = ["render_pet_strip_pixel"]