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(cu): keep screen indicator visible on macOS

Ruben Lütkefdca8bf131e9
diff --git a/jarvis/cu/indicator/renderer.py b/jarvis/cu/indicator/renderer.py
index 39ddf47cfe..22cb231de7 100644
--- a/jarvis/cu/indicator/renderer.py
+++ b/jarvis/cu/indicator/renderer.py
@@ -77,6 +77,15 @@ class _GlowWindow(QWidget):
self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
self.setAttribute(Qt.WidgetAttribute.WA_TransparentForMouseEvents)
self.setAttribute(Qt.WidgetAttribute.WA_ShowWithoutActivating)
+ if sys.platform == "darwin":
+ # Qt::Tool maps to NSPanel on macOS. An NSPanel normally stays
+ # off-screen while its process is inactive, but this sidecar is
+ # deliberately never activated. Without the always-show
+ # attribute the animation advances and commands are acknowledged
+ # while the native window remains invisible.
+ mac_always_show = getattr(Qt.WidgetAttribute, "WA_MacAlwaysShowToolWindow", None)
+ if mac_always_show is not None:
+ self.setAttribute(mac_always_show)
self.setScreen(screen)
self.setGeometry(screen.geometry())
self.setWindowOpacity(0.0)
@@ -176,7 +185,7 @@ class Renderer(QObject):
self._app = app
self._windows: list[_GlowWindow] = []
self._hint = ""
- self._active = False # "show" was requested and not yet "hide"
+ self._active = False # "show" was requested and not yet "hide"
self._blanked = False # capture guard currently hiding the border
# Breathing pulse: 0 → 1 → 0 per period, applied as a factor on
@@ -307,9 +316,7 @@ class _StdinPump(QObject):
eof = Signal()
def start(self) -> None:
- threading.Thread(
- target=self._run, name="cu-indicator-stdin", daemon=True
- ).start()
+ threading.Thread(target=self._run, name="cu-indicator-stdin", daemon=True).start()
def _run(self) -> None:
# A dying pipe simply means "parent gone" — treated as EOF.
@@ -336,9 +343,7 @@ def run() -> int:
try:
app = QApplication(sys.argv[:1] or ["cu-indicator"])
except Exception as exc: # noqa: BLE001 — no display / no platform plugin
- sys.stderr.write(
- f"cu-indicator: no usable display ({exc!r}) — indicator disabled.\n"
- )
+ sys.stderr.write(f"cu-indicator: no usable display ({exc!r}) — indicator disabled.\n")
return protocol.EXIT_NO_GUI
# All windows are frequently hidden (blank/hide) — that must never
# terminate the sidecar; only stdin EOF or "quit" does.
diff --git a/tests/unit/cu/indicator/test_sidecar_smoke.py b/tests/unit/cu/indicator/test_sidecar_smoke.py
index a7cbb26320..22cc974d9a 100644
--- a/tests/unit/cu/indicator/test_sidecar_smoke.py
+++ b/tests/unit/cu/indicator/test_sidecar_smoke.py
@@ -4,6 +4,7 @@ Runs the real ``python -m jarvis.cu.indicator`` subprocess on Qt's
offscreen platform plugin so it works on CI boxes without a display.
Auto-skips when PySide6 is not installed (base install / headless floor).
"""
+
from __future__ import annotations
import importlib.util
@@ -13,6 +14,7 @@ import sys
import pytest
+from jarvis.core.process_utils import NO_WINDOW_CREATIONFLAGS
from jarvis.cu.indicator import protocol
pytestmark = pytest.mark.skipif(
@@ -32,13 +34,12 @@ def test_sidecar_show_quit_round_trip() -> None:
stderr=subprocess.PIPE,
text=True,
encoding="utf-8",
+ creationflags=NO_WINDOW_CREATIONFLAGS,
env=env,
)
try:
assert proc.stdin is not None and proc.stdout is not None
- proc.stdin.write(
- protocol.encode_command(protocol.CMD_SHOW, hint="Esc to cancel")
- )
+ proc.stdin.write(protocol.encode_command(protocol.CMD_SHOW, hint="Esc to cancel"))
proc.stdin.write(protocol.encode_command(protocol.CMD_BLANK))
proc.stdin.write(protocol.encode_command(protocol.CMD_UNBLANK))
proc.stdin.write(protocol.encode_command(protocol.CMD_QUIT))
@@ -65,8 +66,41 @@ def test_sidecar_exits_cleanly_on_stdin_eof() -> None:
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
text=True,
+ creationflags=NO_WINDOW_CREATIONFLAGS,
env=env,
)
assert proc.stdin is not None
proc.stdin.close() # parent "dies" — EOF must end the sidecar
assert proc.wait(timeout=30) == 0
+
+
+def test_macos_tool_window_stays_visible_while_sidecar_is_inactive() -> None:
+ """The sidecar never activates, so its macOS NSPanel must opt into
+ remaining visible while another application owns focus."""
+ env = os.environ.copy()
+ env["QT_QPA_PLATFORM"] = "offscreen"
+ script = "\n".join(
+ [
+ "from PySide6.QtCore import Qt",
+ "from PySide6.QtWidgets import QApplication",
+ "from jarvis.cu.indicator import renderer",
+ "app = QApplication(['cu-indicator-attribute-test'])",
+ "renderer.sys.platform = 'darwin'",
+ "win = renderer._GlowWindow(",
+ " app.primaryScreen(), with_pill=False, hint=''",
+ ")",
+ "attribute = Qt.WidgetAttribute.WA_MacAlwaysShowToolWindow",
+ "raise SystemExit(0 if win.testAttribute(attribute) else 1)",
+ ]
+ )
+ result = subprocess.run(
+ [sys.executable, "-c", script],
+ capture_output=True,
+ text=True,
+ encoding="utf-8",
+ creationflags=NO_WINDOW_CREATIONFLAGS,
+ env=env,
+ timeout=30,
+ check=False,
+ )
+ assert result.returncode == 0, result.stderr