CLI: Add /rewind checkpoint restore that reverts both chat context and Codex-applied code edits
What variant of Codex are you using?
CLI
What feature would you like to see?
Add a native /rewind checkpoint flow that restores both:
- conversation state
- Codex-applied workspace edits
from the same selected checkpoint.
Current behavior: Esc rewind only rewinds conversation/history (fork point), but does not revert code changes made after that point.
Requested behavior:
/rewindshows recent checkpoints with:- timestamp
- prompt snippet
- files changed
- Selecting a checkpoint rewinds chat and reverts Codex-made edits after that checkpoint.
- Provide a pre-apply preview of file changes to be reverted.
- Allow editing the restored prompt before resubmitting.
Safety requirements:
- Only revert Codex-created edits after the selected checkpoint.
- Do not touch unrelated local changes that existed before checkpoint creation.
- If any file cannot be cleanly restored, show conflicts and require explicit confirmation before partial apply.
Additional information
Repro for current gap:
- Ask Codex CLI to modify files.
- Press Esc twice to rewind a prior user message and fork.
- Conversation rewinds, but prior file edits remain in the working tree.
Workarounds today (/diff, !git diff, manual git restore/reset) are useful but fragmented. A unified checkpoint rewind would make iterative prompting much safer and faster.
Related context: #9203, #4487, #8819.
Also related to #2948.
This is also a duplicate of #9344, but that issue hasn't received any upvotes. I think this is a better articulation of the feature, so I'm going to close #9344 in favor of this one.
This is something I really miss coming from other tools (i.e. Cursor, Claude Code), would greatly appreciate to have this implemented
Can we distinguish between an "undo" feature and a "restore conversation to this point" feature?
My understanding is that a true "undo" might be more complex to implement reliably, since it would need to reverse prior actions and state changes. In contrast, "restore conversation to this point" seems more like a context management operation, where the conversation state is reverted to an earlier message and everything after that point is ignored.
I can implement the restore logic on my side, but I’m unsure about the correct approach to trimming the context. Specifically, how should I prevent messages after the restore point from being included in the next request? Should those messages simply be removed from the message history before sending the next prompt?
@etraut-openai please consider providing more context management options. Claude code at least has restore conversation (restore conversation without trying to restore any code changes)
Editing context past messages would be highly appreciated
@BorisMolch Codex CLI already has a 'restore conversation' feature by double-tapping Esc -- BUT this is different than proper undo/rewind. This issue is for undo/rewind feature that may or may not be coupled with 'restore conversation' feature.
@BorisMolch Codex CLI already has a 'restore conversation' feature by double-tapping Esc. This issue is for undo/rewind feature that may or may not be coupled with 'restore conversation' feature.
Thank you. indeed already possible, will give it another go. So far the ux is clunky I can't easily restore conversation in a nice flow.
Thank you. indeed already possible, will give it another go. So far the ux is clunky I can't easily restore conversation in a nice flow.
I would search for issue on this and if no satisfactory issues exists, create a new one for improving the UX of conversation restore. You might be able to contribute.
I don't get it. So is there "rewind" feature in Codex CLI or not? E.g. i am used to Claude code. I can REWIND changes OR conversation OR both. I don't care about the damn conversation rewind :) It's important that i can revert / rewind the changes agent made if things go sideways! So is this possible or not? If it is not possible, do not promote double ESC, because reverting conversation is more or less useless. Ask Codex to implement the revert feature if it is not available already, otherwise document it, i cannot find it in docs.
I don't get it. So is there "rewind" feature in Codex CLI or not? E.g. i am used to Claude code. I can REWIND changes OR conversation OR both. I don't care about the damn conversation rewind :) It's important that i can revert / rewind the changes agent made if things go sideways! So is this possible or not? If it is not possible, do not promote double ESC, because reverting conversation is more or less useless. Ask Codex to implement the revert feature if it is not available already, otherwise document it, i cannot find it in docs.
No - the rewind or undo does NOT exist in Codex CLI. Hence this issue. We really need it. Give an upvote if you can.
I think if we're gonna have a rewind/undo feature there should be a toggle for doing it in version control. Every apply_patch can be a commit, and every undo can be a rebase dropping that commit or cherry pick that commit into a stash (undo + redo). The way it appears to currently work is Codex is tracking changes separately from VC. Codex already does not track when an agent uses cat << EOF ... EOF > some_file or any command that edits a file outside of apply_patch, so it makes sense to start with apply_patch -> commit -m "{stable apply_patch identifier}". That would enable you to resume a conversation inside a worktree and restore all of the "undo" points for that conversation.
"Undo" eventually becomes an invalid operation as the codebase evolves, so if it's scoped to a worktree under a specific commit hash, when you eventually PR+squash/merge that worktree and delete the branch you no longer need the undo tracking. It would use version control with good stewardship. That's how I envision a good rewind/undo feature. And as a toggle, for folks using Perforce or other centralized SCM they can just toggle that off and do the double diff tracking like it currently works.
the rewind function should not be like the "undo" and needs to ONLY revert to a previous position in the agent's context. The files on the disk should not have any relation. This confusion is probably why the "undo" in Codex was buggy and difficult to maintain, as you are conflating two separate asks together.
the rewind function should not be like the "undo" and needs to ONLY revert to a previous position in the agent's context. The files on the disk should not have any relation. This confusion is probably why the "undo" in Codex was buggy and difficult to maintain, as you are conflating two separate asks together.
I was aware of this, and the issue mentions an already available feature for this (double -Esc).
The issue is specifically for both conversation as well as file changes revert, for good reason.
I think this is a really important feature to implement. OpenCode seems to have it working really well. It enables a kind of workflow where you can let the model implement stuff, start reviewing and then sometimes decide it's less work to revert, adapt your prompt and let it do it again than letting it adapt 20 things.
Plus one-ing this. It would be a very convenient feature to have. It feels very intuitive in Claude Code and Cursor. Reverting code and conversation to last checkpoint. It should act similar to double escape, but instead of just restoring conversation, it should also restore the files the agent has touched since that point in time.
I understand the user case about conversation restore, but code restore? Aren't folks using this in a git tracked repo? Adding features like these just bloat the product. Am I missing any specific usecase that users are seeing here?
Also forking from a past history is a great feature!
@rrajpuro This is meant to be a quality of life feature. Making the agent remember to checkpoint with git is context polluting. This feature will maintain the checkpoints out of the agent's context.
The /rewind feature is needed, for returning to a previous point in the conversation with the agent, and needs to have NOTHING to do with the state of the codebase of recent changes to it.
Hard disagree. When you ask codex "Why is this slow", it investigates and start writing code. Then we might have to say "Revert this code". But it would be more convenient if we can just go back in that point in time and correct the prompt to "Why is this slow, only investigate, do not write code".
@suparious what you are saying already exists, double press Esc.