Skip to content

refactor: 移除 PI 协议外扩展 - #405

Merged
MistEO merged 4 commits into
mainfrom
codex/remove-pi-extensions
Nov 6, 2026
Merged

MistEO merged 4 commits into
mainfrom
codex/remove-pi-extensions

Conversation

@MistEO

@MistEO MistEO commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

MXU 仍会解释 PI 未定义的输入元数据、标签 Markdown 和 focus 截图占位符,导致同一份资源在不同客户端产生不同效果。本 PR 移除这些私有行为,按 PI V2 标准字段处理资源。

  • option/case/input 标签、搜索、提示和任务预览使用普通国际化文本;保留协议定义的 option/case 图标及 description/focus Markdown。
  • 移除 inputs[].placeholder、inputs[].icon、input_type: "time" 和 agent.timeout;hotkey 只消费协议定义的字段。内置任务的时间控件与占位提示使用独立客户端配置。
  • 保留标准文件/目录输入、手工路径编辑、校验及 Web 文本框降级;文件和目录密码输入均掩码显示。
  • 删除旧 WlRoots 控制器声明和连接分支,保留标准 Linux 控制器使用的 Wlr socket 发现、键码转换、PipeWire/Portal/UInput/LibEI 和显示配置。
  • focus 的 {image} 与其他回调详情占位符采用相同替换规则,不再自动截图;保留最新主分支的国际化、外部模板加载、密码脱敏和展示渠道处理。

已对照 MaaFramework main a0ae79a9 的 PI 文档和 schema 核对。PI v2.11.0 的 PI_USER_DATA_DIR 已由主分支后端注入;新增标准 IOS/ios 类型声明,并将尚未实现的 IOS 连接明确作为客户端不支持的类型过滤,日志记录实际被过滤的类型。完整真机 IOS 连接仍需 Rust 绑定支持。

已合并 MXU main 至 f68a35f,解决冲突并修复自动合并残留的重复属性、旧组件引用和 focus 调用参数。

验证:pnpm test(120 项:119 通过、1 项 macOS 专属测试跳过)、pnpm build、pnpm format:check、cargo check --locked、cargo fmt --check、git diff --check 均通过。新增回归覆盖 IOS/旧控制器过滤、密码路径输入、私有输入元数据不被使用及 focus 模板加载/替换/脱敏。未验证原生文件选择对话框及 Linux 实机连接。

Copilot AI balanced review requested due to automatic review settings October 29, 2026 09:18
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-29T09:32:53.566540Z b8c5543 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@MistEO
MistEO force-pushed the codex/remove-pi-extensions branch from f84b48c to be1499b Compare October 29, 2026 09:19

@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 智能体的提示
请处理此代码审查中的评论:

## 单条评论

