Skip to content

Commit c753155

Browse files
authored
Merge pull request #7 from vitry/fix/rescue-progress-lifecycle
fix: surface ZCode progress and cancel foreground jobs
2 parents 665de46 + 6f6dbc1 commit c753155

27 files changed

Lines changed: 2746 additions & 84 deletions

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ All notable changes follow Semantic Versioning.
88
- Added marketplace-qualified plugin-data discovery and a restart-safe `$zcode:setup` bootstrap that configures the data directory as a writable root before persisting state.
99
- Added ZCode CLI 0.16.1 compatibility for runtime-preference server requests with string IDs.
1010
- Improved `$zcode:setup` guidance when the ZCode CLI has no model provider configured, including the distinction between Desktop and CLI settings and API-key providers that do not require OAuth.
11+
- Added foreground activity output, a 20-second heartbeat, and durable status previews for long-running ZCode work.
12+
- Added bounded foreground `SIGINT` and `SIGTERM` handling: the plugin cancels before session creation or sends `session/stop` only to the exact persisted ZCode session, while background jobs continue until completion or explicit cancellation with `$zcode:cancel`.
13+
- Kept the package version at `0.1.0` for these Unreleased behavior changes.
1114

1215
## 0.1.0 - 2026-08-06
1316

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,24 @@ To verify configuration, rerun `$zcode:setup`, then run `$zcode:rescue --fresh -
6363

6464
Every run is reserved as a durable, owner-scoped job. Installed plugin state lives beneath `$CODEX_HOME/plugins/data/zcode-<marketplace>/workspaces/<workspace-hash>/` with private permissions; prompts, results, session IDs, and logs are never written into the repository or plugin cache. `$zcode:status`, `$zcode:result`, and `$zcode:cancel` work across later turns in the same Codex session, while sibling sessions cannot adopt a job.
6565

66+
Foreground runs stream ZCode activity to the current terminal. If no new activity arrives, they emit a 20-second heartbeat so a long model or tool call remains visibly alive. The same safe activity is stored on the job; `$zcode:status <job-id>` shows its phase, last activity time, and recent progress previews. For example:
67+
68+
```text
69+
$zcode:rescue --wait repair the failing tests
70+
[zcode] ZCode started a tool call.
71+
[zcode] Still waiting for ZCode; last activity 20s ago.
72+
73+
$zcode:status <job-id>
74+
Status: running
75+
Phase: running
76+
Progress:
77+
- ZCode started a tool call.
78+
```
79+
80+
Background jobs have a separate lifecycle: ending the launching foreground command or Codex turn does not automatically cancel them. Use `$zcode:status <job-id>` to inspect one and `$zcode:cancel <job-id>` for explicit cancellation; ownership remains limited to the Codex session that reserved the job.
81+
82+
On supported foreground paths, `SIGINT` and `SIGTERM` are observed at safe protocol boundaries. Before a ZCode session exists, interruption cancels the queued reservation. Once the exact persisted ZCode session ID exists, the plugin sends `session/stop` only for that session. A confirmed stop durably marks the job cancelled; if `session/stop` fails or times out, the job remains running with the cancellation error available through status so cancellation can be retried. This is intentionally a session-level boundary: the plugin does not claim to stop or kill arbitrary detached grandchildren created by ZCode or nested tools.
83+
6684
Transfer reads a persisted Codex thread through `codex app-server` and imports only ordered visible user/assistant text. It does not transfer hidden reasoning, tools, permissions, or ZCode job ownership.
6785

6886
The optional Stop review gate runs a bounded foreground read-only review only after a changed, user-driven parent turn. Enable or disable it with `$zcode:setup`; a Codex restart may be required. Missing, outdated, or unauthenticated ZCode fails open with setup guidance. Once a review session starts, malformed, failed, or timed-out review output blocks conservatively.

README.zh-CN.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,24 @@ Setup 会把以下 schema 写入 `$CODEX_HOME/plugins/data/zcode-<marketplace>/w
6363

6464
每次运行都会先建立持久、带 owner 的 job。已安装插件的状态保存在 `$CODEX_HOME/plugins/data/zcode-<marketplace>/workspaces/<workspace-hash>/`,使用私有权限;prompt、result、session ID 和日志都不会写进仓库或插件缓存。后续 turn 仍可使用 `$zcode:status``$zcode:result``$zcode:cancel`,但 sibling Codex session 无法接管任务。
6565

66+
前台运行会把 ZCode 活动流式显示在当前终端。如果没有新活动,则每 20 秒输出一次心跳,让耗时较长的模型请求或工具调用仍然可见。同一份安全活动也会持久化到 job;`$zcode:status <job-id>` 会显示阶段、最后活动时间和近期进度预览。例如:
67+
68+
```text
69+
$zcode:rescue --wait 修复失败的测试
70+
[zcode] ZCode started a tool call.
71+
[zcode] Still waiting for ZCode; last activity 20s ago.
72+
73+
$zcode:status <job-id>
74+
Status: running
75+
Phase: running
76+
Progress:
77+
- ZCode started a tool call.
78+
```
79+
80+
后台任务有独立生命周期:启动它的前台命令或 Codex turn 结束时,后台任务不会自动取消。用 `$zcode:status <job-id>` 查看,用 `$zcode:cancel <job-id>` 显式取消;ownership 仍只属于预留该 job 的 Codex session。
81+
82+
在支持的前台路径上,插件会在安全协议边界处理 `SIGINT``SIGTERM`。ZCode session 尚未建立时,中断会取消排队中的预留;精确持久化的 ZCode session ID 一旦存在,插件只会对该 session 发送 `session/stop`。停止得到确认后,job 会持久标记为 cancelled;如果 `session/stop` 失败或超时,job 会保持 running,并通过 status 暴露取消错误,以便重试取消。这是刻意限定的 session 级边界:插件不声称停止或杀死 ZCode 或嵌套工具创建的任意 detached grandchildren。
83+
6684
Transfer 通过 `codex app-server` 读取持久 Codex thread,只导入按顺序排列、用户可见的 user/assistant 文本;不转移隐藏推理、工具状态、permission 或 job ownership。
6785

6886
可选 Stop review gate 只会在用户驱动的父 turn 确实改变工作区后执行有界、前台、只读审查。用 `$zcode:setup` 开关,可能需要重启 Codex。ZCode 缺失、过旧或未认证时会附 setup 指引并 fail open;一旦审查会话已启动,畸形、失败或超时输出会保守阻止结束。

0 commit comments

Comments
 (0)