Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[Architecture] Split app/ui/tui.py (8.5k lines, 21 modals + app class) into a ui package and move session/recovery logic to core

Open
#710 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
desktop, devtools

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

architecture enhancement ready-for-human

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 ModalScreen classes. Some are very large: SettingsModal 1721-2268 (~550 lines), DropZoneModal 3959-4719 (~760), AuditReportModal 4850-5317 (~470), QuarantineVaultModal 5489-6078 (~590), ModelManagerModal 2461-2783.
  • AutoSorterTUI 6162-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. AutoSorterTUI has no direct shutil.rmtree, DBWorker() or build_corpus_generator usage.
  • All existing tests/test_tui*.py and visual snapshot tests pass unchanged, or with only import-path updates.
  • Plugins import app.ui.a11y, not app.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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from fderuiter/sortify

All issues in fderuiter/sortify

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.