Skip to content

Refactor: Split app.rs monolith into focused modules #39

@muk2

Description

@muk2

Summary

Refactor src/ui/app.rs (~1,100 lines) into smaller, focused modules to improve maintainability, testability, and code navigation.

Motivation

app.rs is the largest file in the codebase and handles too many concerns:

  • Application state management
  • Connection dialog input handling
  • Sidebar navigation logic
  • Editor input dispatching
  • Results pane navigation
  • Export picker logic
  • Async task management
  • Toast notification system

This makes it difficult to understand, modify, or test individual features. As more features are added (autocomplete, transactions, vim mode), this file will only grow.

Proposed Refactoring

src/ui/
├── app.rs              # Core App struct, state, and tick() loop (reduced to ~200 lines)
├── app/
│   ├── mod.rs          # Re-exports
│   ├── connection.rs   # Connection dialog state and input handling
│   ├── sidebar.rs      # Sidebar navigation and schema interaction
│   ├── editor.rs       # Editor input dispatching and query execution
│   ├── results.rs      # Results pane navigation and sorting
│   ├── export.rs       # Export picker state and logic
│   └── toast.rs        # Toast notification system
├── components.rs       # UI rendering (unchanged)
└── theme.rs            # Theme system (unchanged)

Acceptance Criteria

  • App struct fields organized with clear sections
  • Each input handler extracted to its own module
  • No behavioral changes (pure refactor)
  • All existing tests still pass
  • Each module < 300 lines
  • New modules are independently unit-testable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions