Skip to content

Show an actionable error when a pasted image can't be attached - #1643

Merged
currentbits merged 6 commits into
mainfrom
coder/p2-show-an-actionable-error-when-an-imag-5607f9
Oct 16, 2026
Merged

currentbits merged 6 commits into
mainfrom
coder/p2-show-an-actionable-error-when-an-imag-5607f9

Conversation

@currentbits

Copy link
Copy Markdown
Owner

Fixes #1211. Pasting an image calls preventDefault, so the paste is used up. Before this change, a failed save left no chip and no message, and the image simply disappeared.

What changed

Composer.tsx

  • Every pasted image now ends up either as an attachment chip or as a visible error in the composer.

  • When the clipboard item or FileReader can't produce data (no blob, read error/abort, empty result), it shows "Couldn't read the pasted image. Copy it again, or attach it from a file."

  • When the host returns null, pasteRejectReason gives a likely cause in terms of what to do next:

    • unsupported type (anything other than PNG, JPEG, GIF, WebP, BMP or SVG)
    • over the 20 MB limit
    • otherwise a generic "try again / attach from a file"

    These values copy EXT_BY_MEDIA / MAX_IMAGE_BYTES from electron/attachments.js, which returns null without saying why.

  • When the save rejects, the host's error message is shown.

  • With several images in one paste, the errors are collected into one message ("N of M pasted images weren't attached. …"), with repeated reasons removed. A paste where every image succeeds clears any earlier error.

  • The error is only set if the user is still on the thread where they pasted, so it doesn't show up on another thread.

useCoderWorkspace.ts / useCoder.ts

  • saveAttachmentImage no longer swallows errors. It now rejects with the host's error so the paste path can show it.
  • A new saveImageOrNull wrapper keeps the old behaviour (skip the item quietly) for batch paths: web file pick, video-frame extraction, and drag/drop from paths or files.
  • Updated the UseCoderResult doc comment to match.

Tests

  • test/pasteImageErrors.test.tsx (new) covers the paste error messages.
  • test/composerAttachments.test.tsx has more composer attachment cases.

🤖 Generated with Claude Code

Solenta added 2 commits October 15, 2026 16:51
Solenta-Message-Id: d8709427-9bf2-4a1c-87a6-7155802519bd
Solenta-Message-Id: 8524452a-15be-41be-87e1-25cdbc5edbb1
@chatgpt-codex-connector

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 ⚠️ Failed 2026-10-15T15:35:18.285033Z 116f937 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

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

Willem and others added 4 commits October 15, 2026 18:02
On Windows CI the first test's debounced async flush ran after done()
removed the dir, logged "[store] async flush failed", and the next test's
console-error check failed it. saveNow() supersedes the in-flight flush so
it cannot log, and flushPending() waits for it to settle before rmSync.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@currentbits
currentbits merged commit 58a0b90 into main Oct 16, 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.

P2: Show an actionable error when an image paste cannot be saved

1 participant