cli: Add debug state command (#66852)

This PR adds a debug state command to the CLI and a `cx.debug_state` API
to GPUI's `App`, so users can better understand where things went wrong
in their GPUI apps when they run into a bug. `zed --debug-state` prints
the running instance's snapshot as JSON.

Release Notes:

- Added a `zed --debug-state` CLI flag that prints the running app's
window, display, and platform state as JSON for debugging
- [GPUI] Added `cx.debug_state` API to output the current GPUI state
This commit is contained in:
Anthony Eid authored and GitHub committed 2026-11-11 19:41:39 +00:00
1 parent ba06cc5191
commit 3d42ca7c09
13 files changed
+327 -16

No files matched your search

+2
View File
@@ -72,6 +72,8 @@ pub enum CliRequest {
SetOpenBehavior {
behavior: CliBehaviorSetting,
},
/// Print a diagnostic snapshot of the app's GPUI and platform state.
DebugState,
}
#[derive(Debug, Serialize, Deserialize)]
+9 -1
View File
@@ -128,6 +128,10 @@ struct Args {
/// Will attempt to give the correct command to run
#[arg(long)]
system_specs: bool,
/// Print a JSON snapshot of the running Zed's GPUI and platform state
/// (windows, displays, frame scheduling, cursor), for debugging.
#[arg(long)]
debug_state: bool,
/// Open the project in a dev container.
///
/// Automatically triggers "Reopen in Dev Container" if a `.devcontainer/`
@@ -684,7 +688,11 @@ fn run() -> Result<()> {
cwd: env::current_dir().ok(),
};
tx.send(open_request)?;
tx.send(if args.debug_state {
CliRequest::DebugState
} else {
open_request
})?;
while let Ok(response) = rx.recv() {
match response {