Agent Zero AI framework
Treat bare desktop canvas as ready
Alessandro854a96e88046
diff --git a/plugins/_desktop/helpers/desktop_state.py b/plugins/_desktop/helpers/desktop_state.pyindex bceb938f2..10225bbca 100644--- a/plugins/_desktop/helpers/desktop_state.py+++ b/plugins/_desktop/helpers/desktop_state.py@@ -372,7 +372,6 @@ def collect_active_window(env: dict[str, str], capabilities: dict[str, str], errreturn Noneresult = run([capabilities["xdotool"], "getactivewindow"], env=env, timeout=3)if result.returncode != 0:- errors.append(command_output(result) or "xdotool could not read the active window.")return Nonewindow_id = result.stdout.strip().splitlines()[0] if result.stdout.strip() else ""if not window_id:diff --git a/plugins/_desktop/skills/linux-desktop/SKILL.md b/plugins/_desktop/skills/linux-desktop/SKILL.mdindex 526c65d8a..6b4717cba 100644--- a/plugins/_desktop/skills/linux-desktop/SKILL.md+++ b/plugins/_desktop/skills/linux-desktop/SKILL.md@@ -60,6 +60,8 @@ $DESKTOP key ctrl+sThe script targets the persistent `agent-zero-desktop` X display, sets `DISPLAY`, `XAUTHORITY`, and `HOME` to the XFCE profile, then uses `xdotool` for input. Startup normally prepares this session. If `check` fails during explicit Desktop work, report that the Desktop runtime is not ready instead of installing packages ad hoc.+If `observe --json --screenshot` shows a reachable display, visible Desktop/window entries, and a fresh screenshot, the Desktop is usable even when `active_window` is `null`; a bare XFCE desktop can have no active application window. Treat missing screenshots, missing display, or unavailable `xdotool`/`xwd` as blockers and stop with the specific readiness message instead of repeating clicks or inventing a fallback.+For direct app launches without coordinates:```bashdiff --git a/tests/test_office_desktop_state.py b/tests/test_office_desktop_state.pyindex 482f54d51..b9139a227 100644--- a/tests/test_office_desktop_state.py+++ b/tests/test_office_desktop_state.py@@ -92,6 +92,61 @@ def test_desktop_state_collects_x11_state_from_mocked_tools(tmp_path, monkeypatcassert [window["title"] for window in state["windows"]] == ["LibreOffice Calc", "Terminal"]+def test_desktop_state_allows_missing_active_window_when_display_is_reachable(tmp_path, monkeypatch):+ session_dir = tmp_path / "sessions"+ profile_dir = tmp_path / "profiles" / desktop_state.SESSION_ID+ session_dir.mkdir(parents=True)+ profile_dir.mkdir(parents=True)+ (session_dir / f"{desktop_state.SESSION_ID}.json").write_text(+ '{"display": 120, "profile_dir": "%s"}' % profile_dir,+ encoding="utf-8",+ )++ monkeypatch.setattr(desktop_state, "SESSION_DIR", session_dir)+ monkeypatch.setattr(desktop_state, "PROFILE_DIR", tmp_path / "profiles")+ monkeypatch.setattr(desktop_state.shutil, "which", lambda name: f"/usr/bin/{name}")++ def fake_run(command, **kwargs):+ del kwargs+ name = Path(command[0]).name+ if name == "xrandr":+ return _completed(command, stdout="Screen 0: current 543 x 792, maximum 1920 x 1080\n")+ if name == "xdotool" and command[1:3] == ["getmouselocation", "--shell"]:+ return _completed(command, stdout="X=43\nY=244\nSCREEN=0\nWINDOW=18874412\n")+ if name == "xdotool" and command[1] == "getactivewindow":+ return _completed(+ command,+ returncode=1,+ stderr="XGetWindowProperty[_NET_ACTIVE_WINDOW] failed (code=1)\n",+ )+ if name == "xdotool" and command[1] == "search":+ return _completed(command, stdout="18874412\n")+ if name == "xdotool" and command[1] == "getwindowname":+ return _completed(command, stdout="Desktop\n")+ if name == "xwininfo":+ return _completed(+ command,+ stdout=(+ " Absolute upper-left X: 0\n"+ " Absolute upper-left Y: 0\n"+ " Width: 543\n"+ " Height: 792\n"+ ),+ )+ if name == "xprop":+ return _completed(command, stdout='WM_CLASS(STRING) = "xfdesktop", "Xfdesktop"\n')+ raise AssertionError(f"unexpected command: {command}")++ monkeypatch.setattr(desktop_state.subprocess, "run", fake_run)++ state = desktop_state.collect_state()++ assert state["ok"] is True+ assert state["active_window"] is None+ assert state["errors"] == []+ assert [window["title"] for window in state["windows"]] == ["Desktop"]++def test_desktop_state_screenshot_capture_uses_xwd_and_pillow_when_available(tmp_path, monkeypatch):monkeypatch.setattr(desktop_state, "SCREENSHOT_DIR", tmp_path)capabilities = {"xwd": "/usr/bin/xwd"}