Skip to content

Refactor app.rs monolith into focused submodules#54

Open
muk2 wants to merge 2 commits intomainfrom
feature/issue-39-refactor-app
Open

Refactor app.rs monolith into focused submodules#54
muk2 wants to merge 2 commits intomainfrom
feature/issue-39-refactor-app

Conversation

@muk2
Copy link
Owner

@muk2 muk2 commented Feb 20, 2026

Summary

  • Splits the ~1900-line src/ui/app.rs monolith into 5 focused submodules under src/ui/app/
  • Pure refactoring with zero behavioral changes - all 225 existing tests pass unchanged
  • Each module handles a single concern, improving navigability and maintainability

Module Structure

src/ui/app/
├── mod.rs          (527 lines) Core App struct, types, enums, constants, new(), tick()
├── connection.rs   (412 lines) Connection dialog input, start_connect, finish_connect
├── sidebar.rs      (221 lines) Sidebar navigation, table inspector, schema refresh
├── editor.rs       (499 lines) Editor input, query execution, autocomplete, query parsing
└── results.rs      (282 lines) Results navigation, table inspector input, export

What moved where

Method/Handler From To
handle_connection_dialog_input, start_connect, finish_connect, try_auto_connect app.rs connection.rs
handle_sidebar_input, handle_sidebar_select, open_table_inspector, refresh_schema app.rs sidebar.rs
handle_editor_input, execute_query, update_autocomplete, find_query_boundaries app.rs editor.rs
handle_results_input, handle_export_input, handle_table_inspector_input, perform_export, copy_selected_cell app.rs results.rs
All type definitions, App struct, new(), handle_input(), tick(), utility methods app.rs mod.rs

Design Decisions

  • Used Rust's split impl block pattern - each submodule adds methods to App via impl App {}
  • Helper methods use pub(super) or pub(crate) visibility to keep the public API unchanged
  • Module-private helpers (like dialog_field_len) stay private to their module
  • ui/mod.rs still uses mod app; pub use app::*; - no changes needed to external imports

Test plan

  • cargo build compiles without warnings
  • cargo test - all 225 tests pass (zero behavioral changes)
  • Verified all public types and functions are still exported correctly

Closes #39

🤖 Generated with Claude Code

muk2 and others added 2 commits February 20, 2026 15:20
Splits the ~1900-line src/ui/app.rs into 5 focused modules:
- app/mod.rs: Core App struct, types, enums, new(), tick(), utilities
- app/connection.rs: Connection dialog input handling, connect/disconnect
- app/sidebar.rs: Sidebar navigation, table inspector, schema refresh
- app/editor.rs: Editor input, query execution, autocomplete, boundaries
- app/results.rs: Results navigation, table inspector input, export

Pure refactor with no behavioral changes. All existing tests pass.

Closes #39

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Run cargo fmt for consistent code formatting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

Refactor: Split app.rs monolith into focused modules

1 participant