Summary
Add a narrow undo last paste feature to the TUI composer.
This is not a full editor undo stack. It only reverts the most recent successful paste transaction, including paste side effects beyond raw text.
Problem
The TUI already treats paste as a first-class composer operation:
- normal pasted text
- oversized paste placeholders backed by
pending_pastes
- pasted image paths that become local image attachments
- shortcut image paste via
Ctrl+V / Alt+V
Today, if a paste is accidental or wrong, the recovery options are inconsistent:
- plain text may be manually deleted
- oversized paste placeholders are not a normal text edit
- pasted image attachments are not just text
- there is no single standard shortcut to “undo the paste I just did”
The existing Ctrl+U / Ctrl+K / Ctrl+W / Ctrl+Y behavior is helpful, but it is kill/yank behavior, not paste undo.
Proposal
Add a composer-level undo last paste shortcut:
- primary binding:
Ctrl+_
- accept terminal-friendly aliases:
Ctrl+/ and raw ^_
Behavior:
- only undoes the most recent successful paste transaction
- restores the entire pre-paste draft state
- includes:
- text
- text elements
- local image attachments
- remote image URLs
- mention bindings
pending_pastes
- cursor position
- cursor-only movement after paste should not invalidate undo
- any content mutation after paste should invalidate it
- single-level only
- no redo
- no general-purpose edit undo stack
Why composer-level, not textarea-level
Paste in the TUI is not only text insertion.
A general textarea undo would not naturally cover:
- large-paste placeholder bookkeeping
- local image attach/remove
- shortcut image paste
- attachment relabeling and related draft state
So the smallest coherent feature is “undo last paste transaction” at the composer layer.
Suggested implementation shape
- capture a full draft snapshot before a successful paste
- capture a post-paste fingerprint after it
- on
Ctrl+_ / alias:
- if the current draft still matches the post-paste fingerprint, restore the pre-paste snapshot
- otherwise treat the undo-paste state as stale and do nothing
This keeps the feature predictable and avoids introducing a broad edit-history system.
Test cases
- undo after plain text paste
- undo after oversized paste with placeholder +
pending_pastes
- undo after image-path paste that attached a local image
- undo after shortcut image paste
- cursor movement does not block undo
- content edits after paste invalidate undo
- one-shot behavior
Ctrl+Z remains suspend, not undo
Rationale / prior art
This key choice follows established terminal/editor conventions:
- Emacs documents undo on
C-/, with C-_ as the terminal-friendly equivalent on systems where Ctrl+/ is delivered that way.
- The current Codex TUI already uses readline/emacs-style editing keys (
Ctrl+U, Ctrl+K, Ctrl+W, Ctrl+Y), so a narrow paste undo on the same family of bindings is a reasonable fit.
Ctrl+Z should not be repurposed because it is already used for terminal suspend in the TUI.
Local status
I also have a local implementation of this behavior in a fork, verified with:
just fmt
cargo clippy -p codex-tui --tests
cargo test -p codex-tui
Reference implementation:
8d0fdd5f
If this direction matches the intended UX, I can turn it into a PR if invited.
Summary
Add a narrow
undo last pastefeature to the TUI composer.This is not a full editor undo stack. It only reverts the most recent successful paste transaction, including paste side effects beyond raw text.
Problem
The TUI already treats paste as a first-class composer operation:
pending_pastesCtrl+V/Alt+VToday, if a paste is accidental or wrong, the recovery options are inconsistent:
The existing
Ctrl+U/Ctrl+K/Ctrl+W/Ctrl+Ybehavior is helpful, but it is kill/yank behavior, not paste undo.Proposal
Add a composer-level
undo last pasteshortcut:Ctrl+_Ctrl+/and raw^_Behavior:
pending_pastesWhy composer-level, not textarea-level
Paste in the TUI is not only text insertion.
A general textarea undo would not naturally cover:
So the smallest coherent feature is “undo last paste transaction” at the composer layer.
Suggested implementation shape
Ctrl+_/ alias:This keeps the feature predictable and avoids introducing a broad edit-history system.
Test cases
pending_pastesCtrl+Zremains suspend, not undoRationale / prior art
This key choice follows established terminal/editor conventions:
C-/, withC-_as the terminal-friendly equivalent on systems whereCtrl+/is delivered that way.Ctrl+U,Ctrl+K,Ctrl+W,Ctrl+Y), so a narrow paste undo on the same family of bindings is a reasonable fit.Ctrl+Zshould not be repurposed because it is already used for terminal suspend in the TUI.Local status
I also have a local implementation of this behavior in a fork, verified with:
just fmtcargo clippy -p codex-tui --testscargo test -p codex-tuiReference implementation:
8d0fdd5f
If this direction matches the intended UX, I can turn it into a PR if invited.