Skip to content

refactor(shell): decompose 1760-line MainScreen into dedicated coordinators #1503

Open

Description

@ZhuchkaTriplesix

Problem

lib/features/main_screen/main_screen.dart is 1,765 lines long. Its state class _MainScreenState is responsible for too many unrelated subsystems:

  1. Global Keyboard Event Routing: Listening to HardwareKeyboard, intercepting shortcuts (Ctrl/Cmd+P, Ctrl/Cmd+K, sidebar toggle, query run, escape).
  2. Layout & Split Management: Managing _MainContentSplitState, sidebar show/hide animations, divider drag delta, width persistence.
  3. Dialog & Flow Coordination: Welcome tour dialog trigger, URL connection import dialog, connection creation modal flow, unsandboxed driver consent gate.
  4. Platform & Window Integration: Safe mode auto-relock timers, bitsdojo window title bar, macOS platform menu bar callbacks, and status bar bindings.

This makes MainScreen fragile to changes, increases widget rebuild scope, and complicates regression testing.

Scope

Decompose MainScreen by extracting dedicated controllers/coordinators:

  • MainScreenKeyboardRouter: Handles global keyboard shortcuts and dispatches actions to command hosts.
  • MainScreenDialogCoordinator: Manages modal flow triggers (connection creation, URL dialog, welcome tour, safe mode lock).
  • MainScreenLayoutCoordinator: Encapsulates sidebar visibility notifier, split drag delta, and width persistence.

Acceptance

  • main_screen.dart acts purely as a structural layout coordinator under 400 lines.
  • Keyboard shortcuts, dialog flows, and split resizing logic covered by isolated unit/widget tests.
  • E2E shell tests (test/e2e/06_shell_theme_and_command_palette/) remain green.

Activity

  1. added
    frontendTheme parser epic label: frontend
    uiUser interface components and widgets
    uxUser experience, keyboard shortcuts and interactions
    P2Medium priority / Parity & Refactoring
    on Oct 12, 2026
  2. added this to the 0.5.0 milestone on Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium priority / Parity & RefactoringfrontendTheme parser epic label: frontenduiUser interface components and widgetsuxUser experience, keyboard shortcuts and interactions

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions