Merged
Conversation
Contributor
There was a problem hiding this comment.
Hey - 我发现了 1 个问题,并给出了一些整体层面的反馈:
- 现在 pre/post 的 wait_freezes 和 delay 调用是在 MaaMsg_Node_Action_Starting/Succeeded|Failed 通知之前/之后执行,而不是像之前那样在 Actuator::run 内部;如果外部使用方依赖于之前的事件触发时机,请考虑这些等待逻辑是否应该仍然围绕实际动作执行本身,而不是围绕通知调用。
- Actuator::run 在 execute_action 周围不再进行 need_to_stop 检查,而 TaskBase::run_action 则在每次调用 Actuator::run 时增加了这些检查;如果 Actuator::run 在其他地方也被使用,请确认这些调用方仍然能获得预期的“提前停止”行为,或者在 Actuator 内重新引入这些检查。
- repeat 处理逻辑(pre/repeat/post 的 wait_freezes 和 delays)现在被拆分到了 TaskBase 和 Actuator 两层;为了让职责更清晰,可以考虑把所有与时间/等待相关的逻辑集中到同一层(例如 TaskBase),并让 Actuator::run 只负责一次纯粹的单次执行,而不再关心计时和等待。
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The pre/post wait_freezes and delay calls are now executed before/after the MaaMsg_Node_Action_Starting/Succeeded|Failed notifications instead of being inside Actuator::run; if external consumers rely on the previous event timing, consider whether these waits should remain around the actual action execution instead of around the notifications.
- Actuator::run has lost the need_to_stop checks around execute_action, while TaskBase::run_action adds them around each Actuator::run; if Actuator::run is used anywhere else, ensure that those callers still get the intended early-stop behavior or reintroduce the checks inside Actuator.
- The repeat handling logic (pre/repeat/post wait_freezes and delays) is now split between TaskBase and Actuator; to keep responsibilities clearer, consider centralizing all timing/wait logic in one layer (e.g., TaskBase) and making Actuator::run a pure single-execution helper with no timing concerns.
## Individual Comments
### Comment 1
<location path="source/MaaFramework/Task/TaskBase.cpp" line_range="142-144" />
<code_context>
- sleep(pipeline_data.pre_delay);
-
- auto& rt_cache = tasker_->runtime_cache();
- ActionResult result;
-
- for (uint i = 0; i < pipeline_data.repeat; ++i) {
</code_context>
<issue_to_address>
**issue:** Potential use of uninitialized `result` when `data.repeat == 0`.
If `data.repeat` can be 0, the loop won't run and `result` will be used uninitialized when building `cb_detail["action_details"]` and as the function return value, leading to undefined behavior. Please either initialize `result` to a default `ActionResult` or handle the `data.repeat == 0` case explicitly (for example, by returning a default `ActionResult` early).
</issue_to_address>帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续的 review。
Original comment in English
Hey - I've found 1 issue, and left some high level feedback:
- The pre/post wait_freezes and delay calls are now executed before/after the MaaMsg_Node_Action_Starting/Succeeded|Failed notifications instead of being inside Actuator::run; if external consumers rely on the previous event timing, consider whether these waits should remain around the actual action execution instead of around the notifications.
- Actuator::run has lost the need_to_stop checks around execute_action, while TaskBase::run_action adds them around each Actuator::run; if Actuator::run is used anywhere else, ensure that those callers still get the intended early-stop behavior or reintroduce the checks inside Actuator.
- The repeat handling logic (pre/repeat/post wait_freezes and delays) is now split between TaskBase and Actuator; to keep responsibilities clearer, consider centralizing all timing/wait logic in one layer (e.g., TaskBase) and making Actuator::run a pure single-execution helper with no timing concerns.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The pre/post wait_freezes and delay calls are now executed before/after the MaaMsg_Node_Action_Starting/Succeeded|Failed notifications instead of being inside Actuator::run; if external consumers rely on the previous event timing, consider whether these waits should remain around the actual action execution instead of around the notifications.
- Actuator::run has lost the need_to_stop checks around execute_action, while TaskBase::run_action adds them around each Actuator::run; if Actuator::run is used anywhere else, ensure that those callers still get the intended early-stop behavior or reintroduce the checks inside Actuator.
- The repeat handling logic (pre/repeat/post wait_freezes and delays) is now split between TaskBase and Actuator; to keep responsibilities clearer, consider centralizing all timing/wait logic in one layer (e.g., TaskBase) and making Actuator::run a pure single-execution helper with no timing concerns.
## Individual Comments
### Comment 1
<location path="source/MaaFramework/Task/TaskBase.cpp" line_range="142-144" />
<code_context>
- sleep(pipeline_data.pre_delay);
-
- auto& rt_cache = tasker_->runtime_cache();
- ActionResult result;
-
- for (uint i = 0; i < pipeline_data.repeat; ++i) {
</code_context>
<issue_to_address>
**issue:** Potential use of uninitialized `result` when `data.repeat == 0`.
If `data.repeat` can be 0, the loop won't run and `result` will be used uninitialized when building `cb_detail["action_details"]` and as the function return value, leading to undefined behavior. Please either initialize `result` to a default `ActionResult` or handle the `data.repeat == 0` case explicitly (for example, by returning a default `ActionResult` early).
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Contributor
There was a problem hiding this comment.
Pull request overview
将节点 action 的 delay / wait_freezes / repeat 编排逻辑从 Actuator::run() 移到 TaskBase::run_action(),使 Actuator 更接近“单次执行 action”的职责边界。
Changes:
- 在
TaskBase::run_action()中新增pre/repeat/post的wait_freezes与sleep_for,并在此处实现 repeat 循环 - 将
Actuator::run()简化为单次execute_action()+ 写入 runtime_cache
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| source/MaaFramework/Task/TaskBase.cpp | 将 action 的 wait/delay/repeat 逻辑上移到 TaskBase 层进行编排 |
| source/MaaFramework/Task/Component/Actuator.cpp | 将 Actuator::run 简化为只负责执行一次 action 并缓存结果 |
MistEO
added a commit
that referenced
this pull request
Mar 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by Sourcery
将延迟和等待冻结(wait-freeze)的处理从动作执行器中移至任务运行器,在动作执行周围集中统一时间控制。
Bug Fixes:
Enhancements:
Original summary in English
Summary by Sourcery
Move delay and wait-freeze handling from the action executor into the task runner, centralizing timing control around action execution.
Bug Fixes:
Enhancements: