Repository navigation
Conversation
autostart / autoRunOnLaunch 的任务跑完后才触发自动安装,重启沿用原命令行参数, 新进程会再次分发同一批自动任务。记录本进程是否已成功启动过自动任务并写入更新完成信息, 重启后据此跳过自动执行;启动时先装挂起更新的场景不受影响。 Refs MaaEnd/MaaEnd#7160
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.
嘿——我发现了 3 个问题
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/components/InstallConfirmModal.tsx" line_range="119" />
<code_context>
releaseNote: updateInfo.releaseNote,
channel: updateInfo.channel,
timestamp: Date.now(),
+ autoTasksAlreadyRan: useAppStore.getState().autoTasksRanInSession,
});
}
</code_context>
<issue_to_address>
**Automatic tasks run again after storage failure**
When writing the update-completion record to localStorage fails, `saveUpdateCompleteInfo` catches the write error, so `handleRestart` continues without saving `autoTasksAlreadyRan`; the relaunched app dispatches the same automatic tasks again.
Make `handleRestart` restart only after the completion record, including `autoTasksAlreadyRan`, has been saved successfully.
Also at `src/App.tsx:1104`.
</issue_to_address>
### Comment 2
<location path="src/components/InstallConfirmModal.tsx" line_range="119" />
<code_context>
releaseNote: updateInfo.releaseNote,
channel: updateInfo.channel,
timestamp: Date.now(),
+ autoTasksAlreadyRan: useAppStore.getState().autoTasksRanInSession,
});
}
</code_context>
<issue_to_address>
**Interrupted installs repeat tasks**
When the process crashes in the interval after installation completes and before `handleRestart` saves the completion info, or the completion-info write fails, `autoTasksAlreadyRan` is saved only by `handleRestart` after `installUpdate` has completed; a crash after the update replaces the files but before that save leaves no marker, so the relaunched app dispatches the same automatic tasks again.
Persist the run marker before the update can replace the running application, and do not proceed with an automatic restart if that durable write fails.
</issue_to_address>
### Comment 3
<location path="src/components/InstallConfirmModal.tsx" line_range="119" />
<code_context>
releaseNote: updateInfo.releaseNote,
channel: updateInfo.channel,
timestamp: Date.now(),
+ autoTasksAlreadyRan: useAppStore.getState().autoTasksRanInSession,
});
}
</code_context>
<issue_to_address>
**Interrupted tasks are not resumed**
When a background download completes while an automatic task is running and the user installs the update before that task finishes, `autoTasksRanInSession` becomes true as soon as the automatic task start succeeds, so installing a downloaded update while that task is still running records it as already run. The restart then skips dispatch and abandons the unfinished task batch.
Only persist the skip marker after the automatic task batch has completed, or prevent update installation and restart while that batch is running.
</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/components/InstallConfirmModal.tsx" line_range="119" />
<code_context>
releaseNote: updateInfo.releaseNote,
channel: updateInfo.channel,
timestamp: Date.now(),
+ autoTasksAlreadyRan: useAppStore.getState().autoTasksRanInSession,
});
}
</code_context>
<issue_to_address>
**Automatic tasks run again after storage failure**
When writing the update-completion record to localStorage fails, `saveUpdateCompleteInfo` catches the write error, so `handleRestart` continues without saving `autoTasksAlreadyRan`; the relaunched app dispatches the same automatic tasks again.
Make `handleRestart` restart only after the completion record, including `autoTasksAlreadyRan`, has been saved successfully.
Also at `src/App.tsx:1104`.
</issue_to_address>
### Comment 2
<location path="src/components/InstallConfirmModal.tsx" line_range="119" />
<code_context>
releaseNote: updateInfo.releaseNote,
channel: updateInfo.channel,
timestamp: Date.now(),
+ autoTasksAlreadyRan: useAppStore.getState().autoTasksRanInSession,
});
}
</code_context>
<issue_to_address>
**Interrupted installs repeat tasks**
When the process crashes in the interval after installation completes and before `handleRestart` saves the completion info, or the completion-info write fails, `autoTasksAlreadyRan` is saved only by `handleRestart` after `installUpdate` has completed; a crash after the update replaces the files but before that save leaves no marker, so the relaunched app dispatches the same automatic tasks again.
Persist the run marker before the update can replace the running application, and do not proceed with an automatic restart if that durable write fails.
</issue_to_address>
### Comment 3
<location path="src/components/InstallConfirmModal.tsx" line_range="119" />
<code_context>
releaseNote: updateInfo.releaseNote,
channel: updateInfo.channel,
timestamp: Date.now(),
+ autoTasksAlreadyRan: useAppStore.getState().autoTasksRanInSession,
});
}
</code_context>
<issue_to_address>
**Interrupted tasks are not resumed**
When a background download completes while an automatic task is running and the user installs the update before that task finishes, `autoTasksRanInSession` becomes true as soon as the automatic task start succeeds, so installing a downloaded update while that task is still running records it as already run. The restart then skips dispatch and abandons the unfinished task batch.
Only persist the skip marker after the automatic task batch has completed, or prevent update installation and restart while that batch is running.
</issue_to_address>There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1bfc18887a
ℹ️ 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".
close MaaEnd/MaaEnd#7160
修改前:通过命令行启动,直接运行任务->更新完成等待任务结束后重启->重启后重复运行已完成任务
修改后:通过命令行启动,直接运行任务->更新完成等待任务结束后重启->重启完成
问题
MaaEnd/MaaEnd#7160:用户用计划任务以
--autostart -i="日常"启动,启动时检查到新版本并在后台下载。任务跑完、实例空闲后自动安装更新并重启,重启沿用原命令行参数,新进程再次进入自动执行分支,把同一批任务完整重跑了一遍。原因:重启后在
consumeUpdateCompleteInfo()的分支里,autostart 模式只跳过了更新完成弹窗,autoStartTasksPending仍为 true,之后照常分发。代码无法区分以下两种更新重启:autoRunOnLaunch(手动启动时也自动执行)存在同样问题。修改
autoTasksRanInSession(仅内存,不持久化),记录本进程内自动任务是否已成功启动过。App.tsx将三处 autostart 分发合并为dispatchAutoStartTasks(),onSettled(true)时置位;启动失败不置位,重启后仍会补跑。UpdateCompleteInfo新增可选字段autoTasksAlreadyRan,zip 自动安装重启前写入。autoTasksAlreadyRan时跳过本次自动执行,并打日志更新重启:更新前已执行过自动任务,跳过本次自动执行。测试
tsc --noEmit通过,pnpm test119 通过 / 1 跳过 / 0 失败。AI 使用信息:
🤖 Generated with Claude Code
Sourcery 摘要
避免更新安装导致应用重启后,再次运行已完成的自动任务。
错误修复:
增强功能:
Original summary in English
Summary by Sourcery
Avoid rerunning completed automatic tasks after an update installation restarts the application.
Bug Fixes:
Enhancements: