Skip to content

fix(maa): 脚本管理页用户标签随理智作战与活动关优先开关显示 - #982

Open
qiyinxi wants to merge 2 commits into
AUTO-MAS-Project:devfrom
qiyinxi:fix/maa-tags-follow-fight-20260924
Open

qiyinxi wants to merge 2 commits into
AUTO-MAS-Project:devfrom
qiyinxi:fix/maa-tags-follow-fight-20260924

Conversation

@qiyinxi

@qiyinxi qiyinxi commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

Refs #558(只做了标签跟随开关;issue 里「显示具体活动关卡」未做)

  • 脚本管理页 MAA 用户标签:「主关卡 / 备选」只在理智作战(Task.IfFight)开启时显示;开启活动关优先(Task.IfActivityFirst)时加一个「活动关优先」标签。
  • 只改 MaaUserConfig.getTags();理智作战开启时原有标签的文字、颜色、顺序不变(git diff -w 只有新增的判断与标签)。具体活动关名要走异步的关卡信息解析,不适合放进同步的 getTags(),留作后续。

本地验证

  • 未提交的本地用例:理智作战 × 活动关优先四种组合,修复前 3 failed / 2 passed,修复后 5 passed;tests/models 42 passed。
  • python -m pytest tests --collect-only -q 退出码 0;ruff 通过。

🤖 Generated with Claude Code

Sourcery 摘要

使脚本管理页中的 MAA 用户标签根据理智作战和活动关优先开关准确显示。

Bug 修复:

  • 更新脚本管理页中的 MAA 用户标签:主关卡和备选关卡标签仅在启用理智作战时显示;启用活动关优先时,显示对应标签。

杂项:

  • 新增对应的 MAA 标签行为变更日志。
Original summary in English

Sourcery 摘要

使 MAA 脚本管理用户标签与理智作战和活动优先级设置保持一致。

Bug 修复:

  • 更新脚本管理页面中的 MAA 用户标签:仅当启用基于理智的作战时显示主关卡和备用关卡标签;启用活动优先级设置后显示活动优先级标签。

杂项:

  • 为 MAA 标签可见性行为变更添加变更日志条目。
Original summary in English

Summary by Sourcery

Align MAA script-management user tags with the sanity-combat and activity-priority settings.

Bug Fixes:

  • Update MAA user tags in the script management page so main and alternate stage tags appear only when sanity-based combat is enabled, while the activity-priority tag appears when its setting is enabled.

Chores:

  • Add a changelog entry for the MAA tag visibility behavior change.

现象:关闭「理智作战」后,脚本管理页的 MAA 用户卡片仍显示主关卡与备选关卡标签;
开启「活动关优先」也没有任何标签体现。

修法:MaaUserConfig.getTags() 只在 Task.IfFight 开启时追加主关卡 / 备选标签;
Task.IfActivityFirst 开启时追加「活动关优先」标签(排在关卡标签前,与执行顺序一致)。
不改配置格式与 schema。

Refs AUTO-MAS-Project#558

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sourcery-ai

sourcery-ai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

审查者指南

本 PR 调整 MaaUserConfig.getTags() 的标签生成逻辑:活动关优先标签独立随 IfActivityFirst 显示,主关卡和备选关卡标签仅在 IfFight 开启时生成,同时保持原有理智作战标签内容与样式不变;具体活动关卡名称解析仍未纳入本次改动。

MAA 用户标签生成流程图

flowchart TD
    A[getTags] --> B{IfActivityFirst enabled?}
    B -- Yes --> C[Add 活动关优先 cyan tag]
    B -- No --> D{IfFight enabled?}
    C --> D
    D -- Yes --> E[Resolve stage information]
    E --> F[Add 主关卡 tag]
    F --> G{Backup stages available?}
    G -- Yes --> H[Add 备选 tag]
    G -- No --> I[Add notes tag]
    D -- No --> I
    H --> I
Loading

文件级变更

变更 详情 文件
使脚本管理页标签按理智作战与活动关优先开关独立显示。
  • 新增“活动关优先”标签,并仅由对应开关控制显示。
  • 将主关卡与备选关卡标签整体置于理智作战开关判断内。
  • 保留理智作战开启时原有主关卡、备选关卡标签的文字、颜色和顺序。
app/models/config.py
补充本次用户标签行为调整的变更记录。
  • 记录标签随相关任务开关显示的修复。
changelog.d/fix-maa-tags-follow-fight-20260924.change.md

可能关联的议题


提示与命令

