feat: add group settings WebUI management page#6577
feat: add group settings WebUI management page#6577Sisyphbaous-DT-Project wants to merge 5 commits intoAstrBotDevs:masterfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a user-friendly WebUI for managing group-specific AI provider and persona settings. It streamlines the configuration process by providing a visual interface that mirrors existing command-line functionalities, significantly improving the ease of use for administrators to customize bot behavior across various chat groups. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Hey - I've found 2 issues, and left some high level feedback:
- The
/group-settings/clearendpoint currently clears all group settings whenumois omitted, which is quite destructive for a generic API; consider requiring an explicit flag (e.g.clear_all=true) or removing the clear-all branch to avoid accidental global wipes. - The frontend search filters by
umo,provider_id, andpersona_idwhile the backend/group-settings/listendpoint only filters byumo; aligning the backend search to also matchprovider_id/persona_id(or removing the extra client-side filter) would make the search behavior more predictable and consistent.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `/group-settings/clear` endpoint currently clears all group settings when `umo` is omitted, which is quite destructive for a generic API; consider requiring an explicit flag (e.g. `clear_all=true`) or removing the clear-all branch to avoid accidental global wipes.
- The frontend search filters by `umo`, `provider_id`, and `persona_id` while the backend `/group-settings/list` endpoint only filters by `umo`; aligning the backend search to also match `provider_id`/`persona_id` (or removing the extra client-side filter) would make the search behavior more predictable and consistent.
## Individual Comments
### Comment 1
<location path="dashboard/src/views/GroupSettingsPage.vue" line_range="281-284" />
<code_context>
+];
+
+// Filtered settings list
+const filteredSettingsList = computed(() => {
+ if (!searchQuery.value) return settingsList.value;
+ const query = searchQuery.value.toLowerCase();
+ return settingsList.value.filter(item =>
+ item.umo.toLowerCase().includes(query) ||
+ (item.provider_id && item.provider_id.toLowerCase().includes(query)) ||
</code_context>
<issue_to_address>
**issue (bug_risk):** Search is applied both server-side and client-side, which can desync the row count and the displayed list.
Because this is a `v-data-table-server`, `loadSettings` already sends `search` to `/api/group-settings/list`, which filters on the backend and sets `totalItems`. `filteredSettingsList` then applies an additional client-side filter with `searchQuery`, so `totalItems` can differ from the number of rendered rows and frontend search behavior may diverge from the backend. It would be more consistent to either rely solely on server-side search (`items = settingsList`) or switch to a non-`server` table and do all filtering client-side.
</issue_to_address>
### Comment 2
<location path="astrbot/dashboard/routes/group_settings.py" line_range="41" />
<code_context>
+ }
+ self.register_routes()
+
+ async def list_group_settings(self):
+ """获取所有群设置列表
+
</code_context>
<issue_to_address>
**issue (complexity):** Consider extracting shared helpers for UMO parsing/serialization, pagination, and clearing all settings to reduce duplication and keep route logic simpler and more consistent.
You can reduce duplication and keep behavior the same with a few small helpers.
### 1. Extract UMO parsing + serialization
The UMO parsing and response shaping are duplicated in `list_group_settings` and `get_group_setting`. A tiny helper keeps them in sync:
```python
def _parse_umo(self, umo: str) -> dict:
parts = umo.split(":")
return {
"umo": umo,
"platform": parts[0] if len(parts) >= 1 else "unknown",
"message_type": parts[1] if len(parts) >= 2 else "unknown",
"group_id": parts[2] if len(parts) >= 3 else umo,
}
def _serialize_settings(self, umo: str, settings) -> dict:
base = self._parse_umo(umo)
base.update(
{
"provider_id": settings.provider_id or "",
"persona_id": settings.persona_id or "",
"model": settings.model or "",
"set_by": settings.set_by or "",
"set_at": settings.set_at or "",
}
)
return base
```
Use it in both places:
```python
# list_group_settings
settings_list = []
for umo, settings in all_settings.items():
if search and search.lower() not in umo.lower():
continue
settings_list.append(self._serialize_settings(umo, settings))
```
```python
# get_group_setting
settings = await self.group_settings_mgr.get_settings(umo)
return (
Response()
.ok(self._serialize_settings(umo, settings))
.__dict__
)
```
This removes the repeated split/field extraction and reduces chances of divergence.
### 2. Extract pagination helper
The manual pagination logic can be hidden behind a small helper to keep the handler focused:
```python
def _paginate(self, items, page: int, page_size: int):
if page < 1:
page = 1
if page_size < 1:
page_size = 20
if page_size > 100:
page_size = 100
total = len(items)
start_idx = (page - 1) * page_size
end_idx = start_idx + page_size
return items[start_idx:end_idx], total, page, page_size
```
Then in `list_group_settings`:
```python
page = request.args.get("page", 1, type=int)
page_size = request.args.get("page_size", 20, type=int)
search = request.args.get("search", "", type=str).strip()
all_settings = await self.group_settings_mgr.get_all_groups_with_settings()
settings_list = []
for umo, settings in all_settings.items():
if search and search.lower() not in umo.lower():
continue
settings_list.append(self._serialize_settings(umo, settings))
paginated, total, page, page_size = self._paginate(settings_list, page, page_size)
return (
Response()
.ok(
{
"settings": paginated,
"total": total,
"page": page,
"page_size": page_size,
}
)
.__dict__
)
```
### 3. Simplify clear-all path (optional, if you can change the manager)
If you can extend `GroupSettingsManager`, exposing a `clear_all_settings()` keeps route logic simpler:
```python
# in GroupSettingsManager
async def clear_all_settings(self):
all_settings = await self.get_all_groups_with_settings()
for group_umo in all_settings.keys():
await self.clear_settings(group_umo)
```
Then the route becomes:
```python
async def clear_group_settings(self):
try:
data = await request.get_json()
umo = data.get("umo", "").strip()
if umo:
await self.group_settings_mgr.clear_settings(umo)
payload = {"message": f"群 {umo} 的设置已清除", "umo": umo}
else:
await self.group_settings_mgr.clear_all_settings()
payload = {"message": "所有群设置已清除"}
return Response().ok(payload).__dict__
except Exception as e:
logger.error(f"清除群设置失败: {e!s}")
return Response().error(f"清除群设置失败: {e!s}").__dict__
```
These small helpers reduce repetition and cognitive load without changing behavior or the public API.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Code Review
This pull request introduces a new 'Group Settings' feature to the AstrBot dashboard, allowing users to configure specific Providers and Personas for different chat groups. The changes include adding a new backend API route (GroupSettingsRoute) to handle listing, getting, setting, and clearing group settings, as well as listing available providers and personas. On the frontend, a new Vue page (GroupSettingsPage.vue) is implemented to provide a user interface for managing these settings, including data display, search, pagination, and CRUD operations for group settings. Internationalization files for English, Russian, and Simplified Chinese are updated to include new strings for this feature, and the navigation menu and routing are updated to integrate the new page. Review comments highlight several areas for improvement: the saveSetting function in the frontend needs to correctly handle clearing previously set provider or persona IDs, the backend API's pagination logic should return explicit errors for invalid input instead of silently correcting them, the UMO parsing logic in the backend should accurately represent group_id as empty if not provided, the frontend UMO validation could be more robust using a regex, and the error reporting for partial updates in the saveSetting function should provide more detailed feedback to the user.
- Add confirm_clear_all flag for clear all operation (security fix) - Add clear-provider and clear-persona endpoints for granular control - Fix UMO parsing to return empty string instead of full UMO - Fix pagination validation to return 400 error instead of silent correction - Enhance search to match provider_id and persona_id in backend - Add strict regex validation for UMO format in frontend - Improve error reporting with detailed operation results - Extract helper methods to reduce code duplication - Update i18n translations for all three languages
- Add astrbot/core/group_settings/manager.py (missing module) - Fix duplicate buttons key in zh-CN/en-US/ru-RU group-settings.json - Ensure all button translations are properly merged
SummaryAdd visual interface for managing group chat specific Provider and Persona settings, matching the existing ChangesBackend
Frontend
i18n
Code Review Fixes
Testing
ScreenshotsN/A (Please add screenshots if needed) Checklist
|
There was a problem hiding this comment.
Code Review
This pull request introduces a comprehensive WebUI for managing group settings, which is a great feature enhancement. The backend APIs are well-structured with validation and error handling, and the Vue.js frontend provides a clean and functional user interface with server-side pagination and batch operations. The code is in a good state, especially since it seems to have already incorporated feedback from a previous review. I have a few suggestions for further improvements regarding efficiency and correctness.
- Add clear_all_settings() method to GroupSettingsManager for efficient bulk clearing - Optimize clear_group_settings API to support umos array for batch deletion - Fix formatDate to correctly handle Unix timestamp (seconds to milliseconds) - Update batchDelete to use single API call instead of multiple requests
|
@gemini-code-assist All review comments have been addressed: ✅ clear_all_settings efficiency: Added All changes are backward compatible. Ready for re-review! 🎉 |
✅ AI Review Comments AddressedAll efficiency and correctness issues have been fixed: 🔧 Backend Fixes
API Usage: // Single delete (backward compatible)
{ "umo": "qq:group:123" }
// Batch delete (new)
{ "umos": ["qq:group:111", "qq:group:222"] }
// Clear all (optimized)
{ "confirm_clear_all": true } |
- Add _update_setting() helper for set_provider/set_persona - Add _cleanup_if_empty() helper for remove_provider_override/remove_persona_override - Improve code maintainability without changing behavior
|
感谢您的更新!很高兴看到 我将对这些更改进行重新审查。 |
|
✅ set_provider / set_persona: 提取 改动范围: 重构效果:
|
|
感谢您的确认!很高兴看到 我将立即开始对这些最新的更改进行重新审查。 |
|
@gemini-code-assist 项目代码还有什么问题吗 |
|
感谢您的提问!我正在对您最新的更改进行全面的重新审查。一旦完成,我将立即提供详细的反馈。感谢您持续的更新和对代码质量的关注! |
|
@gemini-code-assist 感谢审查和肯定! |
|
感谢您的详细更新和对所有反馈的积极处理! 我已重新审查了您的更改,并确认
此外,低优先级的建议,如 UMO 验证的严格性和 部分更新错误报告的详细程度,也已在代码中实现。 关于列表推导式的建议,我理解您为了代码简洁性而选择保持现有实现。这在功能正确且性能良好的情况下是合理的。 总的来说,所有关键问题都已解决,代码质量得到了显著提升。此 PR 已准备好合并。干得好! |
|
感谢您的确认和对所有反馈的积极处理!很高兴看到所有关键问题都已解决,并且您对代码质量的关注带来了显著的改进。此 PR 确实已准备好合并。干得好! |
Summary
Add visual interface for managing group chat specific Provider and Persona settings, matching the existing
/group_setcommand functionality.Changes
Backend
astrbot/dashboard/routes/group_settings.pywith REST APIs:GET /api/group-settings/list- List all group settings (pagination)GET /api/group-settings/get- Get single group settingPOST /api/group-settings/set-provider- Set group ProviderPOST /api/group-settings/set-persona- Set group PersonaPOST /api/group-settings/clear- Clear group settingsGET /api/group-settings/providers- List available providersGET /api/group-settings/personas- List available personasGroupSettingsRouteinastrbot/dashboard/server.pyFrontend
dashboard/src/views/GroupSettingsPage.vuewith full CRUD UI:dashboard/src/router/MainRoutes.tsdashboard/src/layouts/full/vertical-sidebar/sidebarItem.tsi18n
dashboard/src/i18n/translations.tsFiles Changed
为群聊设置功能添加 WebUI 管理界面,与现有的
/group_set命令功能匹配,提供可视化的群聊特定 Provider 和 Persona 设置管理。Modifications / 改动点
新增文件 (5个):
astrbot/dashboard/routes/group_settings.py- 后端 REST API 路由dashboard/src/views/GroupSettingsPage.vue- 前端管理页面dashboard/src/i18n/locales/zh-CN/features/group-settings.json- 中文翻译dashboard/src/i18n/locales/en-US/features/group-settings.json- 英文翻译dashboard/src/i18n/locales/ru-RU/features/group-settings.json- 俄文翻译修改文件 (7个):
astrbot/dashboard/server.py- 注册 GroupSettingsRoutedashboard/src/layouts/full/vertical-sidebar/sidebarItem.ts- 添加侧边栏导航dashboard/src/router/MainRoutes.ts- 添加路由配置dashboard/src/i18n/translations.ts- 注册三语言翻译dashboard/src/i18n/locales/zh-CN/core/navigation.json- 添加中文导航标签dashboard/src/i18n/locales/en-US/core/navigation.json- 添加英文导航标签dashboard/src/i18n/locales/ru-RU/core/navigation.json- 添加俄文导航标签Screenshots or Test Results / 运行截图或测试结果
访问地址:
http://localhost:6185/group-settings功能验证:
Checklist / 检查清单
😊 If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
/ 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。
👀 My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
/ 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”。
🤓 I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in
requirements.txtandpyproject.toml./ 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到
requirements.txt和pyproject.toml文件相应位置。😮 My changes do not introduce malicious code.
/ 我的更改没有引入恶意代码。
Summary by Sourcery
Add a WebUI page and backend APIs for managing group-specific provider and persona settings, including listing, editing, and clearing group chat configurations.
New Features:
Enhancements: