Skip to content

feat(pi): 支持 MaaFramework v5.13.0 - #13

Merged
Craun718 merged 13 commits into
MaaXYZ:mainfrom
Craun718:feat/maafw-v5.13.0
Sep 21, 2026
Merged

Craun718 merged 13 commits into
MaaXYZ:mainfrom
Craun718:feat/maafw-v5.13.0

Conversation

@Craun718

@Craun718 Craun718 commented Sep 21, 2026 •

Copy link
Copy Markdown
Member

Sourcery 摘要

将 MaaPiCli 升级至 MaaFramework v5.13.0,支持 Linux 控制器、扩展 PI 选项处理,并增强配置迁移与验证的可靠性。

新功能:

  • 添加 MaaFramework v5.13.0 Linux 控制器支持,包括 Wlr、PipeWire、UInput 和 Libei 捕获与输入模式。
  • 支持 display_expand 截图尺寸设置和 Win32 AnchoredTouch 输入配置。
  • 在 CLI 中支持复选框的 min_count 和 max_count 约束,并处理空选择情况。
  • 随着配置和接口的演进,自动补全并协调运行时、任务和预任务选项树。

Bug 修复:

  • 通过将旧版 WlRoots 接口和配置数据迁移至 Linux 控制器模型,保持兼容性。
  • 在配置验证期间过滤未激活的任务和选项,并清理已保存选择中的无效、过时、重复或超出范围的项。
  • 防止接受无效的选项图、显示设置、Linux 设置和复选框定义。

增强:

  • 更新运行时生成和控制器创建逻辑,以适配 MaaFramework Linux 控制器 API,包括 PipeWire 资源发现和显示尺寸设置。
  • 改进适用性、嵌套选项树、任务预设和自动默认值的配置验证与恢复。
  • 将 MaaDeps 构建依赖更新至 v2.12.6。

文档:

  • 记录 MaaFramework v5.13.0 和 PI v2.10.1 支持,包括复选框约束和 Linux 控制器设置。

测试:

  • 扩展解析器、CLI 输入和交互器测试覆盖范围,涵盖 Linux 设置、旧版迁移、复选框约束、选项恢复、任务适用性和空选择。
Original summary in English

Sourcery 摘要

将 MaaPiCli 升级到 MaaFramework v5.13.0,并增强 Linux 控制器支持、配置兼容性、验证以及运行时选项恢复功能。

新功能:

  • 添加 MaaFramework v5.13.0 Linux 控制器支持,包括 Wlr、PipeWire、UInput 和 Libei 捕获与输入模式。
  • 支持可扩展的截图尺寸、Win32 AnchoredTouch 输入,以及包括显式空选择在内的复选框选择数量约束。

错误修复:

  • 将旧版 WlRoots 接口和配置数据迁移到 Linux 控制器模型,同时保持兼容性。
  • 改进配置验证和清理,处理未激活、过时、重复、无效或超出范围的任务和选项。

增强功能:

  • 完善并协调运行时、任务和预任务选项树,加入适用性筛选和默认值恢复。
  • 更新运行时生成和控制器创建逻辑,以适配 MaaFramework Linux 控制器 API,包括 PipeWire 资源发现和显示尺寸获取。
  • 改进 macOS 测试钥匙串设置和钥匙串存储可靠性。

构建:

  • 将 MaaDeps 构建依赖更新至 v2.12.6。

CI:

  • 修正格式化工作流的检出行为,并配置隔离的 macOS 测试钥匙串。

文档:

  • 记录对 MaaFramework v5.13.0 和 PI v2.10.1 的支持,包括复选框约束和 Linux 控制器配置。

测试:

  • 扩展解析器、CLI 输入和交互器测试覆盖范围,涵盖 Linux 控制器、旧版迁移、复选框约束、选项恢复、任务适用性和空选择。
Original summary in English

Sourcery 摘要

将 MaaPiCli 升级至 MaaFramework v5.13.0,并增强 Linux 控制器支持、配置兼容性、验证机制和运行时选项恢复功能。

新功能:

  • 新增 MaaFramework v5.13.0 Linux 控制器支持,包括 Wlr、PipeWire、UInput 和 Libei 捕获与输入模式。
  • 支持可扩展的截图尺寸、Win32 AnchoredTouch 输入,以及复选框选择数量限制(包括明确的空选择)。

错误修复:

  • 将旧版 WlRoots 接口和配置数据迁移至 Linux 控制器模型,同时保持兼容性。
  • 改进配置验证和清理,处理不活跃、过时、重复、无效以及超出范围的任务和选项选择。

增强功能:

  • 通过适用性筛选、自动完成和默认值恢复,协调运行时、任务和预任务选项树。
  • 根据 MaaFramework Linux 控制器 API 调整运行时生成和控制器创建逻辑,包括 PipeWire 资源发现和显示尺寸获取。
  • 提高 macOS 钥匙串存储在测试环境和运行时密钥场景中的可靠性。

构建:

  • 将 MaaDeps 构建依赖更新至 v2.12.6。

CI:

  • 修正格式化工作流中的检出行为,并配置隔离的 macOS 测试钥匙串。

文档:

  • 记录对 MaaFramework v5.13.0 和 PI v2.10.1 的支持,包括复选框限制和 Linux 控制器配置。

测试:

  • 扩展解析器、CLI 输入和交互器测试覆盖范围,涵盖 Linux 控制器、旧版迁移、复选框限制、选项恢复、任务适用性和空选择。
Original summary in English

Summary by Sourcery

Upgrade MaaPiCli to MaaFramework v5.13.0 and strengthen Linux controller support, configuration compatibility, validation, and runtime option recovery.

New Features:

  • Add MaaFramework v5.13.0 Linux controller support with Wlr, PipeWire, UInput, and Libei capture and input modes.
  • Support expandable screenshot dimensions, Win32 AnchoredTouch input, and checkbox selection count constraints including explicit empty selections.

Bug Fixes:

  • Migrate legacy WlRoots interface and configuration data to the Linux controller model while preserving compatibility.
  • Improve configuration validation and cleanup for inactive, stale, duplicate, invalid, and out-of-range tasks and option selections.

Enhancements:

  • Coordinate runtime, task, and pre-task option trees with applicability filtering, automatic completion, and default restoration.
  • Adapt runtime generation and controller creation to the MaaFramework Linux controller API, including PipeWire resource discovery and display sizing.
  • Improve macOS keychain storage reliability for tests and runtime secrets.

Build:

  • Update the MaaDeps build dependency to v2.12.6.

CI:

  • Correct formatting workflow checkout behavior and configure an isolated macOS test keychain.

Documentation:

  • Document MaaFramework v5.13.0 and PI v2.10.1 support, including checkbox constraints and Linux controller configuration.

Tests:

  • Expand parser, CLI input, and interactor coverage for Linux controllers, legacy migration, checkbox constraints, option recovery, task applicability, and empty selections.

按任务适用的控制器和资源校验并补全选项,避免清理或生成非活动任务的子树;同时补充空 checkbox 选择提示。
自动补全 Input 默认值,恢复失效运行时选项并过滤不适用任务;同时防御异常配置和 Linux 控制器创建失败。

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

嘿——我发现了 3 个问题

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

## 个别评论

