feat: 为聊天消息和工具调用块添加角色头像#231
Open
SpikeJulia wants to merge 6 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
为 pi-web 添加按角色显示的头像支持:用户(蓝色 U)、助手(紫色 A)、工具(灰色 T)的默认头像出现在聊天消息旁以及工具调用块的头部。用户可通过「设置 → 头像」上传自定义头像,按项目保存在
<cwd>/.pi/avatars.json,并支持恢复默认。改动内容
五张功能 ticket
fac79a1— 聊天区默认角色头像:通过Avatar组件在MessageView中渲染用户(蓝色 U)、助手(紫色 A)、工具(灰色 T)29a6c50— 头像设置面板:AppShell 新增入口,提供只读预览模态框和GET /api/avatars?cwd=接口(含安全的默认加载逻辑)681cb78— 自定义头像上传:浏览器端 resize 处理、PUT /api/avatars接口(按项目隔离)、AvatarConfigProvider上下文1aa1133— 头像恢复控件:每个角色可单独重置为默认,draft/save 用户体验与上传一致3e337a5— 上传硬化:拒绝 SVG/不支持的 MIME、无法解码的图片、超过 2 MB 编码大小的 data URL;所有拒绝操作均保留 draft 和已保存状态Bug 修复
cdbaa9c— 修复头像上传时OffscreenCanvas缺少toDataURL的问题(浏览器上传会抛s.toDataURL is not a function)涉及文件
验证结果
npm run lint✓npx tsc --noEmit✓npm run build --turbopack✓功能说明
<cwd>/.pi/avatars.json→ 聊天立即更新{user:null, assistant:null, tool:null},不会自动创建文件备注
<项目目录>/.pi/avatars.json(与 Pi 项目本地约定一致)next build --turbopack(webpack 模式会扫描用户目录中的符号链接导致权限错误)