Repository navigation
fix(web): pasting text copied from Word inserts the text instead of an image - #40686
Conversation
Fails on main: shouldHandleComposerAttachmentPaste claims any clipboard holding an image, so a plain paste from Word attaches a picture of the text instead of inserting it (#40681). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n image Word and other rich text sources put a picture of the selection on the clipboard next to the text. The composer claimed any clipboard holding a supported image before looking at the text, so a plain paste attached the picture and dropped the text. Text now wins over a raster image, unless the text is only the pasted files' names, as when an image file is copied in Finder. Fixes #40681 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… is on the clipboard Firefox's Copy Image puts the image URL in text/plain and only an <img> in text/html. The Word fix let any text win over a raster image unless it was the files' names, so that paste inserted the URL. The image now also wins when the clipboard HTML is only an image with no text, which is what separates it from rich text sources like Word. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Pasting a paragraph copied from Microsoft Word (or another rich text app) into the composer attached a picture of the paragraph and inserted no text, because Word puts a PNG of the selection on the clipboard next to the text. The composer now pastes the text in that case, while copied images still attach.
shouldHandleComposerAttachmentPasteno longer lets an image on the clipboard win over text by default. With text present, a raster image attaches only when the clipboard's HTML is just an image, or the text is only the copied files' names (a Finder copy).isImageOnlyClipboardHtmltells a browser's Copy Image (an<img>intext/html, the image URL as text) apart from rich text sources, whose HTML carries the text.ChatComposerpasses its result ashtmlIsOnlyImage.Fixes #40681
Reproduction on main
Commit f9b19a7 (origin/main). In a fresh worktree:
vp i, thenT3CODE_DEV_SEED=0 vp run dev(fresh database). Paired headless Chromium (Playwright, 1280x800) via the startup pairing URL, which opened the new-thread composer. Clicked the composer's contenteditable and dispatched a ClipboardEvent('paste') whose DataTransfer held what Word puts on the macOS clipboard: text/plain 'Hello from Word', text/html 'Hello from Word
' and a File image.png (image/png). Result: defaultPrevented=true, composer text empty ('\n'), and an image.png attachment tile appeared in the composer. No text was inserted. Real Word on macOS was not available. The desktop app runs the same onComposerPaste handler, so this exercises the same code path. The failing unit test is on factory/repro-40681 (b37c3b2):vp test run src/components/chat/composerAttachmentFiles.test.tsin apps/web gives 1 failed / 10 passed, with 'expected true to be false' for the plain-paste assertion.Evidence
Real web app, Chromium 1280×800, light theme, fresh database on each commit. Open the new-thread composer and paste the same clipboard payload: plain text 'Hello from Word', Word-style HTML, and image.png. Base attaches the image and inserts no text; head inserts the paragraph without an image attachment. scenarios:prove exited 0.
Scenario source
The reproduction uses a synthetic Word-shaped clipboard payload; real Microsoft Word on macOS was not exercised.
Not shown:
Tests
vp test run src/components/chat/composerAttachmentFiles.test.ts(apps/web): 11 passedvp run check:changed: format, lint, knip, typecheck (2 packages), tests and react compiler passisImageOnlyClipboardHtmllogic in headless Chromium (Playwright): Firefox-style Copy Image HTML true, Word-style HTML false, empty falseNot in this change
Who did the work
Run by the t3code factory in T3 Code.