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.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
fix(appshot): diagnosable Qt sidecars, no Dock icons, private drag files
rubenluetke10-beepfc693e5923f7
diff --git a/jarvis/appshot/hotkey.py b/jarvis/appshot/hotkey.pyindex 3fa3cf0bce..eaa548870e 100644--- a/jarvis/appshot/hotkey.py+++ b/jarvis/appshot/hotkey.py@@ -237,7 +237,10 @@ class AppshotShortcut:@staticmethoddef _check_combo(hotkey: str) -> ShortcutStatus:from jarvis.platform import detect_platform # noqa: PLC0415- from jarvis.platform.probes import has_hotkey # noqa: PLC0415+ from jarvis.platform.probes import ( # noqa: PLC0415+ has_hotkey,+ hotkey_unavailable_reason,+ )from jarvis.trigger.hotkey import validate_hotkey # noqa: PLC0415verdict = validate_hotkey(hotkey)@@ -252,7 +255,7 @@ class AppshotShortcut:return ShortcutStatus(hotkey=hotkey,armed=False,- detail="Global shortcuts are not available on this desktop.",+ detail=hotkey_unavailable_reason(),)return ShortcutStatus(hotkey=hotkey, armed=True)diff --git a/jarvis/appshot/picker/renderer.py b/jarvis/appshot/picker/renderer.pyindex f507843301..377092c488 100644--- a/jarvis/appshot/picker/renderer.py+++ b/jarvis/appshot/picker/renderer.py@@ -1223,6 +1223,9 @@ def run(language: str = "en") -> int:except Exception as exc: # noqa: BLE001 - no display / no platform pluginsys.stderr.write(f"appshot-picker: no usable display ({exc!r}).\n")return wire.EXIT_NO_GUI+ from jarvis.platform.qt_sidecar import hide_from_dock++ hide_from_dock() # macOS: no "Python" Dock icon for the resident pickerapp.setQuitOnLastWindowClosed(False)picker = Picker(app, language=language)pump = _StdinPump()diff --git a/jarvis/appshot/recording.py b/jarvis/appshot/recording.pyindex 370dacc7ef..dfd60e1271 100644--- a/jarvis/appshot/recording.py+++ b/jarvis/appshot/recording.py@@ -50,6 +50,7 @@ def recent_recordings() -> list[dict[str, Any]]:def capability() -> dict[str, Any]:from jarvis.platform.probes import display_present, is_wayland+ from jarvis.platform.qt_sidecar import missing_system_library as qt_missingdetail = ""permission = False@@ -59,6 +60,8 @@ def capability() -> dict[str, Any]:detail = "Screen recording requires the desktop capture and video packages."elif is_wayland() and importlib.util.find_spec("PySide6.QtMultimedia") is None:detail = "Wayland recording requires Qt Multimedia, PipeWire and a ScreenCast portal."+ elif qt_missing():+ detail = f"{qt_missing()}."elif sys.platform == "darwin":from jarvis.platform import screen_accessdiff --git a/jarvis/appshot/recording_worker.py b/jarvis/appshot/recording_worker.pyindex bdf7331393..7d6af8540d 100644--- a/jarvis/appshot/recording_worker.py+++ b/jarvis/appshot/recording_worker.py@@ -45,6 +45,9 @@ def run(output: Path, language: str = "en") -> int:from jarvis.platform.probes import is_waylandapp = QApplication(["Personal Jarvis — Screen recording"])+ from jarvis.platform.qt_sidecar import hide_from_dock++ hide_from_dock() # macOS: no "Python" Dock icon for the standby recorderapp.setQuitOnLastWindowClosed(False)labels = LABELS.get(language, LABELS["en"])diff --git a/jarvis/appshot/region.py b/jarvis/appshot/region.pyindex a65a07b859..db4123e1fe 100644--- a/jarvis/appshot/region.py+++ b/jarvis/appshot/region.py@@ -242,6 +242,11 @@ def picker_capability() -> tuple[bool, str]:log.debug("appshot: platform probes unavailable", exc_info=True)if importlib.util.find_spec("PySide6") is None:return False, "the selection overlay needs PySide6 (the [desktop] extra)"+ from jarvis.platform.qt_sidecar import missing_system_library # noqa: PLC0415++ missing = missing_system_library()+ if missing:+ return False, missingreturn True, ""@@ -292,12 +297,13 @@ def snap_layout() -> dict[str, Any]:def _spawn(language: str = "en") -> subprocess.Popen[str]:from jarvis.core.process_utils import NO_WINDOW_CREATIONFLAGS # noqa: PLC0415+ from jarvis.platform.qt_sidecar import stderr_sink # noqa: PLC0415return subprocess.Popen([sys.executable, "-m", "jarvis.appshot.picker", "--lang", language or "en"],stdin=subprocess.PIPE,stdout=subprocess.PIPE,- stderr=subprocess.DEVNULL,+ stderr=stderr_sink("appshot-picker"),text=True,encoding="utf-8",creationflags=NO_WINDOW_CREATIONFLAGS,@@ -426,7 +432,12 @@ def _exit_message(code: int) -> str:if code == EXIT_NO_GUI:return "An area cannot be selected here: the selection overlay found no usable screen."- return f"The selection overlay stopped unexpectedly (exit code {code}). Nothing was captured."+ from jarvis.platform.qt_sidecar import crash_hint # noqa: PLC0415++ return (+ f"The selection overlay stopped unexpectedly (exit code {code}). "+ f"Nothing was captured.{crash_hint(code, 'appshot-picker')}"+ )async def _run_picker(timeout_s: float) -> tuple[dict[str, Any] | None, int | None, bool]:diff --git a/jarvis/cu/indicator/controller.py b/jarvis/cu/indicator/controller.pyindex 1673f0f3a2..d338104672 100644--- a/jarvis/cu/indicator/controller.py+++ b/jarvis/cu/indicator/controller.py@@ -530,6 +530,13 @@ class CUIndicatorController:return False, ("PySide6 not installed (install the [desktop] extra)")+ from jarvis.platform.qt_sidecar import ( # noqa: PLC0415+ missing_system_library,+ )++ missing = missing_system_library()+ if missing:+ return False, missingreturn True, ""# ---------------------------------------------------------------- sidecar@@ -540,13 +547,14 @@ class CUIndicatorController:from jarvis.core.process_utils import ( # noqa: PLC0415NO_WINDOW_CREATIONFLAGS,)+ from jarvis.platform.qt_sidecar import stderr_sink # noqa: PLC0415self._card_open = False # a fresh sidecar has no card yetself._proc = subprocess.Popen([sys.executable, "-m", "jarvis.cu.indicator"],stdin=subprocess.PIPE,stdout=subprocess.PIPE,- stderr=subprocess.DEVNULL,+ stderr=stderr_sink("cu-indicator"),text=True,encoding="utf-8",creationflags=NO_WINDOW_CREATIONFLAGS,diff --git a/jarvis/cu/indicator/renderer.py b/jarvis/cu/indicator/renderer.pyindex 2bc35e4665..68d6c55446 100644--- a/jarvis/cu/indicator/renderer.py+++ b/jarvis/cu/indicator/renderer.py@@ -22,7 +22,6 @@ from __future__ import annotationsimport osimport sys-import tempfileimport threadingimport timefrom collections import deque@@ -1547,9 +1546,11 @@ class Renderer(QObject):Only on the user's drag; files older than an hour are removed first,so the folder never grows (see ``docs/appshots.md``)."""- folder = Path(tempfile.gettempdir()) / "jarvis-appshots"+ from jarvis.appshot.dragfile import prepare_drag_folder+try:- folder.mkdir(parents=True, exist_ok=True)+ # Private to this user: a shared /tmp is readable by everyone.+ folder = prepare_drag_folder()cutoff = time.time() - _DRAG_FILE_MAX_AGE_Sfor old in folder.glob("appshot-*.png"):with suppress(OSError): # a file still open elsewhere stays@@ -1682,6 +1683,9 @@ def run() -> int:except Exception as exc: # noqa: BLE001 — no display / no platform pluginsys.stderr.write(f"cu-indicator: no usable display ({exc!r}) — indicator disabled.\n")return protocol.EXIT_NO_GUI+ from jarvis.platform.qt_sidecar import hide_from_dock++ hide_from_dock() # macOS: no "Python" Dock icon for the resident card# All windows are frequently hidden (blank/hide) — that must never# terminate the sidecar; only stdin EOF or "quit" does.app.setQuitOnLastWindowClosed(False)diff --git a/jarvis/platform/qt_sidecar.py b/jarvis/platform/qt_sidecar.pynew file mode 100644index 0000000000..8ea0f650dd--- /dev/null+++ b/jarvis/platform/qt_sidecar.py@@ -0,0 +1,112 @@+"""Small OS duties of the PySide6 sidecars: the area picker, corner card, recorder.++* :func:`hide_from_dock` — on macOS a plain Python process that opens a Qt+ window becomes a foreground app with its own "Python" Dock icon and+ app-switcher entry. Each resident sidecar turns itself into an accessory+ app (windows, no Dock icon, no menu bar), the way the Jarvis bar does.+* :func:`missing_system_library` — on Linux X11, Qt 6.5+ needs the system+ library ``libxcb-cursor0``. Without it Qt aborts the process (SIGABRT) before+ any Python handler runs, so the sidecar just "stopped unexpectedly". The+ capability checks ask this first and name the package instead.+* :func:`stderr_sink` / :func:`crash_hint` — sidecar stderr goes to+ ``<data dir>/logs/<name>.log`` (the latest run) instead of nowhere, and a+ crash message points at that file.++Nothing here imports Qt or initialises at import time (AP-26).+"""++from __future__ import annotations++import ctypes.util+import logging+import os+import sys+from pathlib import Path+from typing import IO++log = logging.getLogger(__name__)++_SINKS: dict[str, IO[bytes]] = {}++#: Shown when Qt's X11 platform plugin cannot load for want of xcb-cursor.+XCB_CURSOR_MESSAGE = (+ "Qt needs the system library libxcb-cursor0 to open windows on X11 "+ "(Debian/Ubuntu: sudo apt install libxcb-cursor0; Fedora and Arch: "+ "xcb-util-cursor)"+)+++def hide_from_dock() -> None:+ """macOS: make this process an accessory app (no Dock icon). No-op elsewhere."""+ if sys.platform != "darwin":+ return+ try:+ from AppKit import NSApplication # type: ignore[import-not-found] # noqa: PLC0415++ # 1 = NSApplicationActivationPolicyAccessory: windows allowed, no Dock+ # icon, no menu bar takeover.+ NSApplication.sharedApplication().setActivationPolicy_(1)+ except Exception: # noqa: BLE001 - without pyobjc the icon simply stays+ log.debug("qt-sidecar: Dock icon hide skipped (pyobjc unavailable?)", exc_info=True)+++def missing_system_library() -> str:+ """Why Qt cannot open a window on this Linux X11 desktop, or ``""``."""+ if not sys.platform.startswith("linux"):+ return ""+ if os.environ.get("WAYLAND_DISPLAY") or not os.environ.get("DISPLAY"):+ return ""+ try:+ if ctypes.util.find_library("xcb-cursor") is None:+ return XCB_CURSOR_MESSAGE+ except Exception: # noqa: BLE001 - an unanswerable probe lets Qt decide+ log.debug("qt-sidecar: library probe failed", exc_info=True)+ return ""+++def stderr_log_path(name: str) -> Path:+ from jarvis.core.config import DATA_DIR # noqa: PLC0415++ return Path(DATA_DIR) / "logs" / f"{name}.log"+++def stderr_sink(name: str) -> IO[bytes] | int:+ """A file for a sidecar's stderr (latest run only); DEVNULL when none can open.++ The handle is kept until the next spawn of the same sidecar replaces it,+ so the parent never leaks one per restart.+ """+ import subprocess # noqa: PLC0415++ previous = _SINKS.pop(name, None)+ if previous is not None:+ previous.close()+ try:+ path = stderr_log_path(name)+ path.parent.mkdir(parents=True, exist_ok=True)+ sink = path.open("wb")+ except OSError:+ log.debug("qt-sidecar: no log file for %s; stderr is dropped", name, exc_info=True)+ return subprocess.DEVNULL+ _SINKS[name] = sink+ return sink+++def crash_hint(code: int | None, name: str) -> str:+ """One extra sentence for a sidecar that died on a signal, or ``""``."""+ if code is None or code >= 0:+ return ""+ missing = missing_system_library()+ if missing:+ return f" {missing}."+ return f" Details are in {stderr_log_path(name)}."+++__all__ = [+ "XCB_CURSOR_MESSAGE",+ "crash_hint",+ "hide_from_dock",+ "missing_system_library",+ "stderr_log_path",+ "stderr_sink",+]diff --git a/jarvis/ui/desktop_app.py b/jarvis/ui/desktop_app.pyindex 3c7592c50a..5a17ad9987 100644--- a/jarvis/ui/desktop_app.py+++ b/jarvis/ui/desktop_app.py@@ -6156,14 +6156,13 @@ class DesktopApp:# lives. Windows and macOS are native; Linux is a logged no-op until its# GTK source lands. Never blocks the window.try:- from pathlib import Path as _Path-from jarvis.appshot.dragfile import drag_folder+ from jarvis.platform.user_dirs import downloads_dirfrom jarvis.ui.native_drag import install_native_drag# Downloads for saved files; the appshot drag folder for the# editor's "Drag me" handle (jarvis/appshot/dragfile.py).- install_native_drag(allowed_base_dirs=[_Path.home() / "Downloads", drag_folder()])+ install_native_drag(allowed_base_dirs=[downloads_dir(), drag_folder()])except Exception: # noqa: BLE001, S110 - the drag bridge is never load-bearingpassdiff --git a/tests/unit/platform/test_qt_sidecar.py b/tests/unit/platform/test_qt_sidecar.pynew file mode 100644index 0000000000..1a9e94d810--- /dev/null+++ b/tests/unit/platform/test_qt_sidecar.py@@ -0,0 +1,73 @@+"""OS duties of the Qt sidecars: no Dock icon, a named missing library, a stderr log."""++from __future__ import annotations++import subprocess+import sys+from pathlib import Path+from types import ModuleType, SimpleNamespace++import pytest++from jarvis.platform import qt_sidecar+++def x11(monkeypatch: pytest.MonkeyPatch):+ monkeypatch.setattr(sys, "platform", "linux")+ monkeypatch.setenv("DISPLAY", ":0")+ monkeypatch.delenv("WAYLAND_DISPLAY", raising=False)+++def test_a_missing_xcb_cursor_is_named(x11, monkeypatch: pytest.MonkeyPatch) -> None:+ monkeypatch.setattr(qt_sidecar.ctypes.util, "find_library", lambda _name: None)+ assert "libxcb-cursor0" in qt_sidecar.missing_system_library()+++def test_a_present_xcb_cursor_says_nothing(x11, monkeypatch: pytest.MonkeyPatch) -> None:+ monkeypatch.setattr(qt_sidecar.ctypes.util, "find_library", lambda _n: "libxcb-cursor.so.0")+ assert qt_sidecar.missing_system_library() == ""++[email protected]("platform", ["win32", "darwin"])+def test_other_systems_never_need_it(monkeypatch: pytest.MonkeyPatch, platform: str) -> None:+ monkeypatch.setattr(sys, "platform", platform)+ monkeypatch.setattr(qt_sidecar.ctypes.util, "find_library", lambda _name: None)+ assert qt_sidecar.missing_system_library() == ""+++def test_a_crash_on_a_signal_points_at_the_cause(x11, monkeypatch: pytest.MonkeyPatch) -> None:+ monkeypatch.setattr(qt_sidecar.ctypes.util, "find_library", lambda _name: None)+ assert "libxcb-cursor0" in qt_sidecar.crash_hint(-6, "appshot-picker")+ assert qt_sidecar.crash_hint(1, "appshot-picker") == ""+ monkeypatch.setattr(qt_sidecar.ctypes.util, "find_library", lambda _n: "libxcb-cursor.so.0")+ assert "appshot-picker.log" in qt_sidecar.crash_hint(-11, "appshot-picker")+++def test_stderr_goes_to_one_log_per_sidecar(+ tmp_path: Path, monkeypatch: pytest.MonkeyPatch+) -> None:+ monkeypatch.setattr(qt_sidecar, "stderr_log_path", lambda name: tmp_path / f"{name}.log")+ first = qt_sidecar.stderr_sink("appshot-picker")+ second = qt_sidecar.stderr_sink("appshot-picker")++ assert first is not subprocess.DEVNULL and first.closed # the earlier run's handle+ second.write(b"qt.qpa.plugin: could not load xcb\n")+ second.flush()+ assert b"xcb" in (tmp_path / "appshot-picker.log").read_bytes()+ second.close()+++def test_the_dock_icon_is_hidden_on_a_mac(monkeypatch: pytest.MonkeyPatch) -> None:+ policies: list[int] = []+ app = SimpleNamespace(setActivationPolicy_=policies.append)+ appkit = ModuleType("AppKit")+ appkit.NSApplication = SimpleNamespace(sharedApplication=lambda: app)+ monkeypatch.setitem(sys.modules, "AppKit", appkit)++ monkeypatch.setattr(sys, "platform", "darwin")+ qt_sidecar.hide_from_dock()+ monkeypatch.setattr(sys, "platform", "linux")+ qt_sidecar.hide_from_dock()++ assert policies == [1] # accessory, and only on macOS