gpui

Provides reference guidance for building GPUI framework applications in Rust.

Updated Oct 15, 2019
One-click install
npx skills add https://github.com/kkkaoru/dotfiles --skill gpui-kkkaoru
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: gpui
Source: https://github.com/kkkaoru/dotfiles/tree/main/.agents/skills-stroage/gpui
Command: npx skills add https://github.com/kkkaoru/dotfiles --skill gpui-kkkaoru

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? GPUI is a complex Rust UI framework with many interlocking concepts—contexts, entities, elements, async tasks, and testing—and developers often struggle to find the right API pattern for a given task. This Skill organizes GPUI knowledge into topic-specific references so you get accurate, example-driven guidance for any GPUI concept. ## Core Features & Use Cases - Topic-Based Navigation: Eleven core reference files covering actions/keybindings, async tasks, context management, custom elements, entity state, events, focus, globals, layout/styling, ElementId, and testing. - Deep-Dive Extended References: Additional API references, patterns, best practices, and advanced guides for the Element trait, entity management, and testing. - Use Case: When implementing a custom scrollable list element in a GPUI app, load the element references to learn the request_layout/prepaint/paint lifecycle, hitbox creation, and scroll event handling with complete Rust code examples. ## Quick Start Ask how to implement keyboard shortcuts with actions and keybindings in a GPUI application.

Frequently Asked Questions about gpui

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement keyboard shortcuts in a GPUI application?

Define actions with the actions! macro or #[derive(Action)], bind keys with cx.bind_keys() using KeyBinding entries, and handle them with .on_action() on elements. Use key_context() to make bindings context-aware so the same key can trigger different actions.

How do I run async tasks in GPUI without blocking the UI?

Use cx.spawn for foreground tasks that update entities and cx.background_spawn for CPU-intensive work on worker threads. Chain background results back to the foreground with .then(cx.spawn(...)) since entities can only be updated on the UI thread.

What is the difference between App, Window, and Context<T> in GPUI?

App is the global context for entity creation and app-wide state, Window handles window-specific operations like painting and layout, and Context<T> is the entity-specific context for a component. AsyncApp and AsyncWindowContext are their async counterparts used inside spawned tasks.

How do I create a custom element in GPUI using the Element trait?

Implement the Element trait with RequestLayoutState and PrepaintState associated types plus the request_layout, prepaint, and paint methods. Create hitboxes in prepaint, paint children before your own content, and handle mouse events in the paint phase.

Why does GPUI panic when updating an entity inside defer_in?

cx.defer_in schedules a callback on the current entity, so GPUI re-acquires that entity's lock to run it. Calling entity.update() on the same entity inside the callback re-enters the lock and panics; use the provided &mut reference directly instead.

How do I test GPUI components in Rust?

Use the #[gpui::test] attribute with TestAppContext for logic tests and VisualTestContext for rendering tests. You can open windows, dispatch synthetic mouse events, and assert on entity state within the test context.