Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Oct 9, 2025

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() and extractImageFilesFromDragEvent() functions in chatDragAndDrop.ts were detecting SVG files as images (since their MIME type starts with image/), 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:

  • Added isImageMimeType() helper function that excludes SVG files from image detection
  • Updated containsImageDragType() to use the new helper, filtering out image/svg* MIME types
  • Updated extractImageFilesFromDragEvent() to use the new helper

This 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

  • ✅ SVG files can now be attached to chat without warnings
  • ✅ SVG files are treated as text/code that agents can edit
  • ✅ Models receive SVG as editable text content, not as image data
  • ✅ Other image formats continue to work correctly as images
  • ✅ Minimal, surgical changes to existing code

Fixes #270607

Original prompt

This section details on the original issue you should resolve

<issue_title>Can't attach an SVG to have the agent edit it</issue_title>
<issue_description>
Type: Bug

Drag SVG into chat input.
🐛 Yellow warning color and struck out as "… does not support this file type."

It is just text, and the agent could edit it just fine. Don't restrict it by treating it as unsupported image.

VS Code version: Code - Insiders 1.105.0-insider (Universal) (03c265b, 2025-10-08T14:07:41.558Z)
OS version: Darwin arm64 24.6.0
Modes:

System Info
Item Value
CPUs Apple M4 Pro (14 x 2400)
GPU Status 2d_canvas: enabled
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: enabled_on
trees_in_viz: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) 9, 7, 6
Memory (System) 24.00GB (0.44GB free)
Process Argv --log trace --enable-proposed-api digitarald.agent-memory --crash-reporter-id 9b206efe-c338-4f34-baff-2aab1c48a82e
Screen Reader no
VM 0%

Comments on the Issue (you are @copilot in this section)

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.

Co-authored-by: digitarald <8599+digitarald@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Fix SVG attachment error in agent edit feature Fix: Allow SVG files as chat attachments Oct 9, 2025
@Copilot Copilot AI requested a review from digitarald October 9, 2025 17:49
Copilot finished work on behalf of digitarald October 9, 2025 17:49
@digitarald
Copy link
Contributor

@copilot > The CHAT_ATTACHABLE_IMAGE_MIME_TYPES constant only included raster image formats (PNG, JPEG, GIF, WebP) but was missing SVG support.

But I don't want SVG to be handled as image, but as code. The models don't understand SVG as images anyways

Co-authored-by: digitarald <8599+digitarald@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 10, 2025

@copilot > The CHAT_ATTACHABLE_IMAGE_MIME_TYPES constant only included raster image formats (PNG, JPEG, GIF, WebP) but was missing SVG support.

But I don't want SVG to be handled as image, but as cod...

You're absolutely right. I've revised the approach to treat SVG files as code/text instead of images.

The fix now excludes SVG files from image detection in the drag-and-drop logic by adding a helper function that filters out image/svg* MIME types. This allows SVG files to be attached and edited as text content while other image formats (PNG, JPEG, etc.) continue to be handled as images.

Changes in commit 5c7a8b4.

@Copilot Copilot AI changed the title Fix: Allow SVG files as chat attachments Fix: Allow SVG files as chat attachments (as code/text, not images) Oct 10, 2025
Copilot finished work on behalf of digitarald October 10, 2025 23:42
@digitarald digitarald closed this Oct 11, 2025
@digitarald digitarald deleted the copilot/fix-svg-attachment-bug branch October 11, 2025 03:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't attach an SVG to have the agent edit it Test: getting started experience for accessibility users

2 participants