Conversation
There was a problem hiding this comment.
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`.帮我变得更有用!请对每条评论点 👍 或 👎,我会根据这些反馈改进之后给你的代码审查。
Original comment in English
Hey - I've left some high level feedback:
- In
_on_next_list_starting, theanchor_flags: List[bool] = []default is a mutable list and will be shared across calls; consider usingOptional[List[bool]] = Noneand 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 checkingisinstance(node_data, dict), which can raise ifget_node_datareturns 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`.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
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/ListDatato carry anchor metadata (flags, anchor name, target, setter). - Emit
anchor_flagsinNextList.*messages fromLaunchGraphContextEventSink. - 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.
| self, current: str, next_list: List[str], anchor_flags: List[bool] = [] | ||
| ): | ||
| """处理 NextList 开始事件""" |
There was a problem hiding this comment.
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 []).
| 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 [] |
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:
Enhancements: