gpui-context

Manage GPUI App, Window, and Context<T> state and rendering.

12.5k|757|Updated Jun 13, 2024
One-click install
npx skills add https://github.com/longbridge/gpui-component --skill gpui-context-longbridge
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: gpui-context
Source: https://github.com/longbridge/gpui-component/tree/main/.claude/skills/gpui-context
Command: npx skills add https://github.com/longbridge/gpui-component --skill gpui-context-longbridge

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

GPUI context management centralizes and orchestrates state, lifecycle, and rendering across App, Window, and per-component contexts, reducing boilerplate and coordinating updates.

Core Features & Use Cases

  • Support for App, Window, Context<T>, AsyncApp, and AsyncWindowContext to cover global, per-window, and component-scoped concerns.
  • Entity management and asynchronous task orchestration with safe and ergonomic APIs.
  • Real-world use cases include managing window lifecycles, triggering re-renders on state changes, and performing background work without leaks.

Quick Start

Initialize the app context, create an entity, and spawn an async task to demonstrate using App, Window, and AsyncApp contexts.

Frequently Asked Questions about gpui-context

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

FAQPage Schema
How do I manage GPUI context across App, Window, and async tasks in Rust?

To manage GPUI context across App, Window, and async tasks, you centralize state and coordinate updates using App, Window, Context<T>, AsyncApp, and AsyncWindowContext. This covers global initialization, per-window rendering, and component-level updates.

What is the best way to spawn async tasks safely in a GPUI window?

Spawning async tasks safely in a GPUI window requires using AsyncWindowContext to preserve lifecycle awareness. This approach orchestrates background work and entity updates without causing memory leaks during window rendering.

How do I trigger a UI re-render when entity state changes in GPUI?

Triggering a UI re-render in GPUI involves reading and updating the entity through its Context<T>, then calling notify. This invalidates the component-scoped context and coordinates the window rendering pipeline.

When should I use AsyncApp versus AsyncWindowContext in GPUI?

Use AsyncApp for background tasks tied to the global application lifecycle, and AsyncWindowContext for tasks scoped to a specific window's rendering and state. This distinction ensures safe asynchronous task orchestration without leaks.

Does GPUI context management support per-window entity lifecycle coordination?

Yes, GPUI context management supports per-window entity lifecycle coordination through Window and AsyncWindowContext. These contexts manage state, trigger re-renders, and handle background work specific to each window.

Why do my GPUI async tasks cause state leaks during window rendering?

Async tasks cause state leaks in GPUI window rendering when spawned outside lifecycle-aware contexts. Using AsyncWindowContext or AsyncApp ensures safe entity management and coordinates updates without leaking memory.