Skip to content

Comments

feat: 适配新 anchor#161

Merged
weinibuliu merged 4 commits intomainfrom
feat/anchor
Feb 21, 2026
Merged

feat: 适配新 anchor#161
weinibuliu merged 4 commits intomainfrom
feat/anchor

Conversation

@weinibuliu
Copy link
Member

@weinibuliu weinibuliu commented Feb 21, 2026

Summary by Sourcery

调整调试器运行时界面和事件处理机制,以支持在识别流水线中基于锚点的下一节点导航元数据。

新功能:

  • 在运行时下一节点列表中,为源自锚点的条目显示锚点元数据和图标。
  • 将锚点标志从框架事件接收端传递到运行时控件,以区分锚点条目和普通节点。

增强改进:

  • 在列表项和列表上跟踪锚点相关属性,使识别结果既可以通过锚点目标匹配,也可以通过名称匹配。
  • 在启动新的下一节点列表时,从流水线节点数据中推导锚点名称和目标节点,并将这些信息附加到对应的列表项上。
Original summary in English

Summary by Sourcery

Adapt the debugger runtime UI and event handling to support anchor-based next-node navigation metadata in recognition pipelines.

New Features:

  • Display anchor metadata and icon for anchor-derived items in the runtime next-node list.
  • Propagate anchor flags from the framework event sink into the runtime control to distinguish anchor entries from normal nodes.

Enhancements:

  • Track anchor-related attributes on list items and lists so recognition results can match by anchor target as well as by name.
  • Derive anchor names and target nodes from pipeline node data when starting a new next-node list, and attach this information to corresponding list items.

Copilot AI review requested due to automatic review settings February 21, 2026 15:42
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - 我已经给出了一些高层次的反馈:

  • _on_next_list_starting 中,anchor_flags: List[bool] = [] 的默认值是一个可变列表,会在多次调用之间被共享;建议改为使用 Optional[List[bool]] = None,并在函数内部进行归一化处理。
  • _on_next_list_starting 中,node_data = maafw.get_node_data(current) 在检查 isinstance(node_data, dict) 之前,就已经把它当作总是字典来使用(node_data.get("next", [])),如果 get_node_data 返回的不是字典,就可能抛异常;在调用 .get 之前应先做类型检查(或提供一个安全的默认值)。
给 AI Agent 的提示词
Please address the comments from this code review:

## Overall Comments
- In `_on_next_list_starting`, the `anchor_flags: List[bool] = []` default is a mutable list and will be shared across calls; consider using `Optional[List[bool]] = None` and normalizing inside the function instead.
- In `_on_next_list_starting`, `node_data = maafw.get_node_data(current)` is used as if it were always a dict (`node_data.get("next", [])`) before checking `isinstance(node_data, dict)`, which can raise if `get_node_data` returns a non-dict; add a type check (or safe default) before calling `.get`.

Sourcery 对开源项目是免费的——如果你喜欢我们的代码审查,请考虑帮我们分享 ✨
帮我变得更有用!请对每条评论点 👍 或 👎,我会根据这些反馈改进之后给你的代码审查。
Original comment in English

Hey - I've left some high level feedback:

  • In _on_next_list_starting, the anchor_flags: List[bool] = [] default is a mutable list and will be shared across calls; consider using Optional[List[bool]] = None and normalizing inside the function instead.
  • In _on_next_list_starting, node_data = maafw.get_node_data(current) is used as if it were always a dict (node_data.get("next", [])) before checking isinstance(node_data, dict), which can raise if get_node_data returns a non-dict; add a type check (or safe default) before calling .get.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `_on_next_list_starting`, the `anchor_flags: List[bool] = []` default is a mutable list and will be shared across calls; consider using `Optional[List[bool]] = None` and normalizing inside the function instead.
- In `_on_next_list_starting`, `node_data = maafw.get_node_data(current)` is used as if it were always a dict (`node_data.get("next", [])`) before checking `isinstance(node_data, dict)`, which can raise if `get_node_data` returns a non-dict; add a type check (or safe default) before calling `.get`.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adapts the runtime-control UI and event handling to support MaaFW “anchor” semantics, allowing NextList entries to be marked as anchors and displayed/matched using their resolved target node.

Changes:

  • Extend ItemData / ListData to carry anchor metadata (flags, anchor name, target, setter).
  • Emit anchor_flags in NextList.* messages from LaunchGraphContextEventSink.
  • Render anchor entries differently in the UI and allow recognition matching against anchor_target.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/MaaDebugger/webpage/index_page/runtime_control.py Parses anchor info from node data, stores it in list/item models, updates UI labeling and recognition matching.
src/MaaDebugger/maafw/__init__.py Adds anchor_flags to NextList event payloads based on detail.next_list.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 513 to 515
self, current: str, next_list: List[str], anchor_flags: List[bool] = []
):
"""处理 NextList 开始事件"""
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

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

anchor_flags uses a mutable default ([]) in the function signature, which can leak state across calls and produce incorrect results if the list is ever mutated. Use None as the default and normalize inside the function (e.g., anchor_flags = anchor_flags or []).

Suggested change
self, current: str, next_list: List[str], anchor_flags: List[bool] = []
):
"""处理 NextList 开始事件"""
self, current: str, next_list: List[str], anchor_flags: List[bool] = None
):
"""处理 NextList 开始事件"""
# Normalize mutable default
anchor_flags = anchor_flags or []

Copilot uses AI. Check for mistakes.
@weinibuliu weinibuliu merged commit b7f6bd2 into main Feb 21, 2026
3 checks passed
@weinibuliu weinibuliu deleted the feat/anchor branch February 21, 2026 15:54
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.

1 participant