Skip to content

Conversation

@hodgesds
Copy link
Contributor

@hodgesds hodgesds commented Oct 27, 2025

Extract all network rendering logic (~687 lines) from app.rs into a new
NetworkRenderer module in src/render/network.rs. This includes:

  • Full network view with interface table and traffic charts
  • Network summary for default view (top 5 interfaces)
  • Historical traffic visualization (bytes and packets)
  • Dual-axis mirrored charts (RX negative, TX positive)
  • Delta calculation for per-second rates
  • Comprehensive error handling and edge cases

Add extensive test coverage with 13 tests covering:

  • Basic rendering, localization, themes
  • Edge cases: no interfaces, zero/high traffic, many interfaces
  • Small terminal compatibility
  • Multiple tick rates

Extract memory view rendering logic from the monolithic app.rs into a
new dedicated render module. This is Phase 2 of the larger refactoring
effort to improve maintainability of the scxtop codebase.

Changes:
- Created src/render/memory.rs
  - Introduced MemoryRenderer struct with static methods
  - Extracted render_memory_view()
  - Extracted render_memory_summary()
  - Extracted render_memory_table()

- Modified src/app.rs
  - Removed duplicate memory rendering implementation
  - Delegated to MemoryRenderer for all memory-related rendering
  - Cleaned up unused imports (memory column functions)

- Modified src/render/mod.rs
  - Added pub mod memory
  - Exported MemoryRenderer

- Added tests/render_memory_tests.rs
  - Tests for memory view rendering
    * Basic rendering with default values
    * Swap usage scenarios (0%, 50%)
    * Low/high memory pressure scenarios
    * Small terminal area handling
  - Tests for memory summary rendering
    * Basic summary rendering
    * Multiple theme support verification
  - Uses ratatui TestBackend for integration-style testing
  - Created helper function create_test_mem_stats() with realistic values

Signed-off-by: Daniel Hodges <[email protected]>
Extract all network rendering logic (~687 lines) from app.rs into a new
NetworkRenderer module in src/render/network.rs. This includes:

- Full network view with interface table and traffic charts
- Network summary for default view (top 5 interfaces)
- Historical traffic visualization (bytes and packets)
- Dual-axis mirrored charts (RX negative, TX positive)
- Delta calculation for per-second rates
- Comprehensive error handling and edge cases

Add extensive test coverage with 13 tests covering:
- Basic rendering, localization, themes
- Edge cases: no interfaces, zero/high traffic, many interfaces
- Small terminal compatibility
- Multiple tick rates

Signed-off-by: Daniel Hodges <[email protected]>
@hodgesds hodgesds marked this pull request as ready for review October 30, 2025 17:27
Copy link
Contributor

@JakeHillion JakeHillion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@hodgesds hodgesds enabled auto-merge October 30, 2025 19:17
@hodgesds hodgesds force-pushed the scxtop-refactor-phase3 branch from 62915d7 to b2396e2 Compare October 30, 2025 20:34
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