Skip to content

Commit 7e10bc4

Browse files
committed
Fix Esc rollback after turn start
Extend the pre-response Esc rollback window through TurnStarted until the first assistant output or tool work appears, while preserving normal interrupt-only behavior after output begins. Also document the fork policy clarifications for subagent spawning and background terminal ownership, and bump the release to 0.133.2 with concrete release notes. Tests: - TMPDIR=/home/admin/zzw/tmp cargo test -p codex-tui esc_rolls_back_submitted_prompt_after_turn_started_before_output - TMPDIR=/home/admin/zzw/tmp cargo test -p codex-tui esc_after_agent_output_interrupts_without_rolling_back_prompt - TMPDIR=/home/admin/zzw/tmp CC=clang CXX=clang++ cargo build --profile release-fast --bin codex --bin bwrap
1 parent bf54343 commit 7e10bc4

12 files changed

Lines changed: 287 additions & 169 deletions

File tree

FEATURES.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ Fast-moving prompt packs, hooks, setup flows, and project policies are better ha
9494

9595
## Release Notes
9696

97+
### 0.133.2 - 2026-05-25
98+
99+
- Extend Claude-style Esc rollback through the `TurnStarted`-before-first-output window: if the model has not emitted assistant text, reasoning, plan output, or tool/command activity yet, Esc restores the submitted prompt to the composer and interrupts the turn.
100+
- Keep Esc interrupt semantics after output begins: once any assistant output or work activity appears, Esc remains interrupt-only and does not silently restore/clear partial responses.
101+
- Clarify the Open Codex subagent spawn policy: explicit user requests for parallel/subagent work are strong triggers, but not prerequisites; the real gate is whether a lane is independent, consumable, bounded, and worth the coordination cost.
102+
- Document the background terminal/process ownership rule: do not stop unrelated work merely because it consumes CPU; stop only current-task-owned, blocking, artifact-risking, or explicitly requested work.
103+
97104
### 0.133.1 - 2026-05-25
98105

99106
- Match Claude Code's "treat the query as not sent" behavior: while a user prompt is awaiting `TurnStarted` from core, pressing Esc now rolls the prompt text back into the composer in addition to issuing the interrupt, so the user can edit and resubmit without retyping.

README.md

Lines changed: 47 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -55,24 +55,6 @@ The goal of **Open Codex CLI** is not to diverge for the sake of divergence. The
5555
- solve real Codex CLI usage problems I run into, whether they are bugs or features worth borrowing from Claude Code
5656
- keep improving the Codex CLI experience under `zellij` (**Fuck Off Tmux!**)
5757

58-
## Fork Reference Docs
59-
60-
Operator-facing reference material that ships with the fork (subagent
61-
delegation policy, `~/.codex/AGENTS.md` snippet, etc.) is collected under
62-
[`docs/open-codex/`](docs/open-codex/) so it stays separated from the
63-
upstream `docs/*.md` namespace and survives merges cleanly.
64-
65-
| Topic | File |
66-
| --- | --- |
67-
| Index of fork reference docs | [`docs/open-codex/README.md`](docs/open-codex/README.md) |
68-
| Drop-in `~/.codex/AGENTS.md` snippet (contract-first subagent rules, per-query reasoning markers, `/btw` vs `/side` etiquette) | [`docs/open-codex/agents-md-snippet.md`](docs/open-codex/agents-md-snippet.md) |
69-
| Full contract-first subagent execution policy with decision procedure, lane counts, edit-ownership rules | [`docs/open-codex/parallel-first-agent-execution.md`](docs/open-codex/parallel-first-agent-execution.md) |
70-
71-
The runtime mirror of the four-gate subagent spawn policy lives in
72-
`codex-rs/core/src/tools/handlers/multi_agents_spec.rs::SPAWN_AGENT_CONTRACT_GUIDANCE_V2`,
73-
so the same contract is injected into the model's `spawn_agent` tool
74-
description even when `~/.codex/AGENTS.md` is empty.
75-
7658
## Current Delta and Roadmap vs. Latest Upstream Codex CLI
7759

7860
This fork is currently based on the latest upstream `openai/codex` and adds a small set of focused CLI improvements from recent fork-specific commits:
@@ -185,6 +167,30 @@ This is an instruction-policy feature rather than a hardcoded scheduler: it enab
185167

186168
From recent fork-specific TUI changes:
187169

