Feat: Refactor tuimon and add a bevy backend (prep for a browser mode)#901
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the monitor UI into a shared cu_tuimon library and introduces a new Bevy-backed monitor (cu_bevymon) plus an example app to demonstrate side-by-side sim + monitor rendering, as prep work for future non-terminal backends (e.g. browser/wasm).
Changes:
- Extract shared monitor state + Ratatui rendering + log pane plumbing into new
components/libs/cu_tuimon. - Rework
cu_consolemonto delegate UI rendering and (optional) log pane behavior tocu_tuimon. - Add new
cu_bevymonmonitor + Bevy plugin (bundled fonts, focus/viewport helpers) and acu_bevymon_demoexample.
Reviewed changes
Copilot reviewed 32 out of 35 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| examples/cu_bevymon_demo/src/tasks.rs | Adds synthetic Copper tasks/payloads for demo runtime + logging. |
| examples/cu_bevymon_demo/src/main.rs | Bevy demo app: split layout, focus routing, viewport syncing, Copper runtime driver. |
| examples/cu_bevymon_demo/copperconfig.ron | Demo Copper graph + logging + monitor selection. |
| examples/cu_bevymon_demo/build.rs | Sets LOG_INDEX_DIR env var for build output. |
| examples/cu_bevymon_demo/README.md | Documents demo purpose and controls. |
| examples/cu_bevymon_demo/Cargo.toml | New example crate deps (Bevy + cu-bevymon + Copper crates). |
| components/monitors/cu_consolemon/src/lib.rs | Refactors console monitor to use shared cu_tuimon::MonitorUi and MonitorModel. |
| components/monitors/cu_consolemon/src/debug_pane.rs | Removes old bespoke debug pane implementation. |
| components/monitors/cu_consolemon/README.md | Updates screen descriptions to match shared log pane behavior. |
| components/monitors/cu_consolemon/Cargo.toml | Switches debug pane feature to cu-tuimon feature flags; trims old deps. |
| components/monitors/cu_bevymon/src/viewport.rs | Adds helper to sync Bevy camera viewports to UI panel rects. |
| components/monitors/cu_bevymon/src/terminal.rs | Adds SoftBackend Ratatui terminal resource with embedded fonts + resize helper. |
| components/monitors/cu_bevymon/src/lib.rs | Implements CuMonitor + Bevy plugin: input translation, drawing, texture upload. |
| components/monitors/cu_bevymon/src/focus.rs | Adds click-to-focus surface tracking + focus border updates + cursor mapping helpers. |
| components/monitors/cu_bevymon/assets/fonts/OFL.txt | Adds font license for bundled JetBrains Mono Nerd Font. |
| components/monitors/cu_bevymon/assets/README.md | Documents bundled font set and provenance. |
| components/monitors/cu_bevymon/README.md | Documents crate intent, integration pattern, and focus/input model. |
| components/monitors/cu_bevymon/Cargo.toml | New monitor crate dependencies (bevy_ratatui, soft_ratatui, cu-tuimon, etc.). |
| components/libs/cu_tuimon/src/ui.rs | New shared Ratatui UI implementation + event model (keys/mouse/scroll). |
| components/libs/cu_tuimon/src/tui_nodes/node.rs | Vendored tui-nodes node layout primitive. |
| components/libs/cu_tuimon/src/tui_nodes/mod.rs | Vendored tui-nodes module wiring + exports. |
| components/libs/cu_tuimon/src/tui_nodes/graph.rs | Vendored + adapted node graph layout/rendering. |
| components/libs/cu_tuimon/src/tui_nodes/connection.rs | Vendored connection routing/rendering implementation. |
| components/libs/cu_tuimon/src/tui_nodes/LICENSE | MIT license for vendored tui-nodes code. |
| components/libs/cu_tuimon/src/model.rs | New shared monitor model (stats/status/pools/copperlist + optional logs). |
| components/libs/cu_tuimon/src/logpane.rs | New shared live log + optional stderr capture pipeline. |
| components/libs/cu_tuimon/src/lib.rs | New library crate root + public exports. |
| components/libs/cu_tuimon/README.md | Documents cu_tuimon role, APIs, and consumers. |
| components/libs/cu_tuimon/Cargo.toml | New crate manifest + feature flags for log pane and stderr capture. |
| Cargo.toml | Adds new workspace members and workspace dep bevy_ratatui. |
| AGENTS.md | Adds Rust clippy-related guidance (casts + .is_multiple_of). |
| .github/actions/rust-ci-setup/action.yml | Installs libasound2-dev for CI builds needing audio deps. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| fn new(target: CaptureTarget, capture_stderr: bool) -> Self { | ||
| #[cfg(debug_assertions)] | ||
| register_live_log_listener({ | ||
| let target = target.clone(); | ||
| move |entry, format_str, param_names| { | ||
| target.handle_structured_log(entry, format_str, param_names); | ||
| } | ||
| }); | ||
|
|
||
| Self { | ||
| target, | ||
| #[cfg(debug_assertions)] | ||
| registered_live_listener: true, | ||
| #[cfg(feature = "stderr_capture")] | ||
| stderr_redirect: if capture_stderr { | ||
| BufferRedirect::stderr().ok() | ||
| } else { | ||
| None | ||
| }, | ||
| } |
There was a problem hiding this comment.
MonitorLogCapture::new sets registered_live_listener: true unconditionally, but cu29_log_runtime::register_live_log_listener is a no-op until the logger runtime is initialized. If LOGGER_STATE isn’t set yet, this instance won’t actually register, but Drop will still call unregister_live_log_listener() later and can inadvertently clear another listener registered after initialization. Consider setting registered_live_listener based on LOGGER_STATE.get().is_some() at construction time, or making registration return a boolean so Drop only unregisters when it truly registered.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Summary
Screencast_20260307_110920.mp4
Related issues
Changes
Testing
just fmtjust lintjust testjust std-ci(if std/runtime paths are impacted)just nostd-ci(if embedded/no_std paths are impacted)pro-tip:
justwith no parameters in the root defaults tojust fmt,just lint, andjust test.Checklist
Breaking changes (if any)
Additional context