Skip to content

Proposal: Refactoring - Split large monolithic files into submodules #1461

@krisclarkdev

Description

@krisclarkdev

Hey! As the project has grown, a few of the core structural files have become quite large and difficult to navigate. I noticed that crates/tui/src/tui/app.rs is sitting at over 5,000 lines and crates/tui/src/compaction.rs is over 2,600 lines.

To help pay down some technical debt and make the codebase easier to approach for new contributors, I'd like to propose splitting these monoliths into smaller, isolated submodules (without changing any underlying logic or behavior).

Here is the structure I'd like to implement:

  1. tui/app.rs -> tui/app/
  • state.rs: Struct/enum definitions (App, SessionState, etc.)
  • mutators.rs: State mutation functions / impl App.
  • actions.rs: UI action enums and standalone helpers.
  • mod.rs: Facade re-exporting the APIs so external callers don't break.
  1. compaction.rs -> compaction/
  • estimation.rs: Token estimation and budget logic.
  • summary.rs: Summarization request execution.
  • rules.rs: Heuristics (should_compact, limits).
  • planning.rs: Compaction planning and pinning logic.
  • extraction.rs / pruning.rs: Path extraction and truncation utilities.

I actually have this working locally on a branch right now and everything compiles cleanly with all tests passing.

Before I open a PR with a 7,000+ line diff, I wanted to check in to see if you'd be open to this structure? I don't want to create massive merge conflicts if you have active development going on in these files. If this looks good to you, I can open the PR whenever you are ready!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    Status
    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions