Skip to content

Integrate eguidev (egui automation) behind an opt-in feature - #276

Draft
frewsxcv wants to merge 1 commit into
mainfrom
integrate-eguidev
Draft

Integrate eguidev (egui automation) behind an opt-in feature#276
frewsxcv wants to merge 1 commit into
mainfrom
integrate-eguidev

Conversation

@frewsxcv

Copy link
Copy Markdown
Collaborator

Draft for review — wires cortesi/eguidev (an egui automation/testing framework: screenshots, widget-state inspection, input injection, Luau scripting over an embedded MCP server) into rgis's bevy_egui UI, behind an off-by-default eguidev feature (native only). Normal builds and the wasm/web build are unaffected.

What this does

Lets an agent/script drive the native app and assert on structured widget state (text, rects, layout) rather than pixels. Driving the running app with edev smoke:

$ edev smoke ab_verify.luau --verbose
LOG: "version value_text = 'rgis v0.1.0'"
LOG: "version rect = [8.0,701.5 .. 67.3,716.5]"
LOG: "scale   rect = [4.0,318.0 .. 104.0,340.0]"
LOG: "check_layout issues = 0"
[PASS]

How it's wired

  • third_party/eguidev/ — vendored fork, patched to build against egui 0.33 (rgis's version; upstream needs 0.34). Four edits, visible in the diff: actions.rs (drop MouseWheel.phase), instrument.rs (intrinsic_size is a field in 0.33), tools/layout.rs (global_style()style()), devmcp.rs (begin_frame/end_frame made pub).
  • rgis-ui/src/eguidev_adapter.rs — the bevy_egui↔eguidev bridge: a PreUpdate raw_input_hook system (after(ProcessInput).before(BeginPass)), begin/end_frame systems bracketing EguiPrimaryContextPass, and that pass set to a single-threaded executor (eguidev uses a thread-local frame model).
  • rgis-ui/src/dev_ui.rs — cfg-switching button/label/track wrappers: register widgets with eguidev ids when the feature is on, plain egui otherwise.
  • Instrumentation demo — bottom status bar (app-version, edit-crs, crs/coords) and the map scale bar.
  • rgis/src/lib.rs — window pinned to 1280×720 @ scale 1.0 under the feature (matches Playwright's coordinate space).
  • .edev.toml — launch config for edev.

Try it

cargo build -p rgis --features eguidev
cargo build -p edev --manifest-path third_party/eguidev/Cargo.toml
third_party/eguidev/target/debug/edev smoke <script>.luau --verbose

Caveats (why it's a draft)

  • Native ≠ wasm. eguidev's runtime is native-only, so this drives a native build of an app that ships as wasm. Real divergence observed: the scale bar anchors mid-window natively vs bottom in the browser — a layout bug Playwright caught did not reproduce here.
  • Screenshots not wired. bevy_egui ignores ViewportCommand::Screenshot, so eguidev's screenshot() would hang; a Bevy capture→egui::Event::Screenshot bridge is not built. Verification uses structured queries.
  • Instrumentation is per-widget opt-in — only the 5 demo widgets are wrapped.
  • Bundles an unrelated wasm build fix (zstd-sys no_asm).

eguidev vs Playwright

  • eguidev: structured, deterministic widget assertions (good for CI) — but high integration cost, per-widget instrumentation, native-proxy fidelity gap.
  • Playwright (already working): zero integration, tests the real shipped wasm in-browser — but pixel/eyeball verification.

Recommendation: Playwright stays the pragmatic choice for verifying what ships; eguidev earns its keep only if you want widget-level CI assertions and accept the tradeoffs.

Wires cortesi/eguidev — an egui automation/testing framework (screenshots,
widget-state inspection, input injection, Luau scripting over an embedded MCP
server) — into rgis's bevy_egui UI on the native target, behind an off-by-default
`eguidev` feature. Normal and wasm builds are unaffected.

What's here:
- third_party/eguidev: vendored fork of cortesi/eguidev, patched to compile
  against egui 0.33 (rgis's version; upstream requires 0.34). Four small edits:
  * actions.rs: drop MouseWheel.phase (0.34-only field)
  * instrument.rs: intrinsic_size is a field in 0.33, not a method
  * tools/layout.rs: global_style() -> style()
  * devmcp.rs: make begin_frame/end_frame pub (called from separate Bevy systems)
- rgis-ui/src/eguidev_adapter.rs: the bevy_egui<->eguidev bridge. Reproduces
  eframe's frame lifecycle inside Bevy: a PreUpdate raw_input_hook system
  (after ProcessInput, before BeginPass), begin/end-frame systems bracketing the
  EguiPrimaryContextPass, and a single-threaded executor for that pass (eguidev
  tracks the active frame via a thread-local).
- rgis-ui/src/dev_ui.rs: cfg-switching wrappers (button/label/track) that register
  widgets with eguidev under stable ids when the feature is on, else plain egui.
- Instrumented the bottom status bar (app-version, edit-crs, crs/coords readouts)
  and the map scale bar as a demo surface.
- rgis window pinned to 1280x720 @ scale 1.0 under the feature, to match the
  Playwright harness's coordinate space.
- .edev.toml: launch config so `edev smoke script.luau` can drive the app.

Also includes a wasm build fix (zstd-sys no_asm) discovered separately.

Draft: see PR description for the eguidev-vs-Playwright comparison and caveats
(native != wasm rendering; eguidev screenshot round-trip needs a Bevy bridge
that is not built here).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant