Skip to content

增強資源選擇邏輯並改善錯誤處理#46

Merged
Colin955023 merged 5 commits into
masterfrom
fix/installer-update-flow
Jun 5, 2026
Merged

增強資源選擇邏輯並改善錯誤處理#46
Colin955023 merged 5 commits into
masterfrom
fix/installer-update-flow

Conversation

@Colin955023

Copy link
Copy Markdown
Owner
  1. 發佈與分發變更
    整合安裝程式: 移除了獨立的便攜版(Portable)ZIP 壓縮包及相關打包腳本。改為統一的安裝執行檔 (-Setup-.exe),使用者可在安裝時自行選擇要使用「標準安裝」或「便攜模式」,藉此簡化更新與版本管理。
    CI/CD 流程優化: 更新了自動化構建流程,導入 Sigstore 對發佈產物進行數位簽章,並新增了 id-token 權限。調整後,發佈資源將僅包含 .exe 檔案及其對應的簽章檔案。

  2. UI 與核心架構升級
    現代化介面: 導入 PySide6-Fluent-Widgets 程式庫,將 UI 全面升級為微軟的 Fluent Design(流暢設計) 風格。新組件封裝於 fluent.py 中,並徹底翻新了主視窗與子視窗的視覺與互動模式。
    效能與資源優化: 重構核心模組(server_manager.py 與 server_instance.py),改為使用共享工作執行緒池(Shared Worker Pool)來處理繁重任務,提升並發處理能力並優化系統資源佔用。
    穩定性提升: 改進了設定值與子程序(Subprocess)的管理機制,強化了序列化安全性以及程序生命週期的異常處理。

  3. 文件與使用者指引
    指南更新: 更新了所有使用者與技術手冊,以反映新的安裝模式、檔案路徑與更新機制。此外,新增了對照表以清晰說明「便攜模式」與「安裝模式」的差異。
    說明文件修正: 修訂了 README 和變更日誌(Changelog),統一採用新的專案術語,並著重強調了 Fluent UI 與新版安裝程式的變更。

  4. 測試與錯誤修復
    網路容錯: 修復了 update_parsing.py 中的錯誤處理邏輯,避免程式因網路問題而崩潰。
    測試覆蓋率: 擴展了自動化測試範圍,涵蓋更新檢查、UI 佈局以及模組整合測試。
    版本號更迭: 專案中繼資料(Metadata)正式更新為 1.7.2.0。

  5. 建置與依賴項更新
    CI 工具升級: 在 CI 環境中將 astral-sh/setup-uv 升級至 v8.2.0,並正式將 PySide6-Fluent-Widgets 列為新增的依賴套件。
    建置指令碼改進: 優化了建置腳本,現在允許透過設定環境變數 MSM_RECREATE_VENV 來強制重新建立虛擬環境(venv),並明確了執行檔的命名規範。

- 修改 `UpdateParsing` 類別,調整選擇安裝程式的邏輯,僅返回符合條件的安裝程式資源。
- 移除可攜式資源的選擇邏輯,簡化更新資源的選擇流程。
- 新增測試以驗證更新資源選擇的正確性。

fix: 修正檢查資源時的錯誤處理

- 在 `update_parsing.py` 中,改善資源檢查的錯誤處理,確保在發生異常時不會中斷流程。

test: 增加針對更新檢查器的單元測試

- 新增測試檔案 `test_update_checker_installer_smoke.py`,涵蓋安裝程式啟動參數的生成及用戶互動的模擬。
- 移除不再需要的測試檔案 `test_update_checker_path_script.py`。

test: 增加對資源解析的測試

- 新增測試檔案 `test_update_parsing_smoke.py`,驗證最新版本的獲取及資源選擇的正確性。
Copilot AI review requested due to automatic review settings June 5, 2026 09:30
Comment thread src/core/server_manager.py Fixed
Comment thread src/utils/runtime_utils/background_task.py Fixed
Comment thread src/utils/runtime_utils/subprocess_utils.py Fixed
Comment thread tests/test_settings_io_smoke.py Fixed
chatgpt-codex-connector[bot]

This comment was marked as resolved.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

此 PR 主要在專案中推進「以單一 installer.exe 作為發布/更新入口」並同步升級 UI 與背景工作架構:更新資產選擇邏輯改為僅挑選 installer、導入 Fluent Widgets 以現代化 UI 元件、並將多處並行/背景工作改為以 Qt(QThreadPool/QProcess)為核心的實作,同時補強網路/壓縮檔安全與錯誤回報,並更新文件與測試以反映新流程。

