Skip to content

fix: 修复 pretask 停止后立即重启丢失取消状态 - #439

Open
MistEO wants to merge 1 commit into
mainfrom
codex/fix-pretask-cancel-generation
Open

MistEO wants to merge 1 commit into
mainfrom
codex/fix-pretask-cancel-generation

Conversation

@MistEO

@MistEO MistEO commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

同一实例收到 Stop 后立即开始下一轮,旧 pretask 还没轮询到停止标记,下一轮的 reset 就会清除它,旧子进程因此继续运行。现在每轮等待者持有自己的取消接收端,reset 开放下一轮时保留旧等待者的停止状态。

已置 Stop 的 pretask 会在创建进程前返回取消。受管 pretask 在取消后等待直接子进程退出,再完成本次调用。等待型前置程序继续只取消等待,允许该程序自行结束。桌面和 Web 入口共用取消注册表。

独立 review 未发现阻塞问题。基于最新 main c321532,与 #434 head 21494a8 对照。可复跑回归位于 tests/pretask,执行生产命令代码和有时限的真实子进程:

  • python tests/pretask/run.py --offline:7 个进程断言和 2 个注册表单测通过。同一回归在 main 上 3 项通过、4 项失败,复现 Stop/reset 丢取消、返回时未等子进程退出、已停止仍启动和前置程序等待丢取消。
  • Rust 库测试:91 passed、1 ignored、4 个更新测试排除。本机直接启动测试 EXE 有基线同样存在的 0xc0000139,为临时测试 EXE 副本嵌入 Common Controls v6 manifest 后执行,未修改应用配置。
  • cargo fmt --check、独立测试源 rustfmt 和 git diff --check 通过。

Stop 请求表示已登记取消,跨客户端的新调用可能与旧进程退出短暂重叠。测试不覆盖任意孙进程树、Tauri/HTTP 传输或真实项目进程。

Sourcery 摘要

在重置期间保留每次运行的预任务取消状态,并确保托管预操作和用户配置的预操作具有一致的取消完成行为。

Bug 修复:

  • 当新运行重置同一实例时,保留正在执行的预任务的取消状态,防止已取消的子进程继续运行。
  • 在启动前拒绝已取消的预任务,并确保托管预任务在取消完成前退出。
  • 用户配置的预操作取消仅中断等待过程,允许程序独立完成。

增强功能:

  • 在桌面端和 Web 端的停止入口之间共享实例级取消注册表。

文档:

  • 为独立的预任务取消回归测试工具及其支持的执行模式添加文档。

测试:

  • 使用真实子进程添加回归测试,覆盖停止与重置竞态、启动前取消、进程退出顺序、实例隔离、重置行为,以及仅中断等待的预操作取消。
Original summary in English

Summary by Sourcery

Preserve per-run pretask cancellation across resets and make cancellation completion consistent for managed and user-configured pre-actions.

Bug Fixes:

  • Preserve cancellation state for in-flight pretasks when a new run resets the same instance, preventing canceled child processes from continuing.
  • Reject already-canceled pretasks before spawning and ensure managed pretasks exit before cancellation completes.
  • Keep user-configured pre-action cancellation limited to interrupting the wait while allowing the program to finish independently.

Enhancements:

  • Share the per-instance cancellation registry across desktop and Web stop entry points.

Documentation:

  • Add documentation for the standalone pretask cancellation regression harness and its supported execution modes.

Tests:

  • Add regression coverage using real child processes for stop/reset races, pre-spawn cancellation, process-exit ordering, instance isolation, reset behavior, and wait-only pre-action cancellation.

AI 使用信息:

  • Agent:Codex
  • 模型:gpt-6-astra(实现与内部复审),gpt-6.1-sol(额外交叉审查)
  • 思考强度:ultra(实现与内部复审),max(额外交叉审查)

@MistEO
MistEO marked this pull request as ready for review November 11, 2026 08:43
Copilot AI balanced review requested due to automatic review settings November 11, 2026 08:43
@sourcery-ai

sourcery-ai Bot commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Sorry @MistEO, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 1 hour and 43 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T08:44:34.551551Z 2d2aad1 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants