Repository navigation
fix(formatting): render a pasted image placeholder only once - #1604
Merged
Merged
Conversation
When the chat paste attaches an image it inserts a literal [Image N] token into the user's text, and ExtractTextFromContent appended another generated token for the same image part, so every renderer showed [Image 1] [Image 1] for a single paste. Skip the generated placeholder when the text part already carries that token - this fixes the conversation view, headless run encoder, queue box and judge at once while keeping the in-input token.
inference-gateway-maintainer
Bot
marked this pull request as ready for review
October 26, 2026 21:25
inference-gateway-maintainer
Bot
requested a review
from a team
as a code owner
October 26, 2026 21:25
Contributor
|
🎉 This PR is included in version 0.236.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
Resolves #1603
Summary
Pasting one image made every renderer show
[Image 1] [Image 1]because two places produced the placeholder: the paste inserts a literal[Image 1]into the user's text, andformatting.ExtractTextFromContentappended a second generated token for the same image part. The generated token is now skipped when the text part already carries that exact token, which fixes the duplicate in the conversation view, headlessrunencoder, queue box and judge with one change, while keeping the in-input token that tells the user where the image sits in the text.Changes
internal/platform/formatting/formatting.go:ExtractTextFromContentno longer appends the generated[Image N]placeholder when the accumulated text already contains it (the TUI paste inserts the token before sending, so the text part arrives with the token embedded).internal/platform/formatting/formatting_extra_test.go: table cases for the repro ([Image 1]+ image part renders once), token beside prose staying as typed, and one token suppressing only its own image ([Image 1]+ two image parts still yields[Image 1] [Image 2]).internal/presentation/tui/components/input_view_test.go:TestInputView_AddImageAttachmentRendersOncereproduces the user flow end to end - oneAddImageAttachment, the message built the wayChatMessageProcessor.buildUserMessagebuilds it, then a single[Image 1]render (fails on main, passes with the fix).Checked with
task test,task vetandtask precommit:run(0 issues).Docs: no docs ticket needed for the code itself - no docs page documents the
[Image N]placeholder rendering (checked configuration-reference.md, directory-structure.md and shortcuts-guide.md). Filing a best-effort tracking issue in inference-gateway/docs anyway for this user-facing rendering change.