Changes:

  • 更新機制調整:更新資產選擇改為偏好 installer exe、移除 portable zip 打包/測試路徑並改為 installer smoke 測試。
  • UI/執行緒模型升級:導入 PySide6-Fluent-Widgets 封裝、ProgressBar/SearchEntry 等元件更新,並將 worker pool / background task / subprocess 管理改為 Qt 友善的執行模型(QThreadPool/QProcess)。
  • 安全與穩定性補強:safe_extract_zip 增加大小/壓縮比/symlink 防護、HTTP 下載錯誤原因更具體(含磁碟空間/timeout)、設定檔寫入加鎖與快照一致性測試。

Reviewed changes

Copilot reviewed 71 out of 72 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/test_update_parsing_smoke.py 更新資產選擇與 digest 解析的 smoke 測試(偏好 installer、sha512 digest 不再接受)。
tests/test_update_checker_path_script.py 移除舊 portable 更新腳本相關測試。
tests/test_update_checker_installer_smoke.py 新增 installer 更新互動與 installer.iss 約束的 smoke 測試。
tests/test_subprocess_utils_smoke.py 新增 QProcess 執行封裝的 smoke 測試。
tests/test_settings_io_smoke.py 新增 SettingsManager 併發更新快照一致性測試。
tests/test_server_properties_utils_smoke.py 新增 server.properties schema/rollback/boolean props 驗證相關測試。
tests/test_server_instance_skeleton.py 驗證停止進程清理前仍可讀取最後輸出。
tests/test_qt_widget_layout_smoke.py 新增 ProgressBar 文字渲染、SearchEntry 綁定與 checkbox 樣式測試。
tests/test_path_utils_json_smoke.py safe_extract_zip 增加解壓總大小限制測試。
tests/test_mod_manager_local_file_ops.py export_mod_list(html) 進行 HTML escape 的測試。
tests/test_mod_management_list_smoke.py 本地更新 review key fallback 與 stale 掃描結果丟棄測試。
tests/test_manage_server_frame_smoke.py monitor window 重用/前景行為測試。
tests/test_local_mod_metadata_utils.py JAR metadata 讀取大小上限測試。
tests/test_loader_manager_smoke.py installer 下載/執行流程改用 run_qprocess_checked 的測試調整。
tests/test_http_utils_download.py 下載磁碟空間不足與 timeout 錯誤原因回報測試。
tests/test_create_server_name_integration.py 命名流程測試改用 TaskUtils.run_async stub。
src/version_info/version_info.py 版本號更新至 1.7.2。
src/utils/update_utils/update_parsing.py 更新資產選擇邏輯:僅選 installer exe;digest 僅接受 sha256。
src/utils/ui_support/ui_utils.py UI thread 判定改用 Qt thread 概念。
src/utils/ui_support/qt_widgets.py 導入 Fluent Widgets wrapper、新增 SearchEntry、ProgressBar signal/paint 強化等。
src/utils/ui_support/qt_runtime.py 新增 install_open_url_click;run_on_ui_thread 改用 QSemaphore。
src/utils/ui_support/fluent.py 新增 qfluentwidgets 可選整合與 SearchFilter/主題套用。
src/utils/server_utils/server_properties_utils.py 更新描述/分類/驗證規則(management server、level-type、region compression 等)。
src/utils/runtime_utils/worker_pool.py shared worker pool 改用 BackgroundTaskManager(Qt 工作池)。
src/utils/runtime_utils/subprocess_utils.py 新增 QProcessResult、create/run_qprocess_checked 封裝。
src/utils/runtime_utils/singleton.py singleton 初始化護欄調整為 type.setattr
src/utils/runtime_utils/settings_manager.py 設定讀寫加 RLock、視窗偏好正規化拆分。
src/utils/runtime_utils/background_task.py 背景任務執行器改用 QThreadPool + Future 封裝。
src/utils/runtime_utils/app_restart.py 重啟流程改用 run_in_background Future 等待結果。
src/utils/network_utils/http_utils.py 更細緻錯誤原因描述、磁碟空間預檢、async 改用 shared worker pool。
src/utils/mod_utils/mod_index_manager.py log 文案微調。
src/utils/java_support/java_utils.py Java 掃描並行改用 shared manager。
src/utils/core_utils/path_utils.py safe_extract_zip 強化:大小/壓縮比/總量/symlink 防護與目的地建立。
src/utils/core_utils/hash_utils.py async hash 計算改用 shared worker pool Future。
src/ui/ui_config.py 套用 Fluent theme、checkbox stylesheet 抽出與加強。
src/ui/task_utils.py 背景任務統一走 run_in_background;失敗回傳 Future exception。
src/ui/server_properties_dialog.py checkbox 判定改由 validator/defaults;預設 properties 載入與分類顯示改善。
src/ui/server_monitor_window.py 監控 loop 改以 Qt timer/debounce 驅動,移除 ThreadPoolExecutor。
src/ui/progress_dialog.py ProgressBar 改用 qt.ProgressBar 並以 Qt signal 更新/關閉。
src/ui/mod_search_service/dependency_planner_facade.py 本地 hash 計算並行改用 shared manager。
src/ui/mod_management/tree_sync.py 本地搜尋改用 SearchFilter normalization/matches。
src/ui/mod_management/review.py review root_key 改用 _build_local_update_review_key。
src/ui/mod_management/online_mod_queue.py 線上搜尋 query 正規化。
src/ui/mod_management/online_browse_presenter.py 線上搜尋輸入改為 SearchEntry + SearchFilter。
src/ui/mod_management/local_mod_list_presenter.py 本地模組掃描增加 token/scope 驗證、signature 防 stale,並行改用 shared manager。
src/ui/mod_management/frame.py 進度更新改用 Qt signal slot。
src/ui/manage_server_frame.py monitor window bring-to-front 行為整理;備份批次檔改用 QProcess.startDetached。
src/ui/main_window.py 多處按鈕改 fluent;GitHub link 點擊改 event filter;初始化伺服器改用 QProcess。
src/ui/dialog_utils.py 非 UI thread 的 ask_yes_no_cancel 改用 run_on_ui_thread。
src/ui/create_server_frame.py fluent 控件導入、背景任務 API 名稱調整、progress dialog 建立改用 call_on_ui。
src/core/version_manager.py 版本詳細查詢並行改用 shared manager 批次提交。
src/core/server_manager.py server process 改以 QProcess 管理與輸出緩衝;建立/刪除/回滾流程更嚴謹。
src/core/server_instance.py 支援 QProcess:pid/running/returncode 抽象、stdout 片段拆行與 pending flush。
src/core/mod_manager.py HTML 匯出改用 html.escape 防注入。
src/core/mod_file_installer.py 下載失敗原因透過 callback 回傳到 result.message。
src/core/local_mod_scanner.py JAR metadata 讀取加入 max_bytes 限制並改用 shared manager 並行掃描。
src/core/loader_manager.py installer 執行改用 run_qprocess_checked,下載失敗原因回傳。
scripts/package-portable.ps1 移除 portable zip 打包腳本。
scripts/installer.iss installer 支援一般/可攜式模式選擇、portable 不建立 uninstall、排除使用者資料。
scripts/format_lint_check.bat secret scan 選項加預設與 timeout。
scripts/build_installer_nuitka.py 移除 portable 產物、支援 MSM_RECREATE_VENV、命名常數化。
README.md 文件更新為單一 installer + 可攜式安裝模式。
docs/USER_GUIDE.md 安裝與資料路徑說明更新(可攜式安裝/一般安裝)。
docs/TECHNICAL_OVERVIEW.md 架構/模組路徑/Release Notes 清理說明更新。
docs/PORTABLE_INSTALLER_MATRIX.md 更新為「可攜式/一般安裝」矩陣與新更新流程。
CHANGELOG.md 新增 v1.7.2 條目與變更摘要。
assets/version_info.txt FileVersion/ProductVersion 更新至 1.7.2.0。
.github/workflows/build-release.yml 發佈流程加入 Sigstore 簽章與資產列表調整(exe + sigstore json)。
.github/actions/setup-python-env/action.yml setup-uv 升級至 v8.2.0。
pyproject.toml 新增 PySide6-Fluent-Widgets 依賴。

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/utils/runtime_utils/subprocess_utils.py Outdated
Comment thread src/utils/runtime_utils/subprocess_utils.py Fixed
Copilot AI review requested due to automatic review settings June 5, 2026 11:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Comment thread src/utils/runtime_utils/subprocess_utils.py Dismissed
@Colin955023 Colin955023 merged commit b0a7c33 into master Jun 5, 2026
7 checks passed
@Colin955023 Colin955023 deleted the fix/installer-update-flow branch June 5, 2026 11:35
Colin955023 added a commit that referenced this pull request Jun 8, 2026
重構 UpdateParsing 邏輯:改為僅篩選安裝程式檔案,並移除可攜式模式支援
優化系統性能與用戶體驗
改善 update_parsing.py 的資源檢查錯誤處理,避免異常導致流程中斷
將部分異常處理放寬為使用更通用的 Exception 類別
修正 QProcess 啟動備份批次檔的邏輯,確保成功啟動後才顯示備份資訊
修正 QProcess 檢查邏輯,確保在 UI 初始化前正確建立 QApplication
新增 test_update_checker_installer_smoke.py,驗證安裝程式啟動參數與模擬用戶互動
新增 test_update_parsing_smoke.py,驗證最新版本獲取與資源選擇邏輯
移除不再需要的 test_update_checker_path_script.py
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.

3 participants