Skip to content

fix(formatting): render a pasted image placeholder only once - #1604

Merged
edenreich merged 1 commit into
mainfrom
fix/issue-1603
Oct 26, 2026
Merged

edenreich merged 1 commit into
mainfrom
fix/issue-1603

Conversation

@inference-gateway-maintainer

@inference-gateway-maintainer inference-gateway-maintainer Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

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, and formatting.ExtractTextFromContent appended 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, headless run encoder, 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: ExtractTextFromContent no 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_AddImageAttachmentRendersOnce reproduces the user flow end to end - one AddImageAttachment, the message built the way ChatMessageProcessor.buildUserMessage builds it, then a single ​[Image 1] render (fails on main, passes with the fix).

Checked with task test, task vet and task 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.

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.
@github-project-automation github-project-automation Bot moved this to Todo in 2026 Oct 26, 2026
@inference-gateway-maintainer
inference-gateway-maintainer Bot marked this pull request as ready for review October 26, 2026 21:25
@inference-gateway-maintainer
inference-gateway-maintainer Bot requested a review from a team as a code owner October 26, 2026 21:25
@edenreich
edenreich merged commit ad0de80 into main Oct 26, 2026
1 check passed
@edenreich
edenreich deleted the fix/issue-1603 branch October 26, 2026 21:37
@edenreich edenreich moved this from Todo to Done in 2026 Oct 26, 2026
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.236.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[BUG] Pasting an image from the clipboard results in duplicate

1 participant