Fix: Allow SVG files as chat attachments (as code/text, not images) #270608
+8
−3
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.
Fixes #228766
Problem
When dragging an SVG file into the chat input, it would show a yellow warning stating "does not support this file type" and prevent the file from being attached. This was problematic because SVG files are text-based XML documents that agents can edit just like any other text file.
Root Cause
The
containsImageDragType()
andextractImageFilesFromDragEvent()
functions inchatDragAndDrop.ts
were detecting SVG files as images (since their MIME type starts withimage/
), which caused them to go through the image handling path. However, SVG files should be treated as code/text files that agents can edit, not as binary images that models cannot understand.Changes
Modified drag-and-drop image detection in
src/vs/workbench/contrib/chat/browser/chatDragAndDrop.ts
:isImageMimeType()
helper function that excludes SVG files from image detectioncontainsImageDragType()
to use the new helper, filtering outimage/svg*
MIME typesextractImageFilesFromDragEvent()
to use the new helperThis allows SVG files to be handled as regular text/code files that can be attached and edited, while other image formats (PNG, JPEG, GIF, WebP) continue to be handled as images.
Impact
Fixes #270607
Original prompt
Fixes #270607
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.