### 评论 1
<location path="src-tauri/src/commands/maa_agent.rs" line_range="525-526" />
<code_context>
-        let timeout = agent.timeout.unwrap_or(-1);
-        if let Err(e) = client.set_timeout(timeout) {
+        // Agent 连接沿用无限等待,不从 PI 读取额外的超时字段。
+        if let Err(e) = client.set_timeout(-1) {
             warn!("Failed to set timeout for agent #{}: {}", agent_index, e);
         }

</code_context>
<issue_to_address>
**已配置的智能体超时未生效**

调用方通过 `maaService.startTasks` 接受的导出型 `AgentConfig` 传入有限的 `timeout` 时,`maaService.startTasks` 虽然接受了这个公开字段,但 Rust 的 `AgentConfig` 会丢弃它,而 `start_single_agent` 始终调用 `client.set_timeout(-1)`,因此请求的有限超时会被忽略,智能体将无限期等待。

请让 Rust 智能体超时与导出型 `AgentConfig.timeout` 保持关联,或者从面向服务的 API 中移除此字段。

另请参见 `src/types/interface.ts:121-122`。
</issue_to_address>

### 评论 2
<location path="src/types/interface.ts" line_range="248" />
<code_context>
-  placeholder?: string;
-  /** MXU 扩展:密码字段;启用后 UI 掩码显示,配置加密存储,日志/遥测脱敏 */
+  /** v2.10.5: 输入控件类型;文件和文件夹选择结果均为路径字符串 */
+  input_type?: 'text' | 'file' | 'directory';
+  /** v2.10.0: 密码字段;启用后 UI 掩码显示,配置加密存储,日志/遥测脱敏 */
   password?: boolean;
</code_context>
<issue_to_address>
**自定义输入控件消失**

当 PI 资源使用内置 MXU UI 映射之外、文档中定义的 `input_type: 'time'` 或 `placeholder` 扩展时,`InputItem` 类型会丢弃 `time` 和 `placeholder`,而 `InputField` 仅使用映射的 MXU UI 配置来处理时间选择器和占位符。普通资源输入会被渲染为文本并丢失提示,因此配置的 UI 不会显示。

请保留 PI 输入项中有文档说明的时间选择器和占位符行为,同时继续为内置任务使用单独的内部 UI 配置。

另请参见 `src/components/OptionEditor.tsx:293`、`src/components/OptionEditor.tsx:340`。
</issue_to_address>

### 评论 3
<location path="tests/protocolUi.test.ts" line_range="74" />
<code_context>
+    const inputHtml = renderOption('Input');
+    assert.match(inputHtml, /\*\*Option\*\*/);
+    assert.match(inputHtml, /&lt;b&gt;Input&lt;\/b&gt;/);
+    assert.doesNotMatch(inputHtml, /PRIVATE|private\.png|type="time"|<b>/);
+    assert.match(inputHtml, /type="password"/);
+    const casesHtml = renderOption('Cases');
</code_context>
<issue_to_address>
**输入图标会绕过断言**

如果通过现有的异步 `AsyncIcon` 组件重新启用输入项 `icon` 的渲染,即使输入图标再次显示,`assert.doesNotMatch(inputHtml, /PRIVATE|private\.png|type="time"|<b>/)` 仍会通过:`AsyncIcon` 会在 effect 中加载图标,而在此测试的服务端渲染期间返回 `null`,因此无论如何图标都不会出现在 `inputHtml` 中。

请在图标加载 effect 完成后测试渲染出的图标,或者以其他方式断言输入图标元数据未被使用。
</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="src-tauri/src/commands/maa_agent.rs" line_range="525-526" />
<code_context>
-        let timeout = agent.timeout.unwrap_or(-1);
-        if let Err(e) = client.set_timeout(timeout) {
+        // Agent 连接沿用无限等待,不从 PI 读取额外的超时字段。
+        if let Err(e) = client.set_timeout(-1) {
             warn!("Failed to set timeout for agent #{}: {}", agent_index, e);
         }

</code_context>
<issue_to_address>
**Configured agent timeouts are ignored**

When a caller passes a finite `timeout` through the exported `AgentConfig` accepted by `maaService.startTasks`, `maaService.startTasks` accepts that public field, but Rust `AgentConfig` drops it and `start_single_agent` always calls `client.set_timeout(-1)`, so the requested finite timeout is ignored and the agent waits indefinitely.

Keep the Rust agent timeout wired to the exported `AgentConfig.timeout`, or remove that field from the service-facing API.

Also at `src/types/interface.ts:121-122`.
</issue_to_address>

### Comment 2
<location path="src/types/interface.ts" line_range="248" />
<code_context>
-  placeholder?: string;
-  /** MXU 扩展:密码字段;启用后 UI 掩码显示,配置加密存储,日志/遥测脱敏 */
+  /** v2.10.5: 输入控件类型;文件和文件夹选择结果均为路径字符串 */
+  input_type?: 'text' | 'file' | 'directory';
+  /** v2.10.0: 密码字段;启用后 UI 掩码显示,配置加密存储,日志/遥测脱敏 */
   password?: boolean;
</code_context>
<issue_to_address>
**Custom input controls disappear**

When a PI resource relies on the documented `input_type: 'time'` or `placeholder` extension outside the built-in MXU UI map, the `InputItem` type drops `time` and `placeholder`, and `InputField` only uses mapped MXU UI configuration for time pickers and placeholders. Ordinary resource inputs render as text and lose their hint, so the configured UI is missing.

Preserve the documented time-picker and placeholder behavior for PI inputs, while keeping the separate internal UI configuration for built-in tasks.

Also at `src/components/OptionEditor.tsx:293`, `src/components/OptionEditor.tsx:340`.
</issue_to_address>

### Comment 3
<location path="tests/protocolUi.test.ts" line_range="74" />
<code_context>
+    const inputHtml = renderOption('Input');
+    assert.match(inputHtml, /\*\*Option\*\*/);
+    assert.match(inputHtml, /&lt;b&gt;Input&lt;\/b&gt;/);
+    assert.doesNotMatch(inputHtml, /PRIVATE|private\.png|type="time"|<b>/);
+    assert.match(inputHtml, /type="password"/);
+    const casesHtml = renderOption('Cases');
</code_context>
<issue_to_address>
**Input icons escape the assertion**

When input `icon` rendering is reintroduced through the existing asynchronous `AsyncIcon` component, `assert.doesNotMatch(inputHtml, /PRIVATE|private\.png|type="time"|<b>/)` passes even if input icons render again: `AsyncIcon` loads them in an effect and returns `null` during this test's server render, so the icon is absent from `inputHtml` regardless.

Test the rendered icon after its loading effect resolves, or otherwise assert that input icon metadata is not used.
</issue_to_address>

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

Comment thread src-tauri/src/commands/maa_agent.rs Resolved
Comment thread src/types/interface.ts
placeholder?: string;
/** MXU 扩展:密码字段;启用后 UI 掩码显示,配置加密存储,日志/遥测脱敏 */
/** v2.10.5: 输入控件类型;文件和文件夹选择结果均为路径字符串 */
input_type?: 'text' | 'file' | 'directory';

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.

🟡 Medium · 自定义输入控件消失

当 PI 资源使用内置 MXU UI 映射之外、文档中定义的 input_type: 'time' 或 placeholder 扩展时,InputItem 类型会丢弃 time 和 placeholder,而 InputField 仅使用映射的 MXU UI 配置来处理时间选择器和占位符。普通资源输入会被渲染为文本并丢失提示,因此配置的 UI 不会显示。

请保留 PI 输入项中有文档说明的时间选择器和占位符行为,同时继续为内置任务使用单独的内部 UI 配置。

另请参见 src/components/OptionEditor.tsx:293、src/components/OptionEditor.tsx:340。

给 AI 智能体的提示
在 `src/types/interface.ts` 第 248 行:

**自定义输入控件消失**

当 PI 资源使用内置 MXU UI 映射之外、文档中定义的 `input_type: 'time'` 或 `placeholder` 扩展时,`InputItem` 类型会丢弃 `time` 和 `placeholder`,而 `InputField` 仅使用映射的 MXU UI 配置来处理时间选择器和占位符。普通资源输入会被渲染为文本并丢失提示,因此配置的 UI 不会显示。

请保留 PI 输入项中有文档说明的时间选择器和占位符行为,同时继续为内置任务使用单独的内部 UI 配置。

另请参见 `src/components/OptionEditor.tsx:293`、`src/components/OptionEditor.tsx:340`。

摘自 docs/add-special-task.md 第 171-173 行、docs/add-special-task.md 第 186-190 行:

      // MXU 扩展字段(可选):
      input_type: 'file',       // 'text'(默认) | 'file'(渲染文件选择器)
      placeholder: 'specialTask.example.placeholder', // 占位提示文本 i18n key
Original comment in English

🟡 Medium · Custom input controls disappear

When a PI resource relies on the documented input_type: 'time' or placeholder extension outside the built-in MXU UI map, the InputItem type drops time and placeholder, and InputField only uses mapped MXU UI configuration for time pickers and placeholders. Ordinary resource inputs render as text and lose their hint, so the configured UI is missing.

Preserve the documented time-picker and placeholder behavior for PI inputs, while keeping the separate internal UI configuration for built-in tasks.

Also at src/components/OptionEditor.tsx:293, src/components/OptionEditor.tsx:340.

Prompt for AI agents
In `src/types/interface.ts` at line 248:

**Custom input controls disappear**

When a PI resource relies on the documented `input_type: 'time'` or `placeholder` extension outside the built-in MXU UI map, the `InputItem` type drops `time` and `placeholder`, and `InputField` only uses mapped MXU UI configuration for time pickers and placeholders. Ordinary resource inputs render as text and lose their hint, so the configured UI is missing.

Preserve the documented time-picker and placeholder behavior for PI inputs, while keeping the separate internal UI configuration for built-in tasks.

Also at `src/components/OptionEditor.tsx:293`, `src/components/OptionEditor.tsx:340`.

From docs/add-special-task.md L171-173, docs/add-special-task.md L186-190:

      // MXU 扩展字段(可选):
      input_type: 'file',       // 'text'(默认) | 'file'(渲染文件选择器)
      placeholder: 'specialTask.example.placeholder', // 占位提示文本 i18n key

Comment thread tests/protocolUi.test.ts Resolved

Copilot AI 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.

🟡 Changes recommended

Directory inputs with password protection use an unmasked FileInput, exposing entered or restored protected values in plaintext.

1 open issue
What changed in this PR

本 PR 将 MXU 的资源声明与界面行为统一到 PI V2,移除客户端私有扩展,同时将内置任务所需的特殊控件配置与协议字段分离。

Changes:

  • 将标签、搜索和任务预览恢复为纯文本处理,移除行内 Markdown 渲染及 {image} 自动截图行为。
  • 清理私有输入字段和 Agent 超时配置,支持标准目录输入,并独立配置内置任务的时间控件与占位提示。
  • 移除 WlRoots 控制器兼容分支,统一使用 Linux 控制器,同时更新文档与回归测试。
File Description
tests/​richText.test.ts 移除已删除的标签富文本工具测试。
tests/​protocolUi.test.ts 新增协议 UI 和 Linux 键码回归测试。
src/​utils/​useMaaCallbackLogger.ts 移除自动截图占位符及 WlRoots 分支。
src/​utils/​richText.ts 仅保留日志富文本检测。
src/​utils/​pipelineOverride.ts 统一 Linux 热键映射并适配收窄后的类型。
src/​utils/​controller.ts 移除 WlRoots 工作站解锁配置。
src/​types/​specialTasks.ts 独立定义内置任务 UI 配置。
src/​types/​maa.ts 移除 WlRoots 连接配置类型。
src/​types/​interface.ts 清理私有协议字段并补充标准目录输入。
src/​services/​telemetryService.ts 移除时间输入值的特殊上报逻辑。
src/​services/​interfaceLoader.ts 过滤非标准控制器类型。
src/​services/​contentResolver.ts 删除标签专用 Markdown 渲染器及 Hook。
src/​i18n/​locales/​zh-TW.ts 删除 WlRoots 繁体中文文案。
src/​i18n/​locales/​zh-CN.ts 删除 WlRoots 简体中文文案。
src/​i18n/​locales/​ko-KR.ts 删除 WlRoots 韩语文案。
src/​i18n/​locales/​ja-JP.ts 删除 WlRoots 日语文案。
src/​i18n/​locales/​en-US.ts 删除 WlRoots 英语文案。
src/​components/​Toolbar.tsx 移除 WlRoots 自动连接兼容逻辑。
src/​components/​TaskItem.tsx 任务预览直接使用原始标签文本。
src/​components/​RichLabel.tsx 删除富文本标签组件。
src/​components/​OptionEditor.tsx 使用纯文本标签、标准输入字段及内置 UI 配置。
src/​components/​FormControls.tsx 为文件选择控件增加目录选择模式。
src/​components/​DeviceSelector.tsx 删除 WlRoots 设备选择与连接逻辑。
src/​components/​ConnectionPanel.tsx 删除旧分支,保留标准 Linux 连接路径。
src/​components/​connection/​useDeviceConnection.ts 移除 WlRoots 连接状态与处理函数。
src-tauri/​src/​commands/​types.rs 删除 WlRoots 配置和 Agent 超时字段。
src-tauri/​src/​commands/​maa_core.rs 删除 WlRoots 后端兼容分支。
src-tauri/​src/​commands/​maa_agent.rs 不再从资源读取 Agent 超时。
src-tauri/​src/​commands/​app_config.rs 仅修正 setting 导入逻辑的协议归属注释。
README.md 删除「MXU 扩展」章节。
docs/​add-special-task.md 更新标准字段与客户端内部 UI 配置说明。

Review effort: Balanced

className="min-w-[min(12rem,100%)] flex-1 basis-[30%]"
/>
) : input.input_type === 'file' ? (
) : input.input_type === 'file' || input.input_type === 'directory' ? (
zmdyy0318 added a commit to MaaEnd/MaaEnd that referenced this pull request Nov 4, 2026
## 背景

MaaXYZ/MXU#405 移除了 PI 协议之外的 MXU 扩展。合入后,`option` / `case` / `input` 的
`label` 只按纯文本显示,不再渲染行内 Markdown。

MaaEnd 目前有 43 个输入项 label(5 种语言共 215 条)写成了
`![](resource/image/UI/Item/xxx.png) 物品名`,MXU 更新后会把这段源码原样显示出来。这些写法来自
#5870,之后 #6537 和 #6895 沿用。

## 修改

- **生成脚本**:`tools/AutoCollectRoute/registry.py` 中
`AutoCollectTargetInventory` 输入项的 label 改为直接使用物品名。`item.icon` 仍用于 case 的
`icon` 字段,保留。
- **文案**:`assets/locales/interface/*.json`(5 种语言)每个文件 43 条去掉图标前缀,只保留文字。
- `option.AutoCollectTargetInventory.inputs.*.label`(27 条):改完脚本后用 `uv
run autocollect-route generate` 重新生成
  - `option.SupplyPlanLimits.inputs.*.label`(16 条,协议空间):手写的,直接去掉前缀
- **文档**:中英文 `developers/getting-started.md` 中「`label` 支持 Markdown
图片」的说法改为:`label` 是纯文本,配图标请用 `option` / `case` 的 `icon` 字段,`input`
的输入项没有图标字段。`description` 中的 Markdown 图片示例保留。

## 影响

- 自动采集「目标库存」和协议空间「补给计划上限」这两组数量输入框只显示文字,**不再显示物品图标**。PI 协议的输入项本身没有图标字段。
- 在当前版本的 MXU 上也能正常显示,只是少了图标,不需要等 MXU#405 发版。
- `assets/resource/image/UI/Item/` 下的图片都保留:其中 33 张仍被其他任务的 case `icon`
引用,其余是 `tools/icon_recognition` 按分类批量生成的通用物品图标库。

## 检查

- 对照 MXU#405 移除的其他扩展逐项排查过:`WlRoots` 控制器类型、`inputs[].placeholder` /
`inputs[].icon` / `input_type: "time"`、`agent.timeout`、hotkeys
额外字段、focus 的 `{image}` 占位符,MaaEnd 都没有用到。`Linux-Wlroots` 控制器已经是标准的
`"type": "Linux"` 写法。
- 扫描 1333 个 option / case / input label,带行内 Markdown 的为
0;改完后再跑一次生成器,没有额外改动。
- `prettier --check` 通过,`pnpm format:md:check` 0 条报错。

🤖 Generated with [Claude Code](https://claude.com/claude-code)


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

- **界面调整**
  - 采集物与培养材料目标标签改为纯文字显示,名称保持不变,不再显示嵌入的物品图片。
- **文档**
  - 补充说明标签以纯文字显示;需要图标时使用相应的图标字段,输入项不提供图标字段。
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@MistEO
MistEO merged commit a05a112 into main Nov 6, 2026
17 checks passed
@MistEO
MistEO deleted the codex/remove-pi-extensions branch November 6, 2026 09:53
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