[BUG] Linux/Wayland: copy runs wl-copy without --type, so code-like text is offered as e.g. application/x-ruby and won't paste into Emacs/GTK apps

Open Beginner friendly
#113,774 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
linux, typescript
Domain
cli

Research direction

The issue identifies the wl-copy calls, including the clipboard and --primary variants, but gives no source file or test path. Find where Claude Code assembles those commands and read the surrounding clipboard handling first. Reproduce with the supplied Ruby-like line, then verify both calls offer text/plain and the text pastes into a GTK or Emacs Wayland app.

Written by the indexing model from the issue text.

Description

area:tui bug has repro platform:linux
What's wrong

On Linux/Wayland, Claude Code copies a selection by running wl-copy with no arguments (Q={"wl-copy":[[],["--primary"]], ...} in 2.1.329). Without --type, wl-copy guesses the MIME type from the content via xdg-mime. When the copied text looks like source code, the guess is a non-text type, and wl-copy then offers only that type, with no text/plain.

Apps that request text types only (e.g. Emacs pgtk, GTK apps) get nothing and paste nothing. wl-paste and clipboard managers still show the text, because they take whatever type is offered, so the clipboard looks fine.

Repro
  1. Wayland session with wl-clipboard installed (WAYLAND_DISPLAY set).
  2. In Claude Code, select and copy this line from the output: default_area = "menupanel";
  3. wl-paste --list-types prints only application/x-ruby.
  4. Paste into Emacs (pgtk): nothing is pasted. (gui-get-selection 'CLIPBOARD 'TARGETS) returns [application/x-ruby], and (gui-get-selection 'CLIPBOARD 'UTF8_STRING) returns nil.

Same root cause, without Claude Code:

$ printf 'default_area = "menupanel";' > t; xdg-mime query filetype t
application/x-ruby

Ordinary prose is detected as text/plain, so the bug shows up only for text that happens to look like code. That is common in Claude Code output.

Expected

The copied text is offered as text, so every app can paste it.

Suggested fix

Pass --type text/plain to wl-copy, for both the clipboard and the --primary calls. Claude Code always copies text, so the type never needs guessing. With text/plain, wl-copy also offers the usual text aliases (text/plain;charset=utf-8, UTF8_STRING, TEXT, STRING).

Environment
  • Claude Code 2.1.329
  • Linux 6.18, NixOS, niri (Wayland)
  • wl-clipboard 2.3.0
  • GNU Emacs 31.1 (pgtk)
Dominant language
TypeScript
Stars
158k
Forks
25.1k
Avg merge
1d 8h
Merged PRs (30d)
4

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

  • No Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from anthropics/claude-code

All issues in anthropics/claude-code

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.