## Summary `SpinnerLabel` and `LoadingLabel` request a frame on every display refresh, though their text changes only 4–17.5 times a second. Each frame re-renders every view above the label: in the agent panel, `ThreadView`, `ConversationView`, `AgentPanel`, and `Workspace`. So while a turn waits on the model, a confirmation, or a subagent, Zed renders at the display's refresh rate, or at 30 fps when the window doesn't have focus. Both labels now render only when their text changes: - `Animation::with_steps`, like CSS `steps()`, advances an animation in equal steps and re-renders it when the next step starts. It counts steps in integers on the animation's clock, so each step renders on time however long Zed has run, and synced animations step, and render, together. - `SpinnerLabel` takes one step per glyph on the shared clock, so all spinners render together. `LoadingLabel` takes four steps a second after its reveal. CPU time of the Zed process while a thread waits, in ms per second, main → this PR: | State | 60 Hz | 120 Hz | 144 Hz | 240 Hz | Unfocused, 120 Hz | |---|---|---|---|---|---| | Waiting for the model | 168 → 48 | 272 → 48 | 319 → 48 | 417 → 49 | 92 → 43 | | Awaiting confirmation | 189 → 87 | 312 → 86 | 337 → 88 | 470 → 88 | 98 → 83 | | One subagent | 177 → 52 | 304 → 52 | 320 → 52 | 437 → 52 | 93 → 45 | | Three subagents | 187 → 56 | 327 → 56 | 318 → 55 | 467 → 57 | 97 → 50 | | Streaming a response | 281 → 266 | 370 → 333 | 379 → 324 | 543 → 335 | 147 → 155 | While waiting, Zed draws 13 frames a second, 14 to 15 with subagents and 24 awaiting confirmation, instead of one per refresh, and GNOME Shell's CPU time falls from 30–45 to 6–13 ms per second. Unfocused windows, which GPUI already caps at 30 fps, draw 11–21. A hidden window draws nothing either way. Measured on a release build with a project and a Rust file open, on a headless GNOME Shell 50 whose virtual monitor refreshes at each rate, with an RTX 4080 and a Ryzen 7 9800X3D. A mock OpenAI-compatible provider holds the thread in each state. CPU time is from `/proc`, all threads, over 6-second windows; medians of 4 runs per variant, alternating variants (3 unfocused, at 120 Hz). A run counts only if everything else on the machine used under 180 ms/s of CPU, because other work changes Zed's own CPU time. [Harness](https://github.com/ptweezy/zed/tree/bench-spinner-real/bench/spinner_real) and [records](https://github.com/ptweezy/zed/tree/bench-spinner-real/bench/spinner_real/results/2026-11-22). On `windows-latest` (4 vCPUs, no GPU, so Zed renders in software), the same harness measured 845 → 188 ms/s while waiting for the model, 939 → 353 awaiting confirmation, 894 → 203 with three subagents, and 1,066 → 847 while streaming. `macos-latest` VMs stopped delivering frames whenever Zed paused its display link, including for the cursor blink, so they're left out. ## Testing - `test_spinner_renders_only_as_often_as_its_glyph_changes` steps a window with a `SpinnerLabel` at 100 Hz for one second and checks that it renders 10 times, once per glyph change. It renders 100 times without steps. - `test_synced_steps_render_once_each` mounts a synced animation of seven steps a second, 30 ms into a step and 300 days into the shared clock, and checks that it renders once as each step starts. It doesn't pass when steps are counted in floats or a step's length is rounded to nanoseconds. - `test_steps_finish_and_repeat_on_time` checks that a one-shot animation of four steps ends on time, that its cap doesn't delay the animation chained after it, and that a repeating one wraps. - `test_sooner_step_replaces_the_pending_one` switches a repeating animation from one step a second to ten and checks that the next step renders on time, and once. - All four pass with `SEED` 0–99. - `cargo test -p gpui -p ui -p agent_ui -p which_key` passes. - `./script/clippy -p gpui -p ui` passes. ## Self-review - [x] I've reviewed my diff for quality, security, reliability, and performance. - [x] UI changes follow the [checklist](https://zed.dev/docs/development/ui-checklist). - [x] Tests cover the new or changed behavior. Release Notes: - Improved CPU usage while the agent waits on a model response, a tool confirmation, or a subagent - [GPUI] Added `Animation::with_steps`, which advances an animation in equal steps and re-renders it only when it steps
Welcome to GPUI!
GPUI is a hybrid immediate and retained mode, GPU accelerated, UI framework for Rust, designed to support a wide variety of applications.
Getting Started
GPUI is still in active development as we work on the Zed code editor, and is still pre-1.0. There will often be breaking changes between versions. You'll also need to use the latest version of stable Rust. Add gpui, and optionally gpui_platform, to your Cargo.toml:
gpui = { version = "*" }
gpui_platform = { version = "*", features = ["font-kit", "wayland", "x11"] }
Everything in a standalone GPUI app starts with an Application. You can create one with gpui_platform::application(), which picks the windowing and text backends for the host OS, and kick off your application by passing a callback to Application::run(). Inside this callback, you can create a new window with App::open_window() and register your first root view.
use gpui::*;
fn main() {
gpui_platform::application().run(|cx: &mut App| {
// ..
});
}
gpui_platform
The features on gpui_platform are platform-specific, so the list above is a safe cross-platform default. If you build for a single platform, you can trim it:
-
macOS — Rendering uses Metal and is always available, but glyph rasterization needs
font-kit. Without it, GPUI falls back to a placeholder text system that lays text out but renders no glyphs.gpui_platform = { version = "*", features = ["font-kit"] } -
Linux / FreeBSD — enable at least one windowing backend for desktop windows:
wayland,x11, or both. These features also compile the renderer and text system, so no separate text feature is needed.gpui_platform = { version = "*", features = ["wayland", "x11"] } -
Windows — no features are required. Windowing uses Win32 and text uses DirectWrite.
font-kithas no effect here.
Additional Topics
Dependencies
GPUI has various system dependencies that it needs in order to work.
macOS
On macOS, GPUI uses Metal for rendering. In order to use Metal, you need to do the following:
- Install Xcode from the macOS App Store, or from the Apple Developer website. Note this requires a developer account.
Ensure you launch Xcode after installing, and install the macOS components, which is the default option.
-
Install Xcode command line tools
xcode-select --install -
Ensure that the Xcode command line tools are using your newly installed copy of Xcode:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
The Big Picture
GPUI offers three different registers depending on your needs:
-
State management and communication with
Entity's. Whenever you need to store application state that communicates between different parts of your application, you'll want to use GPUI's entities. Entities are owned by GPUI and are only accessible through an owned smart pointer similar to anRc. See theapp::contextmodule for more information. -
High level, declarative UI with views. All UI in GPUI starts with a view. A view is simply an
Entitythat can be rendered, by implementing theRendertrait. At the start of each frame, GPUI will call this render method on the root view of a given window. Views build a tree ofelements, lay them out and style them with a tailwind-style API, and then give them to GPUI to turn into pixels. See thedivelement for an all purpose swiss-army knife of rendering. -
Low level, imperative UI with Elements. Elements are the building blocks of UI in GPUI, and they provide a nice wrapper around an imperative API that provides as much flexibility and control as you need. Elements have total control over how they and their child elements are rendered and can be used for making efficient views into large lists, implement custom layouting for a code editor, and anything else you can think of. See the
elementmodule for more information.
Each of these registers has one or more corresponding contexts that can be accessed from all GPUI services. This context is your main interface to GPUI, and is used extensively throughout the framework.
Other Resources
In addition to the systems above, GPUI provides a range of smaller services that are useful for building complex applications:
-
Actions are user-defined structs that are used for converting keystrokes into logical operations in your UI. Use this for implementing keyboard shortcuts, such as cmd-q. See the
actionmodule for more information. -
Platform services, such as
quit the apporopen a URLare available as methods on theapp::App. -
An async executor that is integrated with the platform's event loop. See the
executormodule for more information., -
The
[gpui::test]macro provides a convenient way to write tests for your GPUI applications. Tests also have their own kind of context, aTestAppContextwhich provides ways of simulating common platform input. Seeapp::test_contextandtestmodules for more details.
Currently, the best way to learn about these APIs is to read the Zed source code or drop a question in the Zed Discord. We're working on improving the documentation, creating more examples, and will be publishing more guides to GPUI on our blog.