Add egui_inspection protocol and plugin - #8234
Merged
Merged
Conversation
|
Preview available at https://egui-pr-preview.github.io/pr/8234-lucasegui-mcp-scoped View snapshot changes at kitdiff |
lucasmerlin
force-pushed
the
lucas/egui-mcp-scoped
branch
3 times, most recently
from
June 12, 2026 07:22
3dd8ebc to
726f89a
Compare
The input/output hooks previously received only `&mut RawInput` / `&mut FullOutput`, so a plugin needing the `Context` (to request a repaint or send a viewport command) had to store a clone — which the `Plugin` docs explicitly warn against, as it creates a reference cycle that keeps the `Context` alive. Pass `&Context` into both hooks (as `on_widget_under_pointer` already does) so plugins can get it on demand instead of holding it. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
lucasmerlin
force-pushed
the
lucas/egui-mcp-scoped
branch
4 times, most recently
from
June 12, 2026 09:11
8b53aa7 to
39d493b
Compare
Live inspection for running egui apps over a small TCP request/response protocol, plus the `egui::Plugin` that serves it. `egui_inspection`: - `protocol`: request/response wire format (`Info` / `GetTree` / `Screenshot` / `HandleEvents` / `Resize`), MessagePack-framed via shared `encode_frame` / `decode_frame_*` helpers. - `plugin`: `InspectionPlugin`. Requests are submitted through egui's plugin handle — `ctx.with_plugin(|p| p.submit(req))` — and serviced on the UI thread via a small per-request state machine (inject events, read the AccessKit tree, capture a screenshot via a 2-frame round-trip). The hooks receive `&Context`, so the plugin stores no `Context` and creates no reference cycle. `serve` runs the TCP listener; a host owning its own transport (e.g. `re_mcp`) drives the plugin the same way. - `png`: shared screenshot encoder. - Env config: `EGUI_INSPECTION` / `EGUI_INSPECTION_ADDR`, default bind `127.0.0.1:5719`, with a loud warning when bound non-loopback. eframe gains an `inspection` feature; `attach_from_env` wires the plugin up on startup when the env var is set (no-op otherwise, no-op on wasm). `egui_demo_app` always enables it on native. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
lucasmerlin
force-pushed
the
lucas/egui-mcp-scoped
branch
from
June 12, 2026 09:43
39d493b to
fe9e4aa
Compare
emilk
marked this pull request as ready for review
June 12, 2026 11:00
emilk
approved these changes
Jun 12, 2026
lucasmerlin
force-pushed
the
lucas/egui-mcp-scoped
branch
5 times, most recently
from
June 12, 2026 12:34
d0625fa to
becc241
Compare
Doc backticks (`MessagePack`), `# Errors` sections, short first doc paragraphs, blank lines before documented fields (egui's lint.py), and gating eframe's `maybe_attach_inspection_plugin` so it isn't dead code on wasm / backend-less builds. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Per @emilk's review of #8234: - Single `EGUI_INSPECTION` env var (truthy / falsy / bind-addr); dropped `EGUI_INSPECTION_ADDR`. - Connection handshake: 4 magic bytes + 4 version bytes, so an incompatible/non-inspection peer is rejected before any MessagePack decode (version no longer rides in `Response::Info`). - Request renames: `GetInfo` / `GetTree` / `GetScreenshot` / `ApplyEvents`; `Response::Ack` → `Response::Done` (means *executed*, not just received). - `EncodedPng { size, bytes }` struct (in `protocol`) with `from_color_image` / `from_rgba` ctors, replacing the `encode_png` free fn + tuple. - Fix screenshot↔request correlation via a `Screenshot::user_data` id, so concurrent screenshots map back to the right request. - `serve_connection` returns `Result`; log/propagate errors instead of silently ignoring; loud error when a request times out (app not painting). - Doc clarifications; `in_flight` doc; `phase != Phase::New`. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
lucasmerlin
force-pushed
the
lucas/egui-mcp-scoped
branch
from
June 12, 2026 12:41
becc241 to
ba6b555
Compare
The `png` feature doc linked the removed `encode_png` (now `EncodedPng`), breaking `cargo doc` (broken-intra-doc-links). Drop that link and the stale `Session` mention in the `plugin` feature doc. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
lucasmerlin
enabled auto-merge (squash)
June 18, 2026 08:58
This was referenced Jun 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduces live inspection for running egui apps over a small TCP request/response protocol, plus the
egui::Pluginthat serves it.This is the minimal surface to get the egui mcp in, we may want to extend this in the future to add support for the inspection gui.