Skip to content

refactor(window): extract auto-update into UpdateController (R4) - #159

Merged
nelsonduarte merged 2 commits into
mainfrom
refactor/window-update-controller
Aug 11, 2026
Merged

refactor(window): extract auto-update into UpdateController (R4)#159
nelsonduarte merged 2 commits into
mainfrom
refactor/window-update-controller

Conversation

@nelsonduarte

Copy link
Copy Markdown
Owner

R4 do plano de modularidade; extrai o subsistema de auto-update de MainWindow (-149 linhas) para app/update_controller.py (classe UpdateController(QObject) parented a MainWindow para AFINIDADE ao main thread - preserva a queued connection Py3.14-safe do slot _on_update_found via 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).

nelsonduarte and others added 2 commits August 11, 2026 14:17
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>
@nelsonduarte
nelsonduarte merged commit 171b80e into main Aug 11, 2026
4 checks passed
@nelsonduarte
nelsonduarte deleted the refactor/window-update-controller branch August 11, 2026 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant