Skip to content

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

@dolzenko

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    TUIIssues related to the terminal user interface: text input, menus and dialogs, and terminal displaybugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions