refactor(window): extract auto-update into UpdateController (R4) - #159
Merged
Conversation
Move the MainWindow auto-update check, its background worker (QObject on a QThread), the notify/decision step and the update dialog into a new app/update_controller.py::UpdateController. The window now composes the controller (self._update_controller) and delegates: the startup deferral (QTimer.singleShot, isValid-guarded, same point in __init__) calls check_async(), the toolbar button click calls show_update_dialog(), and closeEvent calls release_worker(). Behaviour, threading and worker lifecycle are unchanged. The controller is a QObject parented to the window (main-thread affinity), so the worker's cross-thread `done` signal still resumes _on_update_found on the main thread via a bound-method (no lambda) queued connection — the Py3.14-safe pattern. The abort/wait(12s)/terminate teardown is preserved verbatim. Tests: add tests/test_update_controller.py (Flatpak/Snap short-circuit, main-thread QObject affinity, end-to-end worker wiring resuming on the main thread, no-update path, notify decision). Repoint the source-scanning lifecycle/audit tests to the new module without weakening assertions. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
R4 do plano de modularidade; extrai o subsistema de auto-update de
MainWindow(-149 linhas) paraapp/update_controller.py(classeUpdateController(QObject)parented a MainWindow para AFINIDADE ao main thread - preserva a queued connection Py3.14-safe do slot_on_update_foundvia bound method, sem lambda cross-thread); comportamento IDENTICO (startup no mesmo ponto, delay 2000ms, guard isValid, dialogo/decisao iguais, lifecycle abort/wait(12s)/terminate do worker chamado do happy-path e do closeEvent); pre-import de updater no main thread preservado; sem ciclo de import; +7 testes novos (incl. prova de que o slot resume no main thread) + 4 testes repontados sem enfraquecer; inclui fix de 2 comentarios stale em updater.py (NIT da revisao); suite 583 passed/0 failed; aprovado por revisao adversarial reproduzida por execucao. Depende de R1/R2 (em main); disjunto do R3 (PR #158, window.py nao colide).