Skip to content

Ctrl+V in TUI is image-only when it reaches Codex as a key event; add symmetric text paste #17103

Closed

Description

@dolzenko

Summary

In the TUI, Ctrl+V currently behaves as an image-paste shortcut if it reaches Codex as a key event.

That means when the clipboard contains text, and the terminal does not convert the paste into a bracketed Paste(...) event, Codex tries to
paste an image instead and shows an error like:

Failed to paste image: no image on clipboard: ...

Root cause

There are currently two different paste paths:

  • text paste: relies on terminal/crossterm Event::Paste(...)
  • Ctrl+V: handled as clipboard image paste in the TUI keybinding layer

So if the terminal forwards Ctrl+V as a keypress instead of surfacing a paste event, text paste does not happen inside Codex.

Proposed behavior

  • Ctrl+V in local desktop sessions:
    • try clipboard text first
    • if non-empty text exists, route it through the existing composer paste path
    • if no text exists, fall back to image paste
  • Alt+V:
    • remain explicit image paste
  • SSH/remote sessions:
    • do not do process-local text clipboard reads
    • rely on terminal-owned paste
    • if Ctrl+V reaches Codex as a key event, show a short hint instead of reading the remote process clipboard

Why this shape

  • preserves terminal-native Paste(...) handling
  • preserves explicit image paste
  • avoids incorrect clipboard semantics in SSH sessions
  • makes Ctrl+V symmetric for local users whose terminal forwards the keypress

Local implementation + verification

I implemented this in a local clone and verified with:

  • just fmt
  • cargo clippy -p codex-tui --tests
  • cargo test -p codex-tui

The change includes:

  • text clipboard read helper
  • WSL text fallback
  • Ctrl+V text-first shortcut policy
  • Alt+V image-only policy
  • SSH hint path
  • updated footer/snapshots/tests

If this approach matches the intended direction, I can turn it into a PR if invited.

