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.

fix(macos): follow live Dock geometry

Ruben Lütkef8cf74a8976e
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ef9b9b8896..9adb94db8d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,13 @@ versioning per [SemVer](https://semver.org/lang/de/).
### Fixed
+- **macOS: the Jarvis Bar now follows the Dock's real visibility instead of an
+ invisible work-area boundary.** Fullscreen Spaces can hide the Dock while Qt
+ continues to reserve its 57-pixel strip, which prevented the bar from being
+ dragged to the true bottom of the app. The bar now uses the complete screen
+ edge while the Dock is hidden, retreats above it when it returns, and restores
+ the user's preferred position when it hides again. Menu-bar and multi-display
+ safe areas remain respected (BUG-094).
- **macOS: the Jarvis Bar is transparent and animation frames no longer pile
up.** Aqua-Tk 9 kept an opaque black Canvas backing and composited every new
RGBA frame over the old one, producing a rectangle at rest and concentric
diff --git a/docs/BUGS.md b/docs/BUGS.md
index 9d3701692d..4302554ff9 100644
--- a/docs/BUGS.md
+++ b/docs/BUGS.md
@@ -6489,3 +6489,46 @@ region to the visible content. An always-on-top helper must also prove that its
periodic ordering operation does not activate the helper application. Keep
compositor workarounds behind a platform backend instead of changing a
rendering path already proven on another OS.
+
+---
+
+## BUG-094: macOS Jarvis Bar cannot enter a hidden Dock strip and stays stranded when the Dock changes state (MEDIUM, FIXED 2026-07-19)
+
+**Symptom (physical-Mac field report).** With the Dock visible, keeping the bar
+above it is correct. After an app enters a fullscreen Space and macOS hides the
+Dock, however, dragging still stops at the old work-area boundary. The blocked
+strip is invisible but remains as tall as the Dock. A bar placed near the real
+screen edge also needs to retreat automatically when the Dock returns rather
+than being covered by it.
+
+**Root cause.** The Qt surface used `QScreen.availableGeometry()` for startup,
+saved-position recovery, and drag release. On the affected `1440x900` Intel Mac,
+Qt reported `(0, 25, 1440, 818)` even while the Dock was absent from Quartz's
+on-screen window catalogue. The resulting 57-pixel bottom reservation was
+therefore stale presentation state, not a real obstacle. The surface also held
+only one position, so temporarily clamping it for a returning Dock would have
+destroyed the user's lower fullscreen preference.
+
+**Fix.** The Darwin Qt backend now compares the complete and available screen
+rectangles, infers the reserved Dock edge (bottom, left, or right), and checks
+the live on-screen Dock window through the optional Quartz capability. A hidden
+Dock restores only its reserved edge; the menu-bar inset is deliberately kept.
+Missing Quartz remains fail-safe and uses Qt's conservative work area. The bar
+stores the user's preferred position separately from its current safe position.
+Its existing 500 ms ordering guard also reconciles geometry: a visible Dock
+moves the bar clear without rewriting the preference, and a hidden Dock restores
+that preference. Reconciliation pauses during an active drag. Windows and Linux
+retain their existing available-work-area behavior.
+
+**Guards.** Pure geometry tests cover bottom, left, and right Dock reservations;
+a Quartz catalogue double proves visibility is scoped to the target display;
+and surface regressions prove visible-Dock retreat, hidden-Dock restoration,
+preferred-position persistence, and drag stability. The physical Mac trace
+confirmed both native states: no on-screen Dock window while hidden, followed by
+an on-screen layer-20 Dock window spanning the target display when revealed.
+
+**Class rule.** A desktop work area is policy, not necessarily current visual
+occupancy. For overlays that may enter fullscreen content, keep user intent
+separate from temporary collision avoidance, preserve unrelated safe-area edges,
+and detect the obstacle's live presentation state through a capability-gated
+native probe. Never persist a transient clamp as the user's new preference.
diff --git a/jarvis/ui/jarvisbar/qt_overlay.py b/jarvis/ui/jarvisbar/qt_overlay.py
index 60acbff357..e351c9c417 100644
--- a/jarvis/ui/jarvisbar/qt_overlay.py
+++ b/jarvis/ui/jarvisbar/qt_overlay.py
@@ -53,6 +53,8 @@ _IDLE_SETTLE_TICKS = 30
_QT: SimpleNamespace | None = None
+GeometryBounds = tuple[int, int, int, int]
+
def _prepare_macos_qt_process() -> None:
"""Keep the companion from becoming macOS' foreground application.
@@ -67,6 +69,109 @@ def _prepare_macos_qt_process() -> None:
os.environ["QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM"] = "1"
+def _geometry_bounds(geometry: Any) -> GeometryBounds:
+ """Return one Qt-like rectangle as ``(x, y, width, height)``."""
+ return (
+ int(geometry.x()),
+ int(geometry.y()),
+ int(geometry.width()),
+ int(geometry.height()),
+ )
+
+
+def _dock_reserved_edge(
+ full: GeometryBounds,
+ available: GeometryBounds,
+) -> str | None:
+ """Infer which non-menu edge macOS reserved for the Dock."""
+ full_x, full_y, full_w, full_h = full
+ avail_x, _avail_y, avail_w, avail_h = available
+ gaps = {
+ "left": max(0, avail_x - full_x),
+ "right": max(0, full_x + full_w - (avail_x + avail_w)),
+ "bottom": max(0, full_y + full_h - (_avail_y + avail_h)),
+ }
+ edge, gap = max(gaps.items(), key=lambda item: item[1])
+ return edge if gap else None
+
+
+def _expand_geometry_for_hidden_dock(
+ full: GeometryBounds,
+ available: GeometryBounds,
+) -> GeometryBounds:
+ """Restore only the hidden Dock edge while preserving the menu-bar inset."""
+ full_x, full_y, full_w, full_h = full
+ avail_x, avail_y, avail_w, avail_h = available
+ edge = _dock_reserved_edge(full, available)
+ if edge == "left":
+ return full_x, avail_y, max(0, avail_x + avail_w - full_x), avail_h
+ if edge == "right":
+ return avail_x, avail_y, max(0, full_x + full_w - avail_x), avail_h
+ if edge == "bottom":
+ return avail_x, avail_y, avail_w, max(0, full_y + full_h - avail_y)
+ return available
+
+
+def _rectangles_overlap(first: GeometryBounds, second: GeometryBounds) -> bool:
+ first_x, first_y, first_w, first_h = first
+ second_x, second_y, second_w, second_h = second
+ return (
+ first_w > 0
+ and first_h > 0
+ and second_w > 0
+ and second_h > 0
+ and first_x < second_x + second_w
+ and second_x < first_x + first_w
+ and first_y < second_y + second_h
+ and second_y < first_y + first_h
+ )
+
+
+def _macos_dock_is_visible_on_screen(screen: GeometryBounds) -> bool | None:
+ """Return whether Quartz currently exposes a visible Dock on ``screen``.
+
+ ``QScreen.availableGeometry()`` keeps reserving the Dock strip while a
+ fullscreen Space hides it. Quartz's on-screen window catalogue reflects
+ the actual presentation state. ``None`` is deliberately fail-safe: if the
+ optional native framework or query is unavailable, callers retain Qt's
+ conservative available geometry.
+ """
+ if sys.platform != "darwin":
+ return None
+ try:
+ import Quartz # type: ignore[import-not-found] # noqa: PLC0415
+
+ options = (
+ Quartz.kCGWindowListOptionOnScreenOnly
+ | Quartz.kCGWindowListExcludeDesktopElements
+ )
+ windows = Quartz.CGWindowListCopyWindowInfo(
+ options,
+ Quartz.kCGNullWindowID,
+ )
+ except Exception: # noqa: BLE001 - optional native capability
+ return None
+
+ for window in windows or ():
+ if str(window.get("kCGWindowOwnerName") or "") != "Dock":
+ continue
+ try:
+ if float(window.get("kCGWindowAlpha", 1.0) or 0.0) <= 0.0:
+ continue
+ bounds = window.get("kCGWindowBounds") or {}
+ dock_bounds = (
+ int(bounds.get("X", 0)),
+ int(bounds.get("Y", 0)),
+ int(bounds.get("Width", 0)),
+ int(bounds.get("Height", 0)),
+ )
+ except (AttributeError, TypeError, ValueError):
+ continue
+ if _rectangles_overlap(screen, dock_bounds):
+ return True
+ return False
+
+
def _qt() -> SimpleNamespace:
"""Return the lazily imported Qt modules.
@@ -262,6 +367,10 @@ class QtJarvisBarOverlay:
self._native_window: Any = None
self._x = 0
self._y = 0
+ # Keep the user's requested location separate from the temporary safe
+ # location. When a hidden Dock returns, the bar retreats above it; when
+ # the Dock hides again, the requested location is restored automatically.
+ self._preferred_position: tuple[int, int] | None = None
self._drag: dict[str, Any] | None = None
self._on_mute_toggle: Callable[[], None] | None = None
@@ -533,6 +642,7 @@ class QtJarvisBarOverlay:
def _do_show_ui(self) -> None:
if self._window is None or self._startup_gated:
return
+ self._reconcile_dynamic_position_ui()
self._invalidate_static_frame()
self._render_frame_ui()
self._window.show()
@@ -558,6 +668,7 @@ class QtJarvisBarOverlay:
def _z_order_guard_ui(self) -> None:
if self._desired_visible:
+ self._reconcile_dynamic_position_ui()
self._raise_ui()
def _configure_macos_nonactivating_window_ui(self) -> None:
@@ -628,14 +739,51 @@ class QtJarvisBarOverlay:
# ------------------------------------------------------------------
# Position, drag, and gestures
# ------------------------------------------------------------------
- def _primary_available_geometry_ui(self) -> Any:
+ def _geometry_for_screen_ui(
+ self,
+ screen: Any,
+ *,
+ respect_visible_dock: bool = True,
+ ) -> Any:
+ if screen is None:
+ return None
+ available = screen.availableGeometry()
+ if sys.platform != "darwin":
+ return available
+
+ full = screen.geometry()
+ full_bounds = _geometry_bounds(full)
+ available_bounds = _geometry_bounds(available)
+ dock_visible = (
+ _macos_dock_is_visible_on_screen(full_bounds)
+ if respect_visible_dock
+ else False
+ )
+ if dock_visible is not False:
+ return available
+ expanded = _expand_geometry_for_hidden_dock(full_bounds, available_bounds)
+ if expanded == available_bounds:
+ return available
+ q = _qt()
+ return q.QtCore.QRect(*expanded)
+
+ def _primary_geometry_ui(self, *, respect_visible_dock: bool = True) -> Any:
app = self._app
if app is None:
return None
screen = app.primaryScreen()
- return screen.availableGeometry() if screen is not None else None
+ return self._geometry_for_screen_ui(
+ screen,
+ respect_visible_dock=respect_visible_dock,
+ )
- def _screen_geometry_for_point_ui(self, x: int, y: int) -> Any:
+ def _screen_geometry_for_point_ui(
+ self,
+ x: int,
+ y: int,
+ *,
+ respect_visible_dock: bool = True,
+ ) -> Any:
q = _qt()
app = self._app
if app is None:
@@ -643,7 +791,10 @@ class QtJarvisBarOverlay:
screen = app.screenAt(q.QtCore.QPoint(int(x), int(y)))
if screen is None:
screen = app.primaryScreen()
- return screen.availableGeometry() if screen is not None else None
+ return self._geometry_for_screen_ui(
+ screen,
+ respect_visible_dock=respect_visible_dock,
+ )
def _clamp_to_geometry_ui(self, x: int, y: int, geometry: Any) -> tuple[int, int]:
if geometry is None:
@@ -660,7 +811,9 @@ class QtJarvisBarOverlay:
return local_x + geometry.x(), local_y + geometry.y()
def _default_position_ui(self) -> tuple[int, int]:
- geometry = self._primary_available_geometry_ui()
+ # The preferred location may occupy a currently hidden Dock strip.
+ # The visible position is reconciled against the live safe area below.
+ geometry = self._primary_geometry_ui(respect_visible_dock=False)
if geometry is None:
return interaction.default_bottom_center(
screen_w=1920,
@@ -682,13 +835,36 @@ class QtJarvisBarOverlay:
except Exception: # noqa: BLE001 - placement degrades to the default
log.debug("Qt Jarvis Bar position load failed", exc_info=True)
if position is None:
- self._x, self._y = self._default_position_ui()
- return
- geometry = self._screen_geometry_for_point_ui(
+ position = self._default_position_ui()
+ preferred_geometry = self._screen_geometry_for_point_ui(
position[0] + renderer.WIN_W // 2,
position[1] + renderer.WIN_H // 2,
+ respect_visible_dock=False,
+ )
+ self._preferred_position = self._clamp_to_geometry_ui(
+ position[0],
+ position[1],
+ preferred_geometry,
+ )
+ self._x, self._y = self._preferred_position
+ self._reconcile_dynamic_position_ui()
+
+ def _reconcile_dynamic_position_ui(self) -> bool:
+ """Move between preferred and Dock-safe positions without rewriting config."""
+ if self._drag is not None:
+ return False
+ preferred = self._preferred_position or (self._x, self._y)
+ geometry = self._screen_geometry_for_point_ui(
+ preferred[0] + renderer.WIN_W // 2,
+ preferred[1] + renderer.WIN_H // 2,
)
- self._x, self._y = self._clamp_to_geometry_ui(position[0], position[1], geometry)
+ target = self._clamp_to_geometry_ui(preferred[0], preferred[1], geometry)
+ if target == (self._x, self._y):
+ return False
+ self._x, self._y = target
+ if self._window is not None:
+ self._window.move(self._x, self._y)
+ return True
def _mouse_press_ui(self, event: Any) -> bool:
q = _qt()
@@ -744,13 +920,17 @@ class QtJarvisBarOverlay:
self._dispatch_click_ui(float(event.position().x()), hovered=True)
return True
- geometry = self._screen_geometry_for_point_ui(
+ preferred_geometry = self._screen_geometry_for_point_ui(
self._x + renderer.WIN_W // 2,
self._y + renderer.WIN_H // 2,
+ respect_visible_dock=False,
)
- self._x, self._y = self._clamp_to_geometry_ui(self._x, self._y, geometry)
- if self._window is not None:
- self._window.move(self._x, self._y)
+ self._preferred_position = self._clamp_to_geometry_ui(
+ self._x,
+ self._y,
+ preferred_geometry,
+ )
+ self._reconcile_dynamic_position_ui()
self._persist_position_ui()
return True
@@ -803,7 +983,12 @@ class QtJarvisBarOverlay:
try:
from jarvis.core.config_writer import DEFAULT_CONFIG_FILE # noqa: PLC0415
- interaction.save_jarvisbar_position(DEFAULT_CONFIG_FILE, self._x, self._y)
+ position = self._preferred_position or (self._x, self._y)
+ interaction.save_jarvisbar_position(
+ DEFAULT_CONFIG_FILE,
+ position[0],
+ position[1],
+ )
except Exception: # noqa: BLE001 - position persistence is non-critical
log.debug("Qt Jarvis Bar position save failed", exc_info=True)
@@ -814,15 +999,18 @@ class QtJarvisBarOverlay:
self._ui_queue.put(self._reset_position_ui)
def _reset_position_ui(self) -> None:
- self._x, self._y = self._default_position_ui()
- if self._window is not None:
- self._window.move(self._x, self._y)
+ self._preferred_position = self._default_position_ui()
+ self._x, self._y = self._preferred_position
+ self._reconcile_dynamic_position_ui()
self._persist_position_ui()
__all__ = [
"QtJarvisBarOverlay",
+ "_dock_reserved_edge",
+ "_expand_geometry_for_hidden_dock",
"_input_mask_from_frame",
+ "_macos_dock_is_visible_on_screen",
"_paint_transparent_frame",
"_prepare_macos_qt_process",
"_qimage_from_pil",
diff --git a/tests/unit/ui/jarvisbar/test_qt_overlay.py b/tests/unit/ui/jarvisbar/test_qt_overlay.py
index 9def2054c6..9f3e2d517d 100644
--- a/tests/unit/ui/jarvisbar/test_qt_overlay.py
+++ b/tests/unit/ui/jarvisbar/test_qt_overlay.py
@@ -3,6 +3,7 @@
from __future__ import annotations
import sys
+from types import SimpleNamespace
from typing import Any
import pytest
@@ -11,6 +12,25 @@ from PIL import Image, ImageDraw
from jarvis.ui.jarvisbar import qt_overlay, renderer
+class _Rect:
+ """Small QRect-compatible test double."""
+
+ def __init__(self, x: int, y: int, width: int, height: int) -> None:
+ self._values = (x, y, width, height)
+
+ def x(self) -> int:
+ return self._values[0]
+
+ def y(self) -> int:
+ return self._values[1]
+
+ def width(self) -> int:
+ return self._values[2]
+
+ def height(self) -> int:
+ return self._values[3]
+
+
def test_surface_state_is_safe_before_qt_is_started(
monkeypatch: pytest.MonkeyPatch,
) -> None:
@@ -49,6 +69,200 @@ def test_macos_qt_process_disables_foreground_activation(
assert qt_overlay.os.environ["QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM"] == "1"
+def test_hidden_bottom_dock_restores_only_the_dock_strip() -> None:
+ full = (0, 0, 1440, 900)
+ available = (0, 25, 1440, 818)
+
+ assert qt_overlay._dock_reserved_edge(full, available) == "bottom" # noqa: SLF001
+ assert qt_overlay._expand_geometry_for_hidden_dock( # noqa: SLF001
+ full,
+ available,
+ ) == (0, 25, 1440, 875)
+
+
+ ("available", "edge", "expanded"),
+ [
+ ((60, 25, 1380, 875), "left", (0, 25, 1440, 875)),
+ ((0, 25, 1380, 875), "right", (0, 25, 1440, 875)),
+ ],
+)
+def test_hidden_side_dock_restores_only_its_reserved_edge(
+ available: tuple[int, int, int, int],
+ edge: str,
+ expanded: tuple[int, int, int, int],
+) -> None:
+ full = (0, 0, 1440, 900)
+
+ assert qt_overlay._dock_reserved_edge(full, available) == edge # noqa: SLF001
+ assert qt_overlay._expand_geometry_for_hidden_dock( # noqa: SLF001
+ full,
+ available,
+ ) == expanded
+
+
+def test_macos_dock_visibility_uses_onscreen_windows_on_the_target_display(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ dock_window = {
+ "kCGWindowOwnerName": "Dock",
+ "kCGWindowAlpha": 1.0,
+ "kCGWindowBounds": {"X": 1440, "Y": 0, "Width": 1920, "Height": 1080},
+ }
+ quartz = SimpleNamespace(
+ kCGWindowListOptionOnScreenOnly=1,
+ kCGWindowListExcludeDesktopElements=2,
+ kCGNullWindowID=0,
+ CGWindowListCopyWindowInfo=lambda _options, _window_id: [dock_window],
+ )
+ monkeypatch.setattr(qt_overlay.sys, "platform", "darwin")
+ monkeypatch.setitem(sys.modules, "Quartz", quartz)
+
+ assert qt_overlay._macos_dock_is_visible_on_screen((0, 0, 1440, 900)) is False # noqa: SLF001
+ assert qt_overlay._macos_dock_is_visible_on_screen((1440, 0, 1920, 1080)) is True # noqa: SLF001
+
+
+def test_macos_geometry_expands_only_while_dock_is_hidden(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ class _Screen:
+ @staticmethod
+ def geometry() -> _Rect:
+ return _Rect(0, 0, 1440, 900)
+
+ @staticmethod
+ def availableGeometry() -> _Rect: # noqa: N802 - Qt-compatible double
+ return _Rect(0, 25, 1440, 818)
+
+ monkeypatch.setattr(qt_overlay.sys, "platform", "darwin")
+ monkeypatch.setattr(
+ qt_overlay,
+ "_qt",
+ lambda: SimpleNamespace(QtCore=SimpleNamespace(QRect=_Rect)),
+ )
+ surface = qt_overlay.QtJarvisBarOverlay()
+
+ for probe_result in (True, None):
+ monkeypatch.setattr(
+ qt_overlay,
+ "_macos_dock_is_visible_on_screen",
+ lambda _screen, result=probe_result: result,
+ )
+ visible_or_unknown = surface._geometry_for_screen_ui(_Screen()) # noqa: SLF001
+ assert qt_overlay._geometry_bounds(visible_or_unknown) == ( # noqa: SLF001
+ 0,
+ 25,
+ 1440,
+ 818,
+ )
+
+ monkeypatch.setattr(qt_overlay, "_macos_dock_is_visible_on_screen", lambda _screen: False)
+ hidden = surface._geometry_for_screen_ui(_Screen()) # noqa: SLF001
+ assert qt_overlay._geometry_bounds(hidden) == (0, 25, 1440, 875) # noqa: SLF001
+
+
+def test_non_macos_geometry_keeps_the_existing_available_area(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ class _Screen:
+ @staticmethod
+ def geometry() -> _Rect:
+ raise AssertionError("non-macOS placement must not inspect full geometry")
+
+ @staticmethod
+ def availableGeometry() -> _Rect: # noqa: N802 - Qt-compatible double
+ return _Rect(10, 20, 1280, 700)
+
+ monkeypatch.setattr(qt_overlay.sys, "platform", "linux")
+ monkeypatch.setattr(
+ qt_overlay,
+ "_macos_dock_is_visible_on_screen",
+ lambda _screen: (_ for _ in ()).throw(
+ AssertionError("non-macOS placement must not probe Quartz")
+ ),
+ )
+ surface = qt_overlay.QtJarvisBarOverlay()
+
+ geometry = surface._geometry_for_screen_ui(_Screen()) # noqa: SLF001
+
+ assert qt_overlay._geometry_bounds(geometry) == (10, 20, 1280, 700) # noqa: SLF001
+
+
+def test_dynamic_position_retreats_for_dock_and_restores_user_preference(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ class _Window:
+ def __init__(self) -> None:
+ self.moves: list[tuple[int, int]] = []
+
+ def move(self, x: int, y: int) -> None:
+ self.moves.append((x, y))
+
+ safe = _Rect(0, 25, 1440, 818)
+ expanded = _Rect(0, 25, 1440, 875)
+ preferred = (600, expanded.y() + expanded.height() - renderer.WIN_H - qt_overlay.MARGIN_PX)
+ safe_position = (
+ preferred[0],
+ safe.y() + safe.height() - renderer.WIN_H - qt_overlay.MARGIN_PX,
+ )
+ active_geometry = [safe]
+ window = _Window()
+ surface = qt_overlay.QtJarvisBarOverlay()
+ surface._window = window # type: ignore[assignment] # noqa: SLF001
+ surface._preferred_position = preferred # noqa: SLF001
+ surface._x, surface._y = preferred # noqa: SLF001
+ monkeypatch.setattr(
+ surface,
+ "_screen_geometry_for_point_ui",
+ lambda _x, _y, **_kwargs: active_geometry[0],
+ )
+
+ assert surface._reconcile_dynamic_position_ui() is True # noqa: SLF001
+ assert (surface._x, surface._y) == safe_position # noqa: SLF001
+ assert surface._preferred_position == preferred # noqa: SLF001
+
+ active_geometry[0] = expanded
+ assert surface._reconcile_dynamic_position_ui() is True # noqa: SLF001
+ assert (surface._x, surface._y) == preferred # noqa: SLF001
+ assert window.moves == [safe_position, preferred]
+
+
+def test_dynamic_position_does_not_move_during_drag(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ surface = qt_overlay.QtJarvisBarOverlay()
+ surface._preferred_position = (600, 850) # noqa: SLF001
+ surface._x, surface._y = 600, 794 # noqa: SLF001
+ surface._drag = {"moved": True} # noqa: SLF001
+ monkeypatch.setattr(
+ surface,
+ "_screen_geometry_for_point_ui",
+ lambda *_args, **_kwargs: (_ for _ in ()).throw(
+ AssertionError("screen geometry must not change an active drag")
+ ),
+ )
+
+ assert surface._reconcile_dynamic_position_ui() is False # noqa: SLF001
+
+
+def test_position_persistence_keeps_preferred_location_when_dock_is_visible(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ saved: list[tuple[int, int]] = []
+ surface = qt_overlay.QtJarvisBarOverlay()
+ surface._preferred_position = (600, 851) # noqa: SLF001
+ surface._x, surface._y = 600, 794 # noqa: SLF001
+ monkeypatch.setattr(
+ qt_overlay.interaction,
+ "save_jarvisbar_position",
+ lambda _path, x, y: saved.append((x, y)),
+ )
+
+ surface._persist_position_ui() # noqa: SLF001
+
+ assert saved == [(600, 851)]
+
+
def test_macos_z_order_uses_native_nonactivating_raise(
monkeypatch: pytest.MonkeyPatch,
) -> None: