Refactor: split monolithic main.py into core/, widgets/, ui/ packages#1
Draft
Refactor: split monolithic main.py into core/, widgets/, ui/ packages#1
Conversation
Co-authored-by: UltraAce258 <174670272+UltraAce258@users.noreply.github.com>
… remove local import, extract timeout constant Co-authored-by: UltraAce258 <174670272+UltraAce258@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor main.py for compatibility and reduced redundancy
Refactor: split monolithic main.py into core/, widgets/, ui/ packages
Mar 9, 2026
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.
main.pywas a 1598-line monolith mixing executor logic, terminal widget, dynamic param UI, script discovery, and the main window. This refactor splits responsibilities into focused modules while preserving 100% backward compatibility with all existing task scripts.New structure
core/i18n.pyUI_TEXTSsingleton;load_ui_texts()mutates it in-place so all modules share one dictcore/utils.pyresource_path()— PyInstaller-compatible path resolvercore/executor.pyScriptExecutor(QThread)— QProcess, output decoding,[PROGRESS]parsing, send_input/terminatecore/script_registry.pyscan(),parse_params(),extract_docstring()widgets/terminal.pyEnhancedTerminalWidgetwidgets/dynamic_params.pyDynamicParamsWidget—build_ui(params, lang)/build_args()/clear()ui/main_window.pyScriptGUI(QMainWindow)main.pyParameter parsing — backward-compatible
--gui-schemaextensionparse_params()tries--gui-schemafirst (returns structured JSON); falls back to the original--helpregex heuristic for legacy scripts:Bugs fixed
self.progress_label = Noneassigned twice in__init__— duplicate removedself.run_button.setText(lang['run_button'])called twice in_update_ui_language— duplicate removed_refresh_scripts: was enabling the Stop button (wrong) and_clear_dynamic_params_ui()was unreachable inside a comment — both corrected_on_script_finished:statusBar().showMessage(...)was inside an inline comment and never executed — fixed_dynamic_params_resize_event(line 646 in original was unreachable) — replaced byDynamicParamsWidget.resizeEventoverride_get_union_of_marked_items()extracted as a helper, eliminating duplicated selected+checked union logic in_on_remove_button_clickedandkeyPressEvent💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.