feat: 在数字员工和公司设置页面添加工具批量删除功能,修复企业微信Webhook配置#277
feat: 在数字员工和公司设置页面添加工具批量删除功能,修复企业微信Webhook配置#277ThomasOscar wants to merge 8 commits intodataelement:mainfrom
Conversation
- 新增 DELETE /api/tools/agent-tools/bulk API,支持批量删除 Agent 工具分配 - 添加 admin/super_admin 角色权限验证和租户隔离检查 - 实现部分失败处理机制,返回 deleted 数量和 errors 数组 - 添加请求数量限制(最多50条),防止滥用 - 添加操作日志记录,含时间戳便于审计追踪 - 前端 AgentDetail.tsx 添加批量选择 UI 和确认弹窗 - 前端 EnterpriseSettings.tsx 添加批量删除 UI - 新增国际化翻译 keys
问题: - 配置Webhook模式后仍显示WebSocket连接状态 - Webhook URL无法正确显示 解决方案: - 后端:优先使用前端指定的connection_mode,避免自动检测错误 - 后端:添加消息发送结果日志,便于调试 - 前端:添加Webhook模式状态显示 - 前端:优雅处理Webhook URL获取失败 - 前端:确保查询失效完成再重置表单 测试: - WebSocket模式:使用Bot ID + Secret配置,显示WebSocket状态 - Webhook模式:使用CorpID + Secret + Token + EncodingAESKey配置,显示Webhook URL
|
Thanks for the PR! The WeCom webhook fix looks good, but the bulk delete feature has several issues that need to be resolved before we can merge. Required Fixes1. Wrong role names — bulk delete endpoint returns 403 for all valid adminsThe permission check uses role names that don't exist in our system: # Current (broken) — these roles don't exist
if current_user.role not in ("admin", "super_admin"):
...
if current_user.role != "super_admin" and ...:
...Our platform uses if current_user.role not in ("org_admin", "platform_admin"):
...
if current_user.role != "platform_admin" and ...:
...2. Async lazy-loading crash (
|
|
感谢您反馈问题,我现在去解决这些问题。 |
## 修改内容 ### 1. 修复角色名称 - 将 "admin", "super_admin" 改为 "org_admin", "platform_admin" - 原代码会导致所有合法管理员收到 403 错误 ### 2. 修复 N+1 查询和 MissingGreenlet 问题 - 将循环逐个查询改为单次 JOIN 查询 - 一次性获取 AgentTool 和 Agent,避免懒加载崩溃 ### 3. 添加英文翻译 - 补充 en.json 中批量删除功能的翻译 - 包含 agent.tools 和 enterprise.tools 命名空间 ### 4. 将 Emoji 替换为 Tabler 图标 - 将 🗑️、🤖、🔌 替换为 IconTrash、IconRobot、IconPlug - 遵循项目使用 Tabler 图标的规范 ## 为什么使用 JOIN 而非 selectinload? 审核者建议使用 selectinload(AgentTool.agent),但 AgentTool 模型 未定义 "agent" relationship。我们选择 JOIN 查询而非添加 relationship,原因如下: 1. 最小改动原则 - 无需修改数据模型 2. 项目中已有 JOIN 用法(如 list_agent_installed_tools 函数) 3. 避免添加 relationship 可能带来的副作用
合并上游的 A2A (Agent-to-Agent) 会话发送者标签显示逻辑: - 引入 showSenderLabel 和 resolvedAvatarText 变量 - 保留 IconRobot 图标替换 emoji 的改进 - 在 Agent 对话中正确区分 "本 Agent" 和 "其他参与者" 关键变更: - ChatMessageItem 组件新增 thisAgentName 参数 - 当发送者不是当前 Agent 时显示发送者标签 - 头像文字根据发送者身份动态计算
合并上游对 ChatMessageItem 组件的重构: - 使用 senderLabel, avatarText, forceSenderLabel 参数替代 thisAgentName - 组件内部逻辑简化,由调用方计算标签和头像文字 - 保留 IconRobot 图标替换 emoji 的改进 关键变更: - ChatMessageItem 组件参数更新为上游格式 - 在 A2A 会话中正确传递 senderLabel 和 forceSenderLabel - 普通聊天会话使用默认参数值
保留 IconRobot 图标替换 emoji 的改进,同时使用上游一致的变量命名
解决合并冲突: 1. 保留 IconRobot 图标(遵循项目不使用 emoji 的规范) 2. 合并上游的 isHumanReadonly 逻辑,支持人类只读会话 3. 统一处理 A2A 和人类只读两种场景的发送者标签显示 关键变更: - showSenderLabel 使用 IconRobot 图标显示发送者名称 - senderLabel 和 avatarText 参数支持两种场景 - forceSenderLabel 合并两种条件
移除合并冲突遗留的重复代码: - 删除重复的 resolvedAvatarText/resolvedSenderLabel/showSenderLabel 声明 - 修复 useMemo 依赖数组引用未定义变量的问题
功能1:Agent工具批量删除
功能位置
新增功能
文件修改
backend/app/api/tools.py- 批量删除API实现frontend/src/pages/AgentDetail.tsx- 数字员工页面批量删除UIfrontend/src/pages/EnterpriseSettings.tsx- 公司设置页面批量删除UIfrontend/src/i18n/zh.json- 中文翻译功能2:企业微信Webhook配置修复
问题
解决方案
文件修改
backend/app/api/wecom.py- 连接模式优先级优化frontend/src/components/ChannelConfig.tsx- Webhook状态显示测试
工具批量删除
企业微信配置
Summary
Checklist