Skip to content

refactor(tui): split content.rs into modular components#63

Merged
daisuke8000 merged 1 commit intomainfrom
refactor/content-module-split
Dec 20, 2025
Merged

refactor(tui): split content.rs into modular components#63
daisuke8000 merged 1 commit intomainfrom
refactor/content-module-split

Conversation

@daisuke8000
Copy link
Owner

Summary

  • Split the large content.rs (4,084 lines) into organized submodules for better maintainability
  • Continue the incremental refactoring approach established in PRs 1-7

Changes

File Lines Description
mod.rs 2,644 ContentPanel struct, state management, navigation, Component trait
views.rs 1,002 View rendering functions (welcome, questions, collections, etc.)
modals.rs 367 Modal overlay rendering (sort, filter, search)

Key Technical Details

  • Rust split impl pattern: impl ContentPanel blocks distributed across files
  • Visibility control: pub(super) for internal module functions
  • Borrow checker fix: render_result_table accesses self.query_result internally to avoid parameter conflicts

Dual Review Summary

Reviewed with Claude + Gemini dual-review:

  • ✅ Module split approach is appropriate
  • ✅ Borrow checker solution is correct for ratatui patterns
  • pub(super) usage follows Rust best practices
  • 🔮 Further mod.rs split (handlers.rs) suggested for future PRs

Test plan

  • cargo test - 32 tests passed
  • cargo clippy - No warnings
  • cargo fmt - Applied
  • TUI functionality verified

Split the large content.rs (4,084 lines) into organized submodules:

- mod.rs (2,644 lines): ContentPanel struct, state management,
  navigation, Component trait implementation
- views.rs (1,002 lines): View rendering functions (render_welcome,
  render_questions, render_collections, render_query_result, etc.)
- modals.rs (367 lines): Modal overlay rendering (render_sort_modal,
  render_filter_modal, render_result_search_bar)

Key changes:
- Use Rust's split impl pattern for better code organization
- Apply pub(super) for internal visibility control
- Fix borrow checker conflicts in render_result_table by accessing
  self.query_result internally instead of passing as parameter
- Remove unused imports (Paragraph, LoadStateConfig) from mod.rs

This is PR 8 of the crates refactoring plan, following the same
incremental approach as PRs 1-7.
@daisuke8000 daisuke8000 merged commit 46968e5 into main Dec 20, 2025
1 check passed
@daisuke8000 daisuke8000 deleted the refactor/content-module-split branch December 20, 2025 15:24
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.

1 participant