170+
This section has two paired layers: the user-facing spawn policy that decides
171+
when subagents should exist, and the runtime/TUI behavior that lets those
172+
subagents run without blocking normal chat.
173+
174+
The user-scope subagent spawn policy guide lives under
175+
[`docs/open-codex/`](docs/open-codex/) so it stays separate from upstream
176+
`docs/*.md` during merges:
177+
178+
Subagent spawning does not require an explicit user request. Explicit
179+
parallel/subagent requests are strong positive triggers; the normal gate is
180+
whether a lane is independent, consumable, bounded, and worth the coordination
181+
cost.
182+
183+
| Guide | Purpose |
184+
| --- | --- |
185+
| [`docs/open-codex/README.md`](docs/open-codex/README.md) | Index for the Open Codex user-scope subagent policy docs and their runtime mirrors. |
186+
| [`docs/open-codex/agents-md-snippet.md`](docs/open-codex/agents-md-snippet.md) | Drop-in `~/.codex/AGENTS.md` snippet for the contract-first spawn gates, small stable profiles, per-query reasoning markers, and `/btw` vs `/side` etiquette. |
187+
| [`docs/open-codex/parallel-first-agent-execution.md`](docs/open-codex/parallel-first-agent-execution.md) | Full policy rationale and decision procedure: when to spawn, how many lanes to use, when to wait, and how to keep edit ownership bounded. |
188+
189+
The runtime mirror of the four-gate spawn policy lives in
190+
`codex-rs/core/src/tools/handlers/multi_agents_spec.rs::SPAWN_AGENT_CONTRACT_GUIDANCE_V2`,
191+
so the same contract is injected into the model's `spawn_agent` tool
192+
description even when `~/.codex/AGENTS.md` is empty.
193+
188194
The feature is centered on two background lanes:
189195

