fix: avoid duplicate full-size image render in user messages - #533
Open
epheien wants to merge 1 commit into
Open
fix: avoid duplicate full-size image render in user messages#533epheien wants to merge 1 commit into
epheien wants to merge 1 commit into
Conversation
pi writes the attached image's path back into the user message text as a Markdown image reference. With image blocks present, that reference was rendered a second time at full size through MarkdownBody's local-path resolver, clipping inside the bubble's max-height. Strip those references from the text when image blocks already cover the picture.
epheien
force-pushed
the
fix/image-render
branch
from
August 17, 2026 10:38
1d9ad47 to
25c2beb
Compare
Author
Reproduction (before the fix)The same picture appears twice in one user message: once as the image-block thumbnail, once as a full-size image rendered from the Markdown reference pi injects into the text — cropped by the bubble's After this fix, only the thumbnail (clickable for a larger preview) is rendered. |
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.

Problem
When a user attaches an image, pi writes the attached image's path back into the user message text as a Markdown image reference (e.g.
). With image blocks present, that reference was rendered a second time at full size throughMarkdownBody's local-path resolver (/api/files), clipping inside the bubble's max-height — the same picture appeared twice in one user message:Fix
UserMessageViewnow strips Markdown image references from the text when image blocks are present (the picture is already rendered from the blocks). When there are no image blocks, local Markdown images keep working as before.Tests
does not re-render the markdown image reference when image blocks exist— fails on the old code (asserts no second/api/filesimage), passes with the fix; red-green verified against the parent commit.still renders local markdown images when there are no image blocks— regression guard for the non-image-block path.MessageView.test.mjssuite: 10/10 pass;tsc --noEmitandeslintclean.Known trade-off
When image blocks exist, all Markdown image references in the text are stripped, including ones manually written by the user (a rare case: hand-written local image reference + attached image in the same message). Since base64 image blocks don't carry the original file path, a precise "only strip the injected reference" match isn't reliably possible. Happy to refine if reviewers consider it necessary.