fix: save pasted clipboard images to temp files to support MCP tools (#14673)#21547
fix: save pasted clipboard images to temp files to support MCP tools (#14673)#21547mikwiseman wants to merge 1 commit intoanomalyco:devfrom
Conversation
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
|
The following comment was made by an LLM, it may be inaccurate: Based on my search results, here are the potentially related PRs: Related PRs found:
These PRs appear to address similar problems in the clipboard/drag-drop image handling space, though they may have been closed or merged already. The current PR (#21547) is specifically focused on the clipboard paste scenario with temporary file storage for MCP tool compatibility. |
|
This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window. Feel free to open a new pull request that follows our guidelines. |
Issue for this PR
Closes #14673
Type of change
What does this PR do?
Currently, when an image is pasted from the clipboard into the prompt, it gets converted to a Base64 data URL and sent directly to the language model. While this works for multimodal models, it breaks workflows where non-vision models (like GLM-5.1) rely on external MCP tools (like
zai-vision) because these tools typically expect a valid file path on disk, not a raw Base64 string.This PR modifies the
pasteAttachmentfunction inpackages/opencode/src/cli/cmd/tui/component/prompt/index.tsx.When an image is pasted from the clipboard (i.e. no
filepathexists), it:os.tmpdir().file://...) as the attachment URL.How did you verify your code works?
Compiled
opencodelocally (bun run build), confirmed that pasting images from clipboard now creates a temporary image file under/tmp, and verified that MCP servers can now read these files properly without throwing Base64 parsing errors.Screenshots / recordings
Checklist
If you do not follow this template your PR will be automatically rejected.