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.

revert(jarvisbar): physical-mm sizing made the bar too small — back to screen-relative

Ruben Lütke9a287f510081
diff --git a/jarvis/ui/jarvisbar/overlay.py b/jarvis/ui/jarvisbar/overlay.py
index 901c0ffa33..d2fae8904d 100644
--- a/jarvis/ui/jarvisbar/overlay.py
+++ b/jarvis/ui/jarvisbar/overlay.py
@@ -600,40 +600,24 @@ class JarvisBarOverlay:
root = _create_hidden_tk_root(tk)
self._root = root
- # Screen-adaptive geometry: keep the bar the same PHYSICAL size on
- # every display. Must run BEFORE the renderer and any window geometry
- # are derived from the module constants. Tk reports the screen's
- # millimetres via winfo_screenmm* — real EDID values on a DPI-aware
- # Windows (GetDeviceCaps HORZSIZE) and on X11/RandR. On macOS aqua-Tk
- # SYNTHESIZES the mm from a fixed 72-dpi assumption, so the physical
- # path must not be fed there (the macOS bar is Qt-hosted anyway, see
- # host.py); the renderer's plausibility gates catch the remaining
- # bogus-EDID cases and fall back to the resolution-relative scale.
+ # Screen-adaptive geometry (screen-relative): shrink the whole bar on
+ # small screens (a 14" laptop) while big monitors keep the approved
+ # 1.0 look. Must run BEFORE the renderer and any window geometry are
+ # derived from the module constants. Tk reports points on macOS and
+ # physical pixels on a DPI-aware Windows/X11 — both are the right
+ # basis for "how much of this screen would the bar occupy".
try:
- physical_w_mm: float | None = None
- physical_h_mm: float | None = None
- if sys.platform != "darwin":
- try:
- physical_w_mm = float(root.winfo_screenmmwidth())
- physical_h_mm = float(root.winfo_screenmmheight())
- except Exception: # noqa: BLE001 — mm probe is best-effort
- log.debug("Tk screen-mm probe failed", exc_info=True)
renderer.apply_display_scale(
- renderer.resolve_display_scale(
- int(root.winfo_screenwidth()),
- int(root.winfo_screenheight()),
- physical_w_mm,
- physical_h_mm,
+ renderer.compute_display_scale(
+ int(root.winfo_screenwidth()), int(root.winfo_screenheight())
)
)
if renderer.DISPLAY_SCALE != 1.0:
log.info(
- "jarvisbar display scale %.3f for screen %sx%s px / %sx%s mm",
+ "jarvisbar display scale %.3f for screen %sx%s",
renderer.DISPLAY_SCALE,
root.winfo_screenwidth(),
root.winfo_screenheight(),
- physical_w_mm,
- physical_h_mm,
)
except Exception: # noqa: BLE001 — sizing is cosmetic; 1.0 is the degrade
log.debug("jarvisbar display-scale probe failed", exc_info=True)
diff --git a/jarvis/ui/jarvisbar/qt_overlay.py b/jarvis/ui/jarvisbar/qt_overlay.py
index b49ef30eb3..b8dc6a84dc 100644
--- a/jarvis/ui/jarvisbar/qt_overlay.py
+++ b/jarvis/ui/jarvisbar/qt_overlay.py
@@ -551,34 +551,9 @@ class QtJarvisBarOverlay:
screen = app.primaryScreen()
if screen is not None:
geometry = screen.geometry()
- # Constant-physical-size bar: QScreen.physicalSize() is real
- # millimetres from the OS display info; renderer plausibility
- # gates fall back to the resolution-relative scale on bogus data.
- physical_w_mm: float | None = None
- physical_h_mm: float | None = None
- try:
- physical = screen.physicalSize()
- physical_w_mm = float(physical.width())
- physical_h_mm = float(physical.height())
- except Exception: # noqa: BLE001 — sizing is cosmetic, never block
- log.debug("QScreen physicalSize probe failed", exc_info=True)
renderer.apply_display_scale(
- renderer.resolve_display_scale(
- geometry.width(),
- geometry.height(),
- physical_w_mm,
- physical_h_mm,
- )
+ renderer.compute_display_scale(geometry.width(), geometry.height())
)
- if renderer.DISPLAY_SCALE != 1.0:
- log.info(
- "jarvisbar display scale %.3f for screen %sx%s px / %sx%s mm",
- renderer.DISPLAY_SCALE,
- geometry.width(),
- geometry.height(),
- physical_w_mm,
- physical_h_mm,
- )
self._renderer = renderer.JarvisBarRenderer(accent=self._accent)
window_type = _window_class()
diff --git a/jarvis/ui/jarvisbar/renderer.py b/jarvis/ui/jarvisbar/renderer.py
index a08bd3b0de..0caa67ce6b 100644
--- a/jarvis/ui/jarvisbar/renderer.py
+++ b/jarvis/ui/jarvisbar/renderer.py
@@ -63,32 +63,26 @@ _IDLE_H = 0.7 # standby pill is slimmer (less "fat") than the active height
_SW = _SCALE * _W # combined horizontal factor
_SH = _SCALE * _H # combined vertical factor
-# --- screen-adaptive display scale (constant PHYSICAL size) ------------------
+# --- screen-adaptive display scale (screen-relative sizing) ------------------
# The pill sizes below were tuned on a desktop monitor and are RAW pixels
-# (Tk points on macOS). A raw pixel is a different PHYSICAL size on every
-# display (a 24" 1080p monitor's pixel is ~1.4x the millimetres of a Retina
-# laptop point), so any fixed pixel geometry reads "perfect" on the screen it
-# was tuned on and clunky everywhere else. ``DISPLAY_SCALE`` therefore targets
-# a constant MILLIMETRE size: when the host can report the screen's physical
-# dimensions, ``compute_physical_scale`` converts the approved look into the
-# pixel budget that reproduces the same physical bar on THIS display. When the
-# physical size is unknown or implausible (broken EDID, VMs, projectors), the
-# resolution-relative ``compute_display_scale`` remains the fail-closed
-# fallback. Scaling happens at RENDER time — the frame is drawn crisply at
+# (Tk points on macOS). On a small laptop screen (a 14" MacBook is ~1512 Tk
+# points wide) the same fixed size occupies nearly twice the relative width
+# and reads as clunky. ``DISPLAY_SCALE`` adapts the whole geometry to the
+# screen the bar actually lives on: 1.0 (the maintainer-approved look) on
+# anything at least REFERENCE_SCREEN_W x REFERENCE_SCREEN_H, proportionally
+# smaller below that, never under MIN_DISPLAY_SCALE so the controls stay
+# clickable. Scaling happens at RENDER time — the frame is drawn crisply at
# the scaled size. This is NOT the blurry DPI bitmap upscaling that was
# explicitly rejected (see overlay.start()'s DPI notes); the DPI strategy
# there is untouched.
REFERENCE_SCREEN_W = 1920
REFERENCE_SCREEN_H = 1080
MIN_DISPLAY_SCALE = 0.55
-# Physical sizing may legitimately EXCEED 1.0 (a 4K screen at 100% OS scaling
-# has physically tiny pixels and needs more of them for the same millimetres).
-MAX_DISPLAY_SCALE = 2.0
DISPLAY_SCALE = 1.0
def compute_display_scale(screen_w: int, screen_h: int) -> float:
- """Resolution-relative fallback scale (pure, unit-testable).
+ """Scale factor for the screen the bar lives on (pure, unit-testable).
Never enlarges beyond 1.0 (big monitors keep the approved look); shrinks
proportionally on screens smaller than the reference in either axis;
@@ -104,73 +98,6 @@ def compute_display_scale(screen_w: int, screen_h: int) -> float:
return max(MIN_DISPLAY_SCALE, round(s, 3))
-# The approved look was signed off on a 14" MacBook Pro (1512x982 points,
-# 302.4x196.4 mm panel): 0.2 mm per point. ``compute_physical_scale``
-# reproduces exactly that millimetre geometry on every other display. The
-# reference scale is derived from ``compute_display_scale`` so the physical
-# path and the fallback path agree byte-identically on the reference laptop.
-_REFERENCE_PITCH_MM_PER_PX = 302.4 / 1512.0
-_REFERENCE_PHYSICAL_SCALE = compute_display_scale(1512, 982)
-# Plausibility bounds for host-reported physical data. Outside these, the
-# EDID/toolkit value is treated as garbage and the caller falls back to the
-# resolution-relative scale (fail closed, never a wildly wrong bar).
-_PLAUSIBLE_WIDTH_MM = (100.0, 1600.0)
-_PLAUSIBLE_HEIGHT_MM = (60.0, 1000.0)
-_PLAUSIBLE_PITCH_MM = (0.05, 0.45)
-_PLAUSIBLE_ASPECT_DRIFT = 0.25
-
-
-def compute_physical_scale(
- screen_w: int,
- screen_h: int,
- physical_w_mm: float,
- physical_h_mm: float,
-) -> float | None:
- """Scale that keeps the bar the same PHYSICAL (mm) size on this screen.
-
- Returns ``None`` whenever the reported physical dimensions are missing or
- implausible — the caller must then fall back to
- ``compute_display_scale``. Pure and unit-testable.
- """
- try:
- sw, sh = int(screen_w), int(screen_h)
- pw, ph = float(physical_w_mm), float(physical_h_mm)
- except (TypeError, ValueError):
- return None
- if sw <= 0 or sh <= 0:
- return None
- if not (_PLAUSIBLE_WIDTH_MM[0] <= pw <= _PLAUSIBLE_WIDTH_MM[1]):
- return None
- if not (_PLAUSIBLE_HEIGHT_MM[0] <= ph <= _PLAUSIBLE_HEIGHT_MM[1]):
- return None
- pitch = pw / sw
- if not (_PLAUSIBLE_PITCH_MM[0] <= pitch <= _PLAUSIBLE_PITCH_MM[1]):
- return None
- # The mm aspect ratio must roughly match the pixel aspect ratio; a large
- # drift means the toolkit synthesized the mm from a DPI assumption or the
- # EDID is bogus (both real-world failure modes on Tk/X11).
- aspect_px = sw / sh
- aspect_mm = pw / ph
- if abs(aspect_mm / aspect_px - 1.0) > _PLAUSIBLE_ASPECT_DRIFT:
- return None
- s = _REFERENCE_PHYSICAL_SCALE * _REFERENCE_PITCH_MM_PER_PX / pitch
- return max(MIN_DISPLAY_SCALE, min(MAX_DISPLAY_SCALE, round(s, 3)))
-
-
-def resolve_display_scale(
- screen_w: int,
- screen_h: int,
- physical_w_mm: float | None = None,
- physical_h_mm: float | None = None,
-) -> float:
- """One entry point for callers: physical-size scale, else the fallback."""
- if physical_w_mm is not None and physical_h_mm is not None:
- s = compute_physical_scale(screen_w, screen_h, physical_w_mm, physical_h_mm)
- if s is not None:
- return s
- return compute_display_scale(screen_w, screen_h)
-
-
# Three pill sizes (width, height), eased between as the state changes:
# - COLLAPSED: the slim idle standby pill (unchanged).
# - OPEN: the hover pill that reveals the X / dictation-square controls.
@@ -202,7 +129,7 @@ def apply_display_scale(scale: float) -> None:
"""
global DISPLAY_SCALE, COLLAPSED_W, COLLAPSED_H, OPEN_W, OPEN_H
global ACTIVE_W, ACTIVE_H, _BOTTOM_PAD, WIN_W, WIN_H
- DISPLAY_SCALE = s = max(MIN_DISPLAY_SCALE, min(MAX_DISPLAY_SCALE, float(scale)))
+ DISPLAY_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")
diff --git a/tests/unit/ui/jarvisbar/test_display_scale.py b/tests/unit/ui/jarvisbar/test_display_scale.py
index 40cab8400d..5b699f6be8 100644
--- a/tests/unit/ui/jarvisbar/test_display_scale.py
+++ b/tests/unit/ui/jarvisbar/test_display_scale.py
@@ -1,23 +1,15 @@
-"""Screen-adaptive bar geometry (constant physical size across displays).
-
-The bar's pill/window sizes are raw pixels; a raw pixel is a different
-physical size on every display, so a fixed pixel geometry reads "perfect"
-only on the screen it was tuned on (maintainer feedback, 14" MacBook
-2026-07-17; "way too big" on the desktop monitor 2026-07-21).
-``compute_physical_scale`` converts the approved look into the pixel budget
-that reproduces the same MILLIMETRE size on the actual display;
-``compute_display_scale`` stays the resolution-relative fallback for hosts
-with missing/implausible physical data; ``apply_display_scale`` recomputes
-the module geometry. These tests pin four contracts:
+"""Screen-adaptive bar geometry (screen-relative sizing).
+
+The bar's pill/window sizes are raw pixels tuned on a desktop monitor; on a
+small laptop screen the same fixed size reads as clunky (maintainer feedback,
+14" MacBook 2026-07-17). ``compute_display_scale`` derives a screen-relative
+factor and ``apply_display_scale`` recomputes the module geometry. These tests
+pin three contracts:
1. Screens at least as big as the reference keep the EXACT historical look
- under the fallback (scale 1.0 reproduces the old constants
- byte-identically).
+ (scale 1.0 must reproduce the old constants byte-identically).
2. Small screens shrink proportionally, bounded by ``MIN_DISPLAY_SCALE``.
-3. Physical sizing is self-consistent on the reference laptop, shrinks on
- physically-coarse monitors, may exceed 1.0 on physically-fine panels, and
- REFUSES implausible physical data (``None`` → fallback).
-4. The renderer picks up a rescale at instantiation time (no import-time
+3. The renderer picks up a rescale at instantiation time (no import-time
freeze) and renders frames at the recomputed window size.
"""
from __future__ import annotations
@@ -66,78 +58,6 @@ def test_invalid_screen_degrades_to_one():
assert renderer.compute_display_scale(None, None) == 1.0 # type: ignore[arg-type]
-# --------------------------------------------------------------------------- #
-# compute_physical_scale / resolve_display_scale #
-# --------------------------------------------------------------------------- #
-# The reference laptop panel the approved look was signed off on:
-# 14" MacBook Pro, 1512x982 points on a 302.4x196.4 mm panel.
-_REF = (1512, 982, 302.4, 196.4)
-
-
-def test_physical_scale_reproduces_the_approved_look_on_the_reference_laptop():
- s = renderer.compute_physical_scale(*_REF)
- assert s == pytest.approx(renderer.compute_display_scale(1512, 982), abs=0.005)
-
-
-def test_physical_scale_shrinks_on_a_coarse_pixel_desktop_monitor():
- # 24" 1080p (531x299 mm): each pixel is ~1.4x the reference millimetres,
- # so the SAME physical bar needs ~40% fewer pixels — this is the exact
- # "way too big on my monitor" complaint.
- s = renderer.compute_physical_scale(1920, 1080, 531.0, 299.0)
- assert s is not None
- assert s < 0.65
- ref = renderer.compute_physical_scale(*_REF)
- assert ref is not None
- # Same physical width on both screens (pixels x mm-per-pixel).
- assert s * (531.0 / 1920) == pytest.approx(ref * (302.4 / 1512), rel=0.02)
-
-
-def test_physical_scale_may_exceed_one_on_fine_pixel_panels():
- # 27" 4K at 100% OS scaling (596x335 mm): physically tiny pixels need
- # MORE of them for the same millimetres — legal above 1.0 now.
- s = renderer.compute_physical_scale(3840, 2160, 596.0, 335.0)
- assert s is not None
- assert 1.0 < s <= renderer.MAX_DISPLAY_SCALE
-
-
-def test_physical_scale_rejects_implausible_data():
- assert renderer.compute_physical_scale(1920, 1080, 0.0, 0.0) is None
- assert renderer.compute_physical_scale(1920, 1080, -531.0, 299.0) is None
- # Toy values (a projector/VM EDID lying about a 5 cm panel).
- assert renderer.compute_physical_scale(1920, 1080, 50.0, 30.0) is None
- # Wall-sized values.
- assert renderer.compute_physical_scale(1920, 1080, 3000.0, 1700.0) is None
- # mm aspect wildly off the pixel aspect → synthesized/bogus data.
- assert renderer.compute_physical_scale(1920, 1080, 531.0, 531.0) is None
- assert renderer.compute_physical_scale(0, 0, 531.0, 299.0) is None
- assert (
- renderer.compute_physical_scale(1920, 1080, "x", "y") # type: ignore[arg-type]
- is None
- )
-
-
-def test_physical_scale_clamps_to_the_floor_and_ceiling():
- # Enormous physical pixels (32"-class 1080p): clamps at the floor.
- assert (
- renderer.compute_physical_scale(1920, 1080, 708.0, 398.0)
- == renderer.MIN_DISPLAY_SCALE
- )
-
-
-def test_resolve_prefers_physical_and_falls_back_cleanly():
- # Plausible mm → the physical result.
- assert renderer.resolve_display_scale(*_REF) == renderer.compute_physical_scale(
- *_REF
- )
- # Missing or implausible mm → the resolution-relative fallback.
- assert renderer.resolve_display_scale(1512, 982) == renderer.compute_display_scale(
- 1512, 982
- )
- assert renderer.resolve_display_scale(
- 1512, 982, 50.0, 30.0
- ) == renderer.compute_display_scale(1512, 982)
-
-
# --------------------------------------------------------------------------- #
# apply_display_scale #
# --------------------------------------------------------------------------- #
@@ -175,19 +95,11 @@ def test_scale_recomputes_geometry_and_restores_cleanly():
assert getattr(renderer, name) == value, name
-def test_scale_clamps_to_ceiling_and_floor():
- # Physical sizing may legitimately exceed 1.0 (fine-pixel panels), but
- # never the ceiling; the floor keeps the controls clickable.
+def test_scale_never_enlarges_and_never_undershoots_the_floor():
renderer.apply_display_scale(1.4)
- assert renderer.DISPLAY_SCALE == 1.4
- renderer.apply_display_scale(3.0)
- assert renderer.DISPLAY_SCALE == renderer.MAX_DISPLAY_SCALE
+ assert renderer.DISPLAY_SCALE == 1.0
renderer.apply_display_scale(0.1)
assert renderer.DISPLAY_SCALE == renderer.MIN_DISPLAY_SCALE
- # An enlarged geometry still contains its biggest pill.
- renderer.apply_display_scale(1.4)
- assert renderer.WIN_W > renderer.ACTIVE_W
- assert renderer.WIN_H > renderer.ACTIVE_H
# --------------------------------------------------------------------------- #