gitmyhub

embedded_gpui

Rust ★ 24 updated 16d ago

An experimental UI plugin API base for Zed

An experimental Zed spike that runs GPUI plugins inside a WebAssembly sandbox and renders them natively.

RustGPUIWebAssemblywasmtimesetup: moderatecomplexity 5/5

embedded_gpui is an experimental spike from Zed Industries exploring how the Zed code editor could support UI plugins. GPUI is the Rust UI framework that powers Zed itself, and this project makes it possible to write an ordinary GPUI program, compile it to a WebAssembly component, and have a host application render it as if it were just another element inside its own native window. The plugin has full access to GPUI's normal building blocks: entities, layout elements, flexbox style positioning, input handling, and async tasks, all running inside a sandboxed WebAssembly module.

On the guest side, the plugin gets its own miniature GPUI platform inside the sandbox, covering windows, saved lists of what to draw, mouse and keyboard input, timers, async tasks, SVG and image rendering, and text where the actual font rendering happens on the host. The host side loads the compiled plugin with the wasmtime WebAssembly runtime, replays what the plugin wants to draw using real native GPUI drawing calls, and never needs to call back into the plugin just to render a frame.

A central design idea is a shared object model that lets the host and the plugin refer to each other's data safely across the sandbox boundary. Each side exposes one root object at a fixed starting point, and everything else is discovered by making typed method calls from there, rather than by name or by direct memory access. Object references are random 64 bit numbers, so a plugin cannot guess or access something it was never explicitly given a reference to. Utility patterns built on top of this include revocable access, allowlisted access, an audit log of calls, and a local read only mirror of remote state.

The repository ships a runnable demo. After installing the wasm32-wasip2 Rust compilation target, running the example host builds and loads a demo plugin automatically, showing a window with two plugin rendered views and one native button, all mutating the same shared counter to demonstrate the object model in action. The project depends on a custom branch of the GPUI library from the main Zed repository while a small required change is still waiting to be merged upstream. The authors are explicit that this is an early, unstable experiment, not a supported plugin API yet, and it is released under the Apache 2.0 license, matching GPUI itself.

Where it fits