-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Description
What feature would you like to see?
Problem
In the TUI, pressing Ctrl+V after copying a PNG succeeds according to the
paste_image_as_png span, yet the composer never shows the [image …] placeholder and no
image is attached. There’s also no user-visible error.
Steps to Reproduce
- Launch Codex TUI on a native Wayland terminal (
kittyWayland backend). - Copy a PNG (I used a fresh screenshot).
- Focus the composer and press
Ctrl+V. - Observe that nothing appears; retrying yields the same result.
Expected
An image placeholder should appear in the composer, just as it does on X11 terminals.
Actual
The log shows the clipboard read finishing successfully, yet the composer stays unchanged
and no attach_image entries appear. Because the Ctrl+V handler ignores the Err from
paste_image_to_temp_png(), any failure in that helper is swallowed, leaving the paste
as a silent no-op. Please add Wayland-safe image paste support and surface the failure so
users know what happened.
Silent error
The Ctrl+V handler in codex-rs/tui/src/chatwidget.rs:1015-1035 calls
paste_image_to_temp_png() inside if let Ok((path, info)) = paste_image_to_temp_png().
Because the Err branch is never matched, any failure immediately exits the handler
without logging or UI feedback. The helper (codex-rs/tui/src/clipboard_paste.rs:121-135)
does return detailed PasteImageError::IoError/NoImage/..., but since the caller ignores
the Err, those messages never reach the log or the user, so the paste simply appears to
do nothing.
// codex-rs/tui/src/chatwidget.rs:1015-1035
KeyEvent {
code: KeyCode::Char('v'),
modifiers: KeyModifiers::CONTROL,
kind: KeyEventKind::Press,
..
} => {
if let Ok((path, info)) = paste_image_to_temp_png() {
self.attach_image(path, info.width, info.height, info.encoded_format.label());
}
return;
}paste_image_to_temp_png() returns a Result, but only the Ok branch is handled. Any Err
immediately returns from handle_key_event with no log or UI feedback.
// codex-rs/tui/src/clipboard_paste.rs:121-134
pub fn paste_image_to_temp_png() -> Result<(PathBuf, PastedImageInfo), PasteImageError> {
let (png, info) = paste_image_as_png()?;
let tmp = Builder::new()
.prefix("codex-clipboard-")
.suffix(".png")
.tempfile()
.map_err(|e| PasteImageError::IoError(e.to_string()))?;
std::fs::write(tmp.path(), &png).map_err(|e| PasteImageError::IoError(e.to_string()))?;
let (_file, path) = tmp
.keep()
.map_err(|e| PasteImageError::IoError(e.error.to_string()))?;
Ok((path, info))
}The helper maps failures to PasteImageError, but because the caller discards
the Err branch, every error path becomes a silent no-op, so nothing reaches the logs or
the user.
Additional information
- Codex CLI: 0.44.0
- OS: Arch Linux (Wayland session; DISPLAY=:0, WAYLAND_DISPLAY=wayland-1)
- Terminal: kitty 0.43.1 (Wayland backend)
- TMPDIR: /tmp (default)
- Repro: copy a PNG screenshot → focus Codex → press Ctrl+V → nothing appears
- Log snippet (ANSI stripped):
2025-10-06T11:11:43.261773Z DEBUG paste_image_as_png: attempting clipboard image read
2025-10-06T11:11:43.263943Z DEBUG paste_image_as_png:get_image: close time.busy=505µs time.idle=11.1µs
2025-10-06T11:11:43.264248Z DEBUG paste_image_as_png: close time.busy=2.47ms time.idle=9.65µs- Note: no subsequent
attach_imageorPasteImageErrorentries appear in~/.codex/log/codex-tui.log.
- Note: no subsequent