Skip to content

Conversation

@MistEO
Copy link
Member

@MistEO MistEO commented Nov 28, 2025

没测!(理直气壮

Summary by Sourcery

将 MaaDebugger 的运行时控制逻辑适配到更新后的 MaaFW 5.1 节点元数据类型,在识别列表中使用 NodeAttr 对象替代纯字符串。

增强内容:

  • 更新运行时控制中的列表处理逻辑,以支持基于 NodeAttr 的识别条目,同时在 UI 中仍然显示它们的名称。
  • 通过 maafw 包对外暴露 ContextEventSink.NodeAttr,以便在整个调试器代码库中使用。
Original summary in English

Summary by Sourcery

Adapt MaaDebugger runtime control to updated MaaFW 5.1 node metadata type, using NodeAttr objects instead of plain strings for recognition lists.

Enhancements:

  • Update list handling in runtime control to work with NodeAttr-based recognition entries while still displaying their names in the UI.
  • Expose ContextEventSink.NodeAttr via the maafw package for use across the debugger codebase.

@MistEO MistEO requested review from Copilot and weinibuliu November 28, 2025 06:59
@sourcery-ai
Copy link

sourcery-ai bot commented Nov 28, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

将 MaaDebugger 运行时控制逻辑和 MaaFW 集成更新为使用 MaaFW 5.1 中新的 NodeAttr 类型来处理识别列表数据,而不是使用普通字符串,并相应更新类型标注以及所有消费列表元素的调用点。

MaaDebugger 运行时控制适配 MaaFW 5_1 中 NodeAttr 的类图

classDiagram
    class RuntimeControl {
        +int row_len
        +dict~int, ListData~ list_data_map
        +void create_list(row, data)
        +void on_next_list_starting(current, list_to_reco)
        +void add_list_data(data)
        +void create_items(index, name, row_len)
        +void add_item_data(index, name, row_len)
    }

    class ListData {
        +int row_len
        +str current
        +list~NodeAttr~ list_to_reco
    }

    class ItemData {
        +int index
        +str name
        +int row_len
    }

    class NodeAttr {
        +str name
        +... other_attributes
    }

    class MaaFW {
        +Screenshotter screenshotter
        +void on_next_list_starting(current, list_to_reco)
    }

    class ContextEventSink {
    }

    RuntimeControl "1" o-- "*" ListData : manages
    ListData "1" *-- "*" NodeAttr : list_to_reco
    RuntimeControl "*" o-- "*" ItemData : creates

    MaaFW ..> ContextEventSink : uses
    ContextEventSink *-- NodeAttr : defines
    MaaFW ..> NodeAttr : aliases
    RuntimeControl ..> NodeAttr : consumes in lists

    RuntimeControl ..> MaaFW : maafw_integration

    MaaFW ..> ListData : passes_list_to_runtime_control
Loading

File-Level Changes

Change Details Files
在整个运行时控制逻辑中将 list_to_reco 从 list[str] 切换为 list[NodeAttr],并调整用法为通过 .name 访问名称。
  • 将 ListData.list_to_reco 的类型标注从 list[str] 改为 list[NodeAttr]。
  • 更新 create_list,使其向 create_items 传入每个元素的 .name,而不是直接传 NodeAttr 对象本身。
  • 更新 on_next_list_starting 函数签名,使其接收 list[NodeAttr],并将其传递给 ListData。
  • 更新 add_list_data,在调用 add_item_data 时从每个 NodeAttr 中提取 .name。
src/MaaDebugger/webpage/index_page/runtime_control.py
在包级别从 MaaFW 的 ContextEventSink 中导出 NodeAttr,供运行时控制使用。
  • 在 maafw 包的 init.py 中导入或将 ContextEventSink.NodeAttr 别名为顶层的 NodeAttr 符号,以便其他模块可以直接引用 NodeAttr。
src/MaaDebugger/maafw/__init__.py

Tips and commands

Interacting with 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 来触发新的审查!

Customizing Your Experience

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

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

Getting Help

Original review guide in English
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adapts the MaaDebugger runtime control and MaaFW integration to use the new NodeAttr type from MaaFW 5.1 instead of plain strings when handling recognition list data, updating type hints and all relevant call sites that consume list elements.

Class diagram for MaaDebugger runtime control adaptation to NodeAttr in MaaFW 5_1

classDiagram
    class RuntimeControl {
        +int row_len
        +dict~int, ListData~ list_data_map
        +void create_list(row, data)
        +void on_next_list_starting(current, list_to_reco)
        +void add_list_data(data)
        +void create_items(index, name, row_len)
        +void add_item_data(index, name, row_len)
    }

    class ListData {
        +int row_len
        +str current
        +list~NodeAttr~ list_to_reco
    }

    class ItemData {
        +int index
        +str name
        +int row_len
    }

    class NodeAttr {
        +str name
        +... other_attributes
    }

    class MaaFW {
        +Screenshotter screenshotter
        +void on_next_list_starting(current, list_to_reco)
    }

    class ContextEventSink {
    }

    RuntimeControl "1" o-- "*" ListData : manages
    ListData "1" *-- "*" NodeAttr : list_to_reco
    RuntimeControl "*" o-- "*" ItemData : creates

    MaaFW ..> ContextEventSink : uses
    ContextEventSink *-- NodeAttr : defines
    MaaFW ..> NodeAttr : aliases
    RuntimeControl ..> NodeAttr : consumes in lists

    RuntimeControl ..> MaaFW : maafw_integration

    MaaFW ..> ListData : passes_list_to_runtime_control
Loading

File-Level Changes

Change Details Files
Switch list_to_reco from list[str] to list[NodeAttr] throughout runtime control logic and adjust usages to access .name.
  • Change ListData.list_to_reco type hint from list[str] to list[NodeAttr].
  • Update create_list to pass each element’s .name into create_items instead of the NodeAttr object itself.
  • Update on_next_list_starting signature to accept list[NodeAttr] and propagate it into ListData.
  • Update add_list_data to extract .name from each NodeAttr when calling add_item_data.
src/MaaDebugger/webpage/index_page/runtime_control.py
Expose NodeAttr from MaaFW’s ContextEventSink at the package level for use by runtime control.
  • Import or alias ContextEventSink.NodeAttr to a top-level NodeAttr symbol in the maafw package init.py so other modules can refer to NodeAttr directly.
src/MaaDebugger/maafw/__init__.py

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

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.

你好——我已经查看了你的改动,这里是一些反馈:

  • 既然 list_to_reco 现在保存的是 NodeAttr 对象,建议直接遍历其中的元素而不是通过索引遍历(例如 for node in data.list_to_reco: name = node.name),这样可以简化 create_listadd_list_data 中的循环,并避免反复索引。
  • 确保在 runtime_control.py 中显式导入或引用 NodeAttr(例如通过 from ..maafw import NodeAttr),这样新的类型标注和属性访问在单独编译时也能正常工作。
给 AI Agent 的提示
Please address the comments from this code review:

## Overall Comments
- Now that `list_to_reco` holds `NodeAttr` objects, consider iterating directly over the items instead of by index (e.g. `for node in data.list_to_reco: name = node.name`), which simplifies the loops in `create_list` and `add_list_data` and avoids repeated indexing.
- Ensure `NodeAttr` is explicitly imported or referenced in `runtime_control.py` (e.g. via `from ..maafw import NodeAttr`) so the new type hints and attribute access compile correctly in isolation.

Sourcery 对开源项目免费——如果你觉得我们的评审有帮助,欢迎分享 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续的评审。
Original comment in English

Hey there - I've reviewed your changes - here's some feedback:

  • Now that list_to_reco holds NodeAttr objects, consider iterating directly over the items instead of by index (e.g. for node in data.list_to_reco: name = node.name), which simplifies the loops in create_list and add_list_data and avoids repeated indexing.
  • Ensure NodeAttr is explicitly imported or referenced in runtime_control.py (e.g. via from ..maafw import NodeAttr) so the new type hints and attribute access compile correctly in isolation.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Now that `list_to_reco` holds `NodeAttr` objects, consider iterating directly over the items instead of by index (e.g. `for node in data.list_to_reco: name = node.name`), which simplifies the loops in `create_list` and `add_list_data` and avoids repeated indexing.
- Ensure `NodeAttr` is explicitly imported or referenced in `runtime_control.py` (e.g. via `from ..maafw import NodeAttr`) so the new type hints and attribute access compile correctly in isolation.

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@MistEO MistEO merged commit 67d1e33 into main Nov 28, 2025
3 checks passed
@MistEO MistEO deleted the feat/maafw_5.1 branch November 28, 2025 12:13
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