[Architecture] Split app/ui/tui.py (8.5k lines, 21 modals + app class) into a ui package and move session/recovery logic to core
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
Research direction
Start by mapping the classes and responsibilities listed in app/ui/tui.py, then read the existing tests/test_tui*.py and the composition-root issue referenced in the body. The work spans many modals, UI widgets, and core session and sorting logic, so identify dependencies before splitting files. It is done when the acceptance criteria are met and the existing TUI and visual snapshot tests pass.
Written by the indexing model from the issue text.
Description
Problem
app/ui/tui.py is 8,486 lines and contains everything in the TUI:
- Shared widgets and mixins:
A11yMixin(180-480),LabeledSwitch(481),DensitySlider(565),VimTree(6078), and path-diff helpers (52-178). - 21
ModalScreenclasses. Some are very large:SettingsModal1721-2268 (~550 lines),DropZoneModal3959-4719 (~760),AuditReportModal4850-5317 (~470),QuarantineVaultModal5489-6078 (~590),ModelManagerModal2461-2783. AutoSorterTUI6162-8371 (~2,200 lines, 62 methods),run_tui(8371) and a11y inspection utilities (8439-8478).- A module-level
__getattr__that imports a plugin view (8480-8486).
The file also holds domain logic that belongs in core:
- The full sort pipeline in
DropZoneModal(tui.py:4646-4689). - Session recovery and rollback orchestration, including deleting session directories with
shutil.rmtree(tui.py:6600-6652). - Hand-wiring
DBWorker/Database/CacheManager/HistoryManager(tui.py:7097-7100, 5744, 1541). - DB/vector statistics helpers
_get_vector_count/_get_model_cache_footprint_mb(tui.py:1530-1566). - About 90 function-local
from app.*imports, against 3 at module top.
Impact
- Merge conflicts: almost every UI PR touches this one file.
- The modals can't be tested in isolation without importing the whole app.
- Plugins have to import the full TUI to reuse
A11yMixin(see the layering issue). - Recovery and rollback rules can't be reused by the CLI or the daemon.
Proposed split
app/ui/
app.py # AutoSorterTUI + run_tui (bindings, layout, dispatch only)
a11y.py # A11yMixin, A11yViolation, inspect_tui_component
widgets/ # labeled_switch.py, density_slider.py, vim_tree.py, path_diff.py
modals/
settings.py # SettingsModal, ScrubArtifactsModal, ConsentRevocationModal
models.py # ModelManagerModal
rules.py # TemplateGalleryModal, RuleImportModal
wizard.py # WizardModal
session.py # SessionRecoveryModal, HistoryModal
drop_zone.py # DropZoneModal (UI only; calls core pipeline)
reports.py # ExportReportModal, AuditReportModal, ExtractionPreviewModal
quarantine.py # QuarantineVaultModal
edit.py # Rename/NewFolder/Reassign/DirectorySelect/ManualPathFallback/DuplicateReview
help.py # ShortcutCheatSheetModal
Move recovery/rollback/cleanup into app/core/session.py (or the session catalog proposed in the composition-root issue). Move DropZone sorting onto the shared pipeline service. Keep app/ui/tui.py as a thin re-export shim for one release so tests and imports keep working.
Acceptance criteria
- No file under
app/ui/exceeds ~1,500 lines.AutoSorterTUIhas no directshutil.rmtree,DBWorker()orbuild_corpus_generatorusage. - All existing
tests/test_tui*.pyand visual snapshot tests pass unchanged, or with only import-path updates. - Plugins import
app.ui.a11y, notapp.ui.tui.
- Dominant language
- Python
- Stars
- 1
- Forks
- 0
- Avg merge
- 9h 3m
- Merged PRs (30d)
- 361
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from fderuiter/sortify
-
bug ready-for-agent
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
security
Difficulty 2/5 1-3 hours Newbie friendliness 57/100
Maintainers usually reply within 1 day
-
architecture enhancement ready-for-agent
Difficulty 5/5 Over a week Newbie friendliness 35/100
fderuiter/sortify#783 · 1 comment ·
Maintainers usually reply within 1 day
-
enhancement ready-for-human
Difficulty 4/5 3-5 days Newbie friendliness 48/100
fderuiter/sortify#740 · 1 comment ·
Maintainers usually reply within 1 day
-
architecture enhancement ready-for-human
Difficulty 5/5 Over a week Newbie friendliness 25/100
fderuiter/sortify#726 · 1 comment ·
Maintainers usually reply within 1 day
All issues in fderuiter/sortify
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
iceboundrock/AutoForge#304 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
fossasia/visdom-dev#77 ·
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
aws-cloudformation/cfn-lint#4890 ·
Maintainers usually reply within 2 days