openai / openai/codex

Linux X11: clipboard owner advertises text/plain targets it refuses to serve, so some apps paste nothing

Open
#40,825 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug CLI TUI
Dominant language
Rust
Stars
125k
Forks
19.4k
PR merge metrics
PR metrics pending

Description

What version of Codex CLI is running?

codex-cli 0.149.1

What platform is your computer?

Ubuntu 24.04.4 LTS, kernel 7.0.0-30-generic, local X11 session (XDG_SESSION_TYPE=x11), KDE Plasma.

What issue are you seeing?

After copying text out of the Codex TUI, codex correctly takes and keeps ownership of the X11 CLIPBOARD selection — but the selection it serves is inconsistent: it advertises three text targets in TARGETS and only answers one of them. Requests for the other two are answered with SelectionNotify / property = None, i.e. "conversion refused".

Any application that picks one of the advertised-but-unserved targets receives nothing and pastes an empty string, while reporting no error. This is not the older "clipboard stays empty" bug (#15663, fixed in 0.121/0.122) — ownership is held correctly here, and one target does return the data.

What steps can reproduce the bug?
  1. Copy some text out of the Codex TUI so that codex becomes the CLIPBOARD owner.
  2. Inspect the advertised targets:
$ xclip -o -selection clipboard -t TARGETS
UTF8_STRING
text/plain;charset=utf-8
text/plain;charset=UTF-8
TARGETS
SAVE_TARGETS
  1. Request each advertised target:
$ xclip -o -selection clipboard -t UTF8_STRING | wc -c
8478

$ xclip -o -selection clipboard -t 'text/plain;charset=utf-8'
Error: target text/plain;charset=utf-8 not available

$ xclip -o -selection clipboard -t 'text/plain;charset=UTF-8'
Error: target text/plain;charset=UTF-8 not available

Confirming that the owner really is codex (via the X-Resource extension, XResQueryClientIds on the selection owner window):

CLIPBOARD owner window: 0x7800000
  pid = 2003984
  cmdline: .../@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/bin/codex
What is the expected behavior?

A selection owner must be able to convert every target it lists in TARGETS (ICCCM 2.2). Either:

  • serve text/plain;charset=utf-8 and text/plain;charset=UTF-8 with the same bytes as UTF8_STRING, or
  • advertise only the targets that are actually served.

Additionally, TIMESTAMP and MULTIPLE are mandatory targets for any selection owner per ICCCM 2.6.2, and neither is advertised; STRING and TEXT are conventionally expected for text selections and are also missing.

What do you see instead?

Whether a paste works depends on which target the receiving application happens to ask for:

Application Target requested Result
Kate, Konsole, Firefox, VS Code UTF8_STRING text pastes correctly
CudaText 1.236 (Lazarus/Qt5) UTF8_STRING, then text/plain;charset=UTF-8 pastes nothing

The failing application is not doing anything exotic — it asks for a target that the owner published.

I confirmed the causal chain on a separate Xvfb display with a ~70-line X11 selection owner that mimics this behaviour, so no Codex or editor internals are involved:

  • owner advertises the three targets and serves only UTF8_STRING → paste produces an empty string
  • same owner, same client, serving all advertised targets → paste produces the text

Owner-side log of the failing case, showing the refusal (231 = UTF8_STRING, 233 = text/plain;charset=UTF-8):

request target=231 -> served
request target=233 -> refused
Additional information

Killing codex makes the problem disappear, because the desktop clipboard manager (Klipper) then takes ownership and serves a complete, consistent target list. Re-publishing the same bytes with xclip also fixes it. This all points at the clipboard backend used for X11 rather than at anything in the TUI itself.

Contributor guide

Open the 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.

Research direction

Start by locating the X11 clipboard backend used when the Codex TUI copies text, then reproduce the issue with xclip on a local X11 session. Verify the advertised TARGETS and request each one; the fix is complete when every advertised text target returns the clipboard bytes, or only served targets are advertised, including the expected mandatory targets.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux, rust
Domain
desktop, operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
62/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.