Repository navigation
fix(wework): keep image previews loaded across session event updates - #2479
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
ChangesAttachment preview lifecycle
Estimated code review effort: 2 (Simple) | ~15 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@wework/src/components/chat/AttachmentImagePreview.tsx`:
- Around line 285-287: Update reusablePreviewUrl in AttachmentImagePreview to
compare each attachment’s complete preview identity using local_preview_url ??
local_path, while retaining the ID comparison. Add a lightbox regression case in
AttachmentImagePreview.test.tsx covering equal IDs, different local_path values,
and absent local_preview_url.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 10501d12-84de-4a54-a1d2-8f5d6380b2eb
📒 Files selected for processing (2)
wework/src/components/chat/AttachmentImagePreview.test.tsxwework/src/components/chat/AttachmentImagePreview.tsx
问题
会话事件更新时,若当前 turn/run 中带有图片(用户消息附件、
view_image/image_generation生成的图片),图片预览会频繁回到 loading 占位状态,导致会话消息区域跳动。根因
AttachmentImagePreview的预览加载 effect 依赖attachment对象引用。会话事件流式更新会通过 turn 投影、block 更新、快照合并等路径重建消息/附件对象(内容相同、引用全新),每次都会触发 effect 重新执行,把previewUrl重置为null并回到 loading。修复
id + local_preview_url/local_path)为依赖,通过 ref 读取最新 attachment,避免对象引用变化导致重复加载;验证
ai:verify在隔离的真实 Tauri 会话中启动确认工作台正常渲染。Summary by CodeRabbit