The agent can inject keyboard and mouse events into the guest and send back a screenshot. That turns "the model ran a command and got a return code" into "the model clicked the thing and looked at what happened", which is the difference between testing a program and testing a user interface.
Both agents support it: ATCPGUI and ATCPBIN. The headless one needs no window
of its own to photograph the screen, so nothing is lost by running without the
GUI.
python3 host/spike_server.py submit \
--ui-capture shot.png # guest picks a scale that fits
--ui-capture big.png,2 # or name one
--ui-move 400,300 # absolute pointer move
--ui-click l,400,300 # move, press, release
--ui-click r # right-click where the pointer already is
--ui-rawkey 0x45 # ESC down
--ui-rawkey 0x45,up # ESC upspike_control.py takes the same flags if you prefer the one-shot server.
Events go to input.device via IND_ADDEVENT, which is the path real hardware
takes. Intuition routes them normally: focus, qualifiers and click-to-front all
behave as they would with a physical keyboard.
The alternative — posting IntuiMessages onto a specific window's UserPort,
which is what AROS's own test utilities do — reaches exactly one window and
bypasses that machinery. It was rejected for this reason.
--ui-rawkey takes an AROS raw key code. 0x45 is ESC; 0x44 is RETURN.
It is not 'A', and there is no translation table on the host — a raw code is
unambiguous, whereas a character depends on the guest's keymap.
A keypress is two events. --ui-rawkey 0x45 sends the down; add ,up for the
release. --ui-click sends both halves for you.
A single ui_input frame carries the whole array and is delivered with one
DoIO, so a move-then-click arrives as one sequence rather than three that the
guest might interleave with other input. Up to 32 events per frame.
--ui-capture FILE[,scale] writes a PNG of the active Intuition screen.
Scale exists because of a hard limit. A frame cannot exceed 2 MiB, and RGB24 base64-encodes to 4/3 of its size:
| Screen | Raw | Base64 | Fits? |
|---|---|---|---|
| 640×480 | 900 KB | 1.2 MB | yes at scale 1 |
| 800×600 | 1.4 MB | 1.9 MB | just barely at scale 1 |
| 1024×768 | 2.3 MB | 3.1 MB | no — needs scale 2 |
Omit scale (or pass 0) and the guest measures its own screen and picks the
smallest factor that fits, reporting back which it used. That is the right
default: on a 1024×768 guest a hardcoded scale 1 fails every time, and the
error is easy to mistake for a broken feature.
An explicit scale that cannot fit is refused with
screen too large at this scale, retry with a higher scale — a refusal, not a
crash, and the job continues.
At scale 2 a 1024×768 screen arrives as 512×384. That is plenty to assert a window opened or a colour changed, and not enough to read small text. If you need legible text, capture a smaller screen mode rather than a larger frame.
Downscaling takes every Nth pixel rather than averaging. A box filter would look nicer and would blend a probe pixel with its neighbours — which is exactly the assertion a test is usually making. Sharp and honest beats smooth here.
The host writes PNGs with Pillow when it is installed and falls back to a
stdlib zlib encoder otherwise. The fallback is the reference implementation, not
an afterthought: tests/test_ui_capture.py decodes what it produced and asserts
it matches Pillow's output pixel for pixel.
Requests and replies use the same framing as everything else:
[4-byte LE length][JSON].
{"type":"ui_input","id":7,"events":[
{"class":"pointerpos","x":400,"y":300},
{"class":"rawmouse","code":104,"up":false},
{"class":"rawmouse","code":104,"up":true}
]}
{"id":7,"type":"result","ok":true,"injected":3}{"type":"ui_capture","id":8,"scale":0}
{"id":8,"type":"result","ok":true,"width":512,"height":384,
"bpp":3,"scale":2,"data":"<base64 RGB24>"}Replies use the ordinary result envelope rather than a bespoke type, so
anything that already understands the transport understands these.
Event classes: rawkey (code, up, qualifier), rawmouse (code, up,
x/y as a relative delta), pointerpos (x, y absolute).
Mouse codes are IECODE_*: left 0x68, right 0x69, middle 0x6A.
This is what you hand a coding agent (opencode, Claude Code, Cursor) to get it
testing a GUI on its own. It assumes AGENTS.md is in place — that file already
teaches the model the build-and-test loop, so the prompt only has to say what to
test and what counts as passing.
Test the AROS GUI app in
src/myapp.con the guest, end to end, without me in the loop.
- Cross-compile it and
--putit toRAM:MYAPP.--exec 'run RAM:MYAPP'so it starts without blocking the job, then--ui-capture /tmp/01-opened.png.- Assert from that PNG that the window actually opened: decode it and check the region you expect the window in is not the same colour as the desktop background. Do not treat "the file exists" as a pass.
- Click its OK button with
--ui-click l,X,Y— find X,Y by looking at the capture, remembering the image is downscaled, so multiply back up by thescalethe guest reported.--ui-capture /tmp/02-clicked.pngand assert the window is gone.- Press ESC (
--ui-rawkey 0x45then--ui-rawkey 0x45,up) and capture again to confirm nothing reopened.Pass
--exec-timeout 120on every job. Report each step as PASS or FAIL with the pixel evidence you used, and if a step fails, stop and tell me which one rather than continuing to the next.
The parts that make it work, and that are worth keeping when you adapt it:
runbefore capture. A foreground GUI program does not return until it exits, so a plain--execblocks the job before anything can be photographed. This is the one context where detachedrunis the right call.- Naming the assertion. "Check the window opened" gets you a screenshot and a confident sentence. "Check the region is not the background colour" gets you a test. Models will accept a valid PNG of a blank screen as success unless you close that door explicitly.
- Reminding it about
scale. Coordinates for--ui-clickare in screen space; the capture it just looked at is not. This is the most common mistake. - Numbered steps with captures between them. Keeping every intermediate PNG means a failure is diagnosable afterwards rather than only reproducible.
- "Stop on failure." Otherwise it clicks where a button would have been and reports on a screen that has nothing to do with the test.
For a working end-to-end version of exactly this shape, see host/ui_smoke.sh
and host/ui_probe.py in the drop.
"Does everything in Contrib still open a window" is a different problem from
testing one app, and hand-driving the flags does not scale to it: a few hundred
apps is a few hundred prompts, and a model asked to repeat a procedure that many
times drifts from it. host/ui_sweep.py is the loop, so the model supplies the
list and reads the report instead of re-deriving the procedure each time.
python3 host/ui_sweep.py --list-dir SYS:Contrib --out /tmp/sweep # enumerate
python3 host/ui_sweep.py --apps /tmp/sweep/apps.txt --out /tmp/sweepPer app: capture a baseline, run the app detached, settle, capture, compare,
try to close it, capture again and confirm the screen came back. Verdicts are
OPENED, NO-WINDOW or DIRTY, written to report.md and report.json
alongside three PNGs per app.
Sweep with the headless agent (ATCPBIN). This is not a preference. With
ATCPGUI on screen its own window repaints as the sweep works — counters,
session timer, a history pane gaining a line per frame — and it sits in the
middle of the screen, which is where app windows open. The sweep measures that
churn first and masks it, so the parts of the screen the agent occupies stop
being watched: a real run of SYS:Utilities/Clock came back NO-WINDOW
because Clock had opened inside the mask. The headless agent draws nothing.
Five things about it are worth knowing before you trust the output:
- The baseline is per app, taken moments before. Not a golden image: a clock in a title bar, the pointer sitting somewhere else, or a leftover window all change the screen without meaning anything.
DIRTYhalts the sweep by default. An app that will not close is still on screen when the next baseline is taken, so every verdict after it is measured against a contaminated screen. A hundred results computed after that point are not results. Close it by hand or reboot the guest, then--start Nto resume.--list-dirwrites a file for you to review, and does not sweep it. A directory listing is full of data files, libraries and drawers; launching those costs an hour and muddies the report.- The churn mask is measured with a job running, not idle. Idle, the agent sends nothing and its window does not move, so an idle baseline masks nothing and the pollution arrives later looking exactly like a window opening.
- Closing is best-effort and cannot be otherwise. The agent injects
hardware-level events; what closes a window is whatever that program listens
for. The sweep tries ESC, then the close gadget at the top-left of whatever
appeared. Anything else is
DIRTY— correctly, because it is.
Budget roughly 13 s per app (four captures at ~1.7 s plus two settles), so about 20 minutes per hundred.
Sweep every GUI app in
SYS:Contribon the guest and tell me which ones no longer open.
python3 host/ui_sweep.py --list-dir SYS:Contrib --out /tmp/sweepto enumerate, then edit/tmp/sweep/apps.txt— drop anything that is not an executable GUI program (libraries, data files, drawers, CLI tools). Show me the list you settled on before you start.- Run the sweep against that file.
- If it halts on
DIRTY, tell me which app and stop — do not--startpast it without me, because the app is still on screen and everything after it would be measured against its window.- When it finishes, read
report.mdand give me theNO-WINDOWlist. For each one, look at its-1-open.pngand its launch log and say whether it failed to start, started without a window, or opened something too small to trip the threshold.Do not re-run the whole sweep to re-check a single app; run that one app on its own with a one-line
--appsfile.
The last two steps are the ones that matter. A sweep produces a verdict per app,
not a diagnosis — NO-WINDOW covers "crashed on launch", "is a CLI tool", and
"opened a 40×20 window", and only the captures and the launch log separate them.
Asking for the diagnosis explicitly is what turns a table into a bug report.
A capture takes about 1.7 s. Most of that is the reply draining through the socket in 20 ms waits. It is deliberate: an earlier version pushed harder and wedged the agent, and one of the attempted fixes froze the whole VM. If capture throughput ever matters, the lever is chunking the reply, not shortening the wait.
Capture reads the screen after presentation. An application that renders into a back buffer has to actually present before its frame is visible to a capture. That is expected, not a bug.
The screenshot is of the active screen, so whatever is frontmost is what you get.