simvx.ide.playtest¶
IDE playtest harness – headless IDE testing with screenshots and input simulation.
Launches the IDE off-screen using App.run_headless(), captures screenshots to PNG, and provides the widget tree as text so an LLM can read widget positions and compose Click/TypeText/PressKey steps to interact with the IDE.
Usage (from Claude Code)::
# 1. Capture a screenshot of the IDE at rest
uv run python -c "
from simvx.ide.playtest import ide_screenshot
path, tree = ide_screenshot(frames=90)
print(tree)
"
# Then: Read /tmp/ide_test/screenshot.png to see it
# 2. Run a scripted interaction
uv run python -c "
from simvx.ide.playtest import ide_run
from simvx.core.scripted_demo import Click, TypeText, PressKey, Wait
from simvx.core.input.enums import Key
report = ide_run([
Wait(0.5),
Click(700, 450), # click in editor area
TypeText('hello world'),
])
print(report)
"
Module Contents¶
Functions¶
Launch the IDE headlessly, render frames frames, save a screenshot. |
|
Run a scripted interaction against the IDE and return a text report. |
|
Parse a ui_describe() tree and return the rect of the first widget matching name. |
|
Return the centre point of a widget found by name in a ui_describe() tree. |
Data¶
API¶
- simvx.ide.playtest.ide_screenshot(*, project_dir: str | None = None, frames: int = 90, width: int = 1400, height: int = 900, output_dir: str | pathlib.Path | None = None) tuple[str, str][source]¶
Launch the IDE headlessly, render frames frames, save a screenshot.
Args: project_dir: Optional project directory to open. frames: Number of frames to render (60 = ~1 second at 60fps). width: Window width. height: Window height. output_dir: Where to save the screenshot. Default
/tmp/ide_test.Returns: (screenshot_path, ui_tree_text) – path to PNG and widget tree description.
- simvx.ide.playtest.ide_run(steps: list, *, project_dir: str | None = None, extra_frames: int = 30, init_frames: int = 90, width: int = 1400, height: int = 900, speed: float = 50.0, output_dir: str | pathlib.Path | None = None, capture_every: int = 0) str[source]¶
Run a scripted interaction against the IDE and return a text report.
Args: steps: List of DemoRunner step dataclasses (Click, TypeText, PressKey, Wait, etc). project_dir: Optional project directory to open. extra_frames: Frames to render after steps complete (for settling). init_frames: Frames to render before starting steps (IDE initialisation). width: Window width. height: Window height. speed: Demo playback speed multiplier. output_dir: Where to save screenshots. Default
/tmp/ide_test. capture_every: Capture a screenshot every N frames (0 = only at end + step boundaries).Returns: Text report with screenshot paths and UI tree.
- simvx.ide.playtest.ide_find_widget(ui_tree: str, name: str) tuple[float, float, float, float] | None[source]¶
Parse a ui_describe() tree and return the rect of the first widget matching name.
Returns (x, y, w, h) or None if not found. Useful for computing click targets.
- simvx.ide.playtest.ide_widget_centre(ui_tree: str, name: str) tuple[float, float] | None[source]¶
Return the centre point of a widget found by name in a ui_describe() tree.
Useful for building Click steps::
tree = ... # from ide_screenshot() cx, cy = ide_widget_centre(tree, "Settings") steps = [Click(cx, cy)]