与 Sourcery 交互

  • 触发新的审查: 在 pull request 中评论 @sourcery-ai review。
  • 继续讨论: 直接回复 Sourcery 的审查评论。
  • 根据审查评论生成 GitHub issue: 回复审查评论,请 Sourcery 根据该评论创建 issue。你也可以使用 @sourcery-ai issue 回复审查评论,以根据该评论创建 issue。
  • 生成 pull request 标题: 在 pull request 标题的任意位置写入 @sourcery-ai,即可随时生成标题。你也可以在 pull request 中评论 @sourcery-ai title,以随时生成或重新生成标题。
  • 生成 pull request 摘要: 在 pull request 正文中需要生成摘要的位置写入 @sourcery-ai summary,即可随时在指定位置生成 PR 摘要。你也可以在 pull request 中评论 @sourcery-ai summary,以随时生成或重新生成摘要。
  • 生成审查者指南: 在 pull request 中评论 @sourcery-ai guide,即可随时生成或重新生成审查者指南。
  • 解决所有 Sourcery 评论: 在 pull request 中评论 @sourcery-ai resolve,即可解决所有 Sourcery 评论。如果你已经处理完所有评论且不想再看到它们,此功能会很有用。
  • 忽略所有 Sourcery 审查: 在 pull request 中评论 @sourcery-ai dismiss,即可忽略所有现有的 Sourcery 审查。如果你想从新的审查开始,这一功能尤其有用——别忘了评论
    @sourcery-ai review 来触发新的审查!

自定义使用体验

访问你的控制面板,即可:

  • 启用或停用审查功能,例如 Sourcery 生成的 pull request
    摘要、审查者指南等。
  • 更改审查语言。
  • 添加、删除或编辑自定义审查说明。
  • 调整其他审查设置。

获取帮助

Original review guide in English

Reviewer's Guide

本 PR 调整 MaaUserConfig.getTags() 的标签生成逻辑:活动关优先标签独立随 IfActivityFirst 显示,主关卡和备选关卡标签仅在 IfFight 开启时生成,同时保持原有理智作战标签内容与样式不变;具体活动关卡名称解析仍未纳入本次改动。

Flow diagram for MAA user tag generation

flowchart TD
    A[getTags] --> B{IfActivityFirst enabled?}
    B -- Yes --> C[Add 活动关优先 cyan tag]
    B -- No --> D{IfFight enabled?}
    C --> D
    D -- Yes --> E[Resolve stage information]
    E --> F[Add 主关卡 tag]
    F --> G{Backup stages available?}
    G -- Yes --> H[Add 备选 tag]
    G -- No --> I[Add notes tag]
    D -- No --> I
    H --> I
Loading

File-Level Changes

Change Details Files
使脚本管理页标签按理智作战与活动关优先开关独立显示。
  • 新增“活动关优先”标签,并仅由对应开关控制显示。
  • 将主关卡与备选关卡标签整体置于理智作战开关判断内。
  • 保留理智作战开启时原有主关卡、备选关卡标签的文字、颜色和顺序。
app/models/config.py
补充本次用户标签行为调整的变更记录。
  • 记录标签随相关任务开关显示的修复。
changelog.d/fix-maa-tags-follow-fight-20260924.change.md

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你好——我发现了 1 个问题

面向 AI 代理的提示
请处理本次代码审查中的评论:

## 单独评论

### 评论 1
<location path="app/models/config.py" line_range="1163" />
<code_context>
-            if isinstance(plan, MaaPlanConfig):
+        # 活动关优先标签:独立任务,只看自身开关,不受理智作战开关影响
+        if self.get("Task", "IfActivityFirst"):
+            tags.append({"text": "活动关优先", "color": "cyan"})
+
+        # 关卡信息标签:只在理智作战开启时显示
</code_context>
<issue_to_address>
**问题(bug_risk):** 新增的“活动关优先”标签使用了颜色 `cyan`,但 `TagItem.color` 模式仅允许使用 red、blue、green、yellow、orange、purple、pink、brown、black、white、gray、silver 和 gold。根据文档中的 `TagItem` 契约验证 JSON 的消费者会拒绝此标签。

**触发条件:** 启用 `Task.IfActivityFirst`,且对生成的标签列表进行模式验证时。

**建议修复:** 将 `cyan` 添加到 `TagItem.color` 允许的字面量中,或使用现有允许的颜色之一。

```suggestion
            tags.append({"text": "活动关优先", "color": "blue"})
```
</issue_to_address>

Sourcery 评估

