The entry point (main.rs:193) creates an Application, registers global services, then calls app.run() which starts the platform event loop and hands control to GPUI.
Rc<AppCell>All mutable application state lives in entities. An Entity<T> is a reference-counted handle to a value of type T stored inside GPUI's entity map. GPUI routes notifications and events through this system, ensuring the single-threaded UI loop has consistent state.
.update() call — GPUI will panic if two mutable borrows overlap. Use the inner cx provided by the closure, not the outer one.
When state changes, call cx.notify() inside an .update() closure. GPUI queues a redraw for views that subscribe to this entity, and calls cx.observe callbacks.
This is the path a keystroke takes before reaching any editor code:
NSApplication / Linux XCB / Windows message loop delivers a key-down event to GPUI's platform shim.dyn Action value..on_action() handlers registered on each element.Editor::move_left) is called. It mutates entity state and calls cx.notify() to schedule a re-render.GPUI's rule: all entity access happens on one foreground thread. Background work runs on a separate thread pool and communicates results back via foreground tasks.
background_spawn. The result is sent back to a foreground spawn task that updates the Buffer entity and calls cx.notify().
After cx.notify() is called, GPUI schedules a frame. On the next frame tick:
T::render(&mut self, window, cx) which returns an element tree.paint(bounds, scene, cx) is called. Elements emit quads, glyphs, underlines, paths, and sprites into the Scene.Scene is handed to gpui_wgpu, which builds GPU draw calls and presents the framebuffer. See Rendering Pipeline.