Files
coder/docs/ai-coder
Ethan 3787528621 fix: accept SVG chat attachments as download-only files (#29330)
Closes
https://linear.app/codercom/issue/CODAGT-1032/allow-svg-uploads-without-inline-rendering

SVG uploads to the agents chat were rejected with `Unsupported file
type`, as was SVG markup pasted as text. Pastes are wrapped as a
`text/plain` file, `ClassifyStoredMediaType` relabels the bytes
`image/svg+xml`, and `IsCompatibleUploadMediaType` didn't allow that
refinement.

This PR adds `image/svg+xml` to `codersdk.AllChatAttachmentMediaTypes`
and treats it like we already treat PDF: storable, but served with
`Content-Disposition: attachment` and never rendered inline, since SVG
can carry script. The model receives the source as inlined text rather
than an image part. No provider accepts SVG as a native part, so
`AcceptsFilePartMediaType` returns false for it up front; the Google
branch would otherwise accept it.

Whilst here, I've collapsed the three hand-synced lists of text types
the model can read (`isInlinableTextMediaType`, the `text/plain`
refinement switch, and `IsSyntheticPaste`) into
`chatfiles.IsTextAttachmentMediaType`. On the frontend, the
`startsWith("image/")` checks go through `isRasterImageMediaType`, so
SVG gets a file card instead of an `<img>`, thumbnail, or resize.

Dropping an unsupported file onto the composer now shows a toast naming
the rejected files instead of silently ignoring them.

Supersedes #26969.
2026-09-16 12:15:14 +10:00
..