ref(MAAUserEdit): 任务配置重构为流水线布局 - #414
Conversation
原九宫格开关的排列顺序与后端 MAA_TASKS 的实际下发顺序无关,库存保持虽是 流水线第 3 位却被放在独立的二级板块,用户无法从界面看出任务执行的先后关系。 改为单列流水线,顺序严格对齐 AutoProxy 构建 TaskQueue 的顺序,折叠态每行 显示当前生效值的摘要,不展开即可核对配置。 - 删除「开始唤醒」开关:AutoProxy 导出配置前无条件置 task_dict["StartUp"]=True, 该开关从未生效,保留 IfStartUp 字段以兼容旧配置文件 - 删除「生息演算」开关:此前硬编码 disabled,永远无法启用 - 「自动肉鸽」移入折叠的「更多任务」,仍保留在 MAA_TASKS 中 - 基建换班/自动公招/信用收支/领取奖励压为单行勾选框,这四项改动频率低 - 库存保持并入流水线;计划模式下改为置灰保留并说明原因,不再整块隐藏 - 剿灭代理提升为流水线前置步骤,反映其为独立一轮完整流程
审查者指南本 PR 将 MAA 用户任务配置从九宫格重构为严格匹配后端执行顺序的单列流水线,以可折叠行、实时摘要和内联详情提升配置核对效率;同时移除两个无效入口、迁移库存保持编辑器,并通过摘要单测覆盖关键配置边界,未修改后端或配置字段。 内联任务配置和摘要更新时序图sequenceDiagram
actor User
participant Pipeline as TaskPipelineSection
participant Row as PipelineRow
participant Editor as DepotMaintainPlanEditor
participant Summary as taskSummaries
participant Parent as MAAUserEdit
User->>Row: click row
Row-->>Pipeline: toggle expanded
Pipeline->>Editor: render inline detail
User->>Editor: addPlan()
Editor->>Editor: savePlans()
Editor-->>Pipeline: save Task.DepotMaintainPlans
Pipeline-->>Parent: handleFieldSave()
Parent->>Summary: summarizeDepot()
Summary-->>Parent: updated summary
有序 MAA 任务流水线流程图flowchart TD
Annihilation[剿灭代理]
Activity[活动关作战]
Depot[库存保持]
Fight[理智作战]
Daily[日常任务]
More[更多任务]
Annihilation --> Activity
Activity --> Depot
Depot --> Fight
Fight --> Daily
Daily --> More
Annihilation -.关闭则跳过.-> Activity
Activity -.关闭则跳过.-> Depot
Depot -.计划模式下不可用.-> Fight
文件级变更
提示和命令与 Sourcery 交互
自定义使用体验访问你的控制面板以:
获取帮助Original review guide in EnglishReviewer's Guide本 PR 将 MAA 用户任务配置从九宫格重构为严格匹配后端执行顺序的单列流水线,以可折叠行、实时摘要和内联详情提升配置核对效率;同时移除两个无效入口、迁移库存保持编辑器,并通过摘要单测覆盖关键配置边界,未修改后端或配置字段。 Sequence diagram for inline task configuration and summary updatessequenceDiagram
actor User
participant Pipeline as TaskPipelineSection
participant Row as PipelineRow
participant Editor as DepotMaintainPlanEditor
participant Summary as taskSummaries
participant Parent as MAAUserEdit
User->>Row: click row
Row-->>Pipeline: toggle expanded
Pipeline->>Editor: render inline detail
User->>Editor: addPlan()
Editor->>Editor: savePlans()
Editor-->>Pipeline: save Task.DepotMaintainPlans
Pipeline-->>Parent: handleFieldSave()
Parent->>Summary: summarizeDepot()
Summary-->>Parent: updated summary
Flow diagram for the ordered MAA task pipelineflowchart TD
Annihilation[剿灭代理]
Activity[活动关作战]
Depot[库存保持]
Fight[理智作战]
Daily[日常任务]
More[更多任务]
Annihilation --> Activity
Activity --> Depot
Depot --> Fight
Fight --> Daily
Daily --> More
Annihilation -.关闭则跳过.-> Activity
Activity -.关闭则跳过.-> Depot
Depot -.计划模式下不可用.-> Fight
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
你好——我发现了 2 个问题
面向 AI Agent 的提示
请处理本次代码审查中的评论:
## 单独评论
### 评论 1
<location path="frontend/src/views/MAAUserEdit/weekMarker.ts" line_range="11" />
<code_context>
- const shifted = new Date(Date.now() + 4 * 60 * 60 * 1000)
- const date = new Date(Date.UTC(shifted.getUTCFullYear(), shifted.getUTCMonth(), shifted.getUTCDate()))
- const day = date.getUTCDay() || 7
- date.setUTCDate(date.getUTCDate() + 4 - day)
- const yearStart = new Date(Date.UTC(date.getUTCFullYear(), 0, 1))
- const week = Math.ceil((((date.getTime() - yearStart.getTime()) / 86400000) + 1) / 7)
- return `${date.getUTCFullYear()}-W${String(week).padStart(2, '0')}`
-})()
-
</code_context>
<issue_to_address>
**issue (bug_risk):** 对于星期四落在一年中的第 7、14、21 或 28 天的日期,ISO 周计算会偏大一周。例如,2024-01-01(星期一)会被调整到 2024-01-04(星期四),并返回 W02 而不是 W01,因此手动标记歼灭完成时会写入一个后端无法识别为当前周的标记。
**触发条件:** 当前 UTC+4 周从星期一开始,且该周的星期四恰好是一年中第 7、14、21 或 28 天时。
**建议修复:** 使用 ISO 周算法或等效于 `date.isocalendar()` 的逻辑计算 ISO 周,而不是使用 `Math.ceil((dayOfYear + 1) / 7)`。
```suggestion
const week = Math.floor((date.getTime() - yearStart.getTime()) / 86400000 / 7) + 1
```
</issue_to_address>
### 评论 2
<location path="frontend/src/views/MAAUserEdit/taskSummaries.ts" line_range="61-70" />
<code_context>
+}
+
+export const summarizeDepot = (isPlanMode: boolean, enabled: boolean, plansJson: string) => {
+ if (isPlanMode) return '计划模式下不可用'
+ if (!enabled) return '已关闭'
+ let count = 0
+ try {
+ const parsed = JSON.parse(plansJson || '[]')
+ count = Array.isArray(parsed) ? parsed.length : 0
+ } catch {
+ count = 0
+ }
+ return count ? `${count} 项计划` : '尚未添加计划'
+}
+
</code_context>
<issue_to_address>
**nitpick:** 库存摘要会统计 `DepotMaintainPlans` 中数组的每个元素,包括 `DepotMaintainPlanEditor` 因缺少有效的 `Stage`、`DropId` 或数值型 `DropCount` 字段而丢弃的格式错误条目。因此,折叠行会报告编辑器无法显示或执行的已配置计划。
**触发条件:** 现有配置包含一个或多个格式错误的库存计划条目时。
**建议修复:** 在统计计划数量之前,应用与 `DepotMaintainPlanEditor` 相同的有效性过滤条件。
</issue_to_address>Sourcery 评估
需要人工审查。 首先需要处理 1 个发现;错误的流水线控制、阶段选择或库存计划可能会持久化错误配置,导致后续自动化运行错误的任务或消耗资源。还原操作可以恢复之前的编辑器,但无法撤销已经触发的自动化;保存的配置本身影响范围有限,可以进行修正或重新运行。
阻塞性发现:frontend/src/views/MAAUserEdit/weekMarker.ts:11
帮助我变得更有用!请在每条评论上点击 👍 或 👎,我会利用您的反馈改进审查结果。
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="frontend/src/views/MAAUserEdit/weekMarker.ts" line_range="11" />
<code_context>
- const shifted = new Date(Date.now() + 4 * 60 * 60 * 1000)
- const date = new Date(Date.UTC(shifted.getUTCFullYear(), shifted.getUTCMonth(), shifted.getUTCDate()))
- const day = date.getUTCDay() || 7
- date.setUTCDate(date.getUTCDate() + 4 - day)
- const yearStart = new Date(Date.UTC(date.getUTCFullYear(), 0, 1))
- const week = Math.ceil((((date.getTime() - yearStart.getTime()) / 86400000) + 1) / 7)
- return `${date.getUTCFullYear()}-W${String(week).padStart(2, '0')}`
-})()
-
</code_context>
<issue_to_address>
**issue (bug_risk):** The ISO week calculation is off by one for dates whose Thursday falls on day 7, 14, 21, or 28 of the year. For example, Monday 2024-01-01 is shifted to Thursday 2024-01-04 and returns W02 instead of W01, so manually marking annihilation complete writes a marker that the backend does not recognize as the current week.
**Triggers:** When the current UTC+4 week begins on a Monday in a week whose Thursday is exactly a multiple of seven days into the year.
**Suggested fix:** Calculate the ISO week using an ISO-week algorithm or `date.isocalendar()`-equivalent logic instead of `Math.ceil((dayOfYear + 1) / 7)`.
```suggestion
const week = Math.floor((date.getTime() - yearStart.getTime()) / 86400000 / 7) + 1
```
</issue_to_address>
### Comment 2
<location path="frontend/src/views/MAAUserEdit/taskSummaries.ts" line_range="61-70" />
<code_context>
+}
+
+export const summarizeDepot = (isPlanMode: boolean, enabled: boolean, plansJson: string) => {
+ if (isPlanMode) return '计划模式下不可用'
+ if (!enabled) return '已关闭'
+ let count = 0
+ try {
+ const parsed = JSON.parse(plansJson || '[]')
+ count = Array.isArray(parsed) ? parsed.length : 0
+ } catch {
+ count = 0
+ }
+ return count ? `${count} 项计划` : '尚未添加计划'
+}
+
</code_context>
<issue_to_address>
**nitpick:** The inventory summary counts every array element in `DepotMaintainPlans`, including malformed entries that `DepotMaintainPlanEditor` discards because they lack valid `Stage`, `DropId`, or numeric `DropCount` fields. The collapsed row therefore reports configured plans that the editor cannot display or execute.
**Triggers:** When an existing configuration contains one or more malformed inventory-plan entries.
**Suggested fix:** Apply the same validity filter as `DepotMaintainPlanEditor` before counting plans.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 1 finding to address first, and a faulty pipeline control, stage selection, or inventory plan could persist an incorrect configuration and cause subsequent automation to run the wrong task or consume resources. Reverting restores the previous editor, but it cannot undo any automation already triggered; the saved configuration itself is bounded and can be corrected or rerun.
Blocking findings: frontend/src/views/MAAUserEdit/weekMarker.ts:11
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| const day = date.getUTCDay() || 7 | ||
| date.setUTCDate(date.getUTCDate() + 4 - day) | ||
| const yearStart = new Date(Date.UTC(date.getUTCFullYear(), 0, 1)) | ||
| const week = Math.ceil(((date.getTime() - yearStart.getTime()) / 86400000 + 1) / 7) |
There was a problem hiding this comment.
issue (bug_risk): 对于星期四落在一年中的第 7、14、21 或 28 天的日期,ISO 周计算会偏大一周。例如,2024-01-01(星期一)会被调整到 2024-01-04(星期四),并返回 W02 而不是 W01,因此手动标记歼灭完成时会写入一个后端无法识别为当前周的标记。
触发条件: 当前 UTC+4 周从星期一开始,且该周的星期四恰好是一年中第 7、14、21 或 28 天时。
建议修复: 使用 ISO 周算法或等效于 date.isocalendar() 的逻辑计算 ISO 周,而不是使用 Math.ceil((dayOfYear + 1) / 7)。
| const week = Math.ceil(((date.getTime() - yearStart.getTime()) / 86400000 + 1) / 7) | |
| const week = Math.floor((date.getTime() - yearStart.getTime()) / 86400000 / 7) + 1 |
Original comment in English
issue (bug_risk): The ISO week calculation is off by one for dates whose Thursday falls on day 7, 14, 21, or 28 of the year. For example, Monday 2024-01-01 is shifted to Thursday 2024-01-04 and returns W02 instead of W01, so manually marking annihilation complete writes a marker that the backend does not recognize as the current week.
Triggers: When the current UTC+4 week begins on a Monday in a week whose Thursday is exactly a multiple of seven days into the year.
Suggested fix: Calculate the ISO week using an ISO-week algorithm or date.isocalendar()-equivalent logic instead of Math.ceil((dayOfYear + 1) / 7).
| const week = Math.ceil(((date.getTime() - yearStart.getTime()) / 86400000 + 1) / 7) | |
| const week = Math.floor((date.getTime() - yearStart.getTime()) / 86400000 / 7) + 1 |
| if (isPlanMode) return '计划模式下不可用' | ||
| if (!enabled) return '已关闭' | ||
| let count = 0 | ||
| try { | ||
| const parsed = JSON.parse(plansJson || '[]') | ||
| count = Array.isArray(parsed) ? parsed.length : 0 | ||
| } catch { | ||
| count = 0 | ||
| } | ||
| return count ? `${count} 项计划` : '尚未添加计划' |
There was a problem hiding this comment.
nitpick: 库存摘要会统计 DepotMaintainPlans 中数组的每个元素,包括 DepotMaintainPlanEditor 因缺少有效的 Stage、DropId 或数值型 DropCount 字段而丢弃的格式错误条目。因此,折叠行会报告编辑器无法显示或执行的已配置计划。
触发条件: 现有配置包含一个或多个格式错误的库存计划条目时。
建议修复: 在统计计划数量之前,应用与 DepotMaintainPlanEditor 相同的有效性过滤条件。
Original comment in English
nitpick: The inventory summary counts every array element in DepotMaintainPlans, including malformed entries that DepotMaintainPlanEditor discards because they lack valid Stage, DropId, or numeric DropCount fields. The collapsed row therefore reports configured plans that the editor cannot display or execute.
Triggers: When an existing configuration contains one or more malformed inventory-plan entries.
Suggested fix: Apply the same validity filter as DepotMaintainPlanEditor before counting plans.
流水线落地后暴露三处层级问题:任务名与二级标签同为 14px/600,仅差 1px, 从属关系看不出来;开关贴在行尾,与它控制的任务名隔着整行;「基建模式」留在 基本信息区,与「日常任务」里的 IfInfrast 开关分处两个板块,关掉基建换班后 该配置仍然亮着,看不出已失效。 基建换班提升为独立流水线行,位置对齐后端 MAA_TASKS 中 Infrast 紧跟 Fight 的 顺序;开关移到任务名左侧;二级标签降一级字重与色阶。 - 基建模式/自定义基建配置/自定义基建排班 从基本信息区移入基建换班行的详情区, 自定义两项沿用 InfrastMode === 'Custom' 条件渲染 - IfInfrast 移出 dailyTasks,该组余下三项均为无配置的一键任务,改名「日常杂项」 - 开关移到圆点与任务名之间,独立 44px 槽位;无开关的行留占位保持任务名列对齐 - 任务名 14px→15px,二级标签 600/primary→500/secondary,详情区加左侧竖线续接轨道 - 「更多任务」原本只包一个开关,折叠为「自动肉鸽」单行,删除整层详情面板 - 行头 hover-only tooltip 图标改为详情区常驻正文,LabelWithHint 补 focus 触发, 键盘与触屏用户不再拿不到提示(WCAG 1.4.13) - StageConfigSection 的 8 处手写 tooltip 统一为 LabelWithHint,删除重复 CSS; 其中「吃理智药数量」「关卡选择」的提示与标签同文,一并去掉 - 清理死代码:infrastructureConfigPath 只声明无读写,BasicInfoSection 的 4 个 props 随基建配置迁出后失效
开发者反馈前两次重构的组名变更幅度过大。「任务流程」「日常杂项」都是新造的 说法,且左侧竖轨 + 圆点把一个普通配置列表画成了流程图,视觉噪声大于信息量。 组名回退到重构前的「任务配置」「日常任务」,删除竖轨、圆点与详情区续接线。 任务执行顺序仍由行的排列表达,标题右侧保留「按执行顺序,从上到下」说明。 - 删除 row-dot 及其连接线、row-detail::before 竖线,行内不再有 position 依赖 - 详情区改用左内边距对齐任务名列(4 + 44 开关槽 + 12 间隙 + 8) - switchable 改名 toggleable;pipeline-row/pipeline-alert 类名改为 task-row/task-alert - 关闭态摘要一律返回空串:关着的开关已表达关闭,摘要再写「已关闭」是重复。 库存保持在计划模式下仍返回「计划模式下不可用」,那是用户需要的失效原因 - 补 activity/depot/fight 三个 summarize 的关闭分支测试,此前无覆盖 顺带修两处对比度不达标(均为 63b7fb5 引入,非本次改动产生): - .is-off .row-name 从 text-tertiary 改 text-secondary。15px/600 不算 WCAG 大字,需按 4.5:1 判定,tertiary 浅色模式下仅 3.36:1,secondary 为 7.00:1 - 删除 .is-off .row-summary 的 text-quaternary。该规则现仅作用于计划模式下的 「计划模式下不可用」,1.84:1 近乎不可见,改为继承 .row-summary 的 7.00:1
背景
原「任务配置」是 8 个开关的九宫格,存在三个问题:
app/utils/constants.py的MAA_TASKS决定,AutoProxy按该数组构建TaskQueue。九宫格的阅读顺序(唤醒/作战/基建/公招 → 信用/奖励/肉鸽/生息)和它对不上。MAA_TASKS第 3 位、紧跟活动关之后,却被放在一个独立的二级板块里,离任务开关很远。改动
改为单列布局,顺序严格对齐
AutoProxy构建TaskQueue的顺序:两级控件语言
一级任务用 switch(44×22),二级子项用勾选框(16px),尺寸差 2.75 倍建立层级。这也符合 HIG 的控件语义:立即生效的设置用 switch,组内选项用 checkbox。
中途试过「按钮显示启用/关闭文字」和「两级都用勾选框」两版,都已放弃:前者 button 的形状承诺「点我执行动作」而内容是状态,形状与语义矛盾;后者两级尺寸零差异,字号建立的层级(15px/600 vs 14px/400)被控件抹平。
删除两个无效开关
AutoProxy.py在导出配置前无条件执行self.task_dict["StartUp"] = True,覆盖用户配置。用户关掉它 MAA 侧照样 enabled,即该开关从未生效。IfStartUp字段保留以兼容旧配置文件。:disabled="true",永远无法点亮。等适配完成后再加回。其他
MAA_TASKS中 Infrast 紧跟 Fight 的顺序;基建模式/自定义配置/自定义排班从「基本信息」区移入它的详情区,关掉基建后这些配置跟着一起收起v-if="!isPlanMode"整块隐藏,用户会误以为功能消失(后端AutoProxy.py在计划模式下会强制task_dict["DepotMaintain"] = False)AutoProxy中它是先于日常的独立一轮完整流程无障碍
LabelWithHint补 focus 触发,键盘与触屏用户不再拿不到提示(WCAG 1.4.13)text-tertiary3.36:1 →text-secondary7.00:1(15px/600 不算 WCAG 大字,需按 4.5:1 判定);计划模式下「计划模式下不可用」原为text-quaternary1.84:1,近乎不可见,改为继承 7.00:1已知遗留:switch 滑块与勾选框是白色图形置于
colorPrimary填充,在青/绿/橙/黄/亮绿/金 6 个主题色下不足 WCAG 1.4.11 要求的 3:1。这是 antd 原生控件在全站的既有状况,修需动主题层,不在本 PR 范围。结构
PipelineRow.vue(折叠行)、TaskPipelineSection.vue(列表容器)taskSummaries.ts,附单元测试TaskConfigSection.vue、DepotMaintainConfigSection.vue删除;后者的表格移入DepotMaintainPlanEditor.vue作为行内详情StageConfigSection.vue精简为理智作战的详情内容组件文件名沿用
PipelineRow/TaskPipelineSection,改名会牵动 import,未做。无后端改动,无配置字段增删。
测试
yarn test— 56 passed(新增 20 个摘要测试,覆盖关闭分支、计划模式前缀、-哨兵值、坏 JSON 兜底)yarn typecheck— 本 PR 涉及文件无报错yarn lint— 本 PR 涉及文件无报错vite build— 通过未做人工 UI 验证:需要 Electron + Python 后端联跑。对比度数值经 antd 调色算法逐主题计算,但间距与实际观感仅经静态检查,建议 review 时实机确认。
Sourcery 摘要
将 MAA 任务配置重构为按执行顺序排列的流水线,并提供简洁摘要和内联设置,同时保留现有配置的兼容性。
新功能:
错误修复:
增强功能:
测试:
杂项:
Original summary in English
Sourcery 摘要
按后端执行顺序重构 MAA 任务配置界面,使用流水线布局整合任务开关、摘要和内联配置。
新功能:
错误修复:
改进:
测试:
日常维护:
Original summary in English
Summary by Sourcery
按后端执行顺序重构 MAA 任务配置界面,使用流水线布局整合任务开关、摘要和内联配置。
New Features:
Bug Fixes:
Enhancements:
Tests:
Chores:
Original summary in English
Sourcery 摘要
按后端执行顺序重构 MAA 任务配置界面,使用流水线布局整合任务开关、摘要和内联配置。
新功能:
错误修复:
改进:
测试:
日常维护:
Original summary in English
Summary by Sourcery
按后端执行顺序重构 MAA 任务配置界面,使用流水线布局整合任务开关、摘要和内联配置。
New Features:
Bug Fixes:
Enhancements:
Tests:
Chores: