Skip to content

fix: 处理点击特定跳过按钮不生效的问题#2232

Open
A-nony-mous wants to merge 1 commit into
OneDragon-Anything:mainfrom
A-nony-mous:fix/cofee-click-skip
Open

fix: 处理点击特定跳过按钮不生效的问题#2232
A-nony-mous wants to merge 1 commit into
OneDragon-Anything:mainfrom
A-nony-mous:fix/cofee-click-skip

Conversation

@A-nony-mous
Copy link
Copy Markdown
Contributor

@A-nony-mous A-nony-mous commented May 5, 2026

引入甩动鼠标方法,在点击前激活可能被隐藏的鼠标

cc @Usagi-wusaqi

Summary by CodeRabbit

更新说明

  • New Features

    • 增加了对跳过按钮前置鼠标激活的处理,提升点击命中率和响应稳定性
  • Bug Fixes

    • 优化了咖啡订单“跳过”交互,减少误点和失败重试
    • 优化了随便庙蛋盒购买界面跳过按钮的响应,提升交互可靠性

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 5, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c11aa07d-c2d4-4abe-ae07-e34a0e0fdf0f

📥 Commits

Reviewing files that changed from the base of the PR and between 20fdb37 and b7d9bd6.

📒 Files selected for processing (3)
  • src/zzz_od/application/coffee/coffee_app.py
  • src/zzz_od/application/suibian_temple/operations/suibian_temple_boo_box.py
  • src/zzz_od/operation/input_utils.py
✅ Files skipped from review due to trivial changes (1)
  • src/zzz_od/application/suibian_temple/operations/suibian_temple_boo_box.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/zzz_od/application/coffee/coffee_app.py

📝 Walkthrough

Walkthrough

在点击 UI 按钮前新增鼠标预激活步骤:添加并调用 wake_mouse_at,在咖啡店的 skip_after_order 路径和随便庙的购买动画跳过按钮点击前,将鼠标移动到目标附近再执行点击操作。

Changes

鼠标预激活模式统一应用

Layer / File(s) Summary
工具函数新增
src/zzz_od/operation/input_utils.py
新增 wake_mouse_at(controller: PcControllerBase, pos: Point, distance: int = 8, interval: float = 0.03) -> None,实现对目标位置的三次微小水平偏移鼠标移动并间隔等待。
导入添加
src/zzz_od/application/coffee/coffee_app.py, src/zzz_od/application/suibian_temple/operations/suibian_temple_boo_box.py
在两个模块中添加对 wake_mouse_at 的导入引用。
核心交互改造
src/zzz_od/application/coffee/coffee_app.py
CoffeeApp.skip_after_order 在查找并点击“点单后跳过”前,调用 wake_mouse_at(self.ctx.controller, skip_area.center)。随后保留原有的查找/点击与重试逻辑。
核心交互改造
src/zzz_od/application/suibian_temple/operations/suibian_temple_boo_box.py
handle_purchase_animation 提取跳过按钮 skip_area,在点击前调用 wake_mouse_at(self.ctx.controller, skip_area.center),然后在该位置执行点击(保留按压时长与等待)。

预计代码审查工作量

🎯 2 (Simple) | ⏱️ ~8 minutes

诗文

🐰 啾啾,鼠标轻轻游,

三跳靠近把位求,
咖啡与庙中一键走,
自动化路上小欢愉,
鼠标醒来,任务有求。

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题清晰具体地总结了主要变更:引入鼠标唤醒机制来修复特定跳过按钮点击失效问题,与三个文件中的实际代码变更完全对应。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

