#8284: Fix: Webchat images now persist after sending
app: web-ui
Cluster:
Web UI Enhancements and Fixes
When pasting images into webchat, they were being sent with the full data URL (including the "data:image/png;base64," prefix) instead of just the base64 content. This caused the images to disappear from the chat display after sending.
The fix extracts just the base64 content and mime type using the existing dataUrlToBase64() helper function, which was already being used for the API attachments but not for the display content blocks.
Fixes #8269
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR fixes webchat image persistence by normalizing pasted image attachments when building the *display* content blocks in `sendChatMessage`. Previously the UI stored `att.dataUrl` (a full `data:*;base64,...` URL) inside a `{type: "base64", data: ...}` source, which the renderer expects to contain only base64 content; now it reuses the existing `dataUrlToBase64()` helper to extract `{mimeType, content}` and stores just the base64 payload.
This aligns the message preview format with the renderer in `ui/src/ui/chat/grouped-render.ts` (which reconstructs a proper `data:${media_type};base64,${data}` URL when needed) and matches how attachments were already being prepared for the API request.
<h3>Confidence Score: 4/5</h3>
- This PR is likely safe to merge and fixes the reported rendering issue, with a minor behavioral change for unexpected attachment formats.
- Change is small and localized: it uses an existing parser already used for API attachments, and the renderer already supports raw base64 in `source.data`. Main remaining concern is that invalid/non-base64 data URLs will now result in silently missing previews.
- ui/src/ui/controllers/chat.ts
<!-- greptile_other_comments_section -->
<sub>(4/5) You can add custom instructions or style guidelines for the agent [here](https://app.greptile.com/review/github)!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#4269: fix: support tool result image format in Control UI
by bobcyw · 2026-01-30
83.6%
#22333: Fix webchat inline image rendering and size handling
by AIflow-Labs · 2026-02-21
82.2%
#6663: Web UI: handle drag-drop image attachments
by mar0der · 2026-02-01
81.6%
#14966: fix(webchat): preserve user message visibility after chat.send
by BenediktSchackenberg · 2026-02-12
80.2%
#3721: fix(ui): webchat not displaying chat responses
by maxmaxrouge-rgb · 2026-01-29
79.7%
#22113: feat: support non-image file attachments in webchat chat.send
by Kt-L · 2026-02-20
78.5%
#21042: fix(ui): render images in tool result messages
by Mellowambience · 2026-02-19
78.5%
#14309: fix(ui): resolve chat event session key mismatch
by justonlyforyou · 2026-02-11
78.1%
#10441: webchat: switch file uploads to HTTP /uploads
by supernewbilityxht1 · 2026-02-06
78.1%
#8742: fix(webchat): hide internal system messages from UI (#7440)
by revenuestack · 2026-02-04
77.7%