Repository navigation
fix(script):适配桌面版空闲策略关闭游戏,修复桌面版关闭游戏后无法重启的问题 - #1994
Conversation
桌面版窗口不在时 Script.run 预截图必抛 GameNotRunningError, Restart 任务永远跑不到,恢复循环空转;command=Restart 时放行预截图。
There was a problem hiding this comment.
嘿——我发现了 1 个问题
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="module/device/method/desktop_impl.py" line_range="1332" />
<code_context>
+ else:
+ # 认领已存在的窗口:可能早已登录。已登录的客户端全系统枚举不到
+ # MPAY_LOGIN 顶层窗口(见 find_desktop_login_popup),以此区分
+ self._desktop_login_done = not self.find_desktop_login_popup()
# 客户端已拉起,强制保持显示器常亮(线程级状态,随客户端关闭解除)
desktop_keep_screen_on(True)
</code_context>
<issue_to_address>
**Tasks run before login**
When an existing client window is claimed before its MPay login popup appears, `desktop_bind_pid` sets `_desktop_login_done` to true based on the initial popup scan, and `app_is_running` trusts that cached flag. The scheduler skips Restart’s login flow and sends gameplay tasks to the loading or login screen.
Keep `_desktop_login_done` false for a newly claimed client until its login state is confirmed, so the login flow runs if the popup appears after the initial scan.
Also at `module/device/desktop_device.py:42`, `module/device/handle.py:187`.
</issue_to_address>Sourcery 评估
等待批准。 请先处理 1 项发现。
阻塞性发现:module/device/method/desktop_impl.py:1332
Original comment in English
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="module/device/method/desktop_impl.py" line_range="1332" />
<code_context>
+ else:
+ # 认领已存在的窗口:可能早已登录。已登录的客户端全系统枚举不到
+ # MPAY_LOGIN 顶层窗口(见 find_desktop_login_popup),以此区分
+ self._desktop_login_done = not self.find_desktop_login_popup()
# 客户端已拉起,强制保持显示器常亮(线程级状态,随客户端关闭解除)
desktop_keep_screen_on(True)
</code_context>
<issue_to_address>
**Tasks run before login**
When an existing client window is claimed before its MPay login popup appears, `desktop_bind_pid` sets `_desktop_login_done` to true based on the initial popup scan, and `app_is_running` trusts that cached flag. The scheduler skips Restart’s login flow and sends gameplay tasks to the loading or login screen.
Keep `_desktop_login_done` false for a newly claimed client until its login state is confirmed, so the login flow runs if the popup appears after the initial scan.
Also at `module/device/desktop_device.py:42`, `module/device/handle.py:187`.
</issue_to_address>Sourcery assessment
Approval pending. 1 finding to address first.
Blocking findings: module/device/method/desktop_impl.py:1332
| else: | ||
| # 认领已存在的窗口:可能早已登录。已登录的客户端全系统枚举不到 | ||
| # MPAY_LOGIN 顶层窗口(见 find_desktop_login_popup),以此区分 | ||
| self._desktop_login_done = not self.find_desktop_login_popup() |
There was a problem hiding this comment.
🟡 中等 · 任务在登录前运行
如果在现有客户端窗口的 MPay 登录弹窗出现之前就认领该窗口,desktop_bind_pid 会根据初始弹窗扫描结果将 _desktop_login_done 设为 true,而 app_is_running 会信任这个缓存标志。调度器因此跳过 Restart 的登录流程,并将游戏任务发送到加载界面或登录界面。
对于新认领的客户端,在确认其登录状态之前,应保持 _desktop_login_done 为 false,这样如果弹窗在初始扫描后才出现,登录流程仍会运行。
另见 module/device/desktop_device.py:42、module/device/handle.py:187。
面向 AI 智能体的提示
在 `module/device/method/desktop_impl.py` 第 1332 行:
**任务在登录前运行**
如果在现有客户端窗口的 MPay 登录弹窗出现之前就认领该窗口,`desktop_bind_pid` 会根据初始弹窗扫描结果将 `_desktop_login_done` 设为 true,而 `app_is_running` 会信任这个缓存标志。调度器因此跳过 Restart 的登录流程,并将游戏任务发送到加载界面或登录界面。
对于新认领的客户端,在确认其登录状态之前,应保持 `_desktop_login_done` 为 false,这样如果弹窗在初始扫描后才出现,登录流程仍会运行。
另见 `module/device/desktop_device.py:42`、`module/device/handle.py:187`。Original comment in English
🟡 Medium · Tasks run before login
When an existing client window is claimed before its MPay login popup appears, desktop_bind_pid sets _desktop_login_done to true based on the initial popup scan, and app_is_running trusts that cached flag. The scheduler skips Restart’s login flow and sends gameplay tasks to the loading or login screen.
Keep _desktop_login_done false for a newly claimed client until its login state is confirmed, so the login flow runs if the popup appears after the initial scan.
Also at module/device/desktop_device.py:42, module/device/handle.py:187.
Prompt for AI agents
In `module/device/method/desktop_impl.py` at line 1332:
**Tasks run before login**
When an existing client window is claimed before its MPay login popup appears, `desktop_bind_pid` sets `_desktop_login_done` to true based on the initial popup scan, and `app_is_running` trusts that cached flag. The scheduler skips Restart’s login flow and sends gameplay tasks to the loading or login screen.
Keep `_desktop_login_done` false for a newly claimed client until its login state is confirmed, so the login flow runs if the popup appears after the initial scan.
Also at `module/device/desktop_device.py:42`, `module/device/handle.py:187`.
最新补丁,配合前面的pr已经可以实现和模拟器一样的闲时关闭,有任务正常唤起的24h挂机
Sourcery 摘要
修复桌面客户端关闭后的恢复流程,并正确处理已存在窗口的登录状态。
错误修复:
功能增强:
Original summary in English
Summary by Sourcery
修复桌面版客户端关闭后的恢复流程,并正确处理已存在窗口的登录状态。
Bug Fixes:
Enhancements: