Repository navigation
Conversation
Tasker::post_stop 会清空排队任务且不为其发送回调,只补发一个 MaaTaskerPostStop 停止任务。 Agent 内部调用 PostStop 时,被清掉的任务永远等不到终态,收尾不会触发,本轮 Agent 残留, 下次启动时新 Agent 注册同名自定义识别失败,报 "MaaFramework internal error: status 0"。 收到 MaaTaskerPostStop 的终态回调且队列仍有任务无结果时,按失败走现有收尾流程。
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c09e240a6a
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
你好 - 我发现了 2 个问题
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src-tauri/src/commands/utils.rs" line_range="189" />
<code_context>
+ {
+ return;
+ }
+ instance.begin_completion(false)
+ };
+
</code_context>
<issue_to_address>
**Tasks run after stop request**
When an append has acquired its start permit and is still registering Agents when the internal PostStop callback arrives, `handle_post_stop_callback` sets neither `stop_in_progress` nor `submission_cancelled`, so `start_tasks_impl` posts the appended tasks after PostStop; work then runs while the run is being finalized as failed.
Make PostStop cancel or block admitted submissions and prevent them from posting tasks after the stop request.
</issue_to_address>
### Comment 2
<location path="src-tauri/src/commands/utils.rs" line_range="189" />
<code_context>
+ {
+ return;
+ }
+ instance.begin_completion(false)
+ };
+
</code_context>
<issue_to_address>
**Tasks remain active after completion**
When an Agent-internal PostStop clears queued tasks that have selected-task status mappings, `begin_completion(false)` updates only the overall run status, and the cleared tasks receive no terminal callbacks to update their mapped statuses. Those statuses remain `pending` or `running` after `tasks-completed`, so the frontend shows unfinished tasks.
Update the mapped statuses of tasks cleared by PostStop to terminal statuses before completing the run.
</issue_to_address>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="src-tauri/src/commands/utils.rs" line_range="189" />
<code_context>
+ {
+ return;
+ }
+ instance.begin_completion(false)
+ };
+
</code_context>
<issue_to_address>
**Tasks run after stop request**
When an append has acquired its start permit and is still registering Agents when the internal PostStop callback arrives, `handle_post_stop_callback` sets neither `stop_in_progress` nor `submission_cancelled`, so `start_tasks_impl` posts the appended tasks after PostStop; work then runs while the run is being finalized as failed.
Make PostStop cancel or block admitted submissions and prevent them from posting tasks after the stop request.
</issue_to_address>
### Comment 2
<location path="src-tauri/src/commands/utils.rs" line_range="189" />
<code_context>
+ {
+ return;
+ }
+ instance.begin_completion(false)
+ };
+
</code_context>
<issue_to_address>
**Tasks remain active after completion**
When an Agent-internal PostStop clears queued tasks that have selected-task status mappings, `begin_completion(false)` updates only the overall run status, and the cleared tasks receive no terminal callbacks to update their mapped statuses. Those statuses remain `pending` or `running` after `tasks-completed`, so the frontend shows unfinished tasks.
Update the mapped statuses of tasks cleared by PostStop to terminal statuses before completing the run.
</issue_to_address>
close MaaEnd/MaaEnd#6167
问题
Agent 内部调用
Tasker.PostStop()时(如 MaaEnd 分辨率检查不通过、pipeline 中的PostStop动作),本轮 Agent 不会被回收。下次启动任务时新 Agent 注册同名自定义识别失败,报:maafw.log 中对应
custom name already registered。相关:MaaEnd/MaaEnd#6167
原因
Tasker::post_stop会task_runner_->clear()清空排队任务,被清掉的任务不会发送任何 Succeeded/Failed 回调,只会补发一个 entry 为MaaTaskerPostStop的停止任务。handle_task_callback只在queue_result()有结果或stop_in_progress(MXU 自己发起停止)时开始收尾。Agent 内部停止时两者都不满足,而MaaTaskerPostStop的 task_id 不在pending_task_ids中会被直接过滤,所以收尾永远不触发,agent_clients/agent_children残留到下一轮。修改
收到
MaaTaskerPostStop的终态回调时,若本轮队列仍有任务没有结果,按失败调用begin_completion(false),走现有schedule_run_completion(等待空闲 → 回收 Agent → 发送tasks-completed)。begin()返回 false,不会重复执行。验证
Win32 控制器、游戏窗口非 16:9、勾选 2 个任务,触发 MaaEnd 分辨率检查的 PostStop 后再次开始:
stop_agent日志,第二次启动报status 0。[stop_agent] Stopping 2 agent client(s) and 2 child process(es)...,子进程退出,前端收到tasks-completed;第二次启动 Agent 正常连接。cargo check通过。AI 使用信息:
🤖 Generated with Claude Code
Sourcery 总结
完成并清理由内部 Tasker PostStop 回调触发的 Agent 运行,以便后续任务运行能够顺利启动。
Bug 修复:
Original summary in English
Sourcery 摘要
错误修复:
Original summary in English
Summary by Sourcery
Bug Fixes: