feat: 为平台日志增加剔除用户对话功能#9165
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a feature to filter out user chat logs from the console display. It tags user chat logs with a category extra field in the backend, and adds a toggle switch in the frontend console page to hide these logs, persisting the setting in local storage. The review feedback suggests handling cases where category might be explicitly set to None or an empty string in the logging backend, using optional chaining to simplify null checks in the frontend, and adding the missing Russian translation file that was omitted from the changes.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| "hideUserChat": { | ||
| "enabled": "User chat hidden", | ||
| "disabled": "Hide user chat" | ||
| }, |
| isHiddenByCategory(log) { | ||
| return this.hideUserChat && log && log.category === 'user_chat'; | ||
| }, |
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Modifications / 改动点
平台日志新增「排除用户对话」开关,方便排查插件/调用类 bug
为 WebUI 「平台日志」页面新增一个开关,开启后过滤掉冲屏的用户收发消息日志,只保留插件调用、Provider 调用、pipeline 调度、异常堆栈等系统侧日志,便于快速定位 bug。
功能简介:
v-switchlocalStorage(console_hide_user_chat),刷新后恢复category标签,默认system;用户收发消息日志标user_chatcategory字段的老条目按system处理,不会被误隐藏,向后兼容改动文件:
astrbot/core/log.py_RecordEnricherFilter.filter()为LogRecord注入默认record.category = "system"_patch_record()在 loguru extra 中设默认category为system,保持对称LogQueueHandler.emit()在发布到LogBroker的字典中新增category字段astrbot/core/event_bus.py_print_event()两处logger.info(...)增加extra={"category": "user_chat"},标记收到用户消息的日志astrbot/core/pipeline/respond/stage.pylogger.info(f"Prepare to send - ...")增加extra={"category": "user_chat"},标记回复用户消息的日志systemdashboard/src/components/shared/ConsoleDisplayer.vuehideUserChat: Boolean(默认false)isHiddenByCategory(log):当hideUserChat && log.category === 'user_chat'时返回 trueprocessNewLogs()与refreshDisplay()中在已有级别筛选基础上复合&& !this.isHiddenByCategory(log)hideUserChatprop 的 watcher,变化时调用refreshDisplay()dashboard/src/views/ConsolePage.vuedata()新增hideUserChatEnabled,从localStorage('console_hide_user_chat')初始化v-switchwatch.hideUserChatEnabled写 localStorage<ConsoleDisplayer>新增:hide-user-chat="hideUserChatEnabled"单向 prop 绑定dashboard/src/i18n/locales/{zh-CN,en-US,ru-RU}/features/console.jsonhideUserChat.enabled/hideUserChat.disabled文案Screenshots or Test Results / 运行截图或测试结果
验证步骤:
[平台] xxx/xxx: ...收消息行、Prepare to send - ...回复行、插件 handler / Provider / stage 调度日志)均显示[平台] xxx/xxx: ...收消息行被隐藏Prepare to send - xxx/xxx: ...回复行被隐藏category字段的老条目不被误隐藏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 categorization to platform logs and a UI toggle to hide user chat entries from the console view.
New Features:
Enhancements: