Skip to content

feat: Add comprehensive read-only Bevy Inspector with remote inspection capabilities #20189

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 49 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
cbfefbf
feat(editor): introduce reusable UI widgets for the editor interface
jbuehler23 Jul 18, 2025
51dcded
remove unnecessary readmes
jbuehler23 Jul 18, 2025
3e9bede
more readme cleanup
jbuehler23 Jul 18, 2025
6543102
feat(editor): integrate ListView for entity list management and updat…
jbuehler23 Jul 18, 2025
53a5fe4
Refactor: Remove inspector module and related components
jbuehler23 Jul 18, 2025
f86ec6f
feat(editor): implement smart entity naming system for improved displ…
jbuehler23 Jul 18, 2025
e39f3f3
Refactor entity list plugin and enhance entity naming system
jbuehler23 Jul 20, 2025
359fb33
chore: remove debug logging and heartbeat systems from entity list an…
jbuehler23 Jul 20, 2025
63b14b9
refactor: begin moving bevy_editor code from PR into bevy_dev_tools
jbuehler23 Jul 21, 2025
d981b40
Refactor inspector module to use updated Bevy APIs and improve organi…
jbuehler23 Jul 21, 2025
9bf1a25
Refactor code structure for improved readability and maintainability
jbuehler23 Jul 22, 2025
016bc85
Implement inspector systems and UI widgets for entity inspection in B…
jbuehler23 Jul 24, 2025
2d3d7e5
Add resizable panel and resize handle components
jbuehler23 Jul 26, 2025
df4117f
feat: Add Entity Inspector plugin for runtime entity/component inspec…
jbuehler23 Jul 30, 2025
400c424
feat: Enhance Entity Inspector with improved UI constraints and state…
jbuehler23 Jul 31, 2025
210e378
feat: Implement connection status UI component and related systems
jbuehler23 Aug 2, 2025
bc02d3f
feat: Implement robust virtual scrolling with infinite loading and en…
jbuehler23 Aug 2, 2025
d25dc03
cleanup: fixed docs and logging
jbuehler23 Aug 2, 2025
64aff14
feat: Refactor infinite scrolling display for improved performance an…
jbuehler23 Aug 2, 2025
dc90d1d
feat: Enhance virtual scrolling with scrollbar implementation and imp…
jbuehler23 Aug 3, 2025
07f622a
feat: Enhance README and UI components with high-performance virtual …
jbuehler23 Aug 3, 2025
900795d
feat: Add moving target application example with real-time updates an…
jbuehler23 Aug 3, 2025
4ef79a5
cleanup: start migrating code to bevy_dev_tools
jbuehler23 Aug 5, 2025
bdfc41e
Remove deprecated widgets and themes from the Bevy Editor, including …
jbuehler23 Aug 5, 2025
f5515b0
refactor: Update virtual scrolling implementation to use viewport-rel…
jbuehler23 Aug 6, 2025
dde2e81
feat(inspector): implement selection debounce to prevent rapid flashi…
jbuehler23 Aug 6, 2025
39f4eb8
feat(inspector): enhance text selection handling with improved state …
jbuehler23 Aug 7, 2025
470557c
refactor(inspector): remove tokio dependency and simplify HTTP client…
jbuehler23 Aug 7, 2025
10b855d
refactor: extract reusable widgets for upstreaming as necessary
jbuehler23 Aug 7, 2025
b027489
refactor: get realtime component updates via bevy_remote and http SSE
jbuehler23 Aug 7, 2025
8d4d89f
fix: get realtime data updates for all components on initial connection
jbuehler23 Aug 8, 2025
ae5317a
docs: add comprehensive documentation and formatting to get the PR re…
jbuehler23 Aug 8, 2025
25a2a42
cleanup: remove unnecessary docs
jbuehler23 Aug 8, 2025
c5f6b61
cleanup: remove debug logging
jbuehler23 Aug 9, 2025
6092ddd
format: run cargo fmt and hope for the best :)
jbuehler23 Aug 9, 2025
25a2be5
bugfix: fix bug with -/+ switching when collapsed/expanded
jbuehler23 Aug 9, 2025
dcd470b
cleanup: remove logging
jbuehler23 Aug 9, 2025
b01a67b
cleanup: more formatting and clippy/docs :)
jbuehler23 Aug 9, 2025
8130889
add examples to readme
jbuehler23 Aug 9, 2025
ca53d03
cleanup readme lints
jbuehler23 Aug 9, 2025
9ae705e
ci: try and get passing builds for a final time :)
jbuehler23 Aug 11, 2025
b44337f
cleanup: remove unnecessary clippy expectations and debug prints for …
jbuehler23 Aug 11, 2025
6440e0b
cleanup: remove redundant blank lines and reorder imports for clarity
jbuehler23 Aug 11, 2025
879b9fb
cleanup: update README sections for clarity and consistency
jbuehler23 Aug 11, 2025
242c4cc
fix: cleanup bugs around query name
jbuehler23 Aug 12, 2025
079986b
fix: fix duplicate components being printed when entity is marked as …
jbuehler23 Aug 12, 2025
fa00184
revert src/lib changes that snuck in at alice's request :)
jbuehler23 Aug 12, 2025
85dbadf
fix: consolidate .DS_Store entries in .gitignore for better clarity
jbuehler23 Aug 12, 2025
288998a
Merge remote-tracking branch 'upstream/main' into joe-editor
jbuehler23 Aug 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ assets/scenes/load_scene_example-new.scn.ron

