Skip to content

Refactor command dispatch from monolithic match to modular strategy pattern #2791

@aboimpinto

Description

@aboimpinto

Refactor command dispatch and command implementation ownership from monolithic files into focused command modules.

Problem

The command area had grown into a mix of central dispatch, large implementation files, and a commands::shared tree that was not truly shared. Several public methods were kept alive only because tests referenced them, not because any command handler or production path called them. That made it hard to see which command owned which behavior and made dead code look like reusable API.

Current work plan

Part 1 summary

The first PR focuses on the command structure itself:

  • Reorganized commands toward the focused folder shape: <command>_command.rs, <command>_impl.rs, and mod.rs.
  • Removed the commands::shared tree because it was not a real shared command layer anymore.
  • Deleted dead-code paths and public methods that were only referenced by tests.
  • Removed placeholder config handler modules and tests that only protected unused public APIs.
  • Moved real cross-module behavior out of commands into neutral TUI modules:
    • config persistence
    • config action handling
    • model routing / auto model selection
    • share export/upload behavior
    • conversation reset state
  • Kept command handlers as the command entry points. UI and runtime code now call neutral modules instead of reaching into command internals.

Why this split matters

This keeps the first PR focused on command ownership and dead-code cleanup. The remaining user_commands work is still important, but it is a separate concern and should be reviewed as its own follow-up instead of being mixed into the broader command-group restructuring.

Paulo Aboim Pinto

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    Status
    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions