GeezerVison is showing github.com — feat(ui): display image attachments from tool results by johnwmail · Pull Request #38846 · anomalyco/opencode
Conversation
johnwmail
commented
Jul 25, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Issue for this PR
Closes #21227
Type of change
What does this PR do?
Tool results can carry image attachments (state.attachments with an image mime type) — e.g. MCP ImageCo ntent blocks from browser/screenshot tools, or images returned by the built-in read tool. They are forw
arded to the model, but the web UI never renders them.
This PR renders image attachments as clickable thumbnails below completed tool calls; clicking a thumbnail
opens the existing ImagePreview dialog.
A small shared ToolImageAttachments component is used in both tool rendering paths:
ToolPartDisplay — MCP tools and other non-grouped tools
ContextToolGroup — the read/grep/glob group row, so images produced by the read tool are visible wit
hout expanding the group
Non-image attachments and non-completed tool states render nothing, as before.
How did you verify your code works?
Ran the backend (bun run --conditions=browser ./src/index.ts serve --port 4096) and the app dev server (
bun dev -- --port 4444) locally, then drove the UI headlessly with Playwright:
- Asked the agent to
read a PNG file → thumbnail strip appears below the "Exploring · 1 read" group row
; clicking it opens the full-size preview dialog.
- Registered a mock MCP server whose tool returns an
ImageContent block → thumbnail appears directly un
der the Called mock-img_take_screenshot row.
Also ran tsgo --noEmit (clean), prettier --check, oxlint (no new issues), and the existing message- part.test.ts (6 pass).
Screenshots / recordings
MCP tool returning an image:
read tool on an image file (context group row):
Clicking a thumbnail opens the full-size preview:
Checklist
- I have tested my changes locally
- I have not included unrelated changes in this PR
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
TheOriginal92 reacted with thumbs up emoji
Tool results can include image attachments (e.g. MCP ImageContent blocks
from browser/screenshot tools, or images returned by the read tool), but
the web UI never rendered them - they were only forwarded to the model.
Show clickable image thumbnails below completed tool calls, for both
rendering paths:
- ToolPartDisplay (MCP and other non-grouped tools)
- ContextToolGroup (read/grep/glob group row)
Clicking a thumbnail opens the existing ImagePreview dialog.
Closes #21227
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Validated this fix against a shipped OpenCode Desktop build. I ported the exact change (ToolImageAttachments in ContextToolGroup + ToolPartDisplay) onto the Electron renderer bundle and tested it live:
- Custom plugin tool returning
{type:"file", mime:"image/png"} attachments → 48px thumbnail renders in the tool row, click opens the fullscreen ImagePreview. Works in both the plain tool row and the context (read/search) tool group.
- Model-side media forwarding is unaffected; attachments still reach the provider as before.
- Confirmed the failure mode this fixes: tool-result images were previously invisible in the UI even though stored correctly in
part.state.attachments.
One observation from testing (not a blocker): the server's tool-result image normalization (image.normalize) upscales small images to ~1200px before storing, so tiny source images look soft at fullscreen preview. Native-resolution photos render crisp.
Thanks for the fix — looking forward to it landing so I can drop my local patch.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Automated PR Cleanup
Thank you for contributing to opencode.
Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.
This PR was closed because it matched the following cleanup criteria:
- The PR was created more than 1 month ago
- The PR had fewer than 2 positive reactions
- Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR
PRs created within the last month are not affected by this cleanup.
If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.
Thanks again for taking the time to contribute.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Also hitting this on opencode web (1.18.5, Docker). Images returned by MCP tools are converted to data: URIs in session/tools.ts and stored in part.state.attachments; they reach the model correctly, but the chat UI never renders them, so the only way to look at a screenshot a tool just produced is to open the file outside opencode.
This PR was closed by the automated cleanup rather than on review, and it already carries an independent verification against a Desktop build in the thread above. Could a maintainer either reopen it, or point at #39817 as the preferred direction so the effort isn't split across two patches?
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
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.
|