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): add a user Bar-size multiplier to the proportional scale math
Ruben Lütked6149e1470ba
diff --git a/jarvis/ui/jarvisbar/renderer.py b/jarvis/ui/jarvisbar/renderer.pyindex 894f448e49..129a597319 100644--- a/jarvis/ui/jarvisbar/renderer.py+++ b/jarvis/ui/jarvisbar/renderer.py@@ -88,6 +88,38 @@ MIN_DISPLAY_SCALE = 0.55BASE_DISPLAY_SCALE = 0.85DISPLAY_SCALE = 1.0+# --- user size preference (the "Bar size" slider) ----------------------------+# A multiplier applied ON TOP of the screen-adaptive DISPLAY_SCALE, chosen by+# the user in Settings → "Bar size". 1.0 reproduces the signed-off default+# look byte-identically; below shrinks, above enlarges. Unlike DISPLAY_SCALE+# (which never enlarges past the approved ceiling because the maintainer's look+# is the ceiling), THIS axis is the user's explicit choice, so it may exceed+# 1.0. The frame is still drawn CRISPLY at the larger geometry — every constant+# is recomputed and the pill is redrawn at the scaled size, exactly like the+# screen-adaptive path. This is NOT the blurry DPI bitmap upscaling that was+# rejected (see overlay.start()'s DPI notes); the DPI strategy is untouched.+# Width AND height scale together (the whole geometry multiplies by one factor),+# so the pill's shape is preserved and only its size changes.+USER_SIZE_MIN = 0.5+USER_SIZE_MAX = 2.0+USER_SIZE_DEFAULT = 1.0+USER_SIZE_SCALE = USER_SIZE_DEFAULT+++def clamp_user_size(user_size: float) -> float:+ """Clamp a user size multiplier into ``[USER_SIZE_MIN, USER_SIZE_MAX]``.++ Non-numeric / non-finite input degrades to ``USER_SIZE_DEFAULT`` so a+ corrupt persisted value can never brick the bar geometry.+ """+ try:+ u = float(user_size)+ except (TypeError, ValueError):+ return USER_SIZE_DEFAULT+ if not math.isfinite(u):+ return USER_SIZE_DEFAULT+ return max(USER_SIZE_MIN, min(USER_SIZE_MAX, u))+def compute_display_scale(screen_w: int, screen_h: int) -> float:"""Scale factor for the screen the bar lives on (pure, unit-testable).@@ -131,7 +163,7 @@ _ACTIVE_VERT_TRIM = 0.22 # fraction removed from top and bottom of the 2x heigh_BASE_BOTTOM_PAD = 10-def apply_display_scale(scale: float) -> None:+def apply_display_scale(scale: float, user_size: float | None = None) -> None:"""Recompute every derived geometry constant for ``scale``.Called once by ``overlay.start()`` (one bar per process) before any@@ -139,17 +171,31 @@ def apply_display_scale(scale: float) -> None:applies 1.0, which reproduces the historical constants byte-identically.``overlay.py`` reads the module attributes dynamically, so the windowfollows the recomputed sizes.++ ``scale`` is the SCREEN-adaptive factor (clamped to ``[MIN_DISPLAY_SCALE,+ 1.0]``). ``user_size`` is the user's "Bar size" preference multiplied on+ top; ``None`` keeps the current ``USER_SIZE_SCALE`` (so the old single-arg+ call sites and the module-load call are byte-identical when the user has+ not changed the size). The effective geometry factor is+ ``DISPLAY_SCALE * USER_SIZE_SCALE`` — one number multiplies width, height,+ padding and window alike, so the bar's SHAPE is preserved and only its+ SIZE changes. The live "Bar size" slider re-invokes this with the same+ screen scale and a new ``user_size`` (surfaces call it via+ ``set_size_scale``)."""- global DISPLAY_SCALE, COLLAPSED_W, COLLAPSED_H, OPEN_W, OPEN_H+ global DISPLAY_SCALE, USER_SIZE_SCALE, COLLAPSED_W, COLLAPSED_H, OPEN_W, OPEN_Hglobal ACTIVE_W, ACTIVE_H, _BOTTOM_PAD, WIN_W, WIN_HDISPLAY_SCALE = s = max(MIN_DISPLAY_SCALE, min(1.0, float(scale)))- COLLAPSED_W = round(168 * _SW * _IDLE_W * s) # standby pill (slightly longer)- COLLAPSED_H = round(30 * _SH * _IDLE_H * s) # standby pill (slim)- OPEN_W = round(284 * _SW * s) # hover/controls pill (the former "expanded")- OPEN_H = round(52 * _SH * s)+ if user_size is not None:+ USER_SIZE_SCALE = clamp_user_size(user_size)+ g = s * USER_SIZE_SCALE # effective geometry factor (screen × user size)+ COLLAPSED_W = round(168 * _SW * _IDLE_W * g) # standby pill (slightly longer)+ COLLAPSED_H = round(30 * _SH * _IDLE_H * g) # standby pill (slim)+ OPEN_W = round(284 * _SW * g) # hover/controls pill (the former "expanded")+ OPEN_H = round(52 * _SH * g)ACTIVE_W = round(2 * OPEN_W * (1.0 - 2 * _ACTIVE_SIDE_TRIM)) # 2x * 0.518ACTIVE_H = round(2 * OPEN_H * (1.0 - 2 * _ACTIVE_VERT_TRIM)) # 2x * 0.56- _BOTTOM_PAD = max(4, round(_BASE_BOTTOM_PAD * s))+ _BOTTOM_PAD = max(4, round(_BASE_BOTTOM_PAD * g))# The fixed Tk window must contain the largest (ACTIVE) pill + its 2px# outline and the flanking hover controls.WIN_W = ACTIVE_W + 12diff --git a/tests/unit/ui/jarvisbar/test_display_scale.py b/tests/unit/ui/jarvisbar/test_display_scale.pyindex 74274cbd7b..dec4fa34db 100644--- a/tests/unit/ui/jarvisbar/test_display_scale.py+++ b/tests/unit/ui/jarvisbar/test_display_scale.py@@ -23,9 +23,15 @@ from jarvis.ui.jarvisbar import renderer@pytest.fixture(autouse=True)def _restore_scale():- """Every test leaves the module at the default 1.0 geometry."""+ """Every test leaves the module at the default 1.0 geometry.++ Resets BOTH axes — the screen-adaptive scale and the user "Bar size"+ multiplier — so a test that exercises ``user_size`` cannot leak the+ enlarged geometry into the next test (``USER_SIZE_SCALE`` is a separate+ module global that ``apply_display_scale(1.0)`` alone would not reset).+ """yield- renderer.apply_display_scale(1.0)+ renderer.apply_display_scale(1.0, user_size=renderer.USER_SIZE_DEFAULT)# --------------------------------------------------------------------------- #@@ -130,3 +136,71 @@ def test_render_produces_frames_at_the_scaled_window_size():renderer.apply_display_scale(1.0)img = renderer.JarvisBarRenderer().render(0.5, "listen", 0.4)assert img.size == (_HISTORICAL["WIN_W"], _HISTORICAL["WIN_H"])+++# --------------------------------------------------------------------------- #+# user "Bar size" multiplier #+# --------------------------------------------------------------------------- #+def test_default_user_size_reproduces_the_historical_geometry():+ # The user axis defaults to 1.0, so passing it explicitly must still yield+ # the byte-identical signed-off geometry (regression guard: the new second+ # arg must not perturb the default look).+ renderer.apply_display_scale(1.0, user_size=1.0)+ for name, value in _HISTORICAL.items():+ assert getattr(renderer, name) == value, name+++def test_user_size_scales_width_and_height_together():+ # The whole geometry multiplies by ONE factor, so the pill's aspect ratio+ # is preserved — exactly "the shape stays, only the size changes".+ renderer.apply_display_scale(1.0, user_size=1.0)+ base_active_w, base_active_h = renderer.ACTIVE_W, renderer.ACTIVE_H+ base_win_w, base_win_h = renderer.WIN_W, renderer.WIN_H++ renderer.apply_display_scale(1.0, user_size=2.0)+ # Both axes grow, and grow by (about) the same factor.+ assert renderer.ACTIVE_W > base_active_w+ assert renderer.ACTIVE_H > base_active_h+ assert renderer.WIN_W > base_win_w+ assert renderer.WIN_H > base_win_h+ wr = renderer.ACTIVE_W / base_active_w+ hr = renderer.ACTIVE_H / base_active_h+ assert abs(wr - 2.0) < 0.06 # ~2x, allowing integer rounding at small px+ assert abs(hr - 2.0) < 0.12+ assert abs(wr - hr) < 0.15 # shape preserved: width ratio ≈ height ratio+++def test_user_size_below_one_shrinks_the_bar():+ renderer.apply_display_scale(1.0, user_size=1.0)+ base_win_w = renderer.WIN_W+ renderer.apply_display_scale(1.0, user_size=0.5)+ assert renderer.WIN_W < base_win_w+++def test_user_size_none_keeps_the_current_multiplier():+ # A screen-scale-only call (user_size omitted) must not reset the user's+ # chosen size — the two axes are independent.+ renderer.apply_display_scale(1.0, user_size=2.0)+ big_win_w = renderer.WIN_W+ renderer.apply_display_scale(1.0) # screen scale only, user size untouched+ assert renderer.WIN_W == big_win_w+ assert renderer.USER_SIZE_SCALE == 2.0+++def test_user_size_clamps_to_the_supported_range():+ assert renderer.clamp_user_size(99.0) == renderer.USER_SIZE_MAX+ assert renderer.clamp_user_size(0.01) == renderer.USER_SIZE_MIN+ assert renderer.clamp_user_size(1.25) == 1.25+ # Corrupt persisted values degrade to the default instead of bricking.+ assert renderer.clamp_user_size(float("nan")) == renderer.USER_SIZE_DEFAULT+ assert renderer.clamp_user_size("oops") == renderer.USER_SIZE_DEFAULT # type: ignore[arg-type]+ # apply_display_scale folds the clamp in, so an out-of-range request is safe.+ renderer.apply_display_scale(1.0, user_size=99.0)+ assert renderer.USER_SIZE_SCALE == renderer.USER_SIZE_MAX+++def test_user_size_multiplies_on_top_of_the_screen_scale():+ # The effective factor is screen × user, so a small screen scaled up by the+ # user meets in the middle. 0.6 screen × 1.5 user == 0.9 effective.+ renderer.apply_display_scale(0.6, user_size=1.5)+ assert renderer.OPEN_W == round(68.16 * 0.9)