feat: 适配 PI v2.7 协议#207
Open
MistEO wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Hey - 我给出了一些高层次的反馈:
- 在
pretaskCounts中,你对每个 pretask 都重复地对preActions进行过滤,而且只用exec作为键;建议在对preActions进行单次遍历时直接构建计数映射,并使用更具体的键(例如name+exec),以避免 O(n²) 的开销以及当多个 pretasks 共享同一个exec时可能出现的键冲突。 - 新的
PreTaskButton在布局和行为上与TaskButton大量重复;可以考虑抽取一个共享的按钮组件,或者在现有组件上通过增加一些 props 来复用,从而减少重复并保持样式/用户体验的一致性。
给 AI Agent 的提示
Please address the comments from this code review:
## Overall Comments
- In `pretaskCounts`, you repeatedly filter `preActions` for each pretask and key by `exec` only; consider building the counts map in a single pass over `preActions` and using a more specific key (e.g., `name`+`exec`) to avoid O(n²) cost and accidental collisions when multiple pretasks share the same `exec`.
- The new `PreTaskButton` largely duplicates the layout and behaviors of `TaskButton`; extracting a shared button component or reusing the existing one with a few props would reduce duplication and keep styling/UX consistent.帮我变得更有用!请在每条评论上点击 👍 或 👎,我会根据这些反馈改进后续的评审。
Original comment in English
Hey - I've left some high level feedback:
- In
pretaskCounts, you repeatedly filterpreActionsfor each pretask and key byexeconly; consider building the counts map in a single pass overpreActionsand using a more specific key (e.g.,name+exec) to avoid O(n²) cost and accidental collisions when multiple pretasks share the sameexec. - The new
PreTaskButtonlargely duplicates the layout and behaviors ofTaskButton; extracting a shared button component or reusing the existing one with a few props would reduce duplication and keep styling/UX consistent.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `pretaskCounts`, you repeatedly filter `preActions` for each pretask and key by `exec` only; consider building the counts map in a single pass over `preActions` and using a more specific key (e.g., `name`+`exec`) to avoid O(n²) cost and accidental collisions when multiple pretasks share the same `exec`.
- The new `PreTaskButton` largely duplicates the layout and behaviors of `TaskButton`; extracting a shared button component or reusing the existing one with a few props would reduce duplication and keep styling/UX consistent.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Contributor
There was a problem hiding this comment.
Pull request overview
本 PR 旨在适配 PI v2.7 协议中的 pretask(Controller 启动前预任务)能力:在类型层新增 pretask 定义与标准化工具,并在导入合并与「添加任务」面板中提供 pretask 的展示与一键加入 preActions 的入口。
Changes:
- 在 PI 类型中新增
PreTaskConfig/pretask字段,并提供normalizePreTaskConfigs标准化工具。 interfaceLoader支持从 import 文件中导入并合并pretask。- AddTaskPanel 增加 “Pretasks/前置任务” 区块:展示、搜索、并将选择的 pretask 转换为
ActionConfig加入实例preActions。 - 各语言包补充
addTaskPanel.pretasks文案。
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/types/interface.ts | 增加 pretask/PreTaskConfig 类型与标准化函数,支撑 v2.7 协议字段落地 |
| src/services/interfaceLoader.ts | import 合并逻辑中追加 pretask 合并支持 |
| src/components/AddTaskPanel.tsx | UI 增加 pretask 展示与添加到 preActions 的行为实现 |
| src/i18n/locales/zh-TW.ts | 新增 addTaskPanel.pretasks 翻译 |
| src/i18n/locales/zh-CN.ts | 新增 addTaskPanel.pretasks 翻译 |
| src/i18n/locales/ko-KR.ts | 新增 addTaskPanel.pretasks 翻译 |
| src/i18n/locales/ja-JP.ts | 新增 addTaskPanel.pretasks 翻译 |
| src/i18n/locales/en-US.ts | 新增 addTaskPanel.pretasks 翻译 |
Comment on lines
+214
to
+216
| for (const [key, value] of Object.entries(valuesMap)) { | ||
| const def = allOptions[key]; | ||
| if (!def) continue; |
Comment on lines
+580
to
+582
| for (const p of allPretasks) { | ||
| counts[p.exec] = preActions.filter((a) => a.program === p.exec).length; | ||
| } |
Comment on lines
+740
to
+746
| const label = | ||
| resolveI18nText(pretask.label, langKey) || pretask.name || pretask.exec; | ||
| const key = pretask.name || pretask.exec; | ||
| return ( | ||
| <PreTaskButton | ||
| key={key} | ||
| pretask={pretask} |
Comment on lines
+240
to
+245
| // v2.7.1: 合并 pretask(主文件已在 normalizePretask 处理;此处把导入文件的条目按数组顺序追加) | ||
| const importedPretasks = normalizePreTaskConfigs(imported.pretask); | ||
| if (importedPretasks.length > 0) { | ||
| const existing = normalizePreTaskConfigs(pi.pretask); | ||
| pi.pretask = [...existing, ...importedPretasks]; | ||
| log.info(`合并了 ${importedPretasks.length} 个导入的 pretask`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary by Sourcery
将客户端适配到 PI v2.7 的预任务(pretask)定义,通过把预任务配置接入接口模型、加载器以及 AddTaskPanel UI,包括参数和选项处理。
New Features:
Enhancements:
Original summary in English
Summary by Sourcery
Adapt the client to PI v2.7 pretask definitions by wiring pretask configs into the interface model, loader, and AddTaskPanel UI, including argument and option handling.
New Features:
Enhancements: