Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
您好,我发现了 3 个问题
面向 AI 智能体的提示
请处理本次代码审查中的意见:
## 各项意见
### 意见 1
<location path="src-tauri/src/commands/system.rs" line_range="760" />
<code_context>
);
+ // pretask 由项目声明、受 MXU 管理,与前置程序不同,停止时直接终止,避免其在后台继续操作
+ if let Err(e) = child.kill() {
+ warn!("Failed to kill pretask {}: {}", program, e);
+ }
std::thread::spawn(move || {
</code_context>
<issue_to_address>
**非 Windows 构建失败**
将项目编译为非 Windows 目标时,`warn!` 未解析,因为 `log::warn` 仅在 `#[cfg(windows)]` 下导入,因此构建会失败。
请使用完整路径限定该宏,或确保非 Windows 目标也能导入 `log::warn`。
另见 `src-tauri/src/commands/system.rs:761`。
</issue_to_address>
### 意见 2
<location path="src-tauri/src/commands/system.rs" line_range="759-760" />
<code_context>
instance_id
);
+ // pretask 由项目声明、受 MXU 管理,与前置程序不同,停止时直接终止,避免其在后台继续操作
+ if let Err(e) = child.kill() {
+ warn!("Failed to kill pretask {}: {}", program, e);
+ }
std::thread::spawn(move || {
</code_context>
<issue_to_address>
**取消后 pretask 仍在运行**
当子进程仍在运行时,如果操作系统拒绝终止请求,`run_pretask` 会记录 `child.kill()` 错误并返回 `MXU_PRE_ACTION_CANCELLED`,而后台线程只会等待,因此尽管报告了取消,pretask 仍会继续运行。
只有确认子进程已停止后,才应报告取消;请妥善处理终止失败的情况。
</issue_to_address>
### 意见 3
<location path="src-tauri/src/commands/system.rs" line_range="759" />
<code_context>
instance_id
);
+ // pretask 由项目声明、受 MXU 管理,与前置程序不同,停止时直接终止,避免其在后台继续操作
+ if let Err(e) = child.kill() {
+ warn!("Failed to kill pretask {}: {}", program, e);
+ }
</code_context>
<issue_to_address>
**辅助进程仍在运行**
如果 pretask 启动了生命周期长于自身的后代进程,`child.kill()` 只会终止由 `Command` 启动的进程,其辅助进程仍会存活,并在取消后继续运行。
请同时终止 pretask 的后代进程和直接子进程。
</issue_to_address>Original comment in English
Hey - I've found 3 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src-tauri/src/commands/system.rs" line_range="760" />
<code_context>
);
+ // pretask 由项目声明、受 MXU 管理,与前置程序不同,停止时直接终止,避免其在后台继续操作
+ if let Err(e) = child.kill() {
+ warn!("Failed to kill pretask {}: {}", program, e);
+ }
std::thread::spawn(move || {
</code_context>
<issue_to_address>
**Non-Windows builds fail**
When the project is compiled for a non-Windows target, `warn!` is unresolved because `log::warn` is imported only under `#[cfg(windows)]`, so the build fails.
Qualify the macro or make the `log::warn` import available on non-Windows targets.
Also at `src-tauri/src/commands/system.rs:761`.
</issue_to_address>
### Comment 2
<location path="src-tauri/src/commands/system.rs" line_range="759-760" />
<code_context>
instance_id
);
+ // pretask 由项目声明、受 MXU 管理,与前置程序不同,停止时直接终止,避免其在后台继续操作
+ if let Err(e) = child.kill() {
+ warn!("Failed to kill pretask {}: {}", program, e);
+ }
std::thread::spawn(move || {
</code_context>
<issue_to_address>
**Cancellation leaves pretask running**
When the OS rejects the kill request while the child is still running, `run_pretask` logs the `child.kill()` error, returns `MXU_PRE_ACTION_CANCELLED`, and the background thread only waits, so the pretask keeps operating despite reported cancellation.
Do not report cancellation unless the child is confirmed stopped; handle a failed kill accordingly.
</issue_to_address>
### Comment 3
<location path="src-tauri/src/commands/system.rs" line_range="759" />
<code_context>
instance_id
);
+ // pretask 由项目声明、受 MXU 管理,与前置程序不同,停止时直接终止,避免其在后台继续操作
+ if let Err(e) = child.kill() {
+ warn!("Failed to kill pretask {}: {}", program, e);
+ }
</code_context>
<issue_to_address>
**Helper processes keep running**
When a pretask starts descendant processes that outlive it, `child.kill()` terminates only the process spawned by `Command`, leaving its helpers alive to continue operating after cancellation.
Terminate the pretask's descendant processes as well as the direct child.
</issue_to_address>
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.
pre_task可能会运行比较久,当用户点击停止时,需要把pre_task的进程关掉。
opus 5.5
问题
run_pretask收到停止请求时,只是把子进程交给后台线程wait,然后直接返回取消。界面上已经停止,但 pretask 进程仍在后台运行。以 MaaEnd 的 LaunchGamePC 为例:它会一直等启动器窗口和游戏窗口,等到后还会去点启动器。用户点了停止之后,它仍可能继续操作。
改动
停止时先
child.kill(),再交给后台线程wait回收。run_action)保持原样:那里结束的可能是用户自己的程序(例如游戏本体),原注释已说明停止不强制终止。🤖 Generated with Claude Code
Sourcery 摘要
错误修复:
Original summary in English
Sourcery 总结
Bug 修复:
Original summary in English
Summary by Sourcery
Bug Fixes: