t3code icon indicating copy to clipboard operation
t3code copied to clipboard

Composer drops pasted text when an image paste follows within ~300 ms

Open electro56435 opened this issue 1 month ago • 2 comments

Before submitting

  • [x] I searched existing issues and did not find a duplicate.
  • [x] I included enough detail to reproduce or investigate the problem.

Area

Desktop app: chat composer (paste)

Steps to reproduce

  1. Open a thread whose agent is running, so the renderer is busy.
  2. Paste plain text into the composer (⌘V).
  3. Within ~200 ms, paste a PNG image (⌘V).

A dictation tool does exactly this: it pastes the transcript, then each screenshot. A script that writes a text item, sends ⌘V, waits for the clipboard read, then writes a PNG and sends ⌘V reproduces it.

Expected behavior

The composer keeps the pasted text, followed by the image chip.

Actual behavior

The pasted text disappears. The image lands on the shelf, and its chip sits in the prompt alone. Earlier draft text in the same composer is sometimes lost as well.

Measured on 0.0.46-nightly.20261007.2761 and 0.0.46-nightly.20261007.2787, in a running thread:

Gap between text paste and image paste Text kept
0 ms no
100 ms no (2761), yes (2787, one run)
200 ms no
300 ms yes
600 ms yes
text only, no image yes

In an idle thread the text survived at 0 ms. The app read the clipboard 8–66 ms after each ⌘V in every run, so the text paste itself arrives.

Impact

Any tool or user that pastes text and then an image in quick succession loses the text silently. The message then goes out with images only.

Version or commit

0.0.46-nightly.20261007.2787 (f570bd21663f), also 0.0.46-nightly.20261007.2761

Environment

macOS 27.0 (Darwin 27.0.0), Apple Silicon, remote environment over SSH, Claude provider

electro56435 avatar Oct 07 '26 22:10 electro56435

@electro56435 Could you add a capture listener in DevTools, document.addEventListener('paste', e => console.log(performance.now(), [...e.clipboardData.types], e.clipboardData.getData('text/plain')), true), run your script at a 0-200 ms gap, and tell us whether the first paste event that loses the text shows text/plain with your transcript, or only Files?

juliusmarminge avatar Nov 12 '26 08:11 juliusmarminge

@juliusmarminge The first paste event that loses the text does carry text/plain with the transcript. It is not a Files-only event. A capture listener read the full transcript in the runs that lost it.

The clipboard change causes the loss, and the composer's timing only widens the window. Chromium reads the system clipboard again on every getData() and returns "" once the clipboard has changed (DataObjectItem::GetAsString in data_object_item.cc). The dictation tool puts the next image on the clipboard as soon as the first read happens. The composer reads the same paste twice, in ChatComposer.onComposerPaste and then in the editor's handlePaste. The second read gets "", and the editor inserts nothing. A busy renderer puts more time between the two reads, which explains why the loss depended on load.

A real ⌘V in a Chromium browser test reproduces it. The first read returns the text, the test replaces the clipboard, and the second read returns "". The composer stays empty.

The same PR fixes two more losses in this flow. When the page has focus instead of the composer, paste-to-focus dropped pasted images. An Enter while an image was still compressing showed a toast and sent nothing.

Fix and tests: #37785.

electro56435 avatar Nov 16 '26 21:11 electro56435