Skip to content

fix: 修复 StopTask 在 need_to_stop 时丢失 action 结果#1213

Merged
MistEO merged 3 commits intomainfrom
fix/notify
Apr 2, 2026
Merged

fix: 修复 StopTask 在 need_to_stop 时丢失 action 结果#1213
MistEO merged 3 commits intomainfrom
fix/notify

Conversation

@Windsland52
Copy link
Copy Markdown
Member

@Windsland52 Windsland52 commented Mar 18, 2026

Summary by Sourcery

Bug Fixes:

  • 即使在操作执行过程中触发 need_to_stop,也要保留并通知 StopTask 操作的结果。
Original summary in English

Summary by Sourcery

Bug Fixes:

  • Preserve and notify the result of StopTask actions even when need_to_stop is triggered during action execution.

@Windsland52
Copy link
Copy Markdown
Member Author

[2026-03-18 10:33:08.822][INF][Px24780][Tx32614][PipelineTask.cpp][L297][MaaNS::TaskNS::PipelineTask::recognize_list] reco hit [result.name=StopNode] [result.box=[0,0,1280,720]] 
[2026-03-18 10:33:08.822][INF][Px24780][Tx32614][Utils/EventDispatcher.hpp][L65][MaaNS::EventDispatcher::notify] !!!OnEventNotify!!! [handle=true] [msg=Node.NextList.Succeeded] [details={"focus":null,"list":[{"anchor":false,"jump_back":false,"name":"GrayCancelButtonWithStop"},{"anchor":false,"jump_back":false,"name":"StopNode"}],"name":"InMainWindow","task_id":200000123}] 
[2026-03-18 10:33:08.822][TRC][Px24780][Tx32614][AgentClient.cpp][L2696][MaaNS::AgentNS::ClientNS::AgentClient::ctx_event_sink] [handle=true] [message=Node.NextList.Succeeded] [details_json={"focus":null,"list":[{"anchor":false,"jump_back":false,"name":"GrayCancelButtonWithStop"},{"anchor":false,"jump_back":false,"name":"StopNode"}],"name":"InMainWindow","task_id":200000123}] [trans_arg=true] 
[2026-03-18 10:33:08.822][TRC][Px24780][Tx32614][AgentClient.cpp][L2696][MaaNS::AgentNS::ClientNS::AgentClient::ctx_event_sink] [handle=true] [message=Node.NextList.Succeeded] [details_json={"focus":null,"list":[{"anchor":false,"jump_back":false,"name":"GrayCancelButtonWithStop"},{"anchor":false,"jump_back":false,"name":"StopNode"}],"name":"InMainWindow","task_id":200000123}] [trans_arg=true] 
[2026-03-18 10:33:08.822][TRC][Px24780][Tx32614][PipelineTask.cpp][L237][MaaNS::TaskNS::PipelineTask::recognize_list] | leave, 25ms 
[2026-03-18 10:33:08.822][DBG][Px24780][Tx32614][TaskBase.cpp][L201][MaaNS::TaskNS::TaskBase::sleep] 0ms 
[2026-03-18 10:33:08.823][INF][Px24780][Tx32614][Utils/EventDispatcher.hpp][L65][MaaNS::EventDispatcher::notify] !!!OnEventNotify!!! [handle=true] [msg=Node.Action.Starting] [details={"action_id":500001485,"focus":null,"name":"StopNode","task_id":200000123}] 
[2026-03-18 10:33:08.823][TRC][Px24780][Tx32614][AgentClient.cpp][L2696][MaaNS::AgentNS::ClientNS::AgentClient::ctx_event_sink] [handle=true] [message=Node.Action.Starting] [details_json={"action_id":500001485,"focus":null,"name":"StopNode","task_id":200000123}] [trans_arg=true] 
[2026-03-18 10:33:08.823][TRC][Px24780][Tx32614][AgentClient.cpp][L2696][MaaNS::AgentNS::ClientNS::AgentClient::ctx_event_sink] [handle=true] [message=Node.Action.Starting] [details_json={"action_id":500001485,"focus":null,"name":"StopNode","task_id":200000123}] [trans_arg=true] 
[2026-03-18 10:33:08.823][TRC][Px24780][Tx32614][Actuator.cpp][L27][MaaNS::TaskNS::Actuator::run] [pipeline_data.name=StopNode] 
[2026-03-18 10:33:08.823][INF][Px24780][Tx32614][Actuator.cpp][L710][MaaNS::TaskNS::Actuator::stop_task] Action: StopTask 
[2026-03-18 10:33:08.823][INF][Px24780][Tx32614][TaskBase.cpp][L130][MaaNS::TaskNS::TaskBase::run_action] action [i=0] [data.repeat=1] [result={"action":"StopTask","action_id":500001485,"box":[0,0,0,0],"detail":{},"name":"StopNode","success":true}] 
[2026-03-18 10:33:08.823][INF][Px24780][Tx32614][PipelineTask.cpp][L211][MaaNS::TaskNS::PipelineTask::run_next] PipelineTask node done [result={"action_id":0,"completed":false,"name":"StopNode","node_id":300001493,"reco_id":400004727}] [task_id_=200000123] 
[2026-03-18 10:33:08.823][INF][Px24780][Tx32614][Utils/EventDispatcher.hpp][L65][MaaNS::EventDispatcher::notify] !!!OnEventNotify!!! [handle=true] [msg=Node.PipelineNode.Failed] [details={"action_details":{"action":"","action_id":0,"box":[0,0,0,0],"detail":null,"name":"","success":false},"focus":null,"name":"InMainWindow","node_details":{"action_id":0,"completed":false,"name":"StopNode","node_id":300001493,"reco_id":400004727},"node_id":300001493,"reco_details":{"algorithm":"DirectHit","box":[0,0,1280,720],"detail":null,"name":"StopNode","reco_id":400004727},"task_id":200000123}] 
[2026-03-18 10:33:08.823][TRC][Px24780][Tx32614][AgentClient.cpp][L2696][MaaNS::AgentNS::ClientNS::AgentClient::ctx_event_sink] [handle=true] [message=Node.PipelineNode.Failed] [details_json={"action_details":{"action":"","action_id":0,"box":[0,0,0,0],"detail":null,"name":"","success":false},"focus":null,"name":"InMainWindow","node_details":{"action_id":0,"completed":false,"name":"StopNode","node_id":300001493,"reco_id":400004727},"node_id":300001493,"reco_details":{"algorithm":"DirectHit","box":[0,0,1280,720],"detail":null,"name":"StopNode","reco_id":400004727},"task_id":200000123}] [trans_arg=true] 
[2026-03-18 10:33:08.825][TRC][Px24780][Tx32614][AgentClient.cpp][L2696][MaaNS::AgentNS::ClientNS::AgentClient::ctx_event_sink] [handle=true] [message=Node.PipelineNode.Failed] [details_json={"action_details":{"action":"","action_id":0,"box":[0,0,0,0],"detail":null,"name":"","success":false},"focus":null,"name":"InMainWindow","node_details":{"action_id":0,"completed":false,"name":"StopNode","node_id":300001493,"reco_id":400004727},"node_id":300001493,"reco_details":{"algorithm":"DirectHit","box":[0,0,1280,720],"detail":null,"name":"StopNode","reco_id":400004727},"task_id":200000123}] [trans_arg=true] 
[2026-03-18 10:33:08.825][WRN][Px24780][Tx32614][PipelineTask.cpp][L47][MaaNS::TaskNS::PipelineTask::run] need_to_stop [node.name=InMainWindow] 
[2026-03-18 10:33:08.825][TRC][Px24780][Tx32614][PipelineTask.cpp][L26][MaaNS::TaskNS::PipelineTask::run] | leave, 64683ms 
[2026-03-18 10:33:08.825][INF][Px24780][Tx32614][Tasker.cpp][L350][MaaNS::Tasker::run_task] task end: [cb_detail={"entry":"DijiangRewards","hash":"464bc12a98747401","task_id":200000123,"uuid":"00000000003B12C8"}] [ret=true] 
[2026-03-18 10:33:08.825][INF][Px24780][Tx32614][Utils/EventDispatcher.hpp][L65][MaaNS::EventDispatcher::notify] !!!OnEventNotify!!! [handle=true] [msg=Tasker.Task.Succeeded] [details={"entry":"DijiangRewards","hash":"464bc12a98747401","task_id":200000123,"uuid":"00000000003B12C8"}] 

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - 我在这里给出了一些高层次的反馈:

  • need_to_stop() 代码块中对 StopTask 的特殊处理,最好加一条简短的注释,解释为何在停止时这个动作仍然需要发送通知并返回结果,以避免未来重构时将其当作“不一致”而删除。
  • 可以考虑是否让 StopTaskneed_to_stop() 分支中的处理,与普通的动作完成路径共享或对齐(例如通过一个辅助函数同时负责发送通知并返回结果),以避免重复通知逻辑,从而降低未来出现行为分歧的风险。