190196
- **Terminal commands** — long-running terminal sessions continue in the background instead of keeping the main turn blocked by foreground waiting or polling. Empty `command/exec/write` interactions keep the terminal backgrounded, so normal chat input can be submitted while the shell process continues.
@@ -195,6 +201,7 @@ The shared interaction model is:
195201
- `Ctrl+B` sends the current terminal activity to the background while keeping streamed output available.
196202
- `Down` opens a live task panel with separate `Tasks`, `Subagents`, and `Terminals` sections.
197203
- `Enter` opens details, `x` stops the selected stoppable background item, and `Esc`/`Left` closes the panel.
204+
- background terminals/processes should not be stopped merely because they look unrelated or consume CPU; stop only work that belongs to the active task, blocks required resources, risks corrupting the active artifact, or was explicitly requested to be stopped.
198205
- the status line keeps foreground `Working` state separate from background subagent/terminal counts.
199206
- terminal details show runtime and recent output; subagent details show role, task, status, runtime, progress, and task-boundary context.
200207
- `/agent` shows available agent profiles, while `/subagents` opens the subagent thread picker/switching workflow for live, resumable, and closed-but-reviewable threads.
@@ -377,22 +384,6 @@ Codex CLI 是开源的,但上游仓库当前对外部代码贡献采用 invita
377384
- 解决我在实际使用 Codex CLI 时遇到的体验问题,不管它们是 bug,还是值得从 Claude Code 借鉴过来的 feature
378385
- 持续优化 Codex CLI 在 `zellij` 下的使用体验(**Fuck Off Tmux!**
379386

380-
## Fork 参考文档
381-
382-
fork 自有的运行规约(子代理委派策略、`~/.codex/AGENTS.md` 模板等)统一放在
383-
[`docs/open-codex/`](docs/open-codex/) 下,与上游 `docs/*.md` 命名空间分离,
384-
便于合 upstream 时不冲突,也便于用户单独引用。
385-
386-
| 主题 | 文件 |
387-
| --- | --- |
388-
| fork 参考文档索引 | [`docs/open-codex/README.md`](docs/open-codex/README.md) |
389-
| `~/.codex/AGENTS.md` 即贴即用片段(contract-first 子代理规则、per-query reasoning 标记、`/btw``/side` 用法约定) | [`docs/open-codex/agents-md-snippet.md`](docs/open-codex/agents-md-snippet.md) |
390-
| 完整 contract-first 子代理执行策略(决策流程、lane 数量、edit ownership 规则) | [`docs/open-codex/parallel-first-agent-execution.md`](docs/open-codex/parallel-first-agent-execution.md) |
391-
392-
四 gate 子代理 spawn 策略在运行时的镜像在
393-
`codex-rs/core/src/tools/handlers/multi_agents_spec.rs::SPAWN_AGENT_CONTRACT_GUIDANCE_V2`
394-
所以即使用户没装 `~/.codex/AGENTS.md`,模型也能在 `spawn_agent` 工具描述里看到同样的契约。
395-
396387
## 当前相对最新 Upstream Codex CLI 的差异与路线图
397388

398389
这个 fork 目前基于最新的 `openai/codex`,并在最近几条 fork 自有 commit 的基础上增加了几项聚焦的 CLI 改进:
@@ -505,6 +496,27 @@ fork 自有的运行规约(子代理委派策略、`~/.codex/AGENTS.md` 模板
505496

506497
来自最近几条 fork 自有 TUI 改动:
507498

499+
这一段分成两层:先是用户侧的 subagent spawn policy,决定什么时候应该 spawn
500+
subagent;再是 runtime/TUI 层,保证这些 subagent 可以非阻塞运行、可见、可管理。
501+
502+
用户侧 subagent spawn policy guide 统一放在
503+
[`docs/open-codex/`](docs/open-codex/) 下,与上游 `docs/*.md` 命名空间分离,
504+
便于合 upstream 时不冲突,也便于用户单独引用:
505+
506+
spawn subagent 不需要用户显式要求。用户显式要求 parallel/subagent 只是强触发;
507+
常规判断标准仍然是该 lane 是否 independent、consumable、bounded,并且值得付出
508+
coordination cost。
509+
510+
| Guide | 用途 |
511+
| --- | --- |
512+
| [`docs/open-codex/README.md`](docs/open-codex/README.md) | Open Codex 用户侧 subagent policy 文档索引,以及它们和 runtime mirror 的对应关系。 |
513+
| [`docs/open-codex/agents-md-snippet.md`](docs/open-codex/agents-md-snippet.md) | 可直接贴进 `~/.codex/AGENTS.md` 的片段,覆盖 contract-first spawn gates、小而稳定的 profile 集合、per-query reasoning 标记,以及 `/btw``/side` 的使用约定。 |
514+
| [`docs/open-codex/parallel-first-agent-execution.md`](docs/open-codex/parallel-first-agent-execution.md) | 完整策略说明:什么时候 spawn、spawn 多少 lanes、什么时候必须等待结果、如何保持 edit ownership 有边界。 |
515+
516+
四 gate 子代理 spawn 策略在运行时的镜像在
517+
`codex-rs/core/src/tools/handlers/multi_agents_spec.rs::SPAWN_AGENT_CONTRACT_GUIDANCE_V2`
518+
所以即使用户没装 `~/.codex/AGENTS.md`,模型也能在 `spawn_agent` 工具描述里看到同样的契约。
519+
508520
这个能力围绕两个 background lanes 展开:
509521

510522
- **Terminal commands** — 长时间运行的 terminal session 会进入后台继续执行,不再通过前台 waiting / polling 阻塞主 turn。空的 `command/exec/write` 交互会保持 terminal backgrounded,因此 shell process 继续运行时也可以正常提交新的聊天输入。
@@ -515,6 +527,7 @@ fork 自有的运行规约(子代理委派策略、`~/.codex/AGENTS.md` 模板
515527
- `Ctrl+B` 把当前 terminal activity 送到后台,同时保留后续 streamed output。
516528
- `Down` 打开实时 task panel,并区分 `Tasks``Subagents``Terminals`
517529
- `Enter` 打开详情,`x` 停止当前选中的 stoppable 后台项,`Esc`/`Left` 关闭 panel。
530+
- 不应该仅仅因为 background terminal/process 看起来和当前 query 无关或者占 CPU 就停止它;只有它属于当前任务、阻塞必要资源、可能污染/破坏当前 artifact,或者用户明确要求停止时才停。
518531
- status line 会把前台 `Working` 状态和后台 subagent/terminal 数量分开显示。
519532
- terminal detail 展示运行时间和最近输出;subagent detail 展示 role、task、status、运行时间、progress 和任务边界信息。
520533
- `/agent` 用于查看可用 agent profiles,`/subagents` 打开 subagent thread picker / 切换工作流,覆盖 live、resumable、以及 closed-but-reviewable threads。

0 commit comments

Comments
 (0)