diff --git a/local/docs/CONSOLE-TO-KDE-DESKTOP-PLAN.md b/local/docs/CONSOLE-TO-KDE-DESKTOP-PLAN.md index 85131503ac..eeca93f41c 100644 --- a/local/docs/CONSOLE-TO-KDE-DESKTOP-PLAN.md +++ b/local/docs/CONSOLE-TO-KDE-DESKTOP-PLAN.md @@ -1493,6 +1493,40 @@ Cross-compiled binary: 3.9 MB stripped Redox ELF 2. **Per-process disk I/O** — show per-process /proc/[pid]/io in Process tab. 3. **Disk temperature** — link hwmon temp to Storage panel. +#### v1.16 Network Throughput in Network Tab (2026-06-20) + +Per the user's "v1.16 = Network throughput (Recommended)" directive, +v1.16 closes the v1.11 §35.7 forward-work item. + +| Item | Status | +|------|--------| +| `rx_kbps: f64` + `tx_kbps: f64` fields on `NetInterface` | ✅ | +| `NetInfo::read_with_throughput(prev, dt_secs)` | ✅ | +| Wall-clock dt (shared with v1.14 + v1.15 via prev_refresh_secs) | ✅ | +| `prev_net: NetInfo` field in App | ✅ | +| R/W KiB/s in render_network_panel RX/TX bytes lines | ✅ | +| 3 new unit tests (formula + underflow + zero dt) | ✅ all pass | +| 52 total tests (5 bench + 12 sensor + 10 network + 12 storage + 13 process) | ✅ all pass | + +**Math sanity check** (verified by unit test): +- prev=1MB, now=5MB, dt=2sec → 1953.125 KiB/s +- prev > now → saturating_sub → 0 (no panic) + +**Linux host smoke test**: +- After 7 ticks (3.5 sec): R/W KiB/s populates per interface +- In `--once` mode: 0.0 (binary exits before second refresh) + +**v1.16 source state**: ~5755 LoC across **19 modules** (was ~5720 in +v1.15). 52 unit tests total. + +Cross-compiled binary: 3.9 MB stripped Redox ELF +(SHA256 `053f1a0cca5185637d0316d56f5cf5832cf2e754b689bc24edf16ea5d0404fa2`). + +**Forward work** (deferred to v1.17+): +1. **Per-process network I/O** — `/proc/[pid]/net/dev` for per-process bytes. +2. **IPv4 addresses** — currently only IPv6. +3. **ethtool driver stats** — driver-specific counters. + ### 3.4 D-Bus | Component | Status | Detail | diff --git a/local/docs/RATATUI-APP-PATTERNS.md b/local/docs/RATATUI-APP-PATTERNS.md index ff7936d876..a1ba15ba84 100644 --- a/local/docs/RATATUI-APP-PATTERNS.md +++ b/local/docs/RATATUI-APP-PATTERNS.md @@ -1092,8 +1092,8 @@ Use the canonical pattern from §1 (poll + sleep). | Modular crates | Single crate | Split (3-4 crates) | More granular split | ### 13.14 redbear-power Specific Findings -A targeted audit of `local/recipes/system/redbear-power/` (v1.15, 5720 LoC -across 19 modules, 49 unit tests) produced these actionable findings: +A targeted audit of `local/recipes/system/redbear-power/` (v1.16, 5755 LoC +across 19 modules, 52 unit tests) produced these actionable findings: | Severity | Finding | Fix | |----------|---------|-----| @@ -1121,6 +1121,7 @@ across 19 modules, 49 unit tests) produced these actionable findings: | feature | No Process list | Implemented in v1.13 (`process.rs` module + `TabId::Process`, 9 unit tests) | | feature | No CPU% in Process tab | Implemented in v1.14 (`ProcInfo::read_with_cpu_pct` + 4 unit tests) | | feature | No disk throughput in Storage tab | Implemented in v1.15 (`StorageInfo::read_with_throughput` + 3 unit tests) | +| feature | No network throughput in Network tab | Implemented in v1.16 (`NetInfo::read_with_throughput` + 3 unit tests) | Full plan: see `local/docs/redbear-power-improvement-plan.md`. @@ -1381,12 +1382,12 @@ gives a natural unit-of-work (count) that scales with thread count. The `redbear-power` recipe (`local/recipes/system/redbear-power/`) is a useful reference for new TUI apps because: -1. **Small enough to read in one sitting** (~5720 LoC across 19 modules, with 49 unit tests) +1. **Small enough to read in one sitting** (~5755 LoC across 19 modules, with 52 unit tests) 2. **Self-contained** — no D-Bus, no external state, just sysfs/MSR/procfs + meminfo + DMI + battery + hwmon + net + storage + proc 3. **Modern ratatui 0.30 patterns** — `TableState`, modular layout, status bars, `Tabs` widget 4. **Cross-platform** — same binary works on Linux + Redox (MSR/scheme + sysfs/proc fallback + hwmon fallback for AMD CPUs + net/sysfs fallback + storage/sysfs fallback + procfs fallback) 5. **Well-documented** — extensive code comments + this doc + improvement plan -6. **Testable** — bench + sensor + network + storage + process modules have 49 unit tests covering stress modes + hwmon unit conversions + multi-vendor pkg_temp_c + binary byte formatting + disk stat parsing + delta math + /proc/[pid]/stat parser with space-handling + CPU% delta math + disk throughput delta math +6. **Testable** — bench + sensor + network + storage + process modules have 52 unit tests covering stress modes + hwmon unit conversions + multi-vendor pkg_temp_c + binary byte formatting + disk stat parsing + delta math + /proc/[pid]/stat parser with space-handling + CPU% delta math + disk throughput delta math + network throughput delta math When porting a new Red Bear TUI app, structure it like redbear-power: diff --git a/local/docs/redbear-power-improvement-plan.md b/local/docs/redbear-power-improvement-plan.md index bb254ef430..9c3022d83d 100644 --- a/local/docs/redbear-power-improvement-plan.md +++ b/local/docs/redbear-power-improvement-plan.md @@ -3334,6 +3334,103 @@ case of clock reset). --- +## 40. v1.16 Network Throughput in Network Tab (2026-06-20) + +Per the user's "v1.16 = Network throughput (Recommended)" directive, +v1.16 closes the v1.11 §35.7 forward-work item. Network tab now +shows real-time R/W throughput (KiB/s) per interface, computed from +delta of rx_bytes/tx_bytes between successive 7th-tick refreshes. + +### 40.1 What was implemented + +**New fields `rx_kbps: f64` + `tx_kbps: f64` on `NetInterface`** — +populated by `NetInfo::read_with_throughput(prev, dt_secs)`. + +**New `NetInfo::read_with_throughput(prev, dt_secs)` method**: +- Calls `read()` to get current interface stats. +- For each interface in info, looks up the matching name in `prev`. +- Computes `delta = now.rx_bytes - prev.rx_bytes` (saturating). +- Normalizes: `rx_kbps = (delta / dt_secs) / 1024`. +- Returns the populated info struct. + +Edge cases match v1.15's `StorageInfo::read_with_throughput`: +- `dt_secs <= 0` → all kbps = 0 +- New interface → kbps = 0 (no prev data) +- `saturating_sub` prevents underflow + +**Updated `app.rs`**: +- New field `prev_net: NetInfo`. +- 7-tick refresh block now uses `read_with_throughput`: + ```rust + if self.refresh_counter % 7 == 0 { + let now_secs = ...; + let dt = ...; + self.prev_net = std::mem::replace( + &mut self.net, + NetInfo::read_with_throughput(&self.prev_net, dt), + ); + } + ``` +- Same `prev_refresh_secs` field shared with v1.14 + v1.15. + +**Updated `render.rs`** — Network tab now shows R/W KiB/s in each +interface's RX/TX bytes line: +``` +RX bytes: 38.7 GiB (137M packets, 46408 drop, 12.3 KiB/s) +TX bytes: 237.4 GiB (237M packets, 20 drop, 156.7 KiB/s) +``` + +### 40.2 Unit tests (3 new, 52/52 total pass) + +```rust +#[test] fn throughput_formula_positive() // (now-prev)/dt/1024 +#[test] fn throughput_saturating_sub_underflow() // now/{statistics,*}` beyond the standard set. + +--- + ## See Also - **`local/docs/RATATUI-APP-PATTERNS.md`** §13 — the canonical ratatui 0.30 best-practices update that this plan is derived from. Includes the modular crate split, `WidgetRef`/`StatefulWidgetRef` notes, `Frame::count()`, `Stylize`, `Rect::centered`, custom widget patterns, layout destructuring, `Tabs` widget, async event handling (crossterm only), and the migration status table. Use this as the implementation guide while this doc is the roadmap.