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: harden screen context intent policy

Ruben Lütke944f52b08864
diff --git a/jarvis/screen_context/intent.py b/jarvis/screen_context/intent.py
index ebe261ea87..587f923f70 100644
--- a/jarvis/screen_context/intent.py
+++ b/jarvis/screen_context/intent.py
@@ -151,6 +151,8 @@ _SCREEN_INTENT_RE: re.Pattern[str] = re.compile(
# screen nouns with a possessive/demonstrative
r"|\b(?:on|at)\s+(?:my|the|this)\s+screen\b|\bmy\s+screen\b"
r"|\bwhat(?:'|)s\s+on\s+(?:my|the)\s+screen\b"
+ r"|\b(?:take|make|capture|grab)\s+(?:a\s+)?screen(?:shot|\s+capture)\b"
+ r"|\bscreen(?:shot|\s+capture)\s+(?:this|that|my\s+screen|the\s+screen)\b"
r"|\b(?:this|that)\s+(?:error|error\s+message|message|button|menu|popup)\b"
# read-out requests
r"|\bwhat\s+does\s+(?:it|this|that|the\s+\w+)\s+say\b"
@@ -171,6 +173,8 @@ _SCREEN_INTENT_RE: re.Pattern[str] = re.compile(
r"|\bwas\s+siehst\s+du\b"
# screen nouns
r"|\bauf\s+(?:dem|meinem)\s+bildschirm\b|\bam\s+bildschirm\b|\bmein\s+bildschirm\b"
+ r"|\b(?:mach|mache|erstelle|nimm)\s+(?:bitte\s+)?(?:einen\s+)?screenshot\b" # i18n-allow: DE input
+ r"|\bbildschirmfoto\s+(?:machen|aufnehmen|erstellen)\b" # i18n-allow: DE input
r"|\bauf\s+dem\s+schirm\b|\bhier\s+auf\s+dem\b" # i18n-allow: DE input
r"|\b(?:diese|die)\s+fehlermeldung\b" # i18n-allow: DE input
r"|\b(?:dieser|der)\s+fehler\s+(?:hier|da)\b" # i18n-allow: DE input
@@ -186,6 +190,7 @@ _SCREEN_INTENT_RE: re.Pattern[str] = re.compile(
r"|\bpuedes\s+ver\s+(?:esto|eso|mi\s+pantalla|la\s+pantalla)\b"
r"|\bves\s+(?:esto|eso|mi\s+pantalla)\b|\bque\s+ves\b"
r"|\ben\s+(?:mi|la)\s+pantalla\b|\bmi\s+pantalla\b"
+ r"|\b(?:haz|toma|captura)\s+(?:una\s+)?captura\s+de\s+pantalla\b"
r"|\bque\s+dice\s+(?:ahi|aqui|esto|eso)\b"
r"|\blee\s+(?:esto|eso|el\s+\w+)\b"
r"|\beste\s+error\b|\besta\s+ventana\s+de\s+error\b"
diff --git a/jarvis/screen_context/service.py b/jarvis/screen_context/service.py
index 31a4d57461..f7cfcdac66 100644
--- a/jarvis/screen_context/service.py
+++ b/jarvis/screen_context/service.py
@@ -244,6 +244,12 @@ class ScreenContextService:
else self.classify(text, locale=locale)
)
+ # A disabled feature is a policy refusal only when the user actually
+ # asked for it. Ordinary conversation must remain a no-op; checking the
+ # switch first would make disabling Screen Context block every turn.
+ if verdict.intent is VisualIntent.NONE:
+ return CaptureOutcome(status="not_requested", verdict=verdict)
+
if not self._settings.enabled:
return CaptureOutcome(
status="refused",
@@ -255,9 +261,6 @@ class ScreenContextService:
),
)
- if verdict.intent is VisualIntent.NONE:
- return CaptureOutcome(status="not_requested", verdict=verdict)
-
if verdict.intent is VisualIntent.AMBIGUOUS:
log.info(
"screen_context: ambiguous visual intent (evidence=%s) — asking "
diff --git a/tests/unit/screen_context/test_intent.py b/tests/unit/screen_context/test_intent.py
index a3edc3e9ab..87cdcceec3 100644
--- a/tests/unit/screen_context/test_intent.py
+++ b/tests/unit/screen_context/test_intent.py
@@ -33,6 +33,7 @@ from jarvis.screen_context.models import VisualIntent
"read this out to me",
"what's on my screen?",
"check this out",
+ "take a screenshot",
# -- German (the two phrasings the feature is specified around)
"Kannst du mal sehen?",
"Schau dir das an",
@@ -42,11 +43,13 @@ from jarvis.screen_context.models import VisualIntent
"was steht da?",
"lies mir das vor",
"auf dem Bildschirm ist eine Fehlermeldung", # i18n-allow: DE input
+ "mach einen Screenshot", # i18n-allow: DE input
# -- Spanish
"mira esto",
"puedes ver esto?",
"que dice ahi?",
"echa un vistazo",
+ "haz una captura de pantalla",
],
)
def test_unambiguous_requests_capture(utterance: str) -> None:
diff --git a/tests/unit/screen_context/test_service.py b/tests/unit/screen_context/test_service.py
index 3ee92967d5..25f541cbac 100644
--- a/tests/unit/screen_context/test_service.py
+++ b/tests/unit/screen_context/test_service.py
@@ -280,6 +280,13 @@ async def test_disabled_feature_refuses_honestly() -> None:
assert "off" in (outcome.message or "").lower()
+async def test_disabled_feature_leaves_ordinary_turns_alone() -> None:
+ """The opt-out disables captures, not the rest of the assistant."""
+ service = make_service(settings=ScreenContextSettings(enabled=False))
+ outcome = await service.capture_for_turn("tell me a joke", locale="en")
+ assert outcome.status == "not_requested"
+
+
async def test_headless_host_refuses_with_an_explanation() -> None:
service = make_service(displays=FakeDisplays([]))
outcome = await service.capture_for_turn("look at this", locale="en")