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(jarvisbar): live-resize the bar via set_size_scale on every surface
Ruben Lütkebbf317959bca
diff --git a/jarvis/ui/desktop_app.py b/jarvis/ui/desktop_app.pyindex 21a62c5e69..36958c16e8 100644--- a/jarvis/ui/desktop_app.py+++ b/jarvis/ui/desktop_app.py@@ -2049,6 +2049,7 @@ class DesktopApp:persistent=self.cfg.ui.bar_persistent,accent=self.cfg.ui.bar_accent,startup_gated=gate_until_voice_ready,+ size_scale=getattr(self.cfg.ui, "bar_size_scale", 1.0),)surface.start_in_thread()logger.info(@@ -2097,6 +2098,7 @@ class DesktopApp:persistent=self.cfg.ui.bar_persistent,accent=self.cfg.ui.bar_accent,startup_gated=gate_until_voice_ready,+ size_scale=getattr(self.cfg.ui, "bar_size_scale", 1.0),)else: # "mascot" (and any legacy style value)from ui.orb.overlay import OrbOverlay@@ -2143,6 +2145,35 @@ class DesktopApp:logger.opt(exception=exc).warning("set_bar_persistent failed")return {"ok": True, "applied_live": False}+ def set_bar_size(self, scale: float) -> dict[str, object]:+ """Live-resize the on-screen bar to a new 'Bar size' multiplier.++ Clamps the value, updates the in-memory config, and calls the surface's+ ``set_size_scale`` so the bar grows/shrinks immediately (proportionally,+ shape preserved). Only the bar surface implements it — on the mascot /+ no-overlay style this reports ``applied_live=False`` (persisted only).+ """+ from loguru import logger++ from jarvis.ui.jarvisbar import renderer++ scale = renderer.clamp_user_size(scale)+ try:+ self.cfg.ui.bar_size_scale = scale+ except Exception: # noqa: BLE001+ pass+ bar = getattr(self, "_orb", None)+ fn = getattr(bar, "set_size_scale", None)+ if not callable(fn):+ return {"ok": True, "applied_live": False, "scale": scale}+ try:+ fn(scale)+ logger.info("bar_size_scale set live to {:.2f}.", scale)+ return {"ok": True, "applied_live": True, "scale": scale}+ except Exception as exc: # noqa: BLE001+ logger.opt(exception=exc).warning("set_bar_size failed")+ return {"ok": True, "applied_live": False, "scale": scale}+def swap_overlay(self, style: str) -> dict[str, object]:"""Apply an overlay style change at runtime *as far as is Tk-safe*.diff --git a/jarvis/ui/jarvisbar/host.py b/jarvis/ui/jarvisbar/host.pyindex d25cc9c686..5d8d263f8e 100644--- a/jarvis/ui/jarvisbar/host.py+++ b/jarvis/ui/jarvisbar/host.py@@ -94,6 +94,8 @@ def dispatch(surface: Any, msg: dict[str, Any]) -> bool:_call(surface, "set_level", float(msg.get("level", 0.0)))elif op == "set_muted":_call(surface, "set_muted", bool(msg.get("muted", False)))+ elif op == "set_size_scale":+ _call(surface, "set_size_scale", float(msg.get("scale", 1.0)))elif op == "set_persistent":# Live flag flip — the same plain attribute write the in-process# set_bar_persistent path performs (no Tk marshal needed).@@ -304,7 +306,9 @@ def _build_surface(cfg: dict[str, Any]) -> Any:mascot_path=cfg.get("mascot_path") or None,)kwargs = {- key: cfg[key] for key in ("persistent", "accent", "opacity", "startup_gated") if key in cfg+ key: cfg[key]+ for key in ("persistent", "accent", "opacity", "startup_gated", "size_scale")+ if key in cfg}if sys.platform == "darwin":# Aqua-Tk 9 composites RGBA Canvas images with SourceOver semantics:diff --git a/jarvis/ui/jarvisbar/null_overlay.py b/jarvis/ui/jarvisbar/null_overlay.pyindex 8eeba83b83..c34423dd68 100644--- a/jarvis/ui/jarvisbar/null_overlay.py+++ b/jarvis/ui/jarvisbar/null_overlay.py@@ -16,6 +16,7 @@ class NullOverlay:def show(self, mode: str = "listen") -> None: ...def hide(self) -> None: ...def set_level(self, level: float) -> None: ...+ def set_size_scale(self, scale: float) -> None: ...def play_animation(self, name: str, **params: Any) -> None: ...def stop_animation(self, name: str) -> None: ...def show_listening_transcript(self, text: str = "", duration_ms: int = 30000) -> None: ...diff --git a/jarvis/ui/jarvisbar/overlay.py b/jarvis/ui/jarvisbar/overlay.pyindex d2fae8904d..3ea4b145eb 100644--- a/jarvis/ui/jarvisbar/overlay.py+++ b/jarvis/ui/jarvisbar/overlay.py@@ -346,10 +346,17 @@ class JarvisBarOverlay:accent: str = "#e7c46e",opacity: float = BAR_ALPHA,startup_gated: bool = False,+ size_scale: float = 1.0,) -> None:self._persistent = persistentself._accent = accentself._opacity = max(0.2, min(1.0, float(opacity))) # clamp to sane range+ # User "Bar size" preference (multiplied on top of the screen-adaptive+ # scale) and the screen-adaptive scale captured at start(). Kept so the+ # live "Bar size" slider can re-derive the geometry without re-probing+ # the screen. See renderer.apply_display_scale / set_size_scale.+ self._user_size_scale = renderer.clamp_user_size(size_scale)+ self._screen_scale = 1.0# The desktop boot path constructs and paints the bar early, while it is# still withdrawn, then releases this gate on the honest voice-usable# signal. This is stronger than an initial ``withdraw``: every early@@ -498,6 +505,19 @@ class JarvisBarOverlay:atomic bool write — the frame loop reads it; no Tk marshal needed."""self._muted = bool(muted)+ def set_size_scale(self, scale: float) -> None:+ """Live-resize the bar to a new user "Bar size" multiplier.++ Thread-safe: the geometry recompute + window resize run on the Tk+ thread via the UI queue, so the route/audio threads only hand over a+ float. Width AND height scale together (the pill's shape is preserved,+ only its size changes), and the bar grows UPWARD from a fixed+ bottom-centre so it never drops into the taskbar."""+ self._user_size_scale = renderer.clamp_user_size(scale)+ if self._root is None:+ return+ self._enqueue_ui(lambda s=self._user_size_scale: self._do_apply_size(s))+def set_on_mute_toggle(self, callback: Callable[[], None] | None) -> None:self._on_mute_toggle = callback@@ -607,15 +627,15 @@ class JarvisBarOverlay:# physical pixels on a DPI-aware Windows/X11 — both are the right# basis for "how much of this screen would the bar occupy".try:- renderer.apply_display_scale(- renderer.compute_display_scale(- int(root.winfo_screenwidth()), int(root.winfo_screenheight())- )+ self._screen_scale = renderer.compute_display_scale(+ int(root.winfo_screenwidth()), int(root.winfo_screenheight()))- if renderer.DISPLAY_SCALE != 1.0:+ renderer.apply_display_scale(self._screen_scale, user_size=self._user_size_scale)+ if renderer.DISPLAY_SCALE != 1.0 or self._user_size_scale != 1.0:log.info(- "jarvisbar display scale %.3f for screen %sx%s",+ "jarvisbar display scale %.3f (user size %.2f) for screen %sx%s",renderer.DISPLAY_SCALE,+ self._user_size_scale,root.winfo_screenwidth(),root.winfo_screenheight(),)@@ -785,6 +805,74 @@ class JarvisBarOverlay:margin=MARGIN_PX,)+ def _do_apply_size(self, user_scale: float) -> None:+ """Recompute geometry for ``user_scale`` and resize the window (Tk thread).++ Runs on the Tk mainloop thread (enqueued by ``set_size_scale``), so it+ is serialized against the frame loop — no lock needed on the module+ geometry globals it mutates via ``apply_display_scale``.+ """+ if self._root is None:+ return+ try:+ old_win_w, old_win_h = renderer.WIN_W, renderer.WIN_H+ old_ref = renderer.OPEN_W or 1 # any pill dim scales by the same factor+ renderer.apply_display_scale(self._screen_scale, user_size=user_scale)+ # Snap the eased pill so it matches the new window immediately: no+ # transient where a still-large pill is clipped by a shrunk window,+ # and no lag where a small pill floats in a grown window. The+ # renderer then eases toward the (already-matching) target, so the+ # pill stays put — the visible change is a clean, instant rescale+ # that tracks the slider live.+ r = self._renderer+ if r is not None and old_ref:+ ratio = renderer.OPEN_W / old_ref+ r._st.pw *= ratio # noqa: SLF001 — same-object render state+ r._st.ph *= ratio # noqa: SLF001+ self._reanchor_after_resize(old_win_w, old_win_h)+ self._invalidate_static_frame()+ except Exception: # noqa: BLE001 — a resize hiccup must never crash the bar+ log.debug("jarvisbar live resize failed", exc_info=True)++ def _reanchor_after_resize(self, old_win_w: int, old_win_h: int) -> None:+ """Resize the window + canvas and keep the bar's bottom-centre fixed.++ The pill is bottom-anchored (grows upward), so preserving the window's+ bottom-centre keeps the resting spot above the taskbar unchanged while+ a bigger bar simply extends higher. Clamped to the screen so an+ enlarged bar near a screen edge can never spill off it.+ """+ if self._root is None:+ return+ center_x = self._x + old_win_w / 2.0+ bottom_y = self._y + old_win_h+ new_x = round(center_x - renderer.WIN_W / 2.0)+ new_y = round(bottom_y - renderer.WIN_H)+ try:+ sw = int(self._root.winfo_screenwidth())+ sh = int(self._root.winfo_screenheight())+ new_x, new_y = interaction.clamp_to_screen(+ new_x,+ new_y,+ screen_w=sw,+ screen_h=sh,+ bar_w=renderer.WIN_W,+ bar_h=renderer.WIN_H,+ margin=MARGIN_PX,+ )+ except Exception: # noqa: BLE001 — clamping is best-effort+ log.debug("jarvisbar resize clamp failed", exc_info=True)+ self._x, self._y = new_x, new_y+ if self._canvas is not None:+ try:+ self._canvas.config(width=renderer.WIN_W, height=renderer.WIN_H)+ except Exception: # noqa: BLE001+ log.debug("jarvisbar canvas resize failed", exc_info=True)+ try:+ self._root.geometry(f"{renderer.WIN_W}x{renderer.WIN_H}+{self._x}+{self._y}")+ except Exception: # noqa: BLE001+ log.debug("jarvisbar geometry resize failed", exc_info=True)+def _do_show(self) -> None:if self._root is None:returndiff --git a/jarvis/ui/jarvisbar/qt_overlay.py b/jarvis/ui/jarvisbar/qt_overlay.pyindex b8dc6a84dc..de79b2744b 100644--- a/jarvis/ui/jarvisbar/qt_overlay.py+++ b/jarvis/ui/jarvisbar/qt_overlay.py@@ -375,11 +375,17 @@ class QtJarvisBarOverlay:accent: str = "#e7c46e",opacity: float = BAR_ALPHA,startup_gated: bool = False,+ size_scale: float = 1.0,) -> None:self._persistent_flag = bool(persistent)self._accent = accentself._opacity = max(0.2, min(1.0, float(opacity)))self._startup_gated = bool(startup_gated)+ # User "Bar size" preference (multiplied on top of the screen-adaptive+ # scale) + the screen scale captured at start(), so the live "Bar size"+ # slider can re-derive geometry without re-probing the screen.+ self._user_size_scale = renderer.clamp_user_size(size_scale)+ self._screen_scale = 1.0self._mode = "idle"self._ext_level = 0.0self._last_audible_t = 0.0@@ -478,6 +484,15 @@ class QtJarvisBarOverlay:self._muted = bool(muted)self._invalidate_static_frame()+ def set_size_scale(self, scale: float) -> None:+ """Live-resize the bar to a new user "Bar size" multiplier (thread-safe).++ The geometry recompute + window resize run on the Qt main thread via the+ UI queue. Width AND height scale together (shape preserved), and the bar+ grows UPWARD from a fixed bottom-centre so it never drops off-screen."""+ self._user_size_scale = renderer.clamp_user_size(scale)+ self._enqueue_if_started(lambda s=self._user_size_scale: self._apply_size_ui(s))+def set_on_mute_toggle(self, callback: Callable[[], None] | None) -> None:self._on_mute_toggle = callback@@ -551,9 +566,10 @@ class QtJarvisBarOverlay:screen = app.primaryScreen()if screen is not None:geometry = screen.geometry()- renderer.apply_display_scale(- renderer.compute_display_scale(geometry.width(), geometry.height())+ self._screen_scale = renderer.compute_display_scale(+ geometry.width(), geometry.height())+ renderer.apply_display_scale(self._screen_scale, user_size=self._user_size_scale)self._renderer = renderer.JarvisBarRenderer(accent=self._accent)window_type = _window_class()@@ -984,6 +1000,46 @@ class QtJarvisBarOverlay:self._x, self._y = self._preferred_positionself._reconcile_dynamic_position_ui()+ def _apply_size_ui(self, user_scale: float) -> None:+ """Recompute geometry for ``user_scale`` and resize the window (Qt thread).++ Runs on the Qt main thread (enqueued by ``set_size_scale``), serialized+ against the frame timer, so mutating the module geometry globals via+ ``apply_display_scale`` needs no lock.+ """+ window = self._window+ if window is None:+ return+ try:+ old_win_w, old_win_h = renderer.WIN_W, renderer.WIN_H+ old_ref = renderer.OPEN_W or 1+ renderer.apply_display_scale(self._screen_scale, user_size=user_scale)+ # Snap the eased pill so it matches the new window immediately (no+ # clip on shrink, no lag on grow) — see the Tk surface for the+ # rationale.+ r = self._renderer+ if r is not None and old_ref:+ ratio = renderer.OPEN_W / old_ref+ r._st.pw *= ratio # noqa: SLF001 — same-object render state+ r._st.ph *= ratio # noqa: SLF001+ # Re-anchor the PREFERRED location by its bottom-centre so the bar+ # grows upward; the Dock-safe reconcile then clamps the actual spot.+ pref = self._preferred_position or (self._x, self._y)+ center_x = pref[0] + old_win_w / 2.0+ bottom_y = pref[1] + old_win_h+ self._preferred_position = (+ round(center_x - renderer.WIN_W / 2.0),+ round(bottom_y - renderer.WIN_H),+ )+ window.setFixedSize(renderer.WIN_W, renderer.WIN_H)+ self._reconcile_dynamic_position_ui()+ # Repaint at the new size right away so the input mask + frame track+ # the slider without waiting a frame tick.+ self._invalidate_static_frame()+ self._render_frame_ui()+ except Exception: # noqa: BLE001 — a resize hiccup must never crash the bar+ log.debug("Qt Jarvis Bar live resize failed", exc_info=True)+def _reconcile_dynamic_position_ui(self) -> bool:"""Move between preferred and Dock-safe positions without rewriting config."""if self._drag is not None:diff --git a/jarvis/ui/jarvisbar/subprocess_overlay.py b/jarvis/ui/jarvisbar/subprocess_overlay.pyindex 71f50d15a4..d05bac1468 100644--- a/jarvis/ui/jarvisbar/subprocess_overlay.py+++ b/jarvis/ui/jarvisbar/subprocess_overlay.py@@ -64,11 +64,15 @@ class SubprocessBarOverlay:accent: str = "#e7c46e",opacity: float | None = None,startup_gated: bool = False,+ size_scale: float = 1.0,) -> None:self._persistent_flag = bool(persistent)self._accent = accentself._opacity = opacityself._startup_gated = bool(startup_gated)+ # User "Bar size" multiplier, forwarded in the init line so the host+ # boots at the right size and a bounded respawn restores it.+ self._size_scale = float(size_scale)self._mode = "idle"self._muted = False# Mirror what the real host does at construction time. A persistent,@@ -193,6 +197,7 @@ class SubprocessBarOverlay:"persistent": self._persistent_flag,"accent": self._accent,"startup_gated": self._startup_gated,+ "size_scale": self._size_scale,}if self._opacity is not None:init["opacity"] = float(self._opacity)@@ -237,6 +242,14 @@ class SubprocessBarOverlay:self._muted = bool(muted)self._send({"op": "set_muted", "muted": self._muted})+ def set_size_scale(self, scale: float) -> None:+ """Forward a live "Bar size" change to the hosted surface.++ Stored too, so a bounded respawn re-sends the latest size in the fresh+ host's init line rather than snapping back to the boot value."""+ self._size_scale = float(scale)+ self._send({"op": "set_size_scale", "scale": self._size_scale})+# The bar draws no text bubble and no mouth — the real surface no-ops# these, so the proxy saves the IPC round-trip and no-ops locally too.def play_animation(self, name: str, **params: Any) -> None: ...diff --git a/tests/unit/ui/jarvisbar/test_host_protocol.py b/tests/unit/ui/jarvisbar/test_host_protocol.pyindex f8e9cb539a..2e574fed05 100644--- a/tests/unit/ui/jarvisbar/test_host_protocol.py+++ b/tests/unit/ui/jarvisbar/test_host_protocol.py@@ -44,6 +44,9 @@ class _RecordingBar:def set_muted(self, muted: bool) -> None:self.calls.append(("set_muted", muted))+ def set_size_scale(self, scale: float) -> None:+ self.calls.append(("set_size_scale", scale))+def release_startup_gate(self) -> bool:self.calls.append(("release_startup_gate",))return True@@ -101,6 +104,7 @@ def test_dispatch_maps_every_op_onto_the_surface() -> None:{"op": "hide"},{"op": "set_level", "level": 0.5},{"op": "set_muted", "muted": True},+ {"op": "set_size_scale", "scale": 1.4},{"op": "set_persistent", "enabled": False},{"op": "release_startup_gate"},{"op": "reassert_z_order"},@@ -118,6 +122,7 @@ def test_dispatch_maps_every_op_onto_the_surface() -> None:assert ("show", "listen") in bar.callsassert ("set_level", 0.5) in bar.callsassert ("set_muted", True) in bar.calls+ assert ("set_size_scale", 1.4) in bar.callsassert ("play_animation", "wave", {"x": 1}) in bar.callsassert ("show_listening_transcript", "hi", 9) in bar.callsassert ("reset_position",) in bar.callsdiff --git a/tests/unit/ui/jarvisbar/test_subprocess_overlay.py b/tests/unit/ui/jarvisbar/test_subprocess_overlay.pyindex 462c7f2502..5478f86d1a 100644--- a/tests/unit/ui/jarvisbar/test_subprocess_overlay.py+++ b/tests/unit/ui/jarvisbar/test_subprocess_overlay.py@@ -100,10 +100,22 @@ def test_init_line_carries_the_constructor_config(monkeypatch) -> None:"persistent": False,"accent": "#123456","startup_gated": True,+ "size_scale": 1.0,}assert surface._ready.is_set() # scripted ready event consumed+def test_size_scale_rides_the_init_line_and_live_op(monkeypatch) -> None:+ # A custom boot size is carried on the init line so the host starts at the+ # right size; a later set_size_scale forwards a live-resize op and updates+ # the stored value (so a bounded respawn re-sends the latest size).+ surface, proc = _started_proxy(monkeypatch, size_scale=1.5)+ assert proc.sent()[0]["size_scale"] == 1.5+ surface.set_size_scale(0.8)+ assert proc.sent()[-1] == {"op": "set_size_scale", "scale": 0.8}+ assert surface._size_scale == 0.8++def test_surface_calls_become_wire_ops_and_mirror_locally(monkeypatch) -> None:surface, proc = _started_proxy(monkeypatch)surface.show("speak")@@ -372,6 +384,7 @@ def test_host_death_triggers_respawn_and_reapplies_desired_state("persistent": True,"accent": "#e7c46e","startup_gated": False,+ "size_scale": 1.0,}# Last known state (shown in "speak", muted, last level 0.9) re-applied.assert [m["op"] for m in sent[1:]] == ["show", "set_muted", "set_level"]@@ -499,6 +512,7 @@ def test_bar_init_payload_is_unchanged_by_the_mascot_variant(monkeypatch) -> Non"persistent": True,"accent": "#e7c46e","startup_gated": False,+ "size_scale": 1.0,}assert not isinstance(surface, SubprocessMascotOverlay)diff --git a/tests/unit/ui/jarvisbar/test_surface_contract.py b/tests/unit/ui/jarvisbar/test_surface_contract.pyindex 974e0abd64..82c6d43cf4 100644--- a/tests/unit/ui/jarvisbar/test_surface_contract.py+++ b/tests/unit/ui/jarvisbar/test_surface_contract.py@@ -12,6 +12,7 @@ REQUIRED = ["release_startup_gate","set_level","set_muted",+ "set_size_scale","play_animation","stop_animation","show_listening_transcript",