Commit 6f86534
fix: render Anthropic base64 images in request viewer (#5555)
* fix: render Anthropic base64 images in request viewer
The Anthropic parser was extracting raw base64 data from message.source.data
without including the data: URL prefix or mime_type. The ChatMessage ImageContent
component requires either a proper data URL (with 'base64,' in it) or an http(s) URL.
Changes:
- Extract mime_type from message.source.media_type (default to image/png)
- Format base64 data as proper data URL: data:{mimeType};base64,{data}
- Store base64 data in content field and mime_type for fallback rendering
Fixes image rendering in browser automation sessions and other Anthropic multimodal requests.
* debug: add logging for Anthropic image parsing
* fix: add unoptimized flag for data URL images and debug logging
* fix: move useMemo hook before early return to fix React hooks order violation
The groupedItems useMemo was being called after an early return statement,
which violated React's rules of hooks (hooks must be called in the same order
every render). This caused 'Rendered more hooks than during the previous render'
error when clicking on requests in the detail panel.
* chore: remove debug logging from Anthropic image parser and ImageContent component
Cleanup after verifying the parser correctly generates data:image/png;base64 URLs
for Anthropic image messages.
* fix: render Anthropic images in request viewer
- Fix contentArray filtering to include image types (was checking content.content but images use image_url)
- Add unoptimized flag for data URL images in Next.js Image component
- Remove debug logging
* test: add mime_type field to Anthropic image test expectations
Update test assertions to include the mime_type field that was added
to image content objects in the Anthropic request parser fix.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* fix: make mime_type optional and only set for base64 source data
The mime_type field should only be set when we have actual base64 data
from the source field. For images that are already URLs (http/https or
data URLs), the mime_type is not relevant and should be omitted.
Changes:
- Updated requestParser to conditionally include mime_type only when
base64Data exists
- Updated existing test expectations to not include mime_type for URL
images
- Added new test case specifically for base64 source images that verifies
mime_type is correctly included with the proper media type
This addresses the AI review feedback about mime_type being optional
and ensures we only set it when it's actually needed for base64 content.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Justin Torre <justin@Justins-MacBook-Pro.local>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent 4345e74 commit 6f86534
File tree
4 files changed
+82
-18
lines changed- packages
- __tests__/llm-mapper
- llm-mapper/mappers/anthropic
- web/components/templates/requests/components
- chatComponent
4 files changed
+82
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
302 | 302 | | |
303 | 303 | | |
304 | 304 | | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
305 | 355 | | |
306 | 356 | | |
307 | 357 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
57 | 62 | | |
58 | | - | |
| 63 | + | |
59 | 64 | | |
60 | 65 | | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
| 66 | + | |
| 67 | + | |
65 | 68 | | |
66 | 69 | | |
67 | 70 | | |
| |||
Lines changed: 11 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
358 | 358 | | |
359 | 359 | | |
360 | 360 | | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | 361 | | |
| 362 | + | |
372 | 363 | | |
373 | 364 | | |
374 | 365 | | |
| |||
398 | 389 | | |
399 | 390 | | |
400 | 391 | | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
401 | 402 | | |
402 | 403 | | |
403 | 404 | | |
| |||
Lines changed: 13 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
192 | 192 | | |
193 | 193 | | |
194 | 194 | | |
| 195 | + | |
195 | 196 | | |
196 | 197 | | |
197 | 198 | | |
| |||
204 | 205 | | |
205 | 206 | | |
206 | 207 | | |
207 | | - | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
208 | 211 | | |
209 | 212 | | |
210 | 213 | | |
211 | 214 | | |
212 | 215 | | |
213 | 216 | | |
214 | 217 | | |
215 | | - | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
216 | 221 | | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
217 | 225 | | |
218 | 226 | | |
219 | 227 | | |
| |||
225 | 233 | | |
226 | 234 | | |
227 | 235 | | |
| 236 | + | |
228 | 237 | | |
229 | 238 | | |
230 | 239 | | |
| |||
822 | 831 | | |
823 | 832 | | |
824 | 833 | | |
| 834 | + | |
825 | 835 | | |
826 | | - | |
| 836 | + | |
827 | 837 | | |
828 | 838 | | |
829 | 839 | | |
| |||
0 commit comments