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(screen-context): never photograph a denylisted window on Linux or macOS

rubenluetke10-beepca8b99f05d92
diff --git a/docs/product/extend-and-automate/screen-context.md b/docs/product/extend-and-automate/screen-context.md
index a664e357df..f0cd743ddc 100644
--- a/docs/product/extend-and-automate/screen-context.md
+++ b/docs/product/extend-and-automate/screen-context.md
@@ -103,7 +103,7 @@ changing settings also clears captures made under old rules.
| Windows desktop | Supported without a separate screen-recording grant | Supported through Windows UI Automation |
| macOS desktop | Requires **Screen Recording** permission | Requires **Accessibility** permission; the image can still work without it |
| Linux with X11 | Supported when the desktop capture dependency is available | Uses an active AT-SPI session |
-| Linux with Wayland | Unavailable until a supported desktop-portal capture backend is installed | Does not make global capture available |
+| Linux with Wayland | Unavailable; sign in with an X11 session (for example GNOME on Xorg) | Does not make global capture available |
| Headless server | Unavailable because there is no addressable display | Not applicable |
Missing support produces a refusal, not a blank screenshot. Reopen the macOS
diff --git a/jarvis/screen_context/intent.py b/jarvis/screen_context/intent.py
index 0005b8327e..4d029f9180 100644
--- a/jarvis/screen_context/intent.py
+++ b/jarvis/screen_context/intent.py
@@ -725,9 +725,9 @@ _CAPTURE_UNAVAILABLE_REPLY: dict[str, dict[str, str]] = {
"action was started."
),
"wayland_portal": (
- "Screen capture is unavailable in this Wayland session. Install and "
- "enable an XDG desktop portal for your compositor, or sign in with "
- "an X11 session, then ask again. No desktop action was started."
+ "Screen capture does not work in a Wayland session yet. Sign in "
+ "with an X11 session, for example GNOME on Xorg, then ask again. "
+ "No desktop action was started."
),
"no_display": (
"I cannot access an interactive display on this device. Sign in to "
@@ -747,10 +747,10 @@ _CAPTURE_UNAVAILABLE_REPLY: dict[str, dict[str, str]] = {
"Desktop-Aktion gestartet." # i18n-allow
),
"wayland_portal": (
- "Die Bildschirmaufnahme ist in dieser Wayland-Sitzung nicht " # i18n-allow
- "verfügbar. Installiere und aktiviere ein XDG-Desktop-Portal für " # i18n-allow
- "deinen Compositor oder melde dich über X11 an und frag noch " # i18n-allow
- "einmal. Es wurde keine Desktop-Aktion gestartet." # i18n-allow
+ "Die Bildschirmaufnahme funktioniert in einer Wayland-Sitzung " # i18n-allow
+ "noch nicht. Melde dich mit einer X11-Sitzung an, zum Beispiel " # i18n-allow
+ "GNOME on Xorg, und frag noch einmal. Es wurde keine " # i18n-allow
+ "Desktop-Aktion gestartet." # i18n-allow
),
"no_display": (
"Ich kann auf diesem Gerät gerade keine interaktive Anzeige " # i18n-allow
@@ -771,10 +771,9 @@ _CAPTURE_UNAVAILABLE_REPLY: dict[str, dict[str, str]] = {
"pedirlo. No se inició ninguna acción de escritorio."
),
"wayland_portal": (
- "La captura de pantalla no está disponible en esta sesión de "
- "Wayland. Instala y activa un portal de escritorio XDG para tu "
- "compositor, o inicia una sesión X11, y vuelve a pedirlo. No se "
- "inició ninguna acción de escritorio."
+ "La captura de pantalla todavía no funciona en una sesión de "
+ "Wayland. Inicia una sesión X11, por ejemplo GNOME on Xorg, y "
+ "vuelve a pedirlo. No se inició ninguna acción de escritorio."
),
"no_display": (
"No puedo acceder a una pantalla interactiva en este dispositivo. "
diff --git a/jarvis/screen_context/ports.py b/jarvis/screen_context/ports.py
index eefb9cfbf8..b554b02125 100644
--- a/jarvis/screen_context/ports.py
+++ b/jarvis/screen_context/ports.py
@@ -26,7 +26,6 @@ the first capture, not at boot.
from __future__ import annotations
import logging
-import os
from collections.abc import Iterator
from contextlib import contextmanager
from dataclasses import dataclass
@@ -421,23 +420,26 @@ class NativeSurfaceCapturer:
)
if native is not None:
return native
- except Exception: # noqa: BLE001 — platform policy below decides fallback
+ except Exception: # noqa: BLE001 — the refusal below is the outcome
log.debug("native window capture failed", exc_info=True)
- if os.name == "nt":
- raise CaptureUnavailable(
- "The focused Windows window could not be captured safely. "
- "A desktop-rectangle fallback was refused because another "
- "window could overlap it. Bring the window to the foreground and "
- "retry; some protected or GPU-rendered windows do not support "
- "window-only capture."
- )
+ # A window handle means "this window ALONE" (the privacy path: a
+ # denylisted window overlaps the rectangle). A desktop-rectangle
+ # grab would photograph exactly that window, so it is refused on
+ # every OS — Linux has no window-only capture at all.
+ raise CaptureUnavailable(
+ "The window could not be captured on its own, and a "
+ "desktop-rectangle fallback was refused because another window "
+ "overlaps it. Bring the window to the foreground or move the "
+ "other window away and retry; some protected or GPU-rendered "
+ "windows do not support window-only capture."
+ )
try:
if _is_wayland():
raise CaptureUnavailable(
- "Screen capture is unavailable in this Wayland session. "
- "Use an X11 session or install a supported desktop-portal "
- "capture backend."
+ "Screen capture does not work in a Wayland session yet. "
+ "Sign in with an X11 session (\"GNOME on Xorg\" or "
+ "\"Plasma (X11)\" on the login screen)."
)
import mss # type: ignore[import-not-found] # noqa: PLC0415
except ImportError as exc:
@@ -533,9 +535,9 @@ def capture_permission_error() -> CapturePermissionIssue | None:
return CapturePermissionIssue(
code="wayland_portal",
message=(
- "Screen capture is unavailable in this Wayland session because "
- "no desktop-portal capture backend is installed. Use an X11 "
- "session or install a supported portal backend, then ask again."
+ "Screen capture does not work in a Wayland session yet. Sign in "
+ "with an X11 session (\"GNOME on Xorg\" or \"Plasma (X11)\" on "
+ "the login screen), then ask again."
),
)
try:
diff --git a/tests/unit/screen_context/test_ports.py b/tests/unit/screen_context/test_ports.py
index 35a212071a..d9f00ae8ca 100644
--- a/tests/unit/screen_context/test_ports.py
+++ b/tests/unit/screen_context/test_ports.py
@@ -2,7 +2,6 @@
from __future__ import annotations
from contextlib import nullcontext
-from types import SimpleNamespace
import pytest
@@ -36,13 +35,20 @@ def test_wayland_permission_probe_is_actionable(
assert issue is not None
assert issue.code == "wayland_portal"
- assert "portal" in issue.message.lower()
+ # The engine has no portal capture path: the honest remedy is an X11 login.
+ assert "X11" in issue.message and "portal" not in issue.message.lower()
-def test_windows_window_capture_never_falls_back_to_desktop_rect(
- monkeypatch: pytest.MonkeyPatch,
[email protected]("platform", ["win32", "darwin", "linux"])
+def test_window_capture_never_falls_back_to_desktop_rect(
+ monkeypatch: pytest.MonkeyPatch, platform: str
) -> None:
- monkeypatch.setattr(ports, "os", SimpleNamespace(name="nt"))
+ """The window-alone path guards a denylisted overlap: a rect grab would show it.
+
+ Linux has no window-only capture, so before this it photographed the
+ denylisted window through the desktop-rectangle fallback.
+ """
+ monkeypatch.setattr("jarvis.platform.window_capture.detect_platform", lambda: platform)
monkeypatch.setattr(ports, "_input_space", nullcontext)
monkeypatch.setattr(
"jarvis.cu.indicator.capture_guard.indicator_suppressed",
diff --git a/tests/unit/screen_context/test_turn.py b/tests/unit/screen_context/test_turn.py
index ff2e14f969..b0c6c990b0 100644
--- a/tests/unit/screen_context/test_turn.py
+++ b/tests/unit/screen_context/test_turn.py
@@ -124,7 +124,7 @@ async def test_technical_unavailability_ends_without_an_action_fallback() -> Non
assert result.diagnostic_detail == "No display available."
-async def test_wayland_unavailability_returns_portal_remediation() -> None:
+async def test_wayland_unavailability_returns_x11_remediation() -> None:
service = FakeService(
outcome(
"refused",
@@ -137,7 +137,9 @@ async def test_wayland_unavailability_returns_portal_remediation() -> None:
result = await screen_context_for_turn("look at this", locale="en", service=service)
assert result.status == "unavailable"
- assert "XDG desktop portal" in (result.message or "")
+ # No portal capture path exists, so the honest remedy is an X11 login.
+ assert "X11 session" in (result.message or "")
+ assert "portal" not in (result.message or "").lower()
assert "No desktop action" in (result.message or "")