gpui-global

Manage app-wide global state in GPUI with the Global trait.

62|1|Updated Feb 5, 2026
One-click install
npx skills add https://github.com/zerx-lab/rmx --skill gpui-global
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: gpui-global
Source: https://github.com/zerx-lab/rmx/tree/main/.opencode/skills/gpui-global
Command: npx skills add https://github.com/zerx-lab/rmx --skill gpui-global

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Global state management in GPUI provides a centralized mechanism to share app-wide data across components.

Core Features & Use Cases

  • Define and register global state types by implementing the Global trait.
  • Set, access, and update globals from anywhere in the app using cx.set_global, cx.global, and cx.update_global.
  • Support immutable reads with easy mutation via interior mutability patterns, and notify components when needed.

Quick Start

The following example shows how to declare a global state type, register it, and use it.

Define a global state use gpui::Global;

#[derive(Clone)] struct AppSettings { theme: Theme, language: String, } impl Global for AppSettings {}

Set global at startup let app = Application::new(); app.run(|cx: &mut App| { cx.set_global(AppSettings { theme: Theme::Dark, language: "en".to_string(), }); let settings = cx.global::<AppSettings>(); });

Update global example impl MyComponent { fn change_theme(&mut self, new_theme: Theme, cx: &mut Context<Self>) { cx.update_global::<AppSettings, _>(|settings, cx| { settings.theme = new_theme; }); cx.notify(); } }

Frequently Asked Questions about gpui-global

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

FAQPage Schema
How do I share global state across GPUI components in Rust?▼

To share global state across GPUI components, you implement the Global trait for your state type and register it using cx.set_global, allowing app-wide access to configuration and shared services.

What is the best way to manage app-wide configuration in a GPUI application?▼

Managing app-wide configuration in GPUI involves defining a state struct, implementing the Global trait, and setting it at startup so features like themes and language settings are accessible globally.

How do I update global state and notify components of changes in GPUI?▼

You update global state in GPUI by calling cx.update_global to mutate your state type, then call cx.notify to notify the component that it needs to re-render based on the updated global data.

When do I need global state management in my GPUI app?▼

You need global state management in GPUI when shared services, feature flags, or app configuration must be accessible across multiple components without prop drilling.

Can I read global state immutably and still allow mutations in GPUI?▼

Yes, GPUI supports immutable reads via cx.global while allowing mutations through interior mutability patterns, enabling safe concurrent state updates within the application context.

Does GPUI global state require any external dependencies?▼

No, GPUI global state management relies solely on the built-in Global trait and context methods like cx.set_global, requiring no external crate dependencies to function.