完善鸣潮官方更新等待流程 - #408
Conversation
审查者指南将《鸣潮》官方启动器版本元数据集成到 OK-WW 自动代理流程中,新增更新/预下载检测、通过 OCR 由启动器驱动的更新编排,以及本地版本轮询,同时继续将实际下载和验证完全交由官方启动器处理。 《鸣潮》官方启动器更新流程时序图sequenceDiagram
participant OKWW as OK-WW AutoProxy
participant API as Official Update API
participant Launcher as Official Launcher
participant FS as Local Version Metadata
OKWW->>API: check_wuthering_waves_update(launcher_path, resource)
API-->>OKWW: default / predownload version metadata
OKWW->>Launcher: _start_wuthering_waves_launcher()
alt Formal update available
OKWW->>Launcher: _click_wuthering_waves_launcher_text(Update)
Launcher-->>FS: Download, install, and verify update
loop Until target version is reached
OKWW->>FS: _read_local_wuthering_waves_version(launcher_path)
FS-->>OKWW: current version
end
OKWW->>OKWW: wait_wuthering_waves_update(launcher_path, target_version)
else Predownload available
OKWW->>Launcher: _click_wuthering_waves_launcher_text(预下载)
OKWW->>Launcher: _click_wuthering_waves_launcher_text(确定下载)
end
OKWW->>OKWW: Start Wuthering Waves client
文件级变更
提示和命令与 Sourcery 交互
自定义使用体验访问你的控制面板:
获取帮助Original review guide in EnglishReviewer's GuideIntegrates Wuthering Waves official launcher version metadata into the OK-WW auto-proxy flow, adding update/predownload detection, launcher-driven update orchestration via OCR, and local version polling, while keeping actual download and verification fully delegated to the official launcher. Sequence diagram for the Wuthering Waves official launcher update flowsequenceDiagram
participant OKWW as OK-WW AutoProxy
participant API as Official Update API
participant Launcher as Official Launcher
participant FS as Local Version Metadata
OKWW->>API: check_wuthering_waves_update(launcher_path, resource)
API-->>OKWW: default / predownload version metadata
OKWW->>Launcher: _start_wuthering_waves_launcher()
alt Formal update available
OKWW->>Launcher: _click_wuthering_waves_launcher_text(Update)
Launcher-->>FS: Download, install, and verify update
loop Until target version is reached
OKWW->>FS: _read_local_wuthering_waves_version(launcher_path)
FS-->>OKWW: current version
end
OKWW->>OKWW: wait_wuthering_waves_update(launcher_path, target_version)
else Predownload available
OKWW->>Launcher: _click_wuthering_waves_launcher_text(预下载)
OKWW->>Launcher: _click_wuthering_waves_launcher_text(确定下载)
end
OKWW->>OKWW: Start Wuthering Waves client
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
嘿——我发现了 2 个问题
面向 AI Agent 的提示
请处理本次代码审查中的评论:
## 单独评论
### 评论 1
<location path="app/services/wuthering_waves.py" line_range="151-152" />
<code_context>
+
+
+def _is_newer_version(candidate: str | None, current: str | None) -> bool:
+ if not candidate or not current:
+ return False
+ return _version_key(candidate) > _version_key(current)
+
+
</code_context>
<issue_to_address>
**问题 (bug_risk):** 当 `launcherDownloadConfig.json` 缺失或不包含可用的本地版本时,`_is_newer_version` 始终返回 `False`,因此正式更新和预下载都会被报告为不可用,并且永远不会启动官方启动器。
**触发条件:** 本地启动器版本记录不存在、为空,或在之前的安装/更新过程中被删除时。
**建议修复:** 将未知的本地版本视为需要启动启动器,或者明确使检查失败,而不是报告没有更新。
```suggestion
if not current:
return True
```
</issue_to_address>
### 评论 2
<location path="app/services/wuthering_waves.py" line_range="234" />
<code_context>
+ if not isinstance(payload, dict):
+ raise ValueError("鸣潮官方更新接口返回格式错误")
+
+ default_info = payload.get("default")
+ predownload_info = payload.get("predownload")
+ if not isinstance(default_info, dict):
+ raise ValueError("鸣潮官方更新接口缺少 default 版本信息")
+
+ release_version = str(default_info.get("version") or "").strip() or None
+ predownload_version = (
+ str(predownload_info.get("version") or "").strip()
+ if isinstance(predownload_info, dict)
</code_context>
<issue_to_address>
**问题 (bug_risk):** 当 API 响应包含 `default` 对象但没有有效的 `version` 时,该响应仍会被接受,导致 `release_version=None`,并且更新检测会被静默禁用,而不是拒绝格式错误的响应。
**触发条件:** 官方更新 API 返回不完整或暂时格式错误的 `default` 条目时。
**建议修复:** 验证 `default_info["version"]` 是非空字符串;当其缺失或无效时,抛出 `ValueError`。
```suggestion
release_version = default_info.get("version")
if not isinstance(release_version, str) or not release_version.strip():
raise ValueError("鸣潮官方更新接口缺少有效的 default version")
release_version = release_version.strip()
```
</issue_to_address>Sourcery 评估
需要人工审查。 需要先处理 2 个发现,并且该变更会根据远程版本接口和 OCR 操作官方启动器,自动下载、解压并覆盖本地游戏安装文件;如果版本判断或按钮识别错误,影响会在代码回滚后仍留在本地安装中。影响范围通常局限于单个游戏安装,可通过官方启动器重新更新或重装修复,但不能仅靠回滚完全撤销。
阻塞性发现:app/services/wuthering_waves.py:152、app/services/wuthering_waves.py:234
帮助我变得更有用!请在每条评论上点击 👍 或 👎,我会利用这些反馈来改进审查结果。
Original comment in English
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="app/services/wuthering_waves.py" line_range="151-152" />
<code_context>
+
+
+def _is_newer_version(candidate: str | None, current: str | None) -> bool:
+ if not candidate or not current:
+ return False
+ return _version_key(candidate) > _version_key(current)
+
+
</code_context>
<issue_to_address>
**issue (bug_risk):** When `launcherDownloadConfig.json` is missing or contains no usable local version, `_is_newer_version` always returns `False`, so both formal updates and predownloads are reported as unavailable and the official launcher is never started.
**Triggers:** When the local launcher version record is absent, empty, or has been removed during a prior installation/update.
**Suggested fix:** Treat an unknown local version as requiring the launcher to start, or explicitly fail the check instead of reporting no update.
```suggestion
if not current:
return True
```
</issue_to_address>
### Comment 2
<location path="app/services/wuthering_waves.py" line_range="234" />
<code_context>
+ if not isinstance(payload, dict):
+ raise ValueError("鸣潮官方更新接口返回格式错误")
+
+ default_info = payload.get("default")
+ predownload_info = payload.get("predownload")
+ if not isinstance(default_info, dict):
+ raise ValueError("鸣潮官方更新接口缺少 default 版本信息")
+
+ release_version = str(default_info.get("version") or "").strip() or None
+ predownload_version = (
+ str(predownload_info.get("version") or "").strip()
+ if isinstance(predownload_info, dict)
</code_context>
<issue_to_address>
**issue (bug_risk):** An API response with a `default` object but without a valid `version` is accepted, producing `release_version=None` and silently disabling update detection instead of rejecting the malformed response.
**Triggers:** When the official update API returns an incomplete or temporarily malformed `default` entry.
**Suggested fix:** Validate that `default_info["version"]` is a non-empty string and raise `ValueError` when it is missing or invalid.
```suggestion
release_version = default_info.get("version")
if not isinstance(release_version, str) or not release_version.strip():
raise ValueError("鸣潮官方更新接口缺少有效的 default version")
release_version = release_version.strip()
```
</issue_to_address>Sourcery assessment
Needs a human reviewer. 2 findings to address first, and 该变更会根据远程版本接口和 OCR 操作官方启动器,自动下载、解压并覆盖本地游戏安装文件;如果版本判断或按钮识别错误,影响会在代码回滚后仍留在本地安装中。影响范围通常局限于单个游戏安装,可通过官方启动器重新更新或重装修复,但不能仅靠回滚完全撤销。.
Blocking findings: app/services/wuthering_waves.py:152, app/services/wuthering_waves.py:234
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| if not candidate or not current: | ||
| return False |
There was a problem hiding this comment.
问题 (bug_risk): 当 launcherDownloadConfig.json 缺失或不包含可用的本地版本时,_is_newer_version 始终返回 False,因此正式更新和预下载都会被报告为不可用,并且永远不会启动官方启动器。
触发条件: 本地启动器版本记录不存在、为空,或在之前的安装/更新过程中被删除时。
建议修复: 将未知的本地版本视为需要启动启动器,或者明确使检查失败,而不是报告没有更新。
| if not candidate or not current: | |
| return False | |
| if not current: | |
| return True |
Original comment in English
issue (bug_risk): When launcherDownloadConfig.json is missing or contains no usable local version, _is_newer_version always returns False, so both formal updates and predownloads are reported as unavailable and the official launcher is never started.
Triggers: When the local launcher version record is absent, empty, or has been removed during a prior installation/update.
Suggested fix: Treat an unknown local version as requiring the launcher to start, or explicitly fail the check instead of reporting no update.
| if not candidate or not current: | |
| return False | |
| if not current: | |
| return True |
| if not isinstance(default_info, dict): | ||
| raise ValueError("鸣潮官方更新接口缺少 default 版本信息") | ||
|
|
||
| release_version = str(default_info.get("version") or "").strip() or None |
There was a problem hiding this comment.
问题 (bug_risk): 当 API 响应包含 default 对象但没有有效的 version 时,该响应仍会被接受,导致 release_version=None,并且更新检测会被静默禁用,而不是拒绝格式错误的响应。
触发条件: 官方更新 API 返回不完整或暂时格式错误的 default 条目时。
建议修复: 验证 default_info["version"] 是非空字符串;当其缺失或无效时,抛出 ValueError。
| release_version = str(default_info.get("version") or "").strip() or None | |
| release_version = default_info.get("version") | |
| if not isinstance(release_version, str) or not release_version.strip(): | |
| raise ValueError("鸣潮官方更新接口缺少有效的 default version") | |
| release_version = release_version.strip() |
Original comment in English
issue (bug_risk): An API response with a default object but without a valid version is accepted, producing release_version=None and silently disabling update detection instead of rejecting the malformed response.
Triggers: When the official update API returns an incomplete or temporarily malformed default entry.
Suggested fix: Validate that default_info["version"] is a non-empty string and raise ValueError when it is missing or invalid.
| release_version = str(default_info.get("version") or "").strip() or None | |
| release_version = default_info.get("version") | |
| if not isinstance(release_version, str) or not release_version.strip(): | |
| raise ValueError("鸣潮官方更新接口缺少有效的 default version") | |
| release_version = release_version.strip() |
变更摘要