Skip to content

[Bug]: Pasting text copied from Microsoft Word attaches an image instead of the text #40681

Closed

Description

@ngthaotrang

Before submitting

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

Area

apps/web

Steps to reproduce

  1. On macOS, open a document in Microsoft Word and select a paragraph of plain text.
  2. Press ⌘C.
  3. In the T3 Code desktop app, click the composer and press ⌘V.

Expected behavior

The paragraph is inserted into the prompt as editable text.

Actual behavior

The composer attaches image.png, a picture of the paragraph, and inserts no text. In dark mode the picture shows as a black tile. Changing the text color to white in Word before copying doesn't help: the result is still an image (white text on a black background).

Word puts both text/plain and a PNG of the selection on the clipboard. shouldHandleComposerAttachmentPaste (apps/web/src/components/chat/composerAttachmentFiles.ts) returns true whenever any pasted file is an image, before it looks at plainText, so onComposerPaste in ChatComposer.tsx always takes the attachment path for Word content.

#38466 / #38475 fixed this only for Paste as Text, using the bypassAutoAttachment flag. Plain ⌘V still attaches the image (checked on main @ f9b19a7f85). One possible rule: when the clipboard has non-empty text/plain alongside text/html, prefer the text, so copied text from a rich-text editor stays text while a copied image still attaches.

Related, but tracked elsewhere: macOS's own "paste as plain text" chords don't help either. ⇧⌘V does nothing in the composer (#21006). ⌥⇧⌘V ("Paste and Match Style" in most Mac apps) also does nothing, since the custom Edit menu in DesktopApplicationMenu.ts has no item bound to it. In practice, the only working route is clicking Edit → Paste as Text in the menu bar, which few users will find.

Impact

Major degradation or frequent failure

Version or commit

0.1.11-nightly.20261120.4969 (desktop app). The logic is unchanged on main @ f9b19a7f85.

Environment

macOS 26.6.2 (arm64), T3 Code (Nightly) desktop app, Microsoft Word for Mac 16.103.3

Logs or stack traces

No error is logged. The paste is handled as a normal image attachment.

Screenshots, recordings, or supporting files

The paragraph selected in Word:

Paragraph selected in Word

After ⌘V in the composer, two attempts (default text color, then white text) each added an image attachment and no text:

Composer with two image attachments

The attached images themselves:

Attached image, default text color

Attached image, white text

Workaround

Click Edit → Paste as Text in the menu bar (not the shortcut). Alternatively, run pbpaste | pbcopy after copying from Word to strip the image from the clipboard, then press ⌘V.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions