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): play the shutter flash and sound when the live model looks
rubenluetke10-beep3ed00460335f
diff --git a/jarvis/plugins/tool/live_screen.py b/jarvis/plugins/tool/live_screen.pyindex 18434ed162..41d4013525 100644--- a/jarvis/plugins/tool/live_screen.py+++ b/jarvis/plugins/tool/live_screen.py@@ -1,4 +1,9 @@-"""An explicitly requested, privacy-filtered frame for a live vision model."""+"""An explicitly requested, privacy-filtered frame for a live vision model.++The capture runs through the shared Screen Context service, so the user sees+and hears it like every other look: the appshot shutter flash, the+click-clack, and a receipt in the Appshots history.+"""from __future__ import annotations@@ -15,26 +20,27 @@ class LiveScreenTool:async def execute(self, args, ctx):import base64- from jarvis.core.config import load_config+ from jarvis.appshot.service import record_turn_capturefrom jarvis.core.protocols import ToolResult- from jarvis.screen_context.service import ScreenContextService, settings_from_config+ from jarvis.plugins.tool.appshot import _app_bus+ from jarvis.screen_context.turn import get_service- service = ScreenContextService(settings=settings_from_config(load_config()))- try:- outcome = await service.capture(trace_id=ctx.trace_id)- image = service.consume(outcome.handle_id) if outcome.handle_id else None- if image is None:- return ToolResult(False, None, outcome.message or "Screen capture unavailable.")- return ToolResult(- True,- {- "description": image.describe(),- "ui_text": image.ui_text,- "_image": {- "mime": image.mime,- "data": base64.b64encode(image.image).decode("ascii"),- },+ del args+ bus = _app_bus()+ service = get_service(bus=bus)+ outcome = await service.capture(trace_id=ctx.trace_id)+ image = service.consume(outcome.handle_id) if outcome.handle_id else None+ if image is None:+ return ToolResult(False, None, outcome.message or "Screen capture unavailable.")+ await record_turn_capture(image, bus=bus, trigger="tool")+ return ToolResult(+ True,+ {+ "description": image.describe(),+ "ui_text": image.ui_text,+ "_image": {+ "mime": image.mime,+ "data": base64.b64encode(image.image).decode("ascii"),},- )- finally:- service.close()+ },+ )diff --git a/tests/unit/appshot/test_live_screen_tool.py b/tests/unit/appshot/test_live_screen_tool.pynew file mode 100644index 0000000000..b69446af3e--- /dev/null+++ b/tests/unit/appshot/test_live_screen_tool.py@@ -0,0 +1,141 @@+"""The live model's ``screen_snapshot`` is an appshot to the user.++It must take its picture through the shared Screen Context service — the one+that carries the shutter flash and publishes the receipt that plays the+click-clack — and record the look in the Appshots history.+"""++from __future__ import annotations++import base64+import uuid+from types import SimpleNamespace++import pytest++from jarvis.appshot import service as appshot_service+from jarvis.appshot.store import get_store+from jarvis.plugins.tool.live_screen import LiveScreenTool+from jarvis.screen_context.models import (+ CaptureTarget,+ IntentVerdict,+ ScreenContext,+ TargetKind,+ TargetReason,+ VisualIntent,+)+from jarvis.screen_context.service import CaptureOutcome+++def make_context() -> ScreenContext:+ return ScreenContext(+ image=b"jpeg-bytes",+ mime="image/jpeg",+ size=(1280, 720),+ target=CaptureTarget(+ kind=TargetKind.MONITOR,+ bbox=(0, 0, 1280, 720),+ reason=TargetReason.CURSOR_MONITOR,+ monitor_name="Main",+ ),+ ui_text="OpenAI console",+ captured_at_ns=1,+ )+++class SharedService:+ def __init__(self, outcome: CaptureOutcome) -> None:+ self.outcome = outcome+ self.handles = {"h1": outcome.context} if outcome.context else {}+ self.closed = False++ async def capture(self, *, verdict=None, trace_id=None):+ return self.outcome++ def consume(self, handle_id):+ return self.handles.pop(handle_id, None)++ def close(self) -> int:+ self.closed = True+ return 0+++class Bus:+ def __init__(self) -> None:+ self.events: list = []++ async def publish(self, event) -> None:+ self.events.append(event)+++class Config:+ class screen_context: # noqa: N801 - mirrors the config attribute+ deck_preview_s = 120.0+++def wired(monkeypatch):+ import jarvis.plugins.tool.appshot as appshot_tool+ import jarvis.screen_context.turn as turn++ bus = Bus()+ asked: list = []+ holder: dict = {}++ def get_service(bus=None):+ asked.append(bus)+ return holder["service"]++ monkeypatch.setattr(turn, "get_service", get_service)+ monkeypatch.setattr(appshot_tool, "_app_bus", lambda: bus)+ monkeypatch.setattr(appshot_service, "_load_config", lambda: Config())+ get_store().clear()+ yield holder, bus, asked+ get_store().clear()+++def _ctx():+ return SimpleNamespace(trace_id=uuid.uuid4())+++async def test_snapshot_uses_the_shared_service_and_records_an_appshot(wired) -> None:+ holder, bus, asked = wired+ service = SharedService(+ CaptureOutcome(+ status="captured",+ verdict=IntentVerdict(intent=VisualIntent.SCREEN),+ context=make_context(),+ handle_id="h1",+ )+ )+ holder["service"] = service++ result = await LiveScreenTool().execute({}, _ctx())++ assert result.success+ assert base64.b64decode(result.output["_image"]["data"]) == b"jpeg-bytes"+ assert asked == [bus], "the shared service gets the app bus, so the sound plays"+ assert not service.closed, "the shared service outlives one tool call"+ assert service.handles == {}, "the capture handle is consumed at once"+ receipt = bus.events[-1]+ assert receipt.trigger == "tool" and receipt.delivered_to == "turn"+ assert get_store().latest().trigger == "tool"+++async def test_a_refused_snapshot_records_nothing(wired) -> None:+ holder, bus, _asked = wired+ holder["service"] = SharedService(+ CaptureOutcome(+ status="refused",+ verdict=IntentVerdict(intent=VisualIntent.SCREEN),+ reason_kind="policy",+ message="Screen context is switched off.",+ )+ )++ result = await LiveScreenTool().execute({}, _ctx())++ assert not result.success+ assert result.error == "Screen context is switched off."+ assert bus.events == []+ assert get_store().latest() is None