Activity

  1. added
    bug
    CLI
    TUI
    on Apr 8, 2026
  2. github-actions commented on Apr 8, 2026

    @github-actions
    Contributor
  3. dolzenko commented on Apr 8, 2026

    @dolzenko
    Author

    A little more context - #4818 (comment) I originally needed this for implementing cross-layout Ctrl-V paste with alacritty

    #16223 is also very likely might be solved with this change.

  4. removed
    CLI
    on Apr 8, 2026
  5. dolzenko commented on Apr 9, 2026

    @dolzenko
    Author

    a64505379 the changeset codex gave me

  6. sunjiajunsunjiajun commented on Jul 16, 2026

    @sunjiajunsunjiajun

    This root-cause explanation matches another real-world reproduction path.

    In a Windows remote-control setup using UU remote connection + WezTerm, plain text paste can fail with the image-paste error:

    Failed to paste image: no image on clipboard...
    

    The user is not pasting an image. The likely sequence is:

    1. Text is copied locally / into the remote Windows clipboard.
    2. The remote-control client forwards Ctrl+V as raw key events.
    3. WezTerm does not convert that particular input path into a terminal paste event.
    4. Codex receives raw Ctrl+V.
    5. The TUI handles it as image paste and reports that no image is on the clipboard.

    The same machine had a working text-paste path in traditional cmd.exe via mouse right-click paste, which suggests the text clipboard can be fine and the failure depends on whether the terminal consumes the paste shortcut or passes Ctrl+V through to Codex.

    Workarounds that avoid the issue:

    • Use Ctrl+Shift+V or Shift+Insert in WezTerm.
    • Configure WezTerm to bind Ctrl+V to PasteFrom 'Clipboard' so the terminal performs text paste before Codex sees the key event.
    • Add a right-click PasteFrom 'Clipboard' mouse binding in WezTerm, including the mouse_reporting = true case for TUI applications.

    This seems like another data point supporting the proposal here: when Ctrl+V reaches Codex as a key event, Codex should either try text clipboard content first in local desktop sessions, or show a text-paste hint instead of immediately taking the image-paste path.

  7. ofirgeller commented on Aug 8, 2026

    @ofirgeller

    Please fix this. I'm unwilling to type into the console like a peasant, and this is also blocking voice to text with programs like blabby.
    i should be able to use ctrl + v for pasting both images, text and the results of vtt.

  8. LANCER1254 commented on Sep 25, 2026

    @LANCER1254

    I can reproduce the plain-text Ctrl+V → image-paste error on native Ubuntu with the standalone Codex CLI 0.157.0.

    Environment:

    • OS: Ubuntu 26.04.1 LTS
    • Terminal: GNOME Terminal
    • TERM: xterm-256color
    • COLORTERM: truecolor
    • Affected: standalone Codex CLI 0.157.0 ($HOME/.local/bin/codex is first on PATH)
    • Comparison on the same PC: older npm-installed Codex CLI 0.142.3 (/usr/local/bin/codex) and the Codex Desktop App

    Steps:

    1. Copy plain text to the OS clipboard.
    2. Open the standalone Codex CLI TUI.
    3. Press Ctrl+V in the input field.

    Expected: The plain text appears in the input field.

    Actual: Codex attempts an image paste and reports an error equivalent to Failed to paste image: no image on clipboard.

    Ctrl+Shift+V pastes the text successfully in the affected CLI. The older npm-installed CLI and Desktop App also behave as expected on the same PC. This comparison narrows the area to investigate, but does not establish the cause or whether the difference is specific to the standalone distribution.

    I also reported this to OpenAI Support. Support could not confirm from available documentation that this is a recognized 0.157.0 bug, intended behavior, or associated with a confirmed fix date. They described a public GitHub issue as a way to share reproduction details.

    I can provide additional session details if useful.

  9. foxsalaf commented on Sep 26, 2026

    @foxsalaf

    Another data point, native Windows this time (no WSL, no remote session): @openai/codex 0.157.0 from npm on Windows 11 Pro N (10.0.26200), TUI running in the legacy console host (conhost, which was the default terminal on this machine).

    • The clipboard holds plain text (checked with Get-Clipboard; formats present: UnicodeText, Text, OEMText).
    • Ctrl+V in the composer → Failed to paste image: no image on clipboard: The clipboard contents were not available in the requested format or the clipboard is empty.
    • TUI log: codex_tui::clipboard_paste paste_image_as_png: attempting clipboard image read, then codex_tui::chatwidget::interaction failed to paste image: no image on clipboard. No text-paste attempt follows.
    • conhost has no bracketed paste and hands Ctrl+V to the application as a key event, so on this terminal the key-event path is the only path there is, and it is image-only, exactly as described in this issue.
    • Right-click (QuickEdit) paste still works, because conhost types the characters itself.
    • Same binary inside Windows Terminal 1.24 (Ctrl+V bound to Terminal.PasteFromClipboard, delivered as a paste event): the text lands in the composer as expected. Verified.

    On this machine Ctrl+V text paste in conhost worked with the previous npm release (updated to 0.157.0 on 2026-09-25).

    Switching the default terminal to Windows Terminal is the workaround used here. A clipboard-text fallback in the key-event path, as proposed above, would make the legacy console usable again.

  10. CallMeAl1973 commented on Sep 26, 2026

    @CallMeAl1973

    Please implement this, as well as a keyboard shortcut for pasting over SSH. I am blind and use a screen reader. I have typically been able to paste by asking my screen reader to send a right click command but recently, that functionality has regressed, see #47469

    Now that right click is also broken, this is becoming a pretty significant a11y issue and might make me switch to another agent.

  11. gaspode commented on Oct 6, 2026

    @gaspode

    Please implement this, as well as a keyboard shortcut for pasting over SSH. I am blind and use a screen reader. I have typically been able to paste by asking my screen reader to send a right click command but recently, that functionality has regressed, see #47469

    Now that right click is also broken, this is becoming a pretty significant a11y issue and might make me switch to another agent.

    Use /tui to switch to "scrollback" mode and the right-click works again

  12. etraut-openai commented on Nov 21, 2026

    @etraut-openai
    Contributor

    Thanks for the bug report. This will be addressed in an upcoming release.

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

    TUIbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions