refactor(desktop): split WindowLatexPdfMixin into compile + pdf-preview (Batch 10 Stage 3)#82
Conversation
… Stage 3, 1/2) _TectonicInstallWorker and _LatexCompileWorker were the only QThread workers defined inside a mixin file; every other worker (CalcWorker/FitWorker/ RootSolvingWorker/...) lives in workers_qt.py. Move both, plus their tightly-coupled helpers used only by them (_TECTONIC_STAGE_LABELS, _LatexEngineRun, _LatexCompileOutcome, _looks_like_plain_tex_output), to workers_qt.py for architectural consistency. They are re-imported into window_latex_pdf_mixin.py so that: - compile_latex_to_pdf / _offer_tectonic_install keep resolving them as module globals (call-time lookup lets the desktop UI tests monkeypatch window_latex_pdf_mixin._LatexCompileWorker), and - external imports (test_latex_compile_worker.py imports _LatexCompileWorker and _looks_like_plain_tex_output from window_latex_pdf_mixin) keep working. Behavior-preserving pure move: no logic change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ew (Stage 3, 2/2) Second half of Batch-10 Stage 3. Split the 759-line WindowLatexPdfMixin (after the worker extraction) into two responsibility mixins via the proven window_fitting_mixin shim pattern: - window_latex_compile_mixin.py — WindowLatexCompileMixin (open/save/reload, compile_latex_to_pdf, engine resolution, tectonic install orchestration). - window_pdf_preview_mixin.py — WindowPdfPreviewMixin (PDF render/zoom/image display, dark-mode inversion, preview-tool location). - window_latex_pdf_mixin.py — now a 66-line shim: an empty subclass composing the two (compile leftmost, since it calls into preview after a successful compile), re-exporting WindowLatexPdfMixin AND the two workers so `from app_desktop.window_latex_pdf_mixin import WindowLatexPdfMixin / _LatexCompileWorker / _TectonicInstallWorker` keep working unchanged. Behavior-identical (pure move + shim). Stage-0 guardrails updated deliberately: _EXPECTED_MRO now expands the shim into its two sub-mixins; no mixin defines __init__ or a Qt event handler; no cross-sibling duplicate method names. Dropped window_latex_pdf_mixin.py from the file-size ratchet baseline (969 -> 66, now well under the 800 soft limit). Independently re-verified (not the subagent's self-report): ruff clean; the public import + full MRO check pass; 53 latex/compile/pdf/installer/ratchet/ desktop tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (8)
📝 WalkthroughWalkthroughThe monolithic ChangesLaTeX compile/preview mixin split
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant CompileMixin as WindowLatexCompileMixin
participant CompileWorker as _LatexCompileWorker
participant TectonicWorker as _TectonicInstallWorker
participant PreviewMixin as WindowPdfPreviewMixin
User->>CompileMixin: compile_latex_to_pdf()
CompileMixin->>CompileMixin: _persist_latex_editor()
CompileMixin->>CompileMixin: _ensure_latex_engine()
alt Tectonic missing
CompileMixin->>TectonicWorker: _offer_tectonic_install()
TectonicWorker-->>CompileMixin: EngineChoice or None
end
CompileMixin->>CompileWorker: start(engine)
CompileWorker-->>CompileMixin: completed(outcome)
CompileMixin->>PreviewMixin: _render_pdf_preview(force_reload=True)
PreviewMixin-->>User: display rendered PDF pages
Related PRs: No related pull requests identified from the provided information. Suggested labels: refactor, desktop-app, latex Suggested reviewers: yilibinbin 🐰 A mixin split, tidy and neat, 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Batch 10 — Stage 3: split
WindowLatexPdfMixin(behavior-preserving)The cleanest, lowest-risk split from the reviewed decomposition plan, backstopped
by the Stage 0 guardrails (merged in #81). Two commits:
1/2 — extract the two LaTeX QThread workers to
workers_qt.py._TectonicInstallWorkerand_LatexCompileWorker(+ their helpers:_TECTONIC_STAGE_LABELS,_LatexEngineRun,_LatexCompileOutcome,_looks_like_plain_tex_output) were the only workers defined inside a mixin file;every other worker (
CalcWorker,FitWorker,RootSolvingWorker, …) lives inworkers_qt.py. Moved for architectural consistency (Gemini review finding).2/2 — split the mixin via the proven
window_fitting_mixinshim pattern.window_latex_compile_mixin.py—WindowLatexCompileMixin(open/save/reload,compile_latex_to_pdf, engine resolution, tectonic install).window_pdf_preview_mixin.py—WindowPdfPreviewMixin(PDF render/zoom/imagedisplay, dark-mode inversion).
window_latex_pdf_mixin.py— now a 66-line shim (was 969): empty subclasscomposing the two (compile leftmost), re-exporting
WindowLatexPdfMixinandthe two workers, so all existing imports keep working unchanged.
Guardrails updated deliberately:
_EXPECTED_MROexpands the shim into its twosub-mixins; the 6 composition guardrails still pass (no mixin
__init__, no Qtevent override, no cross-sibling duplicate names).
window_latex_pdf_mixin.pydropped from the file-size ratchet (969 → 66);
workers_qt.pyconsciouslybaselined at 807.
Test plan
public import + full MRO check pass.
Stage 1 (statistics, larger) is a possible future PR; Stage 2 (cross-family run
controller) and Stage 4 (Protocol) are NO-GO per the two-model review.
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes