Repository navigation
fix(GameUi): 过图加载时等待可识别页面,不再盲点关闭按钮 - #1944
Enough1122 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
嘿——我发现了 2 个问题
给 AI 智能体的提示
请处理这次代码审查中的评论:
## 单条评论
### 评论 1
<location path="tasks/GameUi/navigator.py" line_range="723" />
<code_context>
+ while not timer.reached():
+ page = self._detect_current_page(
+ skip_first_screenshot=False,
+ categories=self._default_detect_categories(),
+ )
+ if page is not None:
</code_context>
<issue_to_address>
**已识别的目标页面被关闭**
在恢复等待期间,如果出现的可识别页面不属于全局类别或当前任务类别,`_wait_for_any_page` 只会搜索全局类别和当前任务类别,因此无法发现该页面;随后 `close_unknown_pages` 会在导航重新识别该页面之前,对它运行关闭器。
运行未知页面关闭器之前,请搜索所有已注册的页面类别,包括目标类别。
另见 `tasks/GameUi/navigator.py:724`。
</issue_to_address>
### 评论 2
<location path="tasks/GameUi/navigator.py" line_range="494-506" />
<code_context>
"""
timer = Timer(timeout).start()
+ last_probe = 0.0
while not timer.reached():
if self.confirm_page(destination, skip_first_screenshot=False):
self.navigator.current_page = destination
return True
+ now = time.time()
+ if now - last_probe >= 3.0:
+ last_probe = now
+ landed = self._detect_current_page(
+ skip_first_screenshot=True,
+ categories=self._navigation_detect_categories(destination),
+ )
+ if landed is not None and landed.key != destination.key:
+ return False
return False
</code_context>
<issue_to_address>
**成功的页面转换受到惩罚**
执行转换操作后、目标页面出现前,如果源页面仍可识别,`_wait_for_destination` 会将源页面视为一次失败的探测并返回 `False`。因此,目标页面还没来得及出现,`_execute_transition` 就会记录一次失败的转换并施加惩罚。
如果检测到的页面仍是转换源页面,请继续轮询;只有目标页面等待超时后才判定失败。
</issue_to_address>Sourcery 评估
待批准。 请先处理 2 项发现。
阻塞性发现:tasks/GameUi/navigator.py:723、tasks/GameUi/navigator.py:506
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="tasks/GameUi/navigator.py" line_range="723" />
<code_context>
+ while not timer.reached():
+ page = self._detect_current_page(
+ skip_first_screenshot=False,
+ categories=self._default_detect_categories(),
+ )
+ if page is not None:
</code_context>
<issue_to_address>
**Recognized destinations get dismissed**
When a recognizable page appears outside the global and current-task categories during the recovery wait, `_wait_for_any_page` searches only the global and current-task categories, so it misses the page and `close_unknown_pages` runs a closer against it before navigation can re-detect it.
Search all registered page categories, including the destination category, before running unknown-page closers.
Also at `tasks/GameUi/navigator.py:724`.
</issue_to_address>
### Comment 2
<location path="tasks/GameUi/navigator.py" line_range="494-506" />
<code_context>
"""
timer = Timer(timeout).start()
+ last_probe = 0.0
while not timer.reached():
if self.confirm_page(destination, skip_first_screenshot=False):
self.navigator.current_page = destination
return True
+ now = time.time()
+ if now - last_probe >= 3.0:
+ last_probe = now
+ landed = self._detect_current_page(
+ skip_first_screenshot=True,
+ categories=self._navigation_detect_categories(destination),
+ )
+ if landed is not None and landed.key != destination.key:
+ return False
return False
</code_context>
<issue_to_address>
**Successful transitions get penalized**
When the source page remains recognizable after the transition action but before the destination appears, `_wait_for_destination` treats the source page as a failed probe and returns `False`, so `_execute_transition` records a failed transition and adds a penalty before the destination has time to appear.
Keep polling when the detected page is still the transition source, and only fail after the destination wait expires.
</issue_to_address>Sourcery assessment
Approval pending. 2 findings to address first.
Blocking findings: tasks/GameUi/navigator.py:723, tasks/GameUi/navigator.py:506
| while not timer.reached(): | ||
| page = self._detect_current_page( | ||
| skip_first_screenshot=False, | ||
| categories=self._default_detect_categories(), |
There was a problem hiding this comment.
🟡 中 · 已识别的目标页面被关闭
在恢复等待期间,如果出现的可识别页面不属于全局类别或当前任务类别,_wait_for_any_page 只会搜索全局类别和当前任务类别,因此无法发现该页面;随后 close_unknown_pages 会在导航重新识别该页面之前,对它运行关闭器。
运行未知页面关闭器之前,请搜索所有已注册的页面类别,包括目标类别。
另见 tasks/GameUi/navigator.py:724。
给 AI 智能体的提示
在 `tasks/GameUi/navigator.py` 第 723 行:
**已识别的目标页面被关闭**
在恢复等待期间,如果出现的可识别页面不属于全局类别或当前任务类别,`_wait_for_any_page` 只会搜索全局类别和当前任务类别,因此无法发现该页面;随后 `close_unknown_pages` 会在导航重新识别该页面之前,对它运行关闭器。
运行未知页面关闭器之前,请搜索所有已注册的页面类别,包括目标类别。
另见 `tasks/GameUi/navigator.py:724`。Original comment in English
🟡 Medium · Recognized destinations get dismissed
When a recognizable page appears outside the global and current-task categories during the recovery wait, _wait_for_any_page searches only the global and current-task categories, so it misses the page and close_unknown_pages runs a closer against it before navigation can re-detect it.
Search all registered page categories, including the destination category, before running unknown-page closers.
Also at tasks/GameUi/navigator.py:724.
Prompt for AI agents
In `tasks/GameUi/navigator.py` at line 723:
**Recognized destinations get dismissed**
When a recognizable page appears outside the global and current-task categories during the recovery wait, `_wait_for_any_page` searches only the global and current-task categories, so it misses the page and `close_unknown_pages` runs a closer against it before navigation can re-detect it.
Search all registered page categories, including the destination category, before running unknown-page closers.
Also at `tasks/GameUi/navigator.py:724`.| last_probe = 0.0 | ||
| while not timer.reached(): | ||
| if self.confirm_page(destination, skip_first_screenshot=False): | ||
| self.navigator.current_page = destination | ||
| return True | ||
| now = time.time() | ||
| if now - last_probe >= 3.0: | ||
| last_probe = now | ||
| landed = self._detect_current_page( | ||
| skip_first_screenshot=True, | ||
| categories=self._navigation_detect_categories(destination), | ||
| ) | ||
| if landed is not None and landed.key != destination.key: |
There was a problem hiding this comment.
🟠 高 · 成功的页面转换受到惩罚
执行转换操作后、目标页面出现前,如果源页面仍可识别,_wait_for_destination 会将源页面视为一次失败的探测并返回 False。因此,目标页面还没来得及出现,_execute_transition 就会记录一次失败的转换并施加惩罚。
如果检测到的页面仍是转换源页面,请继续轮询;只有目标页面等待超时后才判定失败。
给 AI 智能体的提示
在 `tasks/GameUi/navigator.py` 第 494–506 行:
**成功的页面转换受到惩罚**
执行转换操作后、目标页面出现前,如果源页面仍可识别,`_wait_for_destination` 会将源页面视为一次失败的探测并返回 `False`。因此,目标页面还没来得及出现,`_execute_transition` 就会记录一次失败的转换并施加惩罚。
如果检测到的页面仍是转换源页面,请继续轮询;只有目标页面等待超时后才判定失败。Original comment in English
🟠 High · Successful transitions get penalized
When the source page remains recognizable after the transition action but before the destination appears, _wait_for_destination treats the source page as a failed probe and returns False, so _execute_transition records a failed transition and adds a penalty before the destination has time to appear.
Keep polling when the detected page is still the transition source, and only fail after the destination wait expires.
Prompt for AI agents
In `tasks/GameUi/navigator.py` at lines 494-506:
**Successful transitions get penalized**
When the source page remains recognizable after the transition action but before the destination appears, `_wait_for_destination` treats the source page as a failed probe and returns `False`, so `_execute_transition` records a failed transition and adds a penalty before the destination has time to appear.
Keep polling when the detected page is still the transition source, and only fail after the destination wait expires.
Findings
Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
To allow these domains, add them to the network:
allowed:
- defaults
- "ab.chatgpt.com"See Network Configuration for more information.
|
现象
page_main -> page_guild跳转反复失败,penalty 一路涨到 13,任务反复 strike,最后整个实例退出(Task KekkaiUtilize failed 3 or more times+Request human takeover)。日志:根因
失败时刻的
log/error/截图(10 张)拍到的全是过图加载画面(十周年加载图),不是任何可识别页面。导航层没有加载等待概念:_wait_for_destination只等 4 秒,加载稍慢就判跳转失败;goto_page里当前页为None就立刻调close_unknown_pages盲点返回键,这些恢复点击把游戏从加载带进了宴会厅等侧房间,之后就彻底对不上了。已排除模板问题:用 cv2 把
page_check_guild.png对失败截图全量匹配最高只有 0.4(画面里根本没有目标);注意该模板画的是结界入口按钮,在宴会厅右下角也会 cross-match 出 0.9,所以宴会厅里的命中不能作为到达寮的证据。改动
_wait_for_destination超时 4s → 15s;等待期间若识别到别的已知页则提前返回失败(真走错了不等满 15 秒),什么都认不出就继续等;close_unknown_pages动手前先静等 15 秒(新增_wait_for_any_page),等到可识别页面就直接返回交给外层重识别,不点任何关闭按钮。验证
Page arrived page_guild([26.8s]、[34.7s]均超过旧 4 秒上限,证明走的是新等待路径),之后结界寄养任务正常跑起选卡 OCR。UTILIZE_UTILIZE_ZONES_GROUP点击无响应)是另一个独立问题,另起处理,本 PR 只解决导航误判。Sourcery 总结
通过等待可识别的目标页面出现,再判定导航失败或采取恢复操作,使页面导航能够更好地应对加载缓慢的情况。
Bug 修复:
Original summary in English
Summary by Sourcery
Make page navigation resilient to slow loading screens by waiting for recognizable destinations before declaring failure or taking recovery actions.
Bug Fixes: