feat(m5a): pallas_webui 改名为 pb_webui#217
Conversation
- matcher:alias_bindings 正式属性、isawaitable 守卫 - capabilities:reload_policy 读取失败打日志 - checklist:补充 extra=None 与脏行测试
- 目录/测试/文档迁移至 src/plugins/pb_webui - plugin_matrix、help 别名与 WebUI env section id 更新 - 保留 pallas_webui 包名映射与 data/ 目录一次性迁移 - pb_core 控制台 hint 改指向 pb_webui
There was a problem hiding this comment.
Hey - 我发现了 3 个问题,并给出了一些整体性的反馈:
- 在
console/webui/env_sections.py中,canonical_plugin_package现在已经在get_webui_env_section中使用,但本次 diff 中没有对应的 import;请确保从src.platform.bot_runtime.plugin_package_aliases引入它,以避免运行时出现NameError。 - 在
pb_webui/data_dir.py中,从pallas_webui迁移到pb_webui的一次性迁移逻辑使用了legacy.rename(new_root),但没有做任何错误处理;建议用带日志的 try/except 包裹这一调用,这样在权限问题或跨设备重命名失败时,不会导致启动中断,并且可以回退到直接使用新目录。
AI 代理提示词
Please address the comments from this code review:
## Overall Comments
- In `console/webui/env_sections.py`, `canonical_plugin_package` is now used in `get_webui_env_section` but there is no corresponding import added in the diff; ensure it is imported from `src.platform.bot_runtime.plugin_package_aliases` to avoid a `NameError` at runtime.
- In `pb_webui/data_dir.py`, the one-time migration from `pallas_webui` to `pb_webui` uses `legacy.rename(new_root)` without any error handling; consider wrapping this in a try/except with logging so that permission or cross-device rename failures don’t break startup and can fall back to using the new directory.
## Individual Comments
### Comment 1
<location path="src/console/webui/env_sections.py" line_range="518-519" />
<code_context>
limit_src = s.model_cls.model_validate(current_values) if current_values is not None else cfg_obj
base.update(_command_limits_payload_extras(limit_src))
- elif section_id == "pallas_webui":
+ elif section_id == "pb_webui":
base.update(_pallas_webui_payload_extras())
elif section_id == "ingress_dispatch":
base.update(_ingress_dispatch_payload_extras())
</code_context>
<issue_to_address>
**issue (bug_risk):** webui_env_section_payload 可能应该使用规范化后的 section id,以保证旧的 id 能保持一致地工作。
get_webui_env_section 现在通过 canonical_plugin_package 对 id 进行了规范化,但 webui_env_section_payload 仍然基于原始的 section_id 分支。任何仍然传入 "pallas_webui" 的调用方,只会得到基础 payload,而拿不到 WebUI 特有的额外字段。请在该函数开头对 section_id 做规范化(使用 canonical_plugin_package),或者在所有调用点强制使用规范化后的 id,并据此更新调用代码。
</issue_to_address>
### Comment 2
<location path="tests/plugins/help/test_visibility.py" line_range="23" />
<code_context>
def test_console_stats_excluded_matches_help_hidden_infra():
excluded = _visibility.resolve_console_stats_excluded_plugin_names()
- assert "pallas_webui" in excluded
+ assert "pb_webui" in excluded
assert "ingress_gate" in excluded
assert "ingress_gate" in excluded
</code_context>
<issue_to_address>
**suggestion (testing):** 添加一个测试,用于覆盖基于旧包名通过 `PLUGIN_PACKAGE_ALIASES` 匹配 help 插件的场景。
由于 `help/plugin_match.py` 现在使用 `PLUGIN_PACKAGE_ALIASES` 将旧名称(例如 `pallas_webui`)映射到 `pb_webui`,当前测试只检查了规范化后的名称,并没有验证使用旧名称进行 help 查询是否仍然有效。
请补充一个测试(例如放在 `tests/plugins/help/test_plugin_match.py` 中),加载 `pb_webui` 的 help 元数据,并断言通过 `pallas_webui`(以及它的中文别名)发起的查询,仍然可以通过别名映射解析到控制台插件,以此保护 help 体验的向后兼容性。
建议实现如下:
```python
def test_console_stats_excluded_matches_help_hidden_infra():
excluded = _visibility.resolve_console_stats_excluded_plugin_names()
assert "pb_webui" in excluded
assert "ingress_gate" in excluded
assert "ingress_gate" in excluded
def test_console_help_legacy_aliases_map_to_pb_webui():
# Ensure legacy console/help package names still resolve to the canonical
# `pb_webui` package via PLUGIN_PACKAGE_ALIASES, protecting backward
# compatibility for help queries using old names (including Chinese aliases).
from help.plugin_match import PLUGIN_PACKAGE_ALIASES
aliases_for_pb_webui = [
alias for alias, pkg in PLUGIN_PACKAGE_ALIASES.items()
if pkg == "pb_webui"
]
# Legacy name must still be supported.
assert "pallas_webui" in aliases_for_pb_webui
# There should be at least one additional alias (e.g. Chinese names) mapped
# to the console/help plugin.
assert len(aliases_for_pb_webui) >= 2
```
如果 `help.plugin_match` 不是你们项目中 `PLUGIN_PACKAGE_ALIASES` 的正确导入路径,请在 `test_console_help_legacy_aliases_map_to_pb_webui` 中相应调整导入(例如 `from plugins.help.plugin_match import PLUGIN_PACKAGE_ALIASES` 或类似形式)。测试的其余部分可以保持不变。
</issue_to_address>
### Comment 3
<location path="docs/develop/webui.md" line_range="3" />
<code_context>
控制台 UI 由独立仓库 **[Pallas-Bot-WebUI](https://github.com/PallasBot/Pallas-Bot-WebUI)** 构建,产物由主仓 `pallas_webui` 插件挂载,基址 **`/pallas/`**。
-后端 API 实现在主仓 `src/plugins/pallas_webui/`(如 `extended_api.py`);**插件配置热重载**等通用能力在 `src/console/webui/`,一般无需改 API 层即可接入新插件配置(见 [WebUI 插件配置](../common/webui/README.md))。
+后端 API 实现在主仓 `src/plugins/pb_webui/`(如 `extended_api.py`);**插件配置热重载**等通用能力在 `src/console/webui/`,一般无需改 API 层即可接入新插件配置(见 [WebUI 插件配置](../common/webui/README.md))。
## 本地联调
</code_context>
<issue_to_address>
**suggestion (typo):** 前一句中的插件名 `pallas_webui` 可能也需要更新为 `pb_webui` 以保持一致。
上一句仍然使用了“产物由主仓 `pallas_webui` 插件挂载…”,而这一行以及路径/文档使用的是 `pb_webui`。如果 `pallas_webui` 并不是一个独立的插件名,建议将该行内代码片段更新为 `pb_webui` 以保持一致性。
```suggestion
控制台 UI 由独立仓库 **[Pallas-Bot-WebUI](https://github.com/PallasBot/Pallas-Bot-WebUI)** 构建,产物由主仓 `pb_webui` 插件挂载,基址 **`/pallas/`**。
```
</issue_to_address>帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈持续改进评审质量。
Original comment in English
Hey - I've found 3 issues, and left some high level feedback:
- In
console/webui/env_sections.py,canonical_plugin_packageis now used inget_webui_env_sectionbut there is no corresponding import added in the diff; ensure it is imported fromsrc.platform.bot_runtime.plugin_package_aliasesto avoid aNameErrorat runtime. - In
pb_webui/data_dir.py, the one-time migration frompallas_webuitopb_webuiuseslegacy.rename(new_root)without any error handling; consider wrapping this in a try/except with logging so that permission or cross-device rename failures don’t break startup and can fall back to using the new directory.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `console/webui/env_sections.py`, `canonical_plugin_package` is now used in `get_webui_env_section` but there is no corresponding import added in the diff; ensure it is imported from `src.platform.bot_runtime.plugin_package_aliases` to avoid a `NameError` at runtime.
- In `pb_webui/data_dir.py`, the one-time migration from `pallas_webui` to `pb_webui` uses `legacy.rename(new_root)` without any error handling; consider wrapping this in a try/except with logging so that permission or cross-device rename failures don’t break startup and can fall back to using the new directory.
## Individual Comments
### Comment 1
<location path="src/console/webui/env_sections.py" line_range="518-519" />
<code_context>
limit_src = s.model_cls.model_validate(current_values) if current_values is not None else cfg_obj
base.update(_command_limits_payload_extras(limit_src))
- elif section_id == "pallas_webui":
+ elif section_id == "pb_webui":
base.update(_pallas_webui_payload_extras())
elif section_id == "ingress_dispatch":
base.update(_ingress_dispatch_payload_extras())
</code_context>
<issue_to_address>
**issue (bug_risk):** webui_env_section_payload should probably use the canonicalized section id to keep legacy ids working consistently.
get_webui_env_section now canonicalizes ids via canonical_plugin_package, but webui_env_section_payload still branches on the raw section_id. Any callers still passing "pallas_webui" will get only the base payload and miss the WebUI-specific extras. Please either normalize section_id at the start of this function (using canonical_plugin_package) or enforce canonical ids at all call sites and update them accordingly.
</issue_to_address>
### Comment 2
<location path="tests/plugins/help/test_visibility.py" line_range="23" />
<code_context>
def test_console_stats_excluded_matches_help_hidden_infra():
excluded = _visibility.resolve_console_stats_excluded_plugin_names()
- assert "pallas_webui" in excluded
+ assert "pb_webui" in excluded
assert "ingress_gate" in excluded
assert "ingress_gate" in excluded
</code_context>
<issue_to_address>
**suggestion (testing):** Add a test to cover help plugin matching against the legacy package name via `PLUGIN_PACKAGE_ALIASES`
Since `help/plugin_match.py` now uses `PLUGIN_PACKAGE_ALIASES` to map legacy names (e.g. `pallas_webui`) to `pb_webui`, the current test only checks the canonical name and doesn’t confirm that help lookups via the old name still work.
Please add a test (e.g. in `tests/plugins/help/test_plugin_match.py`) that loads help metadata for `pb_webui` and asserts that queries using `pallas_webui` (and its Chinese aliases) still resolve to the console plugin via the alias map, to protect backward compatibility of the help UX.
Suggested implementation:
```python
def test_console_stats_excluded_matches_help_hidden_infra():
excluded = _visibility.resolve_console_stats_excluded_plugin_names()
assert "pb_webui" in excluded
assert "ingress_gate" in excluded
assert "ingress_gate" in excluded
def test_console_help_legacy_aliases_map_to_pb_webui():
# Ensure legacy console/help package names still resolve to the canonical
# `pb_webui` package via PLUGIN_PACKAGE_ALIASES, protecting backward
# compatibility for help queries using old names (including Chinese aliases).
from help.plugin_match import PLUGIN_PACKAGE_ALIASES
aliases_for_pb_webui = [
alias for alias, pkg in PLUGIN_PACKAGE_ALIASES.items()
if pkg == "pb_webui"
]
# Legacy name must still be supported.
assert "pallas_webui" in aliases_for_pb_webui
# There should be at least one additional alias (e.g. Chinese names) mapped
# to the console/help plugin.
assert len(aliases_for_pb_webui) >= 2
```
If `help.plugin_match` is not the correct import path for `PLUGIN_PACKAGE_ALIASES` in your project layout, adjust the import inside `test_console_help_legacy_aliases_map_to_pb_webui` accordingly (e.g. `from plugins.help.plugin_match import PLUGIN_PACKAGE_ALIASES` or similar). The rest of the test can remain unchanged.
</issue_to_address>
### Comment 3
<location path="docs/develop/webui.md" line_range="3" />
<code_context>
控制台 UI 由独立仓库 **[Pallas-Bot-WebUI](https://github.com/PallasBot/Pallas-Bot-WebUI)** 构建,产物由主仓 `pallas_webui` 插件挂载,基址 **`/pallas/`**。
-后端 API 实现在主仓 `src/plugins/pallas_webui/`(如 `extended_api.py`);**插件配置热重载**等通用能力在 `src/console/webui/`,一般无需改 API 层即可接入新插件配置(见 [WebUI 插件配置](../common/webui/README.md))。
+后端 API 实现在主仓 `src/plugins/pb_webui/`(如 `extended_api.py`);**插件配置热重载**等通用能力在 `src/console/webui/`,一般无需改 API 层即可接入新插件配置(见 [WebUI 插件配置](../common/webui/README.md))。
## 本地联调
</code_context>
<issue_to_address>
**suggestion (typo):** The plugin name `pallas_webui` in the preceding sentence may need to be updated to `pb_webui` for consistency.
The previous sentence still uses “产物由主仓 `pallas_webui` 插件挂载…”, while this line and the paths/docs use `pb_webui`. If `pallas_webui` is not a distinct plugin name, consider updating that inline code span to `pb_webui` for consistency.
```suggestion
控制台 UI 由独立仓库 **[Pallas-Bot-WebUI](https://github.com/PallasBot/Pallas-Bot-WebUI)** 构建,产物由主仓 `pb_webui` 插件挂载,基址 **`/pallas/`**。
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| elif section_id == "pb_webui": | ||
| base.update(_pallas_webui_payload_extras()) |
There was a problem hiding this comment.
issue (bug_risk): webui_env_section_payload 可能应该使用规范化后的 section id,以保证旧的 id 能保持一致地工作。
get_webui_env_section 现在通过 canonical_plugin_package 对 id 进行了规范化,但 webui_env_section_payload 仍然基于原始的 section_id 分支。任何仍然传入 "pallas_webui" 的调用方,只会得到基础 payload,而拿不到 WebUI 特有的额外字段。请在该函数开头对 section_id 做规范化(使用 canonical_plugin_package),或者在所有调用点强制使用规范化后的 id,并据此更新调用代码。
Original comment in English
issue (bug_risk): webui_env_section_payload should probably use the canonicalized section id to keep legacy ids working consistently.
get_webui_env_section now canonicalizes ids via canonical_plugin_package, but webui_env_section_payload still branches on the raw section_id. Any callers still passing "pallas_webui" will get only the base payload and miss the WebUI-specific extras. Please either normalize section_id at the start of this function (using canonical_plugin_package) or enforce canonical ids at all call sites and update them accordingly.
| def test_console_stats_excluded_matches_help_hidden_infra(): | ||
| excluded = _visibility.resolve_console_stats_excluded_plugin_names() | ||
| assert "pallas_webui" in excluded | ||
| assert "pb_webui" in excluded |
There was a problem hiding this comment.
suggestion (testing): 添加一个测试,用于覆盖基于旧包名通过 PLUGIN_PACKAGE_ALIASES 匹配 help 插件的场景。
由于 help/plugin_match.py 现在使用 PLUGIN_PACKAGE_ALIASES 将旧名称(例如 pallas_webui)映射到 pb_webui,当前测试只检查了规范化后的名称,并没有验证使用旧名称进行 help 查询是否仍然有效。
请补充一个测试(例如放在 tests/plugins/help/test_plugin_match.py 中),加载 pb_webui 的 help 元数据,并断言通过 pallas_webui(以及它的中文别名)发起的查询,仍然可以通过别名映射解析到控制台插件,以此保护 help 体验的向后兼容性。
建议实现如下:
def test_console_stats_excluded_matches_help_hidden_infra():
excluded = _visibility.resolve_console_stats_excluded_plugin_names()
assert "pb_webui" in excluded
assert "ingress_gate" in excluded
assert "ingress_gate" in excluded
def test_console_help_legacy_aliases_map_to_pb_webui():
# Ensure legacy console/help package names still resolve to the canonical
# `pb_webui` package via PLUGIN_PACKAGE_ALIASES, protecting backward
# compatibility for help queries using old names (including Chinese aliases).
from help.plugin_match import PLUGIN_PACKAGE_ALIASES
aliases_for_pb_webui = [
alias for alias, pkg in PLUGIN_PACKAGE_ALIASES.items()
if pkg == "pb_webui"
]
# Legacy name must still be supported.
assert "pallas_webui" in aliases_for_pb_webui
# There should be at least one additional alias (e.g. Chinese names) mapped
# to the console/help plugin.
assert len(aliases_for_pb_webui) >= 2如果 help.plugin_match 不是你们项目中 PLUGIN_PACKAGE_ALIASES 的正确导入路径,请在 test_console_help_legacy_aliases_map_to_pb_webui 中相应调整导入(例如 from plugins.help.plugin_match import PLUGIN_PACKAGE_ALIASES 或类似形式)。测试的其余部分可以保持不变。
Original comment in English
suggestion (testing): Add a test to cover help plugin matching against the legacy package name via PLUGIN_PACKAGE_ALIASES
Since help/plugin_match.py now uses PLUGIN_PACKAGE_ALIASES to map legacy names (e.g. pallas_webui) to pb_webui, the current test only checks the canonical name and doesn’t confirm that help lookups via the old name still work.
Please add a test (e.g. in tests/plugins/help/test_plugin_match.py) that loads help metadata for pb_webui and asserts that queries using pallas_webui (and its Chinese aliases) still resolve to the console plugin via the alias map, to protect backward compatibility of the help UX.
Suggested implementation:
def test_console_stats_excluded_matches_help_hidden_infra():
excluded = _visibility.resolve_console_stats_excluded_plugin_names()
assert "pb_webui" in excluded
assert "ingress_gate" in excluded
assert "ingress_gate" in excluded
def test_console_help_legacy_aliases_map_to_pb_webui():
# Ensure legacy console/help package names still resolve to the canonical
# `pb_webui` package via PLUGIN_PACKAGE_ALIASES, protecting backward
# compatibility for help queries using old names (including Chinese aliases).
from help.plugin_match import PLUGIN_PACKAGE_ALIASES
aliases_for_pb_webui = [
alias for alias, pkg in PLUGIN_PACKAGE_ALIASES.items()
if pkg == "pb_webui"
]
# Legacy name must still be supported.
assert "pallas_webui" in aliases_for_pb_webui
# There should be at least one additional alias (e.g. Chinese names) mapped
# to the console/help plugin.
assert len(aliases_for_pb_webui) >= 2If help.plugin_match is not the correct import path for PLUGIN_PACKAGE_ALIASES in your project layout, adjust the import inside test_console_help_legacy_aliases_map_to_pb_webui accordingly (e.g. from plugins.help.plugin_match import PLUGIN_PACKAGE_ALIASES or similar). The rest of the test can remain unchanged.
| @@ -2,7 +2,7 @@ | |||
|
|
|||
| 控制台 UI 由独立仓库 **[Pallas-Bot-WebUI](https://github.com/PallasBot/Pallas-Bot-WebUI)** 构建,产物由主仓 `pallas_webui` 插件挂载,基址 **`/pallas/`**。 | |||
There was a problem hiding this comment.
suggestion (typo): 前一句中的插件名 pallas_webui 可能也需要更新为 pb_webui 以保持一致。
上一句仍然使用了“产物由主仓 pallas_webui 插件挂载…”,而这一行以及路径/文档使用的是 pb_webui。如果 pallas_webui 并不是一个独立的插件名,建议将该行内代码片段更新为 pb_webui 以保持一致性。
| 控制台 UI 由独立仓库 **[Pallas-Bot-WebUI](https://github.com/PallasBot/Pallas-Bot-WebUI)** 构建,产物由主仓 `pallas_webui` 插件挂载,基址 **`/pallas/`**。 | |
| 控制台 UI 由独立仓库 **[Pallas-Bot-WebUI](https://github.com/PallasBot/Pallas-Bot-WebUI)** 构建,产物由主仓 `pb_webui` 插件挂载,基址 **`/pallas/`**。 |
Original comment in English
suggestion (typo): The plugin name pallas_webui in the preceding sentence may need to be updated to pb_webui for consistency.
The previous sentence still uses “产物由主仓 pallas_webui 插件挂载…”, while this line and the paths/docs use pb_webui. If pallas_webui is not a distinct plugin name, consider updating that inline code span to pb_webui for consistency.
| 控制台 UI 由独立仓库 **[Pallas-Bot-WebUI](https://github.com/PallasBot/Pallas-Bot-WebUI)** 构建,产物由主仓 `pallas_webui` 插件挂载,基址 **`/pallas/`**。 | |
| 控制台 UI 由独立仓库 **[Pallas-Bot-WebUI](https://github.com/PallasBot/Pallas-Bot-WebUI)** 构建,产物由主仓 `pb_webui` 插件挂载,基址 **`/pallas/`**。 |
Summary
M5a: 将
pallas_webui插件包重命名为pb_webui,保留旧包名兼容别名。Test plan
uv run ruff check src/Summary by Sourcery
将 WebUI 插件包从
pallas_webui重命名为pb_webui,同时保持对旧名称的兼容性并迁移持久化数据。新功能:
pb_webui数据目录辅助工具,在首次使用时透明地迁移现有的pallas_webui数据。错误修复:
await,而不是对任何非 None 的返回值都进行等待。ImportError,以便在插件缺失时能够优雅地失败。增强改进:
pb_webui插件包和 ID,同时为两个名称保留日志和帮助信息的可见性。pb_webui视为基础设施插件,并支持旧名称匹配。测试:
pb_webui插件,并增加对插件 SDK 检查清单验证和包别名行为的覆盖。Original summary in English
Summary by Sourcery
Rename the WebUI plugin package from pallas_webui to pb_webui while maintaining compatibility with the legacy name and migrating persisted data.
New Features:
Bug Fixes:
Enhancements:
Tests: