feat(image): cross-platform clipboard paste, SVG support, and multi-model image handling#197
Merged
Merged
Conversation
…odel image handling - Add src/utils/image/media.ts: magic-byte detection, MIME normalization, SVG rasterization - Add src/utils/model/visionContent.ts: extract text+images from mixed content, convert formats - FileReadTool: SVG rasterized to PNG, detect media type from magic bytes instead of extension - imagePaste.ts: now supports Windows (PowerShell) and Linux (wl-paste/xclip) in addition to macOS - ClipboardImage struct replaces raw base64 string, preserving actual media type - ChatCompletions adapter: tool result images become adjacent user vision messages - ResponsesAPI adapter: user images become input_image, tool result images become function_call_output - openaiMessageConversion: tool result images become adjacent user vision messages with MIME preserved - UI: onImagePaste now receives ClipboardImage struct for accurate media type - Tests: 13 new cases covering media detection, SVG, chat-completions, responses-api, message conversion
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.
Summary
Cross-platform image handling: clipboard paste on all platforms, SVG support, and multi-model image passthrough.
New Modules
src/utils/image/media.tsdetectImageMediaType()- magic byte detection for PNG/JPEG/GIF/WebPnormalizeSupportedImageMediaType()- MIME normalization (image/jpg to image/jpeg)isSvgBuffer()/isSvgExtension()- SVG detectionrasterizeSvgToPng()- SVG to PNG via sharpimageBase64ToDataUrl()/imageBufferToDataUrl()- base64 to data: URLsrc/utils/model/visionContent.tsextractTextAndImageUrls()- split text and images from mixed content arraysgetImageUrlFromPart()- extract data: URLs from Anthropic, image_url, and input_image blockstoOpenAIImageUrlParts()/toResponsesImageParts()- format convertersEnhancements
Tests (+13 cases)
Gaps Closed