Skip to content

refactor(tui): split app.rs and views.rs into modular components#65

Merged
daisuke8000 merged 1 commit intomainfrom
refactor/file-split-views-app
Dec 20, 2025
Merged

refactor(tui): split app.rs and views.rs into modular components#65
daisuke8000 merged 1 commit intomainfrom
refactor/file-split-views-app

Conversation

@daisuke8000
Copy link
Owner

Summary

  • Split app.rs (1165 lines) into app/ directory with 4 modules
  • Split views.rs (1004 lines) into views/ directory with 4 modules
  • Additional splits for content/mod.rs functionality into 9 modules

Changes

app/ directory

File Responsibility
mod.rs App struct, initialization, rendering
action_handler.rs AppAction event processing
data_handler.rs Async data loading with tokio tasks
input_handler.rs Keyboard event processing

views/ directory

File Responsibility
mod.rs Module exports
welcome.rs Welcome screen and placeholder
lists.rs Questions, Collections, Databases list views
drill_down.rs Collection→Questions, DB→Schemas→Tables
results.rs Query result and table preview rendering

content/ additional modules

File Responsibility
types.rs ContentView, InputMode, SortOrder, QueryResultData
navigation.rs Navigation stack and view transitions
selection.rs Selection navigation for each view type
search.rs Search mode handling
sort.rs Sort modal and index-based sorting
filter.rs Filter modal and filtering
result_search.rs All-column search in results
pagination.rs Pagination and scrolling
key_handler.rs Key event handling per view

Test plan

  • All 32 tests pass
  • cargo fmt
  • cargo clippy (1 warning for unused trait method)
  • cargo build

Split large files for better readability and maintainability:

app.rs (1165 lines) → app/ directory:
- mod.rs: App struct, initialization, and rendering
- action_handler.rs: AppAction event processing
- data_handler.rs: Async data loading with tokio tasks
- input_handler.rs: Keyboard event processing

views.rs (1004 lines) → views/ directory:
- mod.rs: Module exports
- welcome.rs: Welcome screen and placeholder
- lists.rs: Questions, Collections, Databases list views
- drill_down.rs: Collection→Questions, DB→Schemas→Tables
- results.rs: Query result and table preview rendering

content/mod.rs additional splits:
- types.rs: ContentView, InputMode, SortOrder, QueryResultData
- navigation.rs: Navigation stack and view transitions
- selection.rs: Selection navigation for each view type
- search.rs: Search mode handling
- sort.rs: Sort modal and index-based sorting
- filter.rs: Filter modal and filtering
- result_search.rs: All-column search in results
- pagination.rs: Pagination and scrolling
- key_handler.rs: Key event handling per view

All 32 tests pass. No functional changes.
@daisuke8000 daisuke8000 merged commit 3087ed7 into main Dec 20, 2025
1 check passed
@daisuke8000 daisuke8000 deleted the refactor/file-split-views-app branch December 20, 2025 16:20
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