feat: add opt-in real nickname controls#8713
Conversation
新增用户真实昵称展示相关配置开关,支持在用户识别元数据中追加真实昵称,或在开启后仅向模型提供真实昵称。 将用户和群组身份信息改为结构化 JSON 元数据,并对昵称、群名等外部输入进行清洗,降低控制字符、零宽字符和伪造标签边界对提示词结构的干扰。 补充 WebUI 配置文案与条件项过渡动画,并增加单元测试覆盖默认行为、真实昵称回退、清洗、去重和对象形态 raw_message 读取。
There was a problem hiding this comment.
Code Review
This pull request introduces features to append and display a user's real nickname in system reminders, along with robust metadata sanitization and formatting. Key changes include adding helper functions to clean metadata values (removing control characters, zero-width characters, and escaping HTML-like tags), updating the configuration schema and localized strings, and wrapping configuration items in the dashboard with a TransitionGroup for smoother UI transitions. Unit tests were also added to verify the new metadata processing and fallback behaviors. Feedback on the changes highlights a potential layout issue in the dashboard transition styles: hardcoding max-height to 180px in the TransitionGroup styles can cause items taller than 180px to be clipped or experience sudden height jumps during transitions. It is recommended to remove the max-height transition and only animate opacity and transform to ensure compatibility with varying item heights.
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.
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In
_append_system_reminders, real-nickname de-duplication currently comparesreal_nickname(unsanitized) againstsanitized_user_nickname; if you want to ensure zero-width/control-character differences don’t cause redundant metadata, consider sanitizingreal_nicknamebefore the equality check and reuse that sanitized value in_format_metadata. - In
AstrBotConfigV4.vue,createSelectorModel(itemKey).valueis called multiple times per item (including insidev-ifs andv-for), which can lead to unnecessary recomputation; you could cache the model per item (e.g., via a computed or local variable inside the loop) to avoid repeated calls.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `_append_system_reminders`, real-nickname de-duplication currently compares `real_nickname` (unsanitized) against `sanitized_user_nickname`; if you want to ensure zero-width/control-character differences don’t cause redundant metadata, consider sanitizing `real_nickname` before the equality check and reuse that sanitized value in `_format_metadata`.
- In `AstrBotConfigV4.vue`, `createSelectorModel(itemKey).value` is called multiple times per item (including inside `v-if`s and `v-for`), which can lead to unnecessary recomputation; you could cache the model per item (e.g., via a computed or local variable inside the loop) to avoid repeated calls.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
移除条件配置项过渡动画中的 max-height 动画,避免较高配置项在进入或离开过渡时被裁切或出现高度跳变。
|
关于 Sourcery 的两点建议,已逐项确认:
补充:关于 Gemini 对 已重新执行 |
撤销此前移除 max-height 过渡的调整。该调整会让条件配置项关闭时直接消失,缺少折叠收起动画;恢复原有高度过渡以保持展开和收起体验一致。
在群聊场景中,当前用户识别信息里的
nickname通常来自群昵称或群名片。这个值更适合作为群内展示名,但它可能被频繁修改,也可能和用户真实昵称不一致。对依赖用户识别、长期上下文或个性化回复的场景来说,模型只能看到群昵称会影响身份信息的一致性。本次改动增加两个默认关闭的真实昵称相关开关,让部署者可以按需选择“追加真实昵称”或“仅使用真实昵称”。未启用新开关时,现有行为保持不变。
同时,本次改动将用户和群组身份信息整理为结构化 JSON 元数据,并对昵称、真实昵称、群名等外部输入做基础清洗,减少控制字符、零宽字符和伪造标签边界对提示词结构的干扰。
Modifications / 改动点
provider_settings.real_nickname_display开关,开启后在支持的平台上向模型额外提供用户真实昵称。provider_settings.real_nickname_only开关,开启后模型只看到真实昵称;当真实昵称不可用或清洗后为空时,回退到原昵称。User metadata: {"user_id":"...","nickname":"..."}。raw_message读取。Screenshots or Test Results / 运行截图或测试结果
已执行以下验证:
本地手动验证:
http://localhost:3000/#/config#normal。Checklist / 检查清单
Summary by Sourcery
Add configurable support for exposing users’ real nicknames and structured metadata in system reminders, along with UI and test updates.
New Features:
Enhancements:
Tests: