Skip to content

feat(ui): add configurable TUI traffic rate units - #755

Open
l1a wants to merge 1 commit into
domcyrus:mainfrom
l1a:feature/rate-units
Open

l1a wants to merge 1 commit into
domcyrus:mainfrom
l1a:feature/rate-units

Conversation

@l1a

@l1a l1a commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds configurable live traffic rate display units to the interactive TUI with three modes:

  • bytes (default): Binary IEC bytes per second (B/s, KiB/s, MiB/s, GiB/s)
  • bits: Decimal SI bits per second (bps, kbps, Mbps, Gbps)
  • iec-bits: Binary IEC bits per second (bps, Kibps, Mibps, Gibps)

Users can select or switch modes from:

  1. CLI flag: --rate-unit <bytes|bits|iec-bits>
  2. Config file (config.toml): [view] rate_unit = "bits" (precedence: --rate-unit > config.toml > bytes)
  3. Interactive TUI: press u from any tab (or with the Help overlay open) to cycle modes with transient status-bar feedback; r on Overview restores the configured startup preference, and 'u' still types normally into active filter queries.

Cumulative byte totals (format_bytes) and headless JSON field names (*_bytes_per_second) remain unchanged in bytes for backwards compatibility. Updated USAGE.md (marked unreleased) and CHANGELOG.md (## [Unreleased]).

Verification

  • cargo fmt --all -- --check
  • cargo clippy --locked --workspace --all-targets --all-features -- -D warnings
  • cargo test --locked --workspace --all-features (1,508 passed, 0 failed, 14 pre-existing privileged/live tests ignored on Linux x86_64)
  • cargo build --locked --workspace --all-targets --release

Also verified interactively on Linux x86_64 against target/release/rustnet: startup --rate-unit flags, [view] rate_unit in config.toml, CLI > config > default precedence, u cycling and r reset, stderr warning fallback on unknown config strings, and invalid TOML type error handling.

Scope

  • One feature or fix per PR (no unrelated cleanups bundled in)
  • I reviewed the changes and the description matches the diff
  • No new dependencies, or rationale provided in the summary above
  • No #[allow(clippy::...)] suppressions, or rationale provided
    (see CONTRIBUTING.md)
  • User-visible changes are added to the ## [Unreleased] section of
    CHANGELOG.md in this PR, or this change is not user-visible
    (see CONTRIBUTING.md)

Notes for the reviewer

  • braille_graph::mirrored_wave_panel previously had 7 parameters (Clippy's too_many_arguments limit). To pass rate_unit cleanly without suppressing warnings, (frac, window, time_window_seconds, rate_unit) are grouped into MirroredPanelOptions, mirroring WavePanelOptions.
  • format_rate_compact preserves the existing 5-cell half-column (↓/↑) and Y-axis label budget across all three modes (B/Ki/Mi, b/kb/Mb, b/Kb/Mb). Large-value formatting (f64::MAX) divides before multiplying by 8 so summary_rate stays finite and fixed at 16 cells.
  • help_overlay_details.snap and help_overlay_host_dns.snap reflect the single-cell scrollbar shift from adding u to GLOBAL_KEYS.
  • AI-assisted contribution (Assisted-By: Gemini 4), reviewed and verified locally.

Support displaying live TUI traffic rates in binary IEC bytes (bytes), decimal SI bits (bits), and binary IEC bits (iec-bits) via --rate-unit, [view] rate_unit in config.toml, and the global u keybinding. Cumulative byte totals and headless JSON output remain in bytes.

Assisted-By: Gemini 4
@domcyrus

Copy link
Copy Markdown
Owner

@l1a Thanks a lot this looks good. Could you narrow this PR to two modes, bytes (the default) and bits (decimal SI), selectable via --rate-unit and [view] rate_unit? SI bits make it easy to compare live traffic with link speeds. Let’s leave iec-bits and the u shortcut out for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants