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(screen-context): a blank window-only capture falls back to the window's screen rectangle
rubenluetke10-beepb3db0582f724
diff --git a/docs/BUGS.md b/docs/BUGS.mdindex d9850fb564..1fce937f09 100644--- a/docs/BUGS.md+++ b/docs/BUGS.md@@ -15473,3 +15473,21 @@ worktree.the app; the IDE workspaces come back from `last_session.json` via`POST /api/agentic-ide/workspaces/{id}/restore`, each pane resuming its CLIsession.++## BUG-220: "look at my screen" / an appshot of the front window sent the model a black picture (MEDIUM, FIXED 2026-09-29)++**Symptom.** Asking Jarvis to look at the window in front answered as if the+screen were empty; the captured image of the Personal Jarvis window was one+flat dark colour.++**Cause.** Window-scoped captures use the native window-only backend+(`jarvis.platform.window_capture.grab_window`). For some GPU-composited+windows — WebView2 apps, the desktop app itself among them — it returns a+frame that is a single colour (measured: every pixel luma 10) instead of+failing, and the service handed that frame on as a successful capture.++**Fix.** `ScreenContextService._grab` detects a flat frame+(`_is_flat_frame`) or a failed window-only grab and uses the window's screen+rectangle instead, under the rule monitor captures already follow: allowed+with no denylist, refused when a visible denylisted window intersects that+rectangle. Guard: `tests/unit/screen_context/test_blank_window_capture.py`.diff --git a/jarvis/screen_context/service.py b/jarvis/screen_context/service.pyindex 4fa7c8338b..eeb9570b11 100644--- a/jarvis/screen_context/service.py+++ b/jarvis/screen_context/service.py@@ -46,6 +46,7 @@ from jarvis.screen_context.models import (IntentVerdict,ScreenContext,TargetKind,+ TargetReason,VisualIntent,)from jarvis.screen_context.ports import (@@ -520,11 +521,7 @@ class ScreenContextService:message=monitor_privacy_error,)try:- size, rgb = await asyncio.to_thread(- self.capturer.grab,- target.bbox,- window_handle=target.window_handle,- )+ size, rgb = await self._grab(target)except CaptureUnavailable as exc:log.info("screen_context: capture failed — %s", exc)return CaptureOutcome(@@ -627,6 +624,49 @@ class ScreenContextService:finally:await self._dismiss_indicator(trace_id=event_trace_id)+ async def _grab(self, target: CaptureTarget) -> tuple[tuple[int, int], bytes]:+ """Grab the target; rescue a window capture that came back empty.++ Native window-only capture returns a single flat colour for some+ GPU-composited windows (WebView2 apps — Jarvis's own window among+ them — measured 2026-09-29: every pixel luma 10; BUG-220). Handing that to a+ model produces a confident description of a blank screen. When the+ window is in front, the same rectangle of the desktop IS the window,+ so the rect grab is used instead — but only under the rule monitor+ captures already follow: no configured denylist, or no visible window+ in that rectangle matching it.+ """+ handle = target.window_handle+ native_error: CaptureUnavailable | None = None+ try:+ size, rgb = await asyncio.to_thread(+ self.capturer.grab, target.bbox, window_handle=handle+ )+ except CaptureUnavailable as exc:+ if handle is None:+ raise+ native_error, size, rgb = exc, (0, 0), b""+ if handle is None:+ return size, rgb+ if native_error is None and not await asyncio.to_thread(_is_flat_frame, size, rgb):+ return size, rgb+ blocked = await asyncio.to_thread(self._rect_privacy_error, target.bbox)+ if blocked:+ raise CaptureUnavailable(blocked) from native_error+ log.info(+ "screen_context: window-only capture %s — using the window's screen rectangle",+ "failed" if native_error is not None else "came back blank",+ )+ return await asyncio.to_thread(self.capturer.grab, target.bbox, window_handle=None)++ def _rect_privacy_error(self, bbox: tuple[int, int, int, int]) -> str | None:+ """Refuse a desktop-rectangle grab a denylisted window could appear in."""+ if not self._settings.denylist:+ return None+ return self._monitor_privacy_error(+ CaptureTarget(kind=TargetKind.MONITOR, bbox=bbox, reason=TargetReason.FOCUSED_WINDOW)+ )+def _run_shutter_hook(self,target: CaptureTarget,@@ -1107,6 +1147,23 @@ class ScreenContextService:)+def _is_flat_frame(size: tuple[int, int], rgb: bytes) -> bool:+ """True when a frame is one flat colour — a capture that produced nothing.++ A real window always carries some contrast (text, borders, an icon); a+ downscaled frame whose every channel spans at most two levels does not.+ """+ width, height = size+ if width <= 0 or height <= 0 or len(rgb) < width * height * 3:+ return True+ from PIL import Image # noqa: PLC0415++ image = Image.frombytes("RGB", size, rgb)+ factor = max(1, min(width, height) // 64)+ sample = image.reduce(factor) if factor > 1 else image+ return all(high - low <= 2 for low, high in sample.getextrema())++def _safe_target_label(target: CaptureTarget) -> str:"""Metadata-only target label; never expose an app or document title."""if target.kind is TargetKind.WINDOW:diff --git a/tests/unit/screen_context/test_blank_window_capture.py b/tests/unit/screen_context/test_blank_window_capture.pynew file mode 100644index 0000000000..e2b696d740--- /dev/null+++ b/tests/unit/screen_context/test_blank_window_capture.py@@ -0,0 +1,84 @@+"""A window-only capture that comes back as one flat colour is not a picture.++Native window capture returns a uniform frame for some GPU-composited windows+(WebView2 apps, measured 2026-09-29). Handing that to a model yields a+confident description of a blank screen, so the service uses the window's+screen rectangle instead — under the same denylist rule monitor captures obey.+"""++from __future__ import annotations++from jarvis.screen_context.models import IntentVerdict, VisualIntent, WindowFacts+from jarvis.screen_context.service import ScreenContextSettings, _is_flat_frame++from .test_service import FakeCapturer, FakeWindowProbe, make_service+++class VisibleWindows(FakeWindowProbe):+ def __init__(self, visible) -> None:+ super().__init__()+ self._visible = visible++ def visible_windows(self):+ return list(self._visible)+++class BlankWindowCapturer(FakeCapturer):+ """Flat frame for the window-only path, real content for the rectangle."""++ def grab(self, bbox, *, window_handle=None):+ (width, height), _ = super().grab(bbox, window_handle=window_handle)+ if window_handle is not None:+ return (width, height), b"\x0a" * (width * height * 3)+ stripes = bytes(((x // 8) % 2) * 255 for x in range(width)) * height+ return (width, height), bytes(v for v in stripes for _ in range(3))+++WINDOW = IntentVerdict(intent=VisualIntent.WINDOW)+++def test_flat_frame_detection() -> None:+ assert _is_flat_frame((4, 4), b"\x0a" * 48)+ assert not _is_flat_frame((4, 1), b"\x00\x00\x00\xff\xff\xff" * 2)+ assert _is_flat_frame((0, 0), b"")+++async def test_a_blank_window_capture_falls_back_to_its_rectangle() -> None:+ capturer = BlankWindowCapturer()+ service = make_service(capturer=capturer)++ outcome = await service.capture(verdict=WINDOW)++ assert outcome.status == "captured"+ assert [handle for _bbox, handle in capturer.grabs] == [7, None]+ assert capturer.grabs[0][0] == capturer.grabs[1][0], "same rectangle both times"+++async def test_the_fallback_obeys_the_denylist() -> None:+ capturer = BlankWindowCapturer()+ service = make_service(+ capturer=capturer,+ settings=ScreenContextSettings(denylist=("vault",)),+ window_probe=VisibleWindows(+ [WindowFacts(app_name="Vault", title="secrets", frame_rect=(10, 10, 800, 600))]+ ),+ )++ outcome = await service.capture(verdict=WINDOW)++ assert outcome.status == "refused"+ assert [handle for _bbox, handle in capturer.grabs] == [7], "no desktop rectangle grab"+++async def test_a_window_with_content_is_used_as_captured() -> None:+ class ContentCapturer(BlankWindowCapturer):+ def grab(self, bbox, *, window_handle=None):+ return super().grab(bbox, window_handle=None)++ capturer = ContentCapturer()+ service = make_service(capturer=capturer)++ outcome = await service.capture(verdict=WINDOW)++ assert outcome.status == "captured"+ assert len(capturer.grabs) == 1