# Generated by "examples/window/screenshot.rs"
**/screenshot-*.png
**/.DS_Store
12 changes: 12 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4030,6 +4030,12 @@ path = "examples/dev_tools/fps_overlay.rs"
doc-scrape-examples = true
required-features = ["bevy_dev_tools"]

[[example]]
name = "entity_inspector_minimal"
path = "examples/inspector/entity_inspector_minimal.rs"
doc-scrape-examples = true
required-features = ["bevy_dev_tools"]

[[example]]
name = "2d_top_down_camera"
path = "examples/camera/2d_top_down_camera.rs"
Expand Down Expand Up @@ -4113,6 +4119,12 @@ description = "Demonstrates FPS overlay"
category = "Dev tools"
wasm = true

[package.metadata.example.entity_inspector_minimal]
name = "Entity Inspector"
description = "Remote entity inspector that connects to a running Bevy app"
category = "Dev tools"
wasm = false

[[example]]
name = "visibility_range"
path = "examples/3d/visibility_range.rs"
Expand Down
27 changes: 25 additions & 2 deletions crates/bevy_dev_tools/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,55 @@ license = "MIT OR Apache-2.0"
keywords = ["bevy"]

[features]
bevy_ci_testing = ["serde", "ron"]
bevy_ci_testing = ["ron"]

[dependencies]
# bevy
bevy_app = { path = "../bevy_app", version = "0.17.0-dev" }
bevy_asset = { path = "../bevy_asset", version = "0.17.0-dev" }
bevy_camera = { path = "../bevy_camera", version = "0.17.0-dev" }
bevy_color = { path = "../bevy_color", version = "0.17.0-dev" }
bevy_core_pipeline = { path = "../bevy_core_pipeline", version = "0.17.0-dev" }
bevy_core_widgets = { path = "../bevy_core_widgets", version = "0.17.0-dev" }
bevy_diagnostic = { path = "../bevy_diagnostic", version = "0.17.0-dev" }
bevy_ecs = { path = "../bevy_ecs", version = "0.17.0-dev" }
bevy_image = { path = "../bevy_image", version = "0.17.0-dev" }
bevy_input = { path = "../bevy_input", version = "0.17.0-dev" }
# bevy_internal removed to avoid cyclic dependency - inspector imports handled via re-exports
bevy_log = { path = "../bevy_log", version = "0.17.0-dev" }
bevy_math = { path = "../bevy_math", version = "0.17.0-dev" }
bevy_pbr = { version = "0.17.0-dev", path = "../bevy_pbr" }
bevy_picking = { path = "../bevy_picking", version = "0.17.0-dev" }
bevy_render = { path = "../bevy_render", version = "0.17.0-dev" }
bevy_reflect = { path = "../bevy_reflect", version = "0.17.0-dev" }
bevy_time = { path = "../bevy_time", version = "0.17.0-dev" }
bevy_text = { path = "../bevy_text", version = "0.17.0-dev" }
bevy_shader = { path = "../bevy_shader", version = "0.17.0-dev" }
bevy_transform = { path = "../bevy_transform", version = "0.17.0-dev" }
bevy_ui = { path = "../bevy_ui", version = "0.17.0-dev" }
bevy_ui_render = { path = "../bevy_ui_render", version = "0.17.0-dev" }
bevy_window = { path = "../bevy_window", version = "0.17.0-dev" }
bevy_scene = { version = "0.17.0-dev", path = "../bevy_scene" }
bevy_state = { path = "../bevy_state", version = "0.17.0-dev" }
bevy_remote = { path = "../bevy_remote", version = "0.17.0-dev" }
bevy_tasks = { path = "../bevy_tasks", version = "0.17.0-dev" }
bevy_winit = { path = "../bevy_winit", version = "0.17.0-dev" }

# other
serde = { version = "1.0", features = ["derive"], optional = true }
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0" }
rand = { version = "0.8" }
ron = { version = "0.10", optional = true }
tracing = { version = "0.1", default-features = false, features = ["std"] }
ureq = { version = "2.0" }

# remote inspector dependencies
reqwest = { version = "0.12", features = ["json", "stream"] }
async-channel = "2.3"
anyhow = "1.0"
futures = "0.3"
tokio = { version = "1.0", features = ["rt", "rt-multi-thread", "macros"] }


[lints]
workspace = true
Expand Down
192 changes: 192 additions & 0 deletions crates/bevy_dev_tools/src/inspector/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
# Bevy Entity Inspector

