﻿---
title: "features.undo 默认关；/undo 只回文件，不回聊天"
summary: "稳定但默认关。打开后 /undo 按整轮快照还原工作区。会话一关快照就没了。要连上下文一起撤用 /fork。"
category: commands
level: intermediate
surfaces: [cli]
tags: ["undo", "features", "/undo"]
canonical: /tips/features-undo/
---

# features.undo 默认关；/undo 只回文件，不回聊天

稳定但默认关。打开后 /undo 按整轮快照还原工作区。会话一关快照就没了。要连上下文一起撤用 /fork。

`undo` 是少数**稳定却默认关**的开关。打开：

```bash
codex features enable undo
codex features list
```

或写入用户 config 后新开会话：

```toml
[features]
undo = true
```

一次性也可用 `codex --enable undo`。`/experimental` 里不一定列这个稳定开关。

打开后 TUI 有 `/undo`：按**这一轮工具调用**的幽灵快照还原工作区，十个文件的重构会整组回去，不是按文件挑。聊天记录不会退；模型仍记得做过那次改动。快照在内存里，重启会话就没了。不要拿它当 git。

需要连对话一起回到分叉点，用 `/fork`。CI 和无头 exec 保持 `undo = false`。本机 `/help` 没有 `/undo` 就先确认 `codex features list` 里是 on。

## 来源

- [OpenAI · Configuration reference](https://learn.chatgpt.com/docs/config-file/config-reference)
- [danielvaughan · Feature flags](https://codex.danielvaughan.com/2026/03/28/codex-cli-feature-flags-tui-tuning/)
