Skip to content

Convert HEIC/HEIF photo attachments to JPEG so Claude and Codex accept them - #1677

Merged
currentbits merged 3 commits into
mainfrom
coder/transcode-heic-heif-attachments-to-jpeg--77e47f
Oct 18, 2026
Merged

currentbits merged 3 commits into
mainfrom
coder/transcode-heic-heif-attachments-to-jpeg--77e47f

Conversation

@currentbits

Copy link
Copy Markdown
Owner

iPhone photos (HEIC, the camera default) couldn't be attached as images. The picker filter skipped them, and anything that did get through went to the agent as a path that no provider can read as an image. Now every HEIC/HEIF attachment is converted to a JPEG before the agent sees it. The original file is not modified. Fixes #463.

Changes

  • Picker, Finder drop, web upload and web paste all convert HEIC/HEIF to JPEG in the main process. It tries sips first (built into macOS), then heif-convert, then ImageMagick. The JPEG goes into the thread's attachments folder, which the existing pruning already cleans up.
  • If no converter works (no thread selected, or Linux/Windows without libheif or ImageMagick), the file is attached as a plain file instead of an image the provider would reject.
  • The composer chip reads "converted from HEIC", so the user knows the file was changed. The agent sees the original file name next to the JPEG path.
  • .heic/.heif now show up in the picker's Images filter.

Verification

  • electron/test/attachments.test.js 20/20. This includes a real macOS round trip: a HEIC made with sips comes back as a JPEG, and the thumbnail path serves it as image/jpeg. The converter fallback order and the plain-file fallback are tested with a fake execFile.
  • On the tree merged with current main: renderer composer, attachments, paste-error and web-degrade tests pass (163/0), tsc --noEmit is clean and vite build succeeds.
  • Full test:electron before the merge with main: 4734 pass / 14 fail, none in attachment code. Four of the failing files (mcp-inject, provider-usage, worktrees, memory-sup) had 9 failures in one combined run, then passed 146/0 on a rerun of the same tree and also 146/0 on pre-change code. The other failures in that run were not rerun.
  • Not tested: real heif-convert/magick runs (only the fake), and clicking through the running app.

Notes for reviewers

  • classifyPaths now labels .heic as kind: "image". That is only true after transcodeHeic runs. Both of its callers (attachments:pick, attachments:fromPaths) go through it. A new caller that skips it would send a HEIC image path.
  • pick/fromPaths now take an optional threadId so the JPEG has a thread folder to live in. Without one, HEIC stays a plain file.
  • No decoder is bundled for non-mac users. We can add one if that becomes a real problem.

claude-opus-5-5 via Claude Code

🤖 Generated with Claude Code

Solenta and others added 2 commits October 18, 2026 21:40
Solenta-Message-Id: d3b1c9b5-333c-4659-99b9-5dcbec4b5a1c
Resolve useCoderWorkspace fromPaths: keep threadId, take main's saveImageOrNull.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-18T21:15:16.317754Z a250826 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a250826f5a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread electron/attachments.js
Comment on lines +356 to +357
return Promise.all(
list.map(async (a) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Limit concurrent HEIC decoder processes

When a user multi-selects or drops a large batch of HEIC photos, this Promise.all invokes heicToJpeg for every item simultaneously. Each conversion can launch up to three external processes with 30-second timeouts, so an ordinary photo album can create a child-process storm that exhausts CPU, memory, or process limits and stalls the attachment request; process these conversions sequentially or with bounded concurrency.

Useful? React with 👍 / 👎.

Comment thread electron/attachments.js
Comment on lines +325 to +326
async function heicToJpeg(src, dir) {
const out = path.join(dir, `${Date.now()}-${randomUUID().slice(0, 8)}.jpg`);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve source identity when generating the JPEG path

When the same HEIC is selected more than once, this generates a new random JPEG path on every conversion. The composer deduplicates attachments only by path (useComposerAttachments.ts:41-42), so unlike other attachments, reselecting one HEIC creates duplicate chips and sends the image multiple times; reuse a prior conversion or retain a stable source identity for deduplication.

Useful? React with 👍 / 👎.

@currentbits
currentbits merged commit 60d8696 into main Oct 18, 2026
6 checks passed
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.

Transcode HEIC/HEIF attachments to JPEG before the provider sees them

1 participant