### 评论 1
<location path="Impl/Runner.cpp" line_range="443-458" />
<code_context>
+            obj["pw_node_id"] = pw_node_id;
+        }
+        else {
+            auto helper_handle = MaaToolkitPortalHelperCreate();
+            if (!helper_handle) {
+                LogError << "Failed to create portal helper";
+                return "";
+            }
+
+            if (!MaaToolkitPortalHelperOpenStream(helper_handle)) {
</code_context>
<issue_to_address>
**issue (bug_risk):** 在 PipeWire 文件描述符和节点 ID 被复制到 JSON 后、`MaaLinuxControllerCreate` 使用该配置之前,Portal helper 就会被立即销毁。销毁 helper 会关闭或使由流支持的文件描述符失效,因此基于 Portal 的 Linux 控制器创建过程会收到过期的文件描述符,并失败或无法捕获屏幕。

**触发条件:** Linux 控制器使用 `screencap: "PipeWire"` 且 `pipewire_source: "Portal"` 时。

**建议修复:** 让 Portal helper 一直存活到 Linux 控制器使用完该流之后,或者在销毁 helper 之前转移/复制文件描述符。
</issue_to_address>

### 评论 2
<location path="CLI/interactor.cpp" line_range="2437-2451" />
<code_context>
+        auto existing_option_iter =
</code_context>
<issue_to_address>
**issue (bug_risk):** 现有的 Input 选项被复制到重建的选项树中,但没有填充缺失的已声明输入。当接口新增 Input 字段,或保存的选项中没有某个现有字段的值时,自动补全路径会使该输入缺失,而不是存储其声明的默认值。

**触发条件:** 保存的配置已经包含 Input 选项,但缺少当前接口声明的一个或多个输入时。

**建议修复:** 在保留现有值的同时,使用已声明的默认值补全缺失的 Input 条目,包括 `process_option` 使用的密码存储路径。
</issue_to_address>

### 评论 3
<location path="Impl/Parser.cpp" line_range="212-214" />
<code_context>
+        return false;
+    }
+
+    if (auto* defaults = std::get_if<std::vector<std::string>>(&option.default_case)) {
+        return checkbox_selection_is_valid(option, *defaults);
+    }
+
</code_context>
<issue_to_address>
**issue (bug_risk):** 当有效名称的数量满足边界条件时,包含未知 case 名称的复选框默认值会被接受,因为 `checkbox_selection_is_valid` 只统计已知 case,却从不拒绝未知值。因此接口可以成功解析,自动补全会静默丢弃无效默认值,而不是拒绝格式错误的定义。

**触发条件:** 复选框的 `default_case` 数组包含未知 case 名称,且有效名称数量仍满足 `min_count`/`max_count` 时(例如没有最小数量限制)。

**建议修复:** 在应用数量约束之前,针对 `option.cases` 验证每个默认值;如果任何默认名称未知,则拒绝该定义。

```suggestion
    if (auto* defaults = std::get_if<std::vector<std::string>>(&option.default_case)) {
        for (const auto& value : *defaults) {
            if (std::ranges::find(option.cases, value, std::mem_fn(&InterfaceData::Option::Case::name)) == option.cases.end()) {
                return false;
            }
        }
        return checkbox_selection_is_valid(option, *defaults);
    }
```
</issue_to_address>

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

Hey - I've found 3 issues

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

## Individual Comments

### Comment 1
<location path="Impl/Runner.cpp" line_range="443-458" />
<code_context>
+            obj["pw_node_id"] = pw_node_id;
+        }
+        else {
+            auto helper_handle = MaaToolkitPortalHelperCreate();
+            if (!helper_handle) {
+                LogError << "Failed to create portal helper";
+                return "";
+            }
+
+            if (!MaaToolkitPortalHelperOpenStream(helper_handle)) {
</code_context>
<issue_to_address>
**issue (bug_risk):** The Portal helper is destroyed immediately after its PipeWire file descriptor and node ID are copied into the JSON, before `MaaLinuxControllerCreate` consumes that configuration. Destroying the helper closes or invalidates the stream-backed file descriptor, so Portal-based Linux controller creation receives a stale descriptor and fails or cannot capture the screen.

**Triggers:** When the Linux controller uses `screencap: "PipeWire"` with `pipewire_source: "Portal"`.

**Suggested fix:** Keep the Portal helper alive until after the Linux controller has consumed the stream, or transfer/duplicate the file descriptor before destroying the helper.
</issue_to_address>

### Comment 2
<location path="CLI/interactor.cpp" line_range="2437-2451" />
<code_context>
+        auto existing_option_iter =
</code_context>
<issue_to_address>
**issue (bug_risk):** An existing Input option is copied into the rebuilt option tree without filling missing declared inputs. When the interface adds a new Input field, or the saved option contains no value for an existing field, the automatic completion path leaves that input absent instead of storing its declared default.

**Triggers:** When a saved configuration already contains the Input option but is missing one or more inputs declared by the current interface.

**Suggested fix:** Complete missing Input entries with their declared defaults while preserving existing values, including the password-storage path used by `process_option`.
</issue_to_address>

### Comment 3
<location path="Impl/Parser.cpp" line_range="212-214" />
<code_context>
+        return false;
+    }
+
+    if (auto* defaults = std::get_if<std::vector<std::string>>(&option.default_case)) {
+        return checkbox_selection_is_valid(option, *defaults);
+    }
+
</code_context>
<issue_to_address>
**issue (bug_risk):** Checkbox defaults containing unknown case names are accepted whenever the count of valid names satisfies the bounds, because `checkbox_selection_is_valid` counts only known cases but never rejects unknown values. The interface therefore parses successfully and automatic completion silently drops the invalid default instead of rejecting the malformed definition.

**Triggers:** When a checkbox `default_case` array contains an unknown case name and its valid-name count still satisfies `min_count`/`max_count` (for example, no minimum count).

**Suggested fix:** Validate every default value against `option.cases` before applying the count constraint, and reject the definition if any default name is unknown.

```suggestion
    if (auto* defaults = std::get_if<std::vector<std::string>>(&option.default_case)) {
        for (const auto& value : *defaults) {
            if (std::ranges::find(option.cases, value, std::mem_fn(&InterfaceData::Option::Case::name)) == option.cases.end()) {
                return false;
            }
        }
        return checkbox_selection_is_valid(option, *defaults);
    }
```
</issue_to_address>

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

Comment thread Impl/Runner.cpp
Comment on lines +443 to +458
auto helper_handle = MaaToolkitPortalHelperCreate();
if (!helper_handle) {
LogError << "Failed to create portal helper";
return "";
}

if (!MaaToolkitPortalHelperOpenStream(helper_handle)) {
LogError << "Failed to open PipeWire stream";
MaaToolkitPortalHelperDestroy(helper_handle);
return "";
}

obj["pw_socket_fd"] = MaaToolkitPortalHelperGetPipeWireFD(helper_handle);
obj["pw_node_id"] = MaaToolkitPortalHelperGetPipeWireNodeID(helper_handle);
MaaToolkitPortalHelperDestroy(helper_handle);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

issue (bug_risk): 在 PipeWire 文件描述符和节点 ID 被复制到 JSON 后、MaaLinuxControllerCreate 使用该配置之前,Portal helper 就会被立即销毁。销毁 helper 会关闭或使由流支持的文件描述符失效,因此基于 Portal 的 Linux 控制器创建过程会收到过期的文件描述符,并失败或无法捕获屏幕。

触发条件: Linux 控制器使用 screencap: "PipeWire" 且 pipewire_source: "Portal" 时。

建议修复: 让 Portal helper 一直存活到 Linux 控制器使用完该流之后,或者在销毁 helper 之前转移/复制文件描述符。

Original comment in English

issue (bug_risk): The Portal helper is destroyed immediately after its PipeWire file descriptor and node ID are copied into the JSON, before MaaLinuxControllerCreate consumes that configuration. Destroying the helper closes or invalidates the stream-backed file descriptor, so Portal-based Linux controller creation receives a stale descriptor and fails or cannot capture the screen.

Triggers: When the Linux controller uses screencap: "PipeWire" with pipewire_source: "Portal".

Suggested fix: Keep the Portal helper alive until after the Linux controller has consumed the stream, or transfer/duplicate the file descriptor before destroying the helper.

Comment thread CLI/interactor.cpp
Comment thread Impl/Parser.cpp
@Craun718

Copy link
Copy Markdown
Member Author

@sourcery-ai review

@sourcery-ai

sourcery-ai Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Sorry @Craun718, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 6 days and 22 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@Craun718
Craun718 merged commit b36beaa into MaaXYZ:main Sep 21, 2026
13 checks passed
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