fix: properly render DALL-E/gpt-image responses in request drawer#5542
fix: properly render DALL-E/gpt-image responses in request drawer#5542
Conversation
- Add `role: "assistant"` to response messages so ChatOnlyView displays them - Add `request.messages` array with user prompt for proper Chat component rendering - Add `data:image/png;base64,` prefix for base64 images so ImageContent can process them The DALL-E mapper was not properly structuring messages for the UI: 1. Response messages lacked a `role` field, causing them to be filtered out 2. Request didn't include a `messages` array, so the user prompt wasn't shown 3. Raw base64 strings from OpenAI's `b64_json` weren't being recognized as images Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
Claude finished @chitalian's task —— View job PR Review: DALL-E Image Rendering FixTodo List:
Score: 8/10 - Good to merge with minor suggestionsThis is a solid fix that properly addresses the rendering issues for DALL-E generated images. The implementation is correct and well-tested. Detailed Review✅ Strengths
🔍 Minor Suggestions for Improvement1. Image Type Detection Enhancement (dalle.ts:41)// Current: Always assumes PNG
: `data:image/png;base64,${rawImageData}`
// Suggestion: Detect image type or make it configurable
: `data:image/${request.response_format === 'b64_json' ? 'png' : 'png'};base64,${rawImageData}`2. Type Safety Enhancement (dalle.ts:36-37)The code accesses nested properties without type guards: // Consider adding optional chaining validation
const rawImageData = response?.data?.[0]?.b64_json || response?.data?.[0]?.url || "";This is actually well-handled, but could benefit from stronger typing. 3. Test Robustness (dalle.test.ts:18)The test uses a very short base64 string // More realistic test data
b64_json: "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg=="🔐 Security Assessment
🎯 Performance Assessment
Suggestions Summary:
✅ Ready to MergeThis PR effectively solves the stated problem with a clean, well-tested implementation. The minor suggestions above are optional improvements that don't block merging. |
Summary
rolefield to response messages so they appear in ChatOnlyViewrequest.messagesarray so user prompts are displayeddata:image/png;base64,prefix for base64 images so ImageContent can render themProblem
After PR #5536 added cost support for gpt-image models, the generated images weren't rendering in the request drawer. The UI showed "No user or assistant messages found in this request."
Root Cause
The DALL-E mapper was not properly structuring messages for the UI:
rolefield, causing ChatOnlyView to filter them outmessagesarray, so the Chat component didn't show the user promptb64_jsonfield weren't being recognized as images by ImageContent (which checks forbase64,orhttps://in the URL)Test plan
npx jest llm-mapperScreenshot
🤖 Generated with Claude Code