The Bevy Entity Inspector is a powerful debugging tool that allows you to inspect and monitor entities and components in real-time, both locally and remotely. It provides two distinct modes of operation:

1. **Local Inspector** - An embedded, in-game inspector overlay
2. **Remote Inspector** - An external application that connects to your game via `bevy_remote`

## Local Inspector (In-Game Overlay)

The local inspector provides an in-game overlay that can be toggled on/off during development.

### Local Setup - TO BE COMPLETED

Add the `InspectorPlugin` to your application:

```rust
use bevy::dev_tools::inspector::InspectorPlugin;
use bevy::prelude::*;

fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugins(InspectorPlugin::debug()) // Use debug preset with F11 toggle
.run();
}
```

### Local Usage - TO BE COMPLETED

- Press **F11** to toggle the inspector overlay
- Browse entities in the left panel
- Click on entities to view their components in the right panel
- Component values update in real-time

### Example

Run the local inspector example:

```bash
cargo run --example inspector --features="bevy_dev_tools"
```

## Remote Inspector (External Application)

The remote inspector runs as a separate application that connects to your game over HTTP using the `bevy_remote` protocol. This is particularly useful for:

- Inspecting headless applications
- Debugging without UI overlay interference
- External tooling and automation
- Multi-monitor setups

### Remote Setup

#### Target Application (Your Game)

Add `bevy_remote` plugins to enable external connections:

```rust
use bevy::prelude::*;
use bevy::remote::{RemotePlugin, http::RemoteHttpPlugin};

fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugins(RemotePlugin::default()) // Enable JSON-RPC
.add_plugins(RemoteHttpPlugin::default()) // Enable HTTP transport
// Your game systems here...
.run();
}
```

#### Inspector Application

Create a separate inspector app:

```rust
use bevy::prelude::*;
use bevy::dev_tools::inspector::InspectorPlugin;

fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugins(InspectorPlugin) // Remote inspector (no debug preset)
.run();
}
```

### Remote Usage

1. **Start your target application** with `bevy_remote` enabled:

```bash
cargo run --example server --features="bevy_remote"
```

2. **Start the inspector** in a separate terminal/window:

```bash
cargo run --example entity_inspector_minimal --features="bevy_dev_tools"
```

The inspector will automatically connect to `localhost:15702` and display your entities.

### Features

- **Real-time Updates**: Component values update live as they change
- **Interactive UI**: Click to select entities, text selection with copy/paste
- **Connection Resilience**: Auto-retry logic handles connection failures gracefully
- **Performance**: Virtual scrolling efficiently handles large numbers of entities
- **All Components**: Automatically discovers and displays all component types

### Connection Details

- **Default Address**: `localhost:15702`
- **Protocol**: HTTP with JSON-RPC 2.0
- **Endpoints**:
- `/health` - Connection health check
- `/jsonrpc` - Main JSON-RPC interface

## Component Registration

For components to be visible in the inspector, they must implement `Reflect`:

```rust
use bevy::prelude::*;
use serde::{Deserialize, Serialize};

#[derive(Component, Reflect, Serialize, Deserialize)]
#[reflect(Component, Serialize, Deserialize)]
struct Player {
health: i32,
speed: f32,
}

fn main() {
App::new()
.add_plugins(DefaultPlugins)
.register_type::<Player>() // Required for reflection
.run();
}
```

## Troubleshooting

### Remote Inspector Issues

**Inspector shows "Awaiting connection":**

- Ensure target app is running with `bevy_remote` plugins enabled
- Verify target app is listening on port 15702
- Check firewall/network connectivity

**Components not visible:**

- Ensure components implement `Reflect`
- Register component types with `.register_type::<YourComponent>()`
- Verify components implement `Serialize`/`Deserialize` for remote inspection

**Connection drops frequently:**

- Check target application stability
- Monitor network connectivity
- The inspector will automatically retry connections

### Local Inspector Issues

**F11 doesn't toggle inspector:**

- Ensure you're using `InspectorPlugin::debug()` not `InspectorPlugin`
- Check if another system is handling F11 key input

**UI elements not visible:**

- Verify UI camera is present in your scene
- Check for UI layer conflicts

## Architecture

The inspector uses several key components:

- **HTTP Client** (`crates/bevy_dev_tools/src/inspector/http_client.rs`): Manages remote connections and JSON-RPC communication
- **UI Components** (`crates/bevy_dev_tools/src/inspector/ui/`): Entity list, component viewer, connection status
- **Virtual Scrolling**: Efficient rendering for large entity lists
- **Live Updates**: Real-time component value streaming

## Examples

| Example | Purpose | Command |
|---------|---------|---------|
| `inspector` | Local in-game overlay | `cargo run --example inspector --features="bevy_dev_tools"` |
| `server` | Target app for remote inspection | `cargo run --example server --features="bevy_remote"` |
| `entity_inspector_minimal` | Remote inspector client | `cargo run --example entity_inspector_minimal --features="bevy_dev_tools"` |
Loading
Loading