给 AI 代理的提示
Please address the comments from this code review:

## Overall Comments
- The special-casing of `StopTask` inside the `need_to_stop()` block would benefit from a short comment explaining why this action still needs to send notifications and return its result when stopping, to avoid future refactors removing it as an apparent inconsistency.
- Consider whether the `need_to_stop()` handling for `StopTask` can be shared with or aligned to the normal action completion path (e.g., via a helper that sends the notification and returns the result) to avoid duplicating notification logic and reduce the chance of future divergence.

Sourcery 对开源项目免费——如果你觉得我们的评审对你有帮助,欢迎分享 ✨
帮我变得更有用!请对每条评论点 👍 或 👎,我会根据这些反馈改进以后的评审。
Original comment in English

Hey - I've left some high level feedback:

  • The special-casing of StopTask inside the need_to_stop() block would benefit from a short comment explaining why this action still needs to send notifications and return its result when stopping, to avoid future refactors removing it as an apparent inconsistency.
  • Consider whether the need_to_stop() handling for StopTask can be shared with or aligned to the normal action completion path (e.g., via a helper that sends the notification and returns the result) to avoid duplicating notification logic and reduce the chance of future divergence.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The special-casing of `StopTask` inside the `need_to_stop()` block would benefit from a short comment explaining why this action still needs to send notifications and return its result when stopping, to avoid future refactors removing it as an apparent inconsistency.
- Consider whether the `need_to_stop()` handling for `StopTask` can be shared with or aligned to the normal action completion path (e.g., via a helper that sends the notification and returns the result) to avoid duplicating notification logic and reduce the chance of future divergence.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Windsland52
Copy link
Copy Markdown
Member Author

custom里的不太懂,玛丽康康@MistEO

@MistEO
Copy link
Copy Markdown
Member

MistEO commented Mar 18, 2026

💩!

@Windsland52
Copy link
Copy Markdown
Member Author

YOU!

@Windsland52
Copy link
Copy Markdown
Member Author

那咋修

@MistEO MistEO merged commit 528e7a4 into main Apr 2, 2026
1 check passed
@MistEO MistEO deleted the fix/notify branch April 2, 2026 11:06
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.

2 participants