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.

chore: auto-save WIP via Claude stop-hook safety net (2026-07-01 14:01)

Ruben Lütke2162fe604e1c
diff --git a/jarvis/ui/jarvisbar/overlay.py b/jarvis/ui/jarvisbar/overlay.py
index e0346acd94..e7034d0dca 100644
--- a/jarvis/ui/jarvisbar/overlay.py
+++ b/jarvis/ui/jarvisbar/overlay.py
@@ -277,22 +277,30 @@ class JarvisBarOverlay:
from PIL import ImageTk # noqa: F401 — fail fast here if Pillow missing
- # Per-monitor DPI awareness MUST be set before THIS surface's Tk root is
- # created — exactly like the orb (ui/orb/overlay.py). Without it, on a
- # scaled display (e.g. 150%) the window's geometry coordinate space and
- # the pointer-event space (``event.x_root``) drift apart, so dragging the
- # bar makes it run AWAY from the cursor toward the bottom-right and become
- # uncontrollable (the HiDPI "drag-teleport"). The bar boots in its own
- # thread, often before any other code has set process DPI awareness, so
- # it must assert it here itself. ``ensure_dpi_awareness`` is idempotent
- # and a no-op off Windows, so this is safe even when the process is
- # already aware.
+ # DPI handling — two steps that TOGETHER keep the bar at its normal size
+ # and stop it shrinking/jumping mid-session, WITHOUT changing how it looks:
+ #
+ # 1. Make the PROCESS DPI-aware. The bar boots in its own thread, often
+ # before anything else claims awareness; doing it here means pywebview's
+ # later ``SetProcessDPIAware`` (inside ``webview.start()``) is a no-op
+ # rather than a RUNTIME awareness flip. Idempotent, no-op off Windows.
+ # 2. Pin THIS thread's window to per-window UNAWARE (``_pin_bar_window_``
+ # ``unaware``). With the process aware but the WINDOW explicitly
+ # unaware, Windows bitmap-upscales the small pill to its normal physical
+ # size — the exact look it has always had, renderer untouched — and,
+ # because the window's context differs from the aware process, that
+ # upscaling is PINNED: a later process-wide flip can no longer strip it.
+ # This is the fix for the recurring "bar shrank to ~2/3 and jumped, only
+ # a restart helps" bug. Geometry and pointer events stay in one
+ # virtualized space, so only the user drags it (and it follows the
+ # cursor); it never repositions itself.
try:
from jarvis.core.win32_dpi import ensure_dpi_awareness
ensure_dpi_awareness()
except Exception: # noqa: BLE001 — never block the bar on a DPI hiccup
log.debug("jarvisbar DPI-awareness setup skipped", exc_info=True)
+ _pin_bar_window_unaware()
self._tk_thread_id = threading.get_ident()
self._renderer = renderer.JarvisBarRenderer(accent=self._accent)
diff --git a/tests/unit/ui/jarvisbar/test_dpi_awareness.py b/tests/unit/ui/jarvisbar/test_dpi_awareness.py
index fe5525969a..5b20f79a34 100644
--- a/tests/unit/ui/jarvisbar/test_dpi_awareness.py
+++ b/tests/unit/ui/jarvisbar/test_dpi_awareness.py
@@ -1,16 +1,23 @@
-"""The JarvisBar makes its Tk window per-monitor DPI aware BEFORE creating it.
-
-Regression (HiDPI "drag-teleport"): the bar's Tk root used to be created without
-``ensure_dpi_awareness()`` — the orb sets it (ui/orb/overlay.py), the bar did
-not. On a scaled display (e.g. 150%) the window's geometry coordinate space and
-the pointer-event space then drift apart, so dragging the bar makes it run AWAY
-from the cursor toward the bottom-right and become uncontrollable. The fix
-mirrors the orb: assert DPI awareness in ``start()`` BEFORE ``tk.Tk()``.
+"""The JarvisBar fixes its window DPI handling BEFORE creating the Tk root.
+
+Two ordered steps in ``start()``, both BEFORE ``tk.Tk()``:
+
+1. ``ensure_dpi_awareness()`` makes the PROCESS DPI-aware, so pywebview's later
+ ``SetProcessDPIAware`` (in ``webview.start()``) is a no-op instead of a
+ runtime awareness flip.
+2. ``_pin_bar_window_unaware()`` pins THIS thread's window to per-window
+ UNAWARE, so Windows keeps bitmap-upscaling the small pill to its normal
+ physical size AND that upscaling is pinned against any later flip.
+
+Together they stop the recurring "bar shrank to ~2/3 and jumped mid-session,
+only a restart helps" bug WITHOUT changing how the bar looks. This test locks in
+that both run, in order, before the Tk root exists (a consolidate-revert guard).
"""
from __future__ import annotations
import tkinter
+import jarvis.ui.jarvisbar.overlay as overlay_mod
from jarvis.ui.jarvisbar.overlay import JarvisBarOverlay
@@ -41,13 +48,16 @@ class _FakeCanvas:
def bind(self, *a, **k) -> None: ...
-def test_start_sets_dpi_awareness_before_creating_tk_root(monkeypatch) -> None:
+def test_start_fixes_dpi_before_creating_tk_root(monkeypatch) -> None:
order: list[str] = []
monkeypatch.setattr(
"jarvis.core.win32_dpi.ensure_dpi_awareness",
lambda: order.append("dpi"),
)
+ monkeypatch.setattr(
+ overlay_mod, "_pin_bar_window_unaware", lambda: order.append("pin")
+ )
def _fake_tk(*_a, **_k) -> _FakeTkRoot:
order.append("tk")
@@ -65,9 +75,12 @@ def test_start_sets_dpi_awareness_before_creating_tk_root(monkeypatch) -> None:
bar.start()
- assert "dpi" in order, "start() must set DPI awareness"
+ assert "dpi" in order, "start() must make the process DPI-aware"
+ assert "pin" in order, "start() must pin the bar window UNAWARE (anti-shrink)"
assert "tk" in order, "start() must create the Tk root"
- assert order.index("dpi") < order.index("tk"), (
- "DPI awareness must be set BEFORE the Tk root is created "
- "(HiDPI drag-teleport fix)"
+ # process-aware THEN window-unaware-pin THEN the Tk window: the pin only holds
+ # because the process is already aware, and both must precede tk.Tk().
+ assert order.index("dpi") < order.index("pin") < order.index("tk"), (
+ "order must be ensure_dpi_awareness → pin-unaware → tk.Tk() "
+ "(the bar-shrink/jump fix)"
)