引入甩动鼠标方法,在点击前激活可能被隐藏的鼠标
@A-nony-mous A-nony-mous force-pushed the fix/cofee-click-skip branch from 20fdb37 to b7d9bd6 Compare May 5, 2026 14:47
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/zzz_od/application/coffee/coffee_app.py`:
- Around line 282-283: The code calls self.ctx.screen_loader.get_area('咖啡店',
'点单后跳过') into skip_area and immediately uses skip_area.center without
null-checking, which can raise AttributeError and duplicates the same area
lookup done later by round_by_find_and_click_area; fix by checking skip_area for
None before using it (e.g., only call wake_mouse_at(self.ctx.controller,
skip_area.center) when skip_area is not None) and avoid redundant lookups by
reusing skip_area (pass it into or use it instead of calling get_area again
inside round_by_find_and_click_area) so both null-safety and single lookup are
ensured for skip_area, referencing skip_area, get_area, wake_mouse_at, and
round_by_find_and_click_area.

In `@src/zzz_od/application/suibian_temple/operations/suibian_temple_boo_box.py`:
- Around line 256-262: The code assumes get_area(...) returns an object but it
can be None; modify the block where skip_area is obtained (skip_area =
self.ctx.screen_loader.get_area(...)) to check for None before accessing
skip_area.center and before calling wake_mouse_at or self.ctx.controller.click;
if skip_area is None, handle gracefully (e.g., log a warning via
self.ctx.logger/processLogger or return/skip the click flow) to avoid
AttributeError; ensure the references to wake_mouse_at(self.ctx.controller,
skip_area.center) and self.ctx.controller.click(...) are only executed when
skip_area is not None.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: dc4e047d-5e3b-47cf-8f0f-d689d8370df9

📥 Commits

Reviewing files that changed from the base of the PR and between 4a6ece5 and 20fdb37.

📒 Files selected for processing (2)
  • src/zzz_od/application/coffee/coffee_app.py
  • src/zzz_od/application/suibian_temple/operations/suibian_temple_boo_box.py

Comment on lines +282 to +283
skip_area = self.ctx.screen_loader.get_area('咖啡店', '点单后跳过')
wake_mouse_at(self.ctx.controller, skip_area.center)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

skip_area 未做空值判断,可能引发 AttributeError

suibian_temple_boo_box.py 中相同的问题:get_area 找不到对应区域时返回 None,直接访问 skip_area.center 将抛出 AttributeError。此外,round_by_find_and_click_area(第 284 行)内部会再次查询同一区域,造成轻微的重复查询。

🛡️ 建议加入空值保护
+        skip_area = self.ctx.screen_loader.get_area('咖啡店', '点单后跳过')
+        if skip_area is not None:
+            wake_mouse_at(self.ctx.controller, skip_area.center)
-        skip_area = self.ctx.screen_loader.get_area('咖啡店', '点单后跳过')
-        wake_mouse_at(self.ctx.controller, skip_area.center)
         result = self.round_by_find_and_click_area(self.last_screenshot, '咖啡店', '点单后跳过')
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/zzz_od/application/coffee/coffee_app.py` around lines 282 - 283, The code
calls self.ctx.screen_loader.get_area('咖啡店', '点单后跳过') into skip_area and
immediately uses skip_area.center without null-checking, which can raise
AttributeError and duplicates the same area lookup done later by
round_by_find_and_click_area; fix by checking skip_area for None before using it
(e.g., only call wake_mouse_at(self.ctx.controller, skip_area.center) when
skip_area is not None) and avoid redundant lookups by reusing skip_area (pass it
into or use it instead of calling get_area again inside
round_by_find_and_click_area) so both null-safety and single lookup are ensured
for skip_area, referencing skip_area, get_area, wake_mouse_at, and
round_by_find_and_click_area.

Comment on lines +256 to 262
skip_area = self.ctx.screen_loader.get_area('随便观-邦巢', '按钮-跳过')
# 点击前甩动一下激活鼠标
wake_mouse_at(self.ctx.controller, skip_area.center)
self.ctx.controller.click(
pos=self.ctx.screen_loader.get_area('随便观-邦巢', '按钮-跳过').center,
pos=skip_area.center,
press_time=0.5, # 长按一点
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

skip_area 未做空值判断,可能引发 AttributeError

get_area 的实际实现为 self._screen_area_map.get(key, None),当区域名称在配置中不存在时会返回 None。此处直接访问 skip_area.center(第 258 行和第 260 行)未先判空,若区域缺失将抛出 AttributeError

🛡️ 建议加入空值保护
         skip_area = self.ctx.screen_loader.get_area('随便观-邦巢', '按钮-跳过')
+        if skip_area is None:
+            return self.round_retry(status='未找到跳过区域', wait=0.5)
         # 点击前甩动一下激活鼠标
         wake_mouse_at(self.ctx.controller, skip_area.center)
         self.ctx.controller.click(
             pos=skip_area.center,
             press_time=0.5,  # 长按一点
         )
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
skip_area = self.ctx.screen_loader.get_area('随便观-邦巢', '按钮-跳过')
# 点击前甩动一下激活鼠标
wake_mouse_at(self.ctx.controller, skip_area.center)
self.ctx.controller.click(
pos=self.ctx.screen_loader.get_area('随便观-邦巢', '按钮-跳过').center,
pos=skip_area.center,
press_time=0.5, # 长按一点
)
skip_area = self.ctx.screen_loader.get_area('随便观-邦巢', '按钮-跳过')
if skip_area is None:
return self.round_retry(status='未找到跳过区域', wait=0.5)
# 点击前甩动一下激活鼠标
wake_mouse_at(self.ctx.controller, skip_area.center)
self.ctx.controller.click(
pos=skip_area.center,
press_time=0.5, # 长按一点
)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/zzz_od/application/suibian_temple/operations/suibian_temple_boo_box.py`
around lines 256 - 262, The code assumes get_area(...) returns an object but it
can be None; modify the block where skip_area is obtained (skip_area =
self.ctx.screen_loader.get_area(...)) to check for None before accessing
skip_area.center and before calling wake_mouse_at or self.ctx.controller.click;
if skip_area is None, handle gracefully (e.g., log a warning via
self.ctx.logger/processLogger or return/skip the click flow) to avoid
AttributeError; ensure the references to wake_mouse_at(self.ctx.controller,
skip_area.center) and self.ctx.controller.click(...) are only executed when
skip_area is not None.

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.

1 participant