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
feat(cu): element-anchored clicks + verified-miss zoom refine
Ruben Lütke45204a9ebdb4
diff --git a/jarvis/cu/verify.py b/jarvis/cu/verify.pyindex f3b3e80476..93590c027a 100644--- a/jarvis/cu/verify.py+++ b/jarvis/cu/verify.py@@ -181,7 +181,9 @@ def clickable_labels(nodes: tuple, max_n: int = 28) -> list[str]:return names-def clickable_rects(nodes: tuple, max_n: int = 200) -> list[tuple[str, str, tuple[int, int, int, int]]]:+def clickable_rects(+ nodes: tuple, max_n: int = 200,+) -> list[tuple[str, str, tuple[int, int, int, int]]]:"""Enabled clickable elements WITH their bounding rects, as``(name, role, (x, y, w, h))`` in screen input units.diff --git a/tests/unit/cu/test_conventions_ledger_verify.py b/tests/unit/cu/test_conventions_ledger_verify.pyindex 5be6ab45c4..75e98becd7 100644--- a/tests/unit/cu/test_conventions_ledger_verify.py+++ b/tests/unit/cu/test_conventions_ledger_verify.py@@ -224,6 +224,44 @@ def test_clickable_labels_filters_roles_and_dedupes():assert clickable_labels(nodes) == ["OK", "File"]+def test_snap_point_to_element_smallest_containing_rect_wins():+ from jarvis.cu.verify import snap_point_to_element++ clickables = [+ ("Panel", "Button", (0, 0, 800, 600)), # container-sized: capped+ ("Row", "ListItem", (100, 100, 400, 40)),+ ("Star", "Button", (480, 110, 24, 24)), # smallest leaf+ ]+ # Point inside BOTH the row and the star -> the star's center wins.+ hit = snap_point_to_element(490, 120, clickables, capture_area=1920 * 1080)+ assert hit == (492, 122, "Star")+ # Point only inside the row -> row center.+ hit = snap_point_to_element(150, 120, clickables, capture_area=1920 * 1080)+ assert hit == (300, 120, "Row")+ # Point in dead space -> no snap.+ assert snap_point_to_element(700, 500, clickables, capture_area=1920 * 1080) is None+ # Container trap: the panel is > 15% of a small capture -> never snaps.+ assert snap_point_to_element(700, 500, [("Panel", "Button", (0, 0, 800, 600))],+ capture_area=800 * 600) is None+++def test_clickable_rects_keeps_nameless_elements_and_valid_bounds():+ from jarvis.cu.verify import clickable_rects++ nodes = (+ _node(role="Button", name="", enabled=True, bounds=(10, 10, 30, 20)),+ _node(role="Button", name="Zero", bounds=(0, 0, 0, 0)), # degenerate+ _node(role="Slider", name="Vol", bounds=(5, 5, 50, 10)), # not clickable role+ _node(role="MenuItem", name="File", bounds=(50, 0, 40, 18)),+ _node(role="Button", name="Off", enabled=False, bounds=(1, 1, 5, 5)),+ )+ rects = clickable_rects(nodes)+ assert ("", "Button", (10, 10, 30, 20)) in rects+ assert ("File", "MenuItem", (50, 0, 40, 18)) in rects+ assert all(name != "Zero" for name, _, _ in rects)+ assert all(name != "Off" for name, _, _ in rects)++def test_regions_equal_tristate():a = ((4, 4), b"\x01" * 48)b = ((4, 4), b"\x01" * 48)diff --git a/tests/unit/cu/test_engine_loop.py b/tests/unit/cu/test_engine_loop.pyindex 4f928360fd..5d8cc62dc7 100644--- a/tests/unit/cu/test_engine_loop.py+++ b/tests/unit/cu/test_engine_loop.py@@ -89,6 +89,7 @@ def patched(monkeypatch, tmp_path):typed_lands=True,region_changes_after_click=True,clicks_seen=0,+ clickables=[],)def fake_select_capture_target(@@ -114,7 +115,7 @@ def patched(monkeypatch, tmp_path):return _solid(state.screen_shade)async def fake_snapshot(*a, **kw):- return [], "", None+ return [], "", None, state.clickablesasync def fake_verify_typed(text):return state.typed_lands@@ -232,6 +233,7 @@ async def test_missed_click_no_visible_change_is_reported_as_failure(patched):patched.region_changes_after_click = False # click voids: nothing changesbrain = FakeBrain(['{"action": "click", "x": 500, "y": 500, "target": "button"}',+ '{"found": false}', # the zoom-refine probe finds nothing either'{"action": "fail", "reason": "the button does not react"}',])executor = FakeExecutor()@@ -288,9 +290,59 @@ async def test_tool_failures_exhaust_consecutive_budget(patched):assert final.exit_code in (5, 8)+async def test_click_is_anchored_to_containing_element_center(patched):+ # Model points a few px off inside a small button whose center is+ # (145, 87): the dispatched click must hit the CENTER, not the estimate.+ patched.clickables = [("Send", "Button", (130, 80, 30, 14))]+ brain = FakeBrain([+ # norm (740, 787) on the 192x108 monitor -> raw point (142, 85).+ '{"action": "click", "x": 740, "y": 787, "target": "Send"}',+ '{"action": "done", "reason": "sent"}',+ '{"done": true, "proof": "the message shows as sent"}',+ ])+ executor = FakeExecutor()+ chunks = await _run(_ctx(brain, executor))+ assert _final(chunks).exit_code == 0+ clicks = [args for (name, args) in executor.calls if name == "click"]+ assert clicks and (clicks[0]["x"], clicks[0]["y"]) == (145, 87)+++async def test_container_sized_elements_never_snap(patched):+ # A rect covering most of the capture is a container — the raw point+ # must be kept.+ patched.clickables = [("Body", "Text", (0, 0, 190, 100))]+ brain = FakeBrain([+ '{"action": "click", "x": 500, "y": 500, "target": "middle"}',+ '{"action": "done", "reason": "ok"}',+ '{"done": true, "proof": "clicked"}',+ ])+ executor = FakeExecutor()+ chunks = await _run(_ctx(brain, executor))+ assert _final(chunks).exit_code == 0+ clicks = [args for (name, args) in executor.calls if name == "click"]+ assert clicks and (clicks[0]["x"], clicks[0]["y"]) == (96, 54)+++async def test_verified_miss_triggers_one_zoom_refined_retry(patched):+ patched.region_changes_after_click = False # every click: no visible change+ brain = FakeBrain([+ '{"action": "click", "x": 500, "y": 500, "target": "tiny icon"}',+ # The zoom-refine call answers with a corrected in-crop position.+ '{"found": true, "x": 900, "y": 900}',+ '{"action": "fail", "reason": "the icon does not react"}',+ ])+ executor = FakeExecutor()+ chunks = await _run(_ctx(brain, executor))+ final = _final(chunks)+ assert final.exit_code == 5+ clicks = [args for (name, args) in executor.calls if name == "click"]+ assert len(clicks) == 2, "exactly one refined retry after the verified miss"+ assert (clicks[1]["x"], clicks[1]["y"]) != (clicks[0]["x"], clicks[0]["y"])++async def test_handoff_screen_fails_fast_with_speakable_reason(patched, monkeypatch):async def snapshot_with_captcha(*a, **kw):- return [], "", "captcha challenge"+ return [], "", "captcha challenge", []monkeypatch.setattr(engine_mod, "foreground_ui_snapshot", snapshot_with_captcha)brain = FakeBrain([])