A Rust UI framework without writing Rust: GPUI apps as state machines
GPUI is the GPU-rendered Rust UI framework behind the Zed editor. This video shows a GPUI app whose whole interface is one Osprey UI machine document.
The full write-up, with the code and its limits, is A Rust UI framework without writing Rust.
Osprey is actively evolving.
Transcript
- GPUI is the GPU rendered Rust UI framework behind the Zed editor. It expects you to write your interface in Rust.
- This casting player runs in a GPUI window, and contains no Rust of its own.
- Its whole interface is one data file: inputs, state machines, a view, and skins.
- egui redraws Rust code every frame. Slint has its own markup. Tauri puts a web front end in a web view. GPUI uses Rust views.
- A UI machine writes every state down and names every transition, so the interface can be checked, tested without a window, and reskinned without code.
- The player has four layers that run in parallel. Each has exactly one current state.
- Entering connecting requests cast.start, with the file and the receiver.
- When the TV reports playing, the layer moves itself. The document holds no code at all.
- The Osprey code that remains answers each request, and feeds what the TV reports back in as inputs.
- It never decides what the screen shows.
- The whole document is checked when it loads. A transition to a misspelled state is refused, with its exact JSON path.
- So is an initial state that does not exist.
- Nothing is partly applied. A cycle is reported instead of spinning, and a refused document shows its problems in place of the app.
- What to know first. The player runs in the GPUI host on macOS today, and the two skins without a canvas still need layout work.
- Build Osprey, and open the player. Osprey is actively evolving. Try it on your projects, and read the UI machines spec.