#17676: fix: support HEIC/HEIF/AVIF image attachments
stale
size: S
Cluster:
Attachment Processing Enhancements
## Problem
HEIC images sent via iMessage (and other channels) are not delivered to the agent context. The attachment metadata is captured correctly, but:
1. `resolveAttachmentKind()` doesn't recognize `.heic`/`.heif`/`.avif` extensions, so these attachments are classified as `unknown` instead of `image`
2. Even when MIME type detection works, HEIC files aren't converted to a format supported by vision models
## Changes
**`src/media-understanding/attachments.ts`:**
- Add `.heic`, `.heif`, `.avif` to the image extension list in `resolveAttachmentKind()`
- Add HEIC→JPEG conversion using macOS `sips` in the local file path of `MediaAttachmentCache.getBuffer()`
- Conversion is best-effort — falls through to the original buffer if `sips` is unavailable or fails
## Notes
- `sips` is available on all macOS installations (ships with the OS)
- Conversion uses a temp directory that is cleaned up in a `finally` block
- Non-macOS hosts will skip conversion gracefully (sips not found → catch → original buffer)
Fixes #17670
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Adds support for HEIC/HEIF/AVIF image extensions and implements macOS `sips`-based conversion to JPEG for HEIC/HEIF files. The PR correctly identifies these formats as images and converts local HEIC/HEIF files to JPEG before sending to vision models.
**Critical issue found:**
- Remote HEIC/HEIF/AVIF attachments fetched via URL bypass the conversion logic entirely and will be sent to vision models in their original format, likely causing failures
**Issues noted in previous review threads (not re-commented):**
- AVIF files are recognized as images but not included in the conversion logic
- No verification that macOS `sips` supports AVIF format
<h3>Confidence Score: 2/5</h3>
- This PR has a critical logic gap that will cause remote HEIC/HEIF/AVIF attachments to fail
- Score reflects a significant functional gap: the conversion logic only applies to local file paths, not remote URLs. Remote HEIC/HEIF/AVIF attachments (a common scenario for iMessage and other messaging channels) will bypass conversion and fail at the vision model. Additionally, AVIF support is incomplete as noted in previous threads.
- Pay close attention to `src/media-understanding/attachments.ts` - the remote URL code path needs the same conversion logic as the local file path
<sub>Last reviewed commit: 2eed6f3</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#17842: Fix Google Chat media upload failure by inferring content-type from...
by Clawborn · 2026-02-16
71.4%
#22113: feat: support non-image file attachments in webchat chat.send
by Kt-L · 2026-02-20
70.0%
#10394: feat(mattermost): add image attachment support for inbound messages
by mithril-logic · 2026-02-06
69.5%
#20480: feat(slack): extract and surface attachment notes in messages
by olyashok · 2026-02-19
69.3%
#4534: fix: packaging and OpenAI vision format conversion
by SalimBinYousuf1 · 2026-01-30
68.6%
#8076: fix(web): handle data URLs in loadWebMedia to prevent ENAMETOOLONG
by batumilove · 2026-02-03
68.6%
#16346: feat: support image attachments in OpenAI chat completions endpoint
by sh1nj1 · 2026-02-14
68.5%
#22781: fix(webchat): persist chat attachments after guards and expose medi...
by Kansodata · 2026-02-21
68.4%
#18763: fix(slack): add auth header when downloading forwarded attachment i...
by amabito · 2026-02-17
68.0%
#20913: fix: intercept Discord embed images to enforce mediaMaxMb
by MumuTW · 2026-02-19
67.5%