等待批准。 请先处理 1 个发现的问题。

阻塞性发现:app/models/config.py:1163


Sourcery 对开源项目免费——如果您喜欢我们的审查结果,请考虑分享给他人 ✨
Original comment in English

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="app/models/config.py" line_range="1163" />
<code_context>
-            if isinstance(plan, MaaPlanConfig):
+        # 活动关优先标签:独立任务,只看自身开关,不受理智作战开关影响
+        if self.get("Task", "IfActivityFirst"):
+            tags.append({"text": "活动关优先", "color": "cyan"})
+
+        # 关卡信息标签:只在理智作战开启时显示
</code_context>
<issue_to_address>
**issue (bug_risk):** The new "活动关优先" tag uses color `cyan`, but the `TagItem.color` schema only permits red, blue, green, yellow, orange, purple, pink, brown, black, white, gray, silver, and gold. Consumers validating the JSON against the documented `TagItem` contract reject this tag.

**Triggers:** When `Task.IfActivityFirst` is enabled and the generated tag list is schema-validated.

**Suggested fix:** Add `cyan` to `TagItem.color`'s allowed literals, or use one of the existing permitted colors.

```suggestion
            tags.append({"text": "活动关优先", "color": "blue"})
```
</issue_to_address>

Sourcery assessment

Approval pending. 1 finding to address first.

Blocking findings: app/models/config.py:1163


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread app/models/config.py Outdated
cyan 不在 TagItem.color 的取值范围内,改用前后端都支持、MAA 标签尚未使用的 gold。

Refs AUTO-MAS-Project#558

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sourcery assessment

Approved.

@1w1w11w1

1w1w11w1 commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

批量审查意见(AI 辅助)· PR #982

结论基于 refs/pr/982 与其 merge-base 的三点 diff(+35/−28,2 文件)。裁决:可合并(当前 mergeable=CONFLICTING,需先同步 dev)。

实现核对

  • 改动集中在 app/models/config.py MaaUserConfig.getTags():把「主关卡 / 备选」整段包进 if self.get("Task", "IfFight"),并在其之前独立追加「活动关优先」标签(Task.IfActivityFirst,gold 色,不受理智作战开关影响)✅ 与正文描述一致;策略作战关闭时不再显示会误导人的关卡标签,方向正确。
  • 正文的克制值得肯定:明确写「Refs [改进]maa模块增加了活动关优先后,脚本管理页是不是应该配合显示 #558,只做了标签跟随开关;『显示具体活动关卡』未做」,理由(具体活动关名要走异步解析,不适合放进同步的 getTags())也站得住 ✅ 没有硬塞异步逻辑进同步函数。
  • 碎片 changelog.d/fix-maa-tags-follow-fight-20260924.change.md:project: maa + 单行「脚本管理页的用户标签改为随理智作战与活动关优先开关显示」✅;分类用 change 而不是 fix 也准确(是显示口径变更)。
  • 一次性测试未提交(tests/ 无新增)✅。

一个既有隐患(非本 PR 引入,但这次重排让位置更显眼,建议顺手兜一下)

app/models/config.py:1189-1200 附近:进入 IfFight 分支后,只有当 StageMode == "Fixed",或 related_config["PlanConfig"][uuid] 取到的对象 isinstance(plan, MaaPlanConfig) 时,plan_data / tag_color 才会被赋值;紧接着第 1204 行无条件读 plan_data['Stage']。也就是说「StageMode 指向的 PlanConfig 不是 MaaPlanConfig」这一种数据状态下会 UnboundLocalError(KeyError 亦同)。原代码结构相同,所以不是本次引入;但如果这种数据状态可达,脚本管理页会直接报错。能否加到防御由维护者判断,我没有构造出可达路径(属不确定项)。

UI/UX

  • 展示层变化:标签更贴合开关的真实语义(关掉理智作战就不再显示关卡标签),属减少误导;没有改变操作路径,也没有新增点击。
  • 新增标签使用 gold 色,与既有标签调色板(blue/green/red/purple)并列时是否需要调整对比度,建议在暗色主题下看一眼(我无渲染环境,仅提示)。

不确定项

  • 「StageMode 指向非 MaaPlanConfig」是否可达(决定上面那条隐患是否为真问题)。
  • 四种开关组合的本地用例(修复前 3 failed / 2 passed,修复后 5 passed)为作者自述,未复现。

(本条为 AI 辅助的批量审查输出,已逐项核对到文件行与命令输出;如与维护者判断不一致,以维护者为准。)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants