Allow /copy to target a specific assistant response by id
What problem are you trying to solve?
In the Codex CLI TUI, /copy currently copies the latest assistant response as markdown. That is useful, but it is hard to copy an earlier assistant response cleanly.
The current workaround is either:
- ask Codex to repeat the earlier answer and then run
/copy, which burns tokens and adds friction; - manually select text in the terminal, which often captures extra indentation, soft-wrap artifacts, or surrounding TUI formatting.
This is especially painful when copying markdown/code blocks from previous answers into chats, tickets, docs, or issue comments.
Related broader request: #2880. This issue is a narrower request for addressable copy of a specific message.
Proposed solution
Add a way for /copy to target a specific assistant response.
Possible command shapes:
/copy # current behavior: copy latest assistant response
/copy 12 # copy assistant response with id 12
/copy a12 # copy assistant response with explicit assistant-message id
/copy last-2 # copy the previous assistant response
The TUI could expose compact ids for assistant messages, for example:
assistant #42
...
Alternatively, ids could stay out of the main transcript and be discoverable through /history or message metadata.
Why this would help
This would make /copy useful for more than the latest response while preserving clean markdown output and avoiding terminal-selection artifacts.
4 Comments
One implementation note from current
main: the TUI already keeps a bounded copy history, not only a single last-response string.codex-rs/tui/src/chatwidget.rssetsMAX_AGENT_COPY_HISTORYto32.codex-rs/tui/src/chatwidget/transcript.rsstoresagent_turn_markdownskeyed by visible user-turn count./copyis still described as "copy last response as markdown" incodex-rs/tui/src/slash_command.rs, and dispatches tocopy_last_agent_markdown()incodex-rs/tui/src/chatwidget/slash_dispatch.rs.So this may not require inventing persistence for older responses from scratch. The missing piece appears to be an addressable selector/argument path plus user-visible labels or metadata for the retained responses.
We need the ability to copy individual commands/blocks.
Like if Codex is giving me a bunch of commands to run in a terminal, it should be easy to copy them.
Any updates?
This would be a great addition to bring Codex in line with most other coding agents.