feat: 特殊任务使用虚拟控制器#255
Conversation
There was a problem hiding this comment.
你好——我发现了 1 个问题,并且留下了一些整体性的反馈:
- 在 src/utils/taskSegmentation.ts 中,needsSegmentedRun 目前只是简单地转发到 hasSpecialSegments,但 JSDoc 里写的是:只有在同时存在特殊段 并且 存在游戏段时才应该为 true;建议额外检查
segments.middle.length > 0,以避免把只有特殊任务的列表视为“分段运行”。 - 在 DashboardView.tsx 中,needsDummyController 变量被计算出来但从未使用;建议要么像 Toolbar 里的 shouldUseDummyController 那样把它接入 start/run 逻辑,要么直接删掉,避免造成困惑和产生死代码。
提供给 AI Agents 的提示词
请处理这次代码评审中的评论:
## 整体评论
- 在 src/utils/taskSegmentation.ts 中,needsSegmentedRun 目前只是简单地转发到 hasSpecialSegments,但 JSDoc 里写的是:只有在同时存在特殊段 *并且* 存在游戏段时才应该为 true;建议额外检查 `segments.middle.length > 0`,以避免把只有特殊任务的列表视为“分段运行”。
- 在 DashboardView.tsx 中,needsDummyController 变量被计算出来但从未使用;建议要么像 Toolbar 里的 shouldUseDummyController 那样把它接入 start/run 逻辑,要么直接删掉,避免造成困惑和产生死代码。
## 具体评论
### 评论 1
<location path="src/utils/taskSegmentation.ts" line_range="49-50" />
<code_context>
+ return segments.leading.length > 0 || segments.trailing.length > 0;
+}
+
+/** 是否应走分段运行(存在特殊段且与游戏段组合) */
+export function needsSegmentedRun(segments: ThreeSegmentSplit<unknown>): boolean {
+ return hasSpecialSegments(segments);
+}
</code_context>
<issue_to_address>
**issue (bug_risk):** needsSegmentedRun 的实现没有体现注释里“与游戏段组合”的条件
当前实现只返回 `hasSpecialSegments(segments)`,与注释“存在特殊段且与游戏段组合”不符。如果所有任务都是特殊任务(`middle` 为空),按注释应不需要分段运行,但现在仍返回 true。建议同时判断 `middle` 非空,例如:
```ts
export function needsSegmentedRun(segments: ThreeSegmentSplit<unknown>): boolean {
return hasSpecialSegments(segments) && segments.middle.length > 0;
}
```
</issue_to_address>帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进今后的评审。
Original comment in English
Hey - I've found 1 issue, and left some high level feedback:
- In src/utils/taskSegmentation.ts, needsSegmentedRun currently just proxies to hasSpecialSegments, but the JSDoc says it should only be true when there are special segments and a game segment; consider also checking segments.middle.length > 0 to avoid treating a pure-special-task list as segmented.
- In DashboardView.tsx, the needsDummyController variable is computed but never used; either wire this into the start/run logic (similar to Toolbar’s shouldUseDummyController) or remove it to avoid confusion and dead code.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In src/utils/taskSegmentation.ts, needsSegmentedRun currently just proxies to hasSpecialSegments, but the JSDoc says it should only be true when there are special segments *and* a game segment; consider also checking segments.middle.length > 0 to avoid treating a pure-special-task list as segmented.
- In DashboardView.tsx, the needsDummyController variable is computed but never used; either wire this into the start/run logic (similar to Toolbar’s shouldUseDummyController) or remove it to avoid confusion and dead code.
## Individual Comments
### Comment 1
<location path="src/utils/taskSegmentation.ts" line_range="49-50" />
<code_context>
+ return segments.leading.length > 0 || segments.trailing.length > 0;
+}
+
+/** 是否应走分段运行(存在特殊段且与游戏段组合) */
+export function needsSegmentedRun(segments: ThreeSegmentSplit<unknown>): boolean {
+ return hasSpecialSegments(segments);
+}
</code_context>
<issue_to_address>
**issue (bug_risk):** needsSegmentedRun 的实现没有体现注释里“与游戏段组合”的条件
当前实现只返回 `hasSpecialSegments(segments)`,与注释“存在特殊段且与游戏段组合”不符。如果所有任务都是特殊任务(`middle` 为空),按注释应不需要分段运行,但现在仍返回 true。建议同时判断 `middle` 非空,例如:
```ts
export function needsSegmentedRun(segments: ThreeSegmentSplit<unknown>): boolean {
return hasSpecialSegments(segments) && segments.middle.length > 0;
}
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| /** 是否应走分段运行(存在特殊段且与游戏段组合) */ | ||
| export function needsSegmentedRun(segments: ThreeSegmentSplit<unknown>): boolean { |
There was a problem hiding this comment.
issue (bug_risk): needsSegmentedRun 的实现没有体现注释里“与游戏段组合”的条件
当前实现只返回 hasSpecialSegments(segments),与注释“存在特殊段且与游戏段组合”不符。如果所有任务都是特殊任务(middle 为空),按注释应不需要分段运行,但现在仍返回 true。建议同时判断 middle 非空,例如:
export function needsSegmentedRun(segments: ThreeSegmentSplit<unknown>): boolean {
return hasSpecialSegments(segments) && segments.middle.length > 0;
}Original comment in English
issue (bug_risk): needsSegmentedRun 的实现没有体现注释里“与游戏段组合”的条件
当前实现只返回 hasSpecialSegments(segments),与注释“存在特殊段且与游戏段组合”不符。如果所有任务都是特殊任务(middle 为空),按注释应不需要分段运行,但现在仍返回 true。建议同时判断 middle 非空,例如:
export function needsSegmentedRun(segments: ThreeSegmentSplit<unknown>): boolean {
return hasSpecialSegments(segments) && segments.middle.length > 0;
}There was a problem hiding this comment.
Hey - 我发现了 1 个问题,并且给了一些整体性的反馈:
- Toolbar 和 DashboardView 中的任务批处理逻辑(拆分为多个段、构建配置以及注册 task ID)现在有相当一部分是重复的;建议抽取一个共享的 helper,接受 runnableTasks 和段信息,从而减少重复代码并保持行为一致。
- 新增的
needsSegmentedRunhelper(位于taskSegmentation.ts)目前只是代理了hasSpecialSegments,并且与它的文档注释(“存在特殊段且与游戏段组合”)不符;建议要么调整实现以满足预期条件,要么在未使用时删除以避免混淆。
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The task batching logic in Toolbar and DashboardView (splitting into segments, building configs, and registering task IDs) is now fairly duplicated; consider extracting a shared helper that takes runnableTasks and segment info to reduce repetition and keep the behavior consistent.
- The new `needsSegmentedRun` helper in `taskSegmentation.ts` currently just proxies `hasSpecialSegments` and doesn’t match its docstring (“存在特殊段且与游戏段组合”); either adjust the implementation to reflect the intended condition or remove it if unused to avoid confusion.
## Individual Comments
### Comment 1
<location path="src/utils/taskSegmentation.ts" line_range="49-50" />
<code_context>
+ return segments.leading.length > 0 || segments.trailing.length > 0;
+}
+
+/** 是否应走分段运行(存在特殊段且与游戏段组合) */
+export function needsSegmentedRun(segments: ThreeSegmentSplit<unknown>): boolean {
+ return hasSpecialSegments(segments);
+}
</code_context>
<issue_to_address>
**suggestion (bug_risk):** `needsSegmentedRun` currently returns true whenever there is any leading/trailing segment, regardless of whether a middle/game segment exists.
The docstring says this should only be true when special segments are combined with a game segment, but the implementation is equivalent to `hasSpecialSegments`. For queues with only special tasks and no game tasks, `needsSegmentedRun` will still be true, which could trigger multi-batch execution when there is no middle segment. If this helper is used to decide multi-batch behavior, consider additionally checking that the `middle` segment is non-empty.
</issue_to_address>帮我变得更有用!请对每条评论点 👍 或 👎,我会根据你的反馈改进后续的评审。
Original comment in English
Hey - I've found 1 issue, and left some high level feedback:
- The task batching logic in Toolbar and DashboardView (splitting into segments, building configs, and registering task IDs) is now fairly duplicated; consider extracting a shared helper that takes runnableTasks and segment info to reduce repetition and keep the behavior consistent.
- The new
needsSegmentedRunhelper intaskSegmentation.tscurrently just proxieshasSpecialSegmentsand doesn’t match its docstring (“存在特殊段且与游戏段组合”); either adjust the implementation to reflect the intended condition or remove it if unused to avoid confusion.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The task batching logic in Toolbar and DashboardView (splitting into segments, building configs, and registering task IDs) is now fairly duplicated; consider extracting a shared helper that takes runnableTasks and segment info to reduce repetition and keep the behavior consistent.
- The new `needsSegmentedRun` helper in `taskSegmentation.ts` currently just proxies `hasSpecialSegments` and doesn’t match its docstring (“存在特殊段且与游戏段组合”); either adjust the implementation to reflect the intended condition or remove it if unused to avoid confusion.
## Individual Comments
### Comment 1
<location path="src/utils/taskSegmentation.ts" line_range="49-50" />
<code_context>
+ return segments.leading.length > 0 || segments.trailing.length > 0;
+}
+
+/** 是否应走分段运行(存在特殊段且与游戏段组合) */
+export function needsSegmentedRun(segments: ThreeSegmentSplit<unknown>): boolean {
+ return hasSpecialSegments(segments);
+}
</code_context>
<issue_to_address>
**suggestion (bug_risk):** `needsSegmentedRun` currently returns true whenever there is any leading/trailing segment, regardless of whether a middle/game segment exists.
The docstring says this should only be true when special segments are combined with a game segment, but the implementation is equivalent to `hasSpecialSegments`. For queues with only special tasks and no game tasks, `needsSegmentedRun` will still be true, which could trigger multi-batch execution when there is no middle segment. If this helper is used to decide multi-batch behavior, consider additionally checking that the `middle` segment is non-empty.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| /** 是否应走分段运行(存在特殊段且与游戏段组合) */ | ||
| export function needsSegmentedRun(segments: ThreeSegmentSplit<unknown>): boolean { |
There was a problem hiding this comment.
suggestion (bug_risk): needsSegmentedRun 目前在存在任意前置 / 后置段时都会返回 true,而不管是否存在 middle/game 段。
文档注释说明它只应在“特殊段与游戏段组合”时返回 true,但当前实现等价于 hasSpecialSegments。对于只包含特殊任务而不包含游戏任务的队列,needsSegmentedRun 仍然会是 true,这可能会在没有 middle 段时触发多批次执行。如果这个 helper 用来决定是否进行多批次执行,建议额外检查 middle 段是否非空。
Original comment in English
suggestion (bug_risk): needsSegmentedRun currently returns true whenever there is any leading/trailing segment, regardless of whether a middle/game segment exists.
The docstring says this should only be true when special segments are combined with a game segment, but the implementation is equivalent to hasSpecialSegments. For queues with only special tasks and no game tasks, needsSegmentedRun will still be true, which could trigger multi-batch execution when there is no middle segment. If this helper is used to decide multi-batch behavior, consider additionally checking that the middle segment is non-empty.
|
自测通过 |
特殊任务都使用虚拟controller,避免游戏主进程退出后截图失败,导致无法执行特殊任务。
close MaaEnd/MaaEnd#1882
close MaaEnd/MaaEnd#2084
close MaaEnd/MaaEnd#2121
close MaaEnd/MaaEnd#2141
close MaaEnd/MaaEnd#2336
close MaaEnd/MaaEnd#2702
close MaaEnd/MaaEnd#2838
close MaaEnd/MaaEnd#3235
opus4.8


Summary by Sourcery
引入 Dummy 控制器支持和分段任务执行功能,使 MXU 的非可视特殊任务在没有实时游戏连接的情况下也能运行,同时在批次之间保持后端任务状态。
New Features:
Enhancements:
reset_state标志选择重置或追加任务 ID。Original summary in English
Summary by Sourcery
Introduce dummy controller support and segmented task execution so MXU non-visual special tasks can run without a live game connection while preserving backend task state across batches.
New Features:
Enhancements: