Background
The following UI modules have grown significantly and now contain multiple responsibilities:
src/ui/editor_panel.py
src/ui/canvas_panel.py
src/ui/main_window.py
This already conflicts with the architectural guidance documented in AGENTS.md:
- separation of concerns
- reusable services
- maintainable UI structure
- rendering isolation
- testability
Goals
Refactor the UI architecture into smaller focused modules while preserving all existing functionality and UX behavior.
Proposed Structure
Editor
src/ui/editor/
editor_widget.py
editor_selection.py
editor_highlighting.py
editor_comments.py
editor_undo.py
editor_search.py
Canvas
src/ui/canvas/
canvas_widget.py
canvas_rendering.py
canvas_selection.py
canvas_navigation.py
canvas_layers.py
canvas_cache.py
Main Window
src/ui/mainwindow/
main_window.py
menus.py
actions.py
statusbar.py
file_workflows.py
dialog_management.py
Requirements
- Preserve all existing UX behavior
- Preserve editor responsiveness
- Preserve rendering performance
- Avoid unnecessary reparsing or allocations
- Keep rendering logic isolated from application logic
- Avoid introducing hidden global state
- Keep tests green during the migration
- Refactor incrementally in reviewable steps
Acceptance Criteria
- Large monolithic UI files reduced substantially
- Responsibilities clearly separated
- Existing tests still pass
- No UX regressions
- Easier navigation and maintainability
- Foundation prepared for stricter typing and future UI tests
Background
The following UI modules have grown significantly and now contain multiple responsibilities:
src/ui/editor_panel.pysrc/ui/canvas_panel.pysrc/ui/main_window.pyThis already conflicts with the architectural guidance documented in
AGENTS.md:Goals
Refactor the UI architecture into smaller focused modules while preserving all existing functionality and UX behavior.
Proposed Structure
Editor
src/ui/editor/editor_widget.pyeditor_selection.pyeditor_highlighting.pyeditor_comments.pyeditor_undo.pyeditor_search.pyCanvas
src/ui/canvas/canvas_widget.pycanvas_rendering.pycanvas_selection.pycanvas_navigation.pycanvas_layers.pycanvas_cache.pyMain Window
src/ui/mainwindow/main_window.pymenus.pyactions.pystatusbar.pyfile_workflows.pydialog_management.pyRequirements
Acceptance Criteria