Skip to content

emrg: pasting one image into the GUI composer attaches it twice #2447

Closed

Description

@argszero

What happens

Pasting one image into the GUI composer produces two [📷 image] attachments, and the message the model receives carries the image twice.

The GUI's own log shows one paste handler run and two attachments inside it:

[composer:image] attach 2 file(s): image/png, image/png

Both attachments resolve to the same saved file (the main process names saved images by a content hash) — so the bytes are identical and only the attach layer doubled them. In the log archive, 7 pastes, 7 of them attach 2 file(s); none read 1 file(s).

Why

emrg/gui/renderer/src/lib/composer.ts — collectImageFiles reads a paste/drop event through two properties, files and items[i].getAsFile(), and de-duplicates by object identity (out.includes(f)).

Reading both was introduced on the premise that a Chromium paste delivers the image only on items, so reading files alone would return nothing. A probe run inside the app shows that premise is wrong: a paste delivers files.length === 1, and files[0] and items[0].getAsFile() are two different objects with the same content — and getAsFile() returns a fresh object on every call. Identity de-duplication cannot see that they are one file, so one pasted image enters the list twice. (The same probe shows the earlier "paste does nothing" defect had a different cause — a digest method Electron does not implement, since fixed.)

What the fix must satisfy

  1. One pasted image attaches once.
  2. A drag that delivers several files still attaches all of them — including two distinct files that happen to share a name, size and type. Nothing may de-duplicate by content.
  3. The shape where files is empty and items is the only way in keeps working.
  4. A unit test that reproduces the measured shape — two distinct File objects, same name/size/type, one per property — and goes red when the collection rule is reverted.
  5. The comment in the source states what was measured, not the premise that turned out to be false.

Where it was observed

GUI composer on macOS, pasting a copied image; log ~/.emrg/logs/emrg-gui.log.

Activity

  1. argszero commented on Oct 21, 2026

    @argszero
    OwnerAuthor

    Handled by #2448

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions