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): restore Jarvis Bar hover states

Ruben Lütke765c6c0eab9b
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9adb94db8d..70c15352db 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,14 @@ versioning per [SemVer](https://semver.org/lang/de/).
### Fixed
+- **macOS: Jarvis Bar hover controls now react and remain stable.** The
+ non-activating Qt panel could miss mouse-move events, while replacing its
+ alpha input mask emitted a false leave as the pill expanded. The result was
+ an unresponsive or flickering hover state whose close and microphone controls
+ could not be used reliably. The panel now explicitly accepts mouse movement
+ and reconciles the real cursor against a stable pill footprint, preserving
+ distinct mouse-out and mouse-over visuals during idle, listening, thinking,
+ and speaking states (BUG-095).
- **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
diff --git a/docs/BUGS.md b/docs/BUGS.md
index 4302554ff9..478a32895a 100644
--- a/docs/BUGS.md
+++ b/docs/BUGS.md
@@ -6532,3 +6532,51 @@ 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.
+
+---
+
+## BUG-095: macOS Jarvis Bar hover effects and controls do not react reliably (HIGH, FIXED 2026-07-19)
+
+**Symptom (physical-Mac field report).** Moving the pointer onto the Qt Jarvis
+Bar often produced no visible hover transition. When it did transition, the
+expanded state could disappear immediately, leaving the close and microphone
+controls unavailable. The failure affected both the idle pill and active voice
+states, so macOS did not expose the same clear mouse-out versus mouse-over
+presentation as the established desktop surface.
+
+**Root cause.** Two native behaviors compounded. First, the non-activating
+`NSPanel` did not explicitly request mouse-move delivery, so Cocoa could omit an
+Enter or Move notification while another application remained active. Second,
+BUG-093 correctly constrained hit testing to the current non-transparent pixels,
+but the input mask changes on every eased pill-size transition. Cocoa can emit a
+Leave while replacing that mask even though the physical pointer is still over
+the bar. The old Qt handlers trusted every Enter and Leave synchronously, so one
+false Leave reversed the hover animation and shrank the hit region beneath the
+pointer.
+
+**Fix.** The native panel now accepts mouse-moved events without becoming key or
+activating its helper process. A lightweight 32 ms UI timer also reads Qt's real
+global cursor position, which covers stationary pointers and omitted native
+notifications. The collapsed state's current alpha mask remains the acquisition
+region, so transparent padding still passes through and cannot trigger hover.
+After acquisition, a deterministic target-pill footprint retains the state while
+the pill expands. Leaving that footprint restores the normal presentation. The
+same state machine runs in idle, listen, think, and speak modes; hiding the
+surface clears hover, and an active drag cannot leave stale controls behind.
+
+**Guards.** Qt surface tests prove the non-activating native panel requests mouse
+movement, transparent padding cannot acquire hover, mask churn cannot cancel a
+real hover, leaving the visible pill restores the non-hover state, hiding clears
+stale state, and all four voice modes follow the same two-state contract. The
+renderer suite separately proves that the mouse-over frame differs visually in
+idle, listening, thinking, and speaking modes. A physical Cocoa smoke placed a
+temporary bar under a stationary cursor and then moved the window away, observing
+`idle_over=True`, `speak_over=True`, and `speak_out=False` without activating the
+helper application.
+
+**Class rule.** Do not treat toolkit Enter/Leave notifications as authoritative
+when the window's native hit-test region changes under the pointer. Acquire only
+through visible pixels, retain against a stable intended interaction footprint,
+and reconcile with the real cursor. Non-activating overlays must explicitly
+prove both states in every visual mode: pointer outside means normal rendering;
+pointer on the bar means controls visible and usable.
diff --git a/jarvis/ui/jarvisbar/qt_overlay.py b/jarvis/ui/jarvisbar/qt_overlay.py
index e351c9c417..bb2081a8a0 100644
--- a/jarvis/ui/jarvisbar/qt_overlay.py
+++ b/jarvis/ui/jarvisbar/qt_overlay.py
@@ -45,6 +45,8 @@ AUDIBLE_HOLD_S = 0.5
TARGET_FRAME_MS = 16
UI_QUEUE_INTERVAL_MS = 20
Z_ORDER_GUARD_INTERVAL_MS = 500
+HOVER_POLL_INTERVAL_MS = 32
+HOVER_HIT_SLOP_PX = 2
DRAG_THRESHOLD_PX = 16
MARGIN_PX = 12
TASKBAR_GAP_PX = 8
@@ -282,15 +284,11 @@ def _window_class() -> type:
painter.end()
def enterEvent(self, event: Any) -> None: # noqa: N802 - Qt override
- self._owner._hovered = True
- self._owner._invalidate_static_frame()
- self.update()
+ self._owner._hover_enter_ui()
super().enterEvent(event)
def leaveEvent(self, event: Any) -> None: # noqa: N802 - Qt override
- self._owner._hovered = False
- self._owner._invalidate_static_frame()
- self.update()
+ self._owner._hover_leave_ui()
super().leaveEvent(event)
def mousePressEvent(self, event: Any) -> None: # noqa: N802 - Qt override
@@ -300,6 +298,9 @@ def _window_class() -> type:
super().mousePressEvent(event)
def mouseMoveEvent(self, event: Any) -> None: # noqa: N802 - Qt override
+ # A native mouse move is also proof that the pointer reached the
+ # masked bar, even if a non-activating NSPanel omitted Enter.
+ self._owner._hover_enter_ui()
if self._owner._mouse_move_ui(event):
event.accept()
return
@@ -364,6 +365,7 @@ class QtJarvisBarOverlay:
self._frame_timer: Any = None
self._queue_timer: Any = None
self._z_timer: Any = None
+ self._hover_timer: Any = None
self._native_window: Any = None
self._x = 0
self._y = 0
@@ -535,6 +537,15 @@ class QtJarvisBarOverlay:
self._z_timer.timeout.connect(self._z_order_guard_ui)
self._z_timer.start()
+ # A changing alpha mask can make Cocoa emit Leave while the pointer is
+ # still inside the fixed bar window. Polling the real global cursor is
+ # the authoritative hover signal and also covers non-activating panels
+ # that omit Enter/Move notifications.
+ self._hover_timer = q.QtCore.QTimer(self._window)
+ self._hover_timer.setInterval(HOVER_POLL_INTERVAL_MS)
+ self._hover_timer.timeout.connect(self._poll_hover_ui)
+ self._hover_timer.start()
+
# Submit a complete RGBA frame before the first map. Qt's translucent
# backing already starts clear, and paintEvent replaces it atomically.
self._render_frame_ui()
@@ -637,6 +648,7 @@ class QtJarvisBarOverlay:
if self._desired_visible and not self._startup_gated:
self._do_show_ui()
else:
+ self._set_hovered_ui(False)
self._window.hide()
def _do_show_ui(self) -> None:
@@ -698,6 +710,9 @@ class QtJarvisBarOverlay:
)
native_window.setBecomesKeyOnlyIfNeeded_(True)
native_window.setHidesOnDeactivate_(False)
+ # WindowDoesNotAcceptFocus keeps the panel non-activating; it must
+ # still request mouse-move delivery so hover controls can react.
+ native_window.setAcceptsMouseMovedEvents_(True)
self._native_window = native_window
except Exception: # noqa: BLE001 - topmost is cosmetic; focus safety wins
# WindowStaysOnTopHint still supplies the normal ordering. Do not
@@ -727,7 +742,12 @@ class QtJarvisBarOverlay:
log.debug("Qt Jarvis Bar feedback publisher failed", exc_info=True)
def _stop_ui(self) -> None:
- for timer in (self._frame_timer, self._queue_timer, self._z_timer):
+ for timer in (
+ self._frame_timer,
+ self._queue_timer,
+ self._z_timer,
+ self._hover_timer,
+ ):
if timer is not None:
timer.stop()
if self._window is not None:
@@ -739,6 +759,76 @@ class QtJarvisBarOverlay:
# ------------------------------------------------------------------
# Position, drag, and gestures
# ------------------------------------------------------------------
+ def _set_hovered_ui(self, hovered: bool) -> bool:
+ """Apply one stable hover transition and request a fresh frame."""
+ hovered = bool(hovered)
+ if hovered == self._hovered:
+ return False
+ self._hovered = hovered
+ self._invalidate_static_frame()
+ if self._window is not None:
+ self._window.update()
+ return True
+
+ def _pointer_over_bar_ui(self) -> bool:
+ """Read the real cursor, retaining hover across transparent-mask churn.
+
+ Before entry, only the current opaque mask acquires hover so clear
+ window padding remains inert. Once acquired, the stable target pill
+ footprint becomes the retention area. That lets the pill expand beneath
+ the pointer without a mask-generated Leave collapsing it again, while a
+ pointer that genuinely leaves the visible bar restores the normal state.
+ """
+ window = self._window
+ if window is None or not window.isVisible():
+ return False
+ try:
+ q = _qt()
+ local = window.mapFromGlobal(q.QtGui.QCursor.pos())
+ if self._hovered:
+ return self._point_in_hover_footprint_ui(local)
+ input_mask = self._input_mask
+ if input_mask is None:
+ return False
+ return bool(input_mask.contains(local))
+ except Exception: # noqa: BLE001 - hover is cosmetic and fail-closed
+ return False
+
+ def _point_in_hover_footprint_ui(self, point: Any) -> bool:
+ """Return whether ``point`` is inside the stable hovered pill bounds."""
+ pill_w, pill_h = renderer.target_pill_size(
+ self._mode,
+ hovered=True,
+ muted=self._muted,
+ )
+ center_x = renderer.WIN_W / 2.0
+ center_y = renderer.pill_center_y(float(pill_h))
+ slop = HOVER_HIT_SLOP_PX
+ x = float(point.x())
+ y = float(point.y())
+ return (
+ center_x - pill_w / 2.0 - slop
+ <= x
+ < center_x + pill_w / 2.0 + slop
+ and center_y - pill_h / 2.0 - slop
+ <= y
+ < center_y + pill_h / 2.0 + slop
+ )
+
+ def _poll_hover_ui(self) -> None:
+ if self._startup_gated or not self._desired_visible:
+ self._set_hovered_ui(False)
+ return
+ self._set_hovered_ui(self._pointer_over_bar_ui())
+
+ def _hover_enter_ui(self) -> None:
+ self._set_hovered_ui(True)
+
+ def _hover_leave_ui(self) -> None:
+ # Never trust a raw Leave generated by replacing the native mask. The
+ # cursor poll collapses only after the pointer exits the stable pill.
+ self._poll_hover_ui()
+
def _geometry_for_screen_ui(
self,
screen: Any,
diff --git a/tests/unit/ui/jarvisbar/test_qt_overlay.py b/tests/unit/ui/jarvisbar/test_qt_overlay.py
index 9f3e2d517d..e11634fa00 100644
--- a/tests/unit/ui/jarvisbar/test_qt_overlay.py
+++ b/tests/unit/ui/jarvisbar/test_qt_overlay.py
@@ -30,6 +30,22 @@ class _Rect:
def height(self) -> int:
return self._values[3]
+ def contains(self, point: _Point) -> bool:
+ x, y, width, height = self._values
+ return x <= point.x() < x + width and y <= point.y() < y + height
+
+
+class _Point:
+ def __init__(self, x: int, y: int) -> None:
+ self._x = x
+ self._y = y
+
+ def x(self) -> int:
+ return self._x
+
+ def y(self) -> int:
+ return self._y
+
def test_surface_state_is_safe_before_qt_is_started(
monkeypatch: pytest.MonkeyPatch,
@@ -343,6 +359,153 @@ def test_non_cocoa_qt_backend_never_enters_the_appkit_bridge(
assert surface._native_window is None # noqa: SLF001
+def test_macos_native_panel_accepts_mouse_moves_without_activation(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ class _App:
+ @staticmethod
+ def platformName() -> str: # noqa: N802 - Qt-compatible double
+ return "cocoa"
+
+ class _Window:
+ @staticmethod
+ def winId() -> int: # noqa: N802 - Qt-compatible double
+ return 42
+
+ class _NativeWindow:
+ def __init__(self) -> None:
+ self.accepts_mouse_moves = False
+
+ @staticmethod
+ def styleMask() -> int: # noqa: N802 - AppKit-compatible double
+ return 0
+
+ def setStyleMask_(self, _mask: int) -> None: ...
+
+ def setBecomesKeyOnlyIfNeeded_(self, _enabled: bool) -> None: ...
+
+ def setHidesOnDeactivate_(self, _enabled: bool) -> None: ...
+
+ def setAcceptsMouseMovedEvents_(self, enabled: bool) -> None:
+ self.accepts_mouse_moves = enabled
+
+ native_window = _NativeWindow()
+ native_view = SimpleNamespace(window=lambda: native_window)
+ monkeypatch.setattr(qt_overlay.sys, "platform", "darwin")
+ monkeypatch.setitem(
+ sys.modules,
+ "objc",
+ SimpleNamespace(objc_object=lambda **_kwargs: native_view),
+ )
+ monkeypatch.setitem(
+ sys.modules,
+ "AppKit",
+ SimpleNamespace(NSWindowStyleMaskNonactivatingPanel=128),
+ )
+ surface = qt_overlay.QtJarvisBarOverlay()
+ surface._app = _App() # type: ignore[assignment] # noqa: SLF001
+ surface._window = _Window() # type: ignore[assignment] # noqa: SLF001
+
+ surface._configure_macos_nonactivating_window_ui() # noqa: SLF001
+
+ assert surface._native_window is native_window # noqa: SLF001
+ assert native_window.accepts_mouse_moves is True
+
+
[email protected]("mode", ["idle", "listen", "think", "speak"])
+def test_hover_poll_tracks_distinct_mouse_out_and_mouse_over_states(
+ monkeypatch: pytest.MonkeyPatch,
+ mode: str,
+) -> None:
+ class _Mask:
+ @staticmethod
+ def contains(point: _Point) -> bool:
+ center_x = renderer.WIN_W // 2
+ center_y = round(renderer.pill_center_y(renderer.COLLAPSED_H))
+ return _Rect(center_x - 5, center_y - 3, 10, 6).contains(point)
+
+ class _Window:
+ def __init__(self) -> None:
+ self.updates = 0
+
+ @staticmethod
+ def isVisible() -> bool: # noqa: N802 - Qt-compatible double
+ return True
+
+ @staticmethod
+ def mapFromGlobal(point: _Point) -> _Point: # noqa: N802 - Qt-compatible double
+ return point
+
+ @staticmethod
+ def rect() -> _Rect:
+ return _Rect(0, 0, renderer.WIN_W, renderer.WIN_H)
+
+ def update(self) -> None:
+ self.updates += 1
+
+ center_x = renderer.WIN_W // 2
+ center_y = round(renderer.pill_center_y(renderer.COLLAPSED_H))
+ cursor = [_Point(center_x, center_y)]
+ monkeypatch.setattr(
+ qt_overlay,
+ "_qt",
+ lambda: SimpleNamespace(
+ QtGui=SimpleNamespace(
+ QCursor=SimpleNamespace(pos=lambda: cursor[0]),
+ )
+ ),
+ )
+ window = _Window()
+ surface = qt_overlay.QtJarvisBarOverlay()
+ surface._mode = mode # noqa: SLF001
+ surface._window = window # type: ignore[assignment] # noqa: SLF001
+ surface._input_mask = _Mask() # type: ignore[assignment] # noqa: SLF001
+
+ surface._poll_hover_ui() # noqa: SLF001
+ assert surface._hovered is True # noqa: SLF001
+
+ # A point outside the collapsed acquisition mask but inside the stable
+ # hovered pill must survive Cocoa's spurious Leave during setMask().
+ hovered_w, hovered_h = renderer.target_pill_size(mode, True)
+ cursor[0] = _Point(
+ round(center_x - hovered_w / 2.0 + 3),
+ round(renderer.pill_center_y(hovered_h)),
+ )
+ surface._hover_leave_ui() # noqa: SLF001
+ assert surface._hovered is True # noqa: SLF001
+
+ # Transparent fixed-window padding is not the bar: leaving the hovered
+ # pill must restore the non-hover state in every voice mode.
+ cursor[0] = _Point(0, 0)
+ surface._poll_hover_ui() # noqa: SLF001
+ assert surface._hovered is False # noqa: SLF001
+ assert window.updates == 2
+
+ # Clear padding cannot acquire hover from the collapsed state.
+ cursor[0] = _Point(0, 0)
+ surface._poll_hover_ui() # noqa: SLF001
+ assert surface._hovered is False # noqa: SLF001
+
+
+def test_hover_poll_clears_stale_state_when_surface_is_hidden(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ surface = qt_overlay.QtJarvisBarOverlay()
+ surface._hovered = True # noqa: SLF001
+ surface._desired_visible = False # noqa: SLF001
+ monkeypatch.setattr(
+ surface,
+ "_pointer_over_bar_ui",
+ lambda: (_ for _ in ()).throw(
+ AssertionError("hidden surface must not inspect the cursor")
+ ),
+ )
+
+ surface._poll_hover_ui() # noqa: SLF001
+
+ assert surface._hovered is False # noqa: SLF001
+
+
def test_clicks_are_forwarded_to_parent_owned_callbacks() -> None:
"""The companion surface must not look for a child-local speech pipeline."""
surface = qt_overlay.QtJarvisBarOverlay()