Skip to content

Conversation

@hodgesds
Copy link
Contributor

Extract process and thread rendering logic from the monolithic app.rs into a new dedicated render module. This is Phase 1 of a larger refactoring effort to improve maintainability of the scxtop codebase.

Changes:

  • Created src/render/mod.rs and src/render/process.rs

    • Introduced ProcessRenderer struct with static methods
    • Extracted create_table_header_and_constraints() (~40 lines)
    • Extracted render_process_table() (~100 lines)
    • Extracted render_thread_table() (~100 lines)
  • Modified src/app.rs

    • Removed duplicate rendering implementation
    • Delegated to ProcessRenderer for process/thread rendering
    • Updated method signatures to return new events_list_size value to avoid borrowing conflicts
  • Modified src/lib.rs

    • Added pub mod render
    • Exported Column type for test access
  • Added tests/render_process_tests.rs

    • Tests for table header generation
    • Tests for process table rendering
    • Tests for thread table rendering
    • Uses ratatui TestBackend for integration-style testing
    • Created helper functions for test data creation

Extract process and thread rendering logic from the monolithic app.rs
into a new dedicated render module. This is Phase 1 of a larger
refactoring effort to improve maintainability of the scxtop codebase.

Changes:
- Created src/render/mod.rs and src/render/process.rs
  - Introduced ProcessRenderer struct with static methods
  - Extracted create_table_header_and_constraints() (~40 lines)
  - Extracted render_process_table() (~100 lines)
  - Extracted render_thread_table() (~100 lines)

- Modified src/app.rs
  - Removed duplicate rendering implementation
  - Delegated to ProcessRenderer for process/thread rendering
  - Updated method signatures to return new events_list_size value
    to avoid borrowing conflicts

- Modified src/lib.rs
  - Added pub mod render
  - Exported Column type for test access

- Added tests/render_process_tests.rs
  - Tests for table header generation
  - Tests for process table rendering
  - Tests for thread table rendering
  - Uses ratatui TestBackend for integration-style testing
  - Created helper functions for test data creation

Signed-off-by: Daniel Hodges <[email protected]>
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.

More separation & new tests seems like a win.

@hodgesds hodgesds marked this pull request as ready for review October 30, 2025 17:26
@hodgesds hodgesds added this pull request to the merge queue Oct 30, 2025
Merged via the queue into sched-ext:main with commit 9a8fa72 Oct 30, 2025
21 checks passed
@hodgesds hodgesds deleted the scxtop-refactor-phase1 branch October 30, 2025 17:51
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