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): re-assert the clear window backing on every reveal + loud pyobjc diagnostics (BUG-075 follow-up)

Ruben Lütkef7748541bbd8
diff --git a/jarvis/ui/jarvisbar/overlay.py b/jarvis/ui/jarvisbar/overlay.py
index dbc8006a86..384ef1e019 100644
--- a/jarvis/ui/jarvisbar/overlay.py
+++ b/jarvis/ui/jarvisbar/overlay.py
@@ -38,6 +38,10 @@ from jarvis.ui.jarvisbar import interaction, renderer
log = logging.getLogger("jarvis.ui.jarvisbar")
+# Warn-once latch: the clear-backing pass runs on every reveal, but a missing
+# pyobjc should produce ONE actionable warning, not a log storm.
+_WARNED_NO_APPKIT = False
+
COLOR_KEY_HEX = "#FF00FF"
DRAG_THRESHOLD_PX = 16
MARGIN_PX = 12
@@ -197,13 +201,28 @@ def _apply_macos_clear_backing() -> None:
return
try:
from AppKit import NSApp, NSColor # type: ignore[import-not-found] # noqa: PLC0415
-
- for win in NSApp.windows():
+ except Exception: # noqa: BLE001
+ # Without this pass Tk 9 paints the window backing as an OPAQUE grey
+ # box (BUG-075) — the single most visible macOS defect. Say so loudly
+ # once instead of hiding the cause in a debug line.
+ global _WARNED_NO_APPKIT
+ if not _WARNED_NO_APPKIT:
+ _WARNED_NO_APPKIT = True
+ log.warning(
+ "pyobjc (AppKit) unavailable — Tk 9 paints the bar backing as "
+ "an opaque grey box. Install the [desktop-macos] extra "
+ "(pip install 'personal-jarvis[desktop-macos]') to fix it."
+ )
+ return
+ try:
+ wins = list(NSApp.windows())
+ for win in wins:
win.setOpaque_(False)
win.setBackgroundColor_(NSColor.clearColor())
win.setHasShadow_(False)
+ log.debug("macOS clear-backing applied to %d window(s)", len(wins))
except Exception: # noqa: BLE001 — cosmetic; the grey box is the degrade
- log.debug("macOS clear-backing pass skipped", exc_info=True)
+ log.warning("macOS clear-backing pass failed", exc_info=True)
def _create_hidden_tk_root(tk: Any) -> Any:
@@ -791,6 +810,12 @@ class JarvisBarOverlay:
except Exception: # noqa: BLE001
log.debug("jarvisbar deiconify failed", exc_info=True)
self._do_reassert_z_order(opacity=0.0)
+ if sys.platform == "darwin" and getattr(self, "_mac_transparent", False):
+ # Tk 9 (re)materializes the NSWindow on mapping; the construction-
+ # time clear-backing pass ran on a still-withdrawn root and can
+ # miss it, leaving the opaque grey box (BUG-075). Re-assert on
+ # every reveal — idempotent and cheap.
+ _apply_macos_clear_backing()
self._refresh_prepared_frame()
try:
# Flush geometry/map/canvas work while the window is still fully
diff --git a/ui/orb/overlay.py b/ui/orb/overlay.py
index 4882cb6725..794ca43fb3 100644
--- a/ui/orb/overlay.py
+++ b/ui/orb/overlay.py
@@ -170,6 +170,11 @@ def key_to_alpha(img: Image.Image) -> Image.Image:
return Image.fromarray(np.dstack((arr, alpha)), "RGBA")
+# Warn-once latch: the clear-backing pass runs on every reveal, but a missing
+# pyobjc should produce ONE actionable warning, not a log storm.
+_WARNED_NO_APPKIT = False
+
+
def apply_macos_clear_backing() -> None:
"""Make every NSWindow of THIS process paint a clear backing (BUG-075).
@@ -184,19 +189,33 @@ def apply_macos_clear_backing() -> None:
"""
if sys.platform != "darwin":
return
+ import logging # noqa: PLC0415
+
+ orb_log = logging.getLogger("jarvis.orb")
try:
from AppKit import NSApp, NSColor # type: ignore[import-not-found] # noqa: PLC0415
-
- for win in NSApp.windows():
+ except Exception: # noqa: BLE001
+ # Without this pass Tk 9 paints the window backing as an OPAQUE grey
+ # box (BUG-075) — the single most visible macOS defect. Say so loudly
+ # once instead of hiding the cause in a debug line.
+ global _WARNED_NO_APPKIT
+ if not _WARNED_NO_APPKIT:
+ _WARNED_NO_APPKIT = True
+ orb_log.warning(
+ "pyobjc (AppKit) unavailable — Tk 9 paints the mascot backing "
+ "as an opaque grey box. Install the [desktop-macos] extra "
+ "(pip install 'personal-jarvis[desktop-macos]') to fix it."
+ )
+ return
+ try:
+ wins = list(NSApp.windows())
+ for win in wins:
win.setOpaque_(False)
win.setBackgroundColor_(NSColor.clearColor())
win.setHasShadow_(False)
+ orb_log.debug("macOS clear-backing applied to %d window(s)", len(wins))
except Exception: # noqa: BLE001 — cosmetic; the grey box is the degrade
- import logging # noqa: PLC0415
-
- logging.getLogger("jarvis.orb").debug(
- "macOS clear-backing pass skipped", exc_info=True
- )
+ orb_log.warning("macOS clear-backing pass failed", exc_info=True)
_GWL_EXSTYLE = -20
@@ -1909,6 +1928,12 @@ class OrbOverlay:
self._set_mode(mode)
if self._root:
self._root.deiconify()
+ if self._mac_transparent:
+ # Tk 9 can (re)materialize the NSWindow on mapping after a
+ # withdraw; a construction-time clear-backing pass does not
+ # survive that, leaving the opaque grey box (BUG-075).
+ # Re-assert on every reveal — idempotent and cheap.
+ apply_macos_clear_backing()
# ADR-0016 visible-feedback contract: schedule a post-frame
# visibility snapshot. 50 ms gives Tk time to actually map
# the window before we sample winfo_viewable / winfo_x.