Skip to content

fix(desktop): Codex 提问卡在 turn 结束后继续等待选择 - #3290

Merged
MagicLizi merged 6 commits into
mainfrom
dash/fix-codex-ask-user-detached
Aug 23, 2026
Merged

fix(desktop): Codex 提问卡在 turn 结束后继续等待选择#3290
MagicLizi merged 6 commits into
mainfrom
dash/fix-codex-ask-user-detached

Conversation

@dashhuang

Copy link
Copy Markdown
Member

这次改了什么

摘要

Codex 用 ask_user 提问时,code-mode 常在用户还没选完就先 task_complete。原先成功 turn/completed 会把提问卡标过期并卸掉 overlay,弹窗一闪而过,用户来不及选择。

这次让成功 turn 只 detach 未答提问,不再当放弃;用户作答(含 Skip)后再开 continuation。Claude 仍按 turn 结束过期。renderer 不再本地写 ask 落库,改由 main onInteractionResolved first-write-wins,避免多窗口输家覆盖赢家。

变更类型

  • feat 新功能
  • fix 缺陷修复
  • refactor / perf 重构或性能优化
  • docs / test / chore 文档、测试或工程维护
  • 其他:

范围

  • 关联 Issue / 需求:用户在桌面 Codex 任务里看到提问卡后,任务在未选择时自动结束
  • 本 PR 包含:
    • Codex 成功 turn/completed 时 detach 未答 ask_user,不发 interaction_dismissed
    • dismissed 的答案(含 Skip / 空答案)启动一次 continuation,并快照 dispatch 时的 auto-review intent
    • Desktop island 在 Codex done 后保留 ask/plan,phase 改为 needs-interaction
    • renderer 答题只乐观改内存;落库与输家 UI 收敛走 main first-write-wins + INTERACTION_DISMISSED
    • RESOLVE_INTERACTION 返回 { accepted: boolean }
  • 明确不包含:词典/听写产品改动;Claude ask_user 跨 turn 存活;plan_review 的 renderer 落库策略
  • 用户可见变化:Codex 提问卡在当前 turn 结束后仍可选择;选完后任务继续。Stop / 真正放弃仍会过期
  • 是否存在 breaking change:无。preload 的 resolveInteraction 返回值从 void 变成 { accepted: boolean },仅 Desktop 本机 IPC

UI 变化

不涉及:复用既有提问卡和 overlay,只修正 Codex turn 结束后的生命周期,不改视觉、布局或文案。

  • 引用的设计规范:不涉及:无新增界面或文案

怎么验证的

自动验证

# worktree /Users/dash/Code/Cindy/cindy-fix-codex-ask-user-detached
# Node v22.22.3

pnpm --filter desktop run typecheck
结果:通过

pnpm --filter @cindy/maker-core run typecheck
结果:通过

pnpm test:unit:related
结果:maker-core / lizi-mcps / orca-workflow 通过;
desktop 28326 passed / 2 failed。
失败仅 ghostInstallReceipt.test.ts 两条(state: invalid vs approved),
与本 diff 无关;此前已在干净 origin/main 复现,本次不计 blocker。

# rebase 到 origin/main(含 #3250)后定向复跑
pnpm exec vitest run \
  src/renderer/__tests__/deviceLinkInteractionScenarios.test.ts \
  src/renderer/__tests__/askUserDoneRace.test.ts \
  src/main/__tests__/messagePersistBroadcaster.test.ts \
  src/main/agent-island/__tests__/state.test.ts
结果:4 files / 288 tests passed

手工验证

未做真实 Electron 多窗口 / 真机 device-link 往返。Orca reviewer 按 main 一赢家顺序、广播 payload 和 renderer reducer 做了静态交错核对。

未执行的验证

  • 真实 Desktop 多窗口同时点提问卡
  • 真机 device-link 控制端答题
  • 完整 pnpm test:unit(相关门禁已覆盖 desktop 全量单测;剩余失败为上述基线)

风险

风险分类

  • 无已知风险
  • SQLite / migration
  • system prompt
  • 协议兼容
  • 权限 / 安全 / 用户数据
  • 存量插件兼容(批准状态 / 指纹 / manifest / 安装布局 / 包格式)
  • 原生层 / fingerprint / OTA
  • 跨平台差异
  • 其他:Codex 提问跨 turn 续跑;多窗口落库竞态

影响与回滚

  • 影响范围:Desktop Codex ask_user 生命周期、island phase、提问卡落库权威点
  • 回滚 / 降级方式:revert 本 PR 即可回到「成功 turn 直接过期提问卡」
  • 存量插件影响:无

提交前检查

  • 已 review 完整 diff
  • 每个 commit 都带 DCO 签名(git commit -s,见 DCO
  • UI 改动已在「UI 变化」注明引用的设计规范章节(不涉及 UI 则跳过)
  • 未提交凭证、令牌或授权文件
  • 已补充必要文档
  • 已确认测试结果或说明未执行原因

Codex code-mode 会在 ask_user 未答时先 task_complete。原先成功
turn/completed 会把提问卡标过期并卸掉 overlay,用户来不及选择。

成功 turn 改为 detach 提问,作答(含 Skip)后再开 continuation;
renderer 不再本地落库,由 main first-write-wins。

Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
@dashhuang
dashhuang requested a review from a team as a code owner August 23, 2026 08:33
@greptile-apps

greptile-apps Bot commented Aug 23, 2026

Copy link
Copy Markdown

Greptile Summary

此 PR 调整 Desktop Codex ask_user 的跨 turn 生命周期,并将交互结果的持久化权威移至 main process。

  • 成功完成 Codex turn 时保留尚未回答的提问,回答后启动一次 continuation
  • 通过 main process 的 first-write-wins 处理多窗口交互结果并广播收敛状态
  • Agent Island 在成功 done 后继续展示待处理的 ask/plan,同时清理失效的 permission
  • preload IPC 现在返回 { accepted: boolean },renderer 改为只做乐观内存更新

Confidence Score: 5/5

当前没有仍需阻止合并的已知故障,PR 看起来可以安全合并。

没有阻塞性故障仍然存在。

Important Files Changed

Filename Overview
packages/maker-core/src/agents/codex/index.ts 为成功结束后仍待回答的 Codex 提问增加 detach 与回答后 continuation 生命周期。
apps/desktop/src/main/maker-ipc/register.ts 将交互解决、持久化、跨窗口广播和无后续 turn 的队列唤醒集中到 main process。
apps/desktop/src/main/messagePersistBroadcaster.ts 为 ask/plan 结果增加 main-owned first-write-wins 持久化路径。
apps/desktop/src/renderer/lib/makerChatStore.ts renderer 停止直接持久化 ask 回答,改由乐观状态和 main 广播完成多窗口收敛。
apps/desktop/src/main/agent-island/state.ts done 后保留待处理的 ask/plan,并清理由已结束 turn 所拥有的 permission 状态。
apps/desktop/src/preload/preload.ts 更新 resolveInteraction IPC 返回契约以暴露交互是否被 main 接受。

Sequence Diagram

sequenceDiagram
  participant C as Codex
  participant M as Desktop Main
  participant R as Renderer
  participant DB as Local DB
  C->>M: ask_user request
  M->>DB: 写入 pending 提问
  M-->>R: INTERACTION_REQUEST
  C->>M: successful turn/completed
  M-->>R: 保留未回答提问
  R->>M: RESOLVE_INTERACTION
  alt 首个有效回答
    M->>DB: 写入最终答案
    M-->>R: accepted: true
    M-->>R: INTERACTION_DISMISSED + decision
    M->>C: 启动 continuation
  else 已被其他窗口解决
    M-->>R: accepted: false
  end
Loading

Reviews (6): Last reviewed commit: "test(desktop): 对齐 resolve 落库 helper 的 F1..." | Re-trigger Greptile

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4ba50dc62c

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/maker-core/src/agents/codex/index.ts
Comment thread apps/desktop/src/main/agent-island/state.ts Outdated
resolver 失败与无 resolver 的 ask 回退标 dismissed,避免被当成 Skip 开 continuation。
done 清理 permission 时延后 prune,让完成态先写进岛面。

Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c864b22d89

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/maker-core/src/agents/codex/index.ts
@MagicLizi MagicLizi added status:threads-open 还有未 resolve 的评审讨论(review-pr 自动维护,仅展示) touches:core 改动碰到架构核心路径(review-pr 自动维护,仅展示) touches:product-ui 改动碰到产品 / UI 面(review-pr 自动维护,仅展示) labels Aug 23, 2026
@MagicLizi

Copy link
Copy Markdown
Contributor

@dashhuang 👋 这个 PR 还有 1 条 review conversation 没 resolve(packages/maker-core/src/agents/codex/index.ts),auto-review 因此暂时跳过、没法继续审查 / 合并。

如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。

成功 turn 后若并发挂着多个 ask_user,等全部作答或系统 dismissed
再合并答案开一轮 continuation,避免先到的答案单独开 turn。

Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 27e0d42fd3

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/maker-core/src/agents/codex/index.ts Outdated
Comment thread packages/maker-core/src/agents/codex/index.ts Outdated
@MagicLizi

Copy link
Copy Markdown
Contributor

@dashhuang 👋 这个 PR 还有 2 条 review conversation 没 resolve(packages/maker-core/src/agents/codex/index.ts),auto-review 因此暂时跳过、没法继续审查 / 合并。

如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。

Desktop 只有一个 pendingAskUser。等齐所有 detached 提问会让被覆盖的
请求永远没有 decision,continuation 卡死。改回按已答请求各自续跑。

Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f7b970daf3

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/maker-core/src/agents/codex/index.ts Outdated
Comment thread packages/maker-core/src/agents/codex/index.ts
@MagicLizi

Copy link
Copy Markdown
Contributor

@dashhuang 👋 这个 PR 还有 2 条 review conversation 没 resolve(packages/maker-core/src/agents/codex/index.ts),auto-review 因此暂时跳过、没法继续审查 / 合并。

如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。

@MagicLizi

Copy link
Copy Markdown
Contributor

命中 UI 路径(apps/desktop/src/renderer/lib/makerChatStore.ts)但 description 未附界面效果证据——建议补充改动后效果:截图/录屏,或改动后界面的 HTML 页面(```html 代码块、.html 附件或在线预览链接),便于确认界面符合 DESIGN.md 设计规范

Desktop 只有一个 pendingAskUser。成功 turn 后若仍挂着多张提问,
只 detach 最后一张,其余标 superseded 并 dismissed,避免被盖住的
resolver 堵住后续发送。

Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5d6343fa28

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/desktop/src/main/maker-ipc/register.ts
@MagicLizi

Copy link
Copy Markdown
Contributor

@dashhuang 👋 这个 PR 还有 1 条 review conversation 没 resolve(apps/desktop/src/main/maker-ipc/register.ts),auto-review 因此暂时跳过、没法继续审查 / 合并。

如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。

resolvePendingInteraction 已改走 persistInteractionDecision。
契约改为锁 helper 调用,并继续要求 helper 内部走 onInteractionResolved。

Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
@MagicLizi MagicLizi added status:ci-failed CI 失败(review-pr 自动维护,仅展示) and removed status:threads-open 还有未 resolve 的评审讨论(review-pr 自动维护,仅展示) status:ci-failed CI 失败(review-pr 自动维护,仅展示) labels Aug 23, 2026

@MagicLizi MagicLizi 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.

独立标准档审查通过:Codex 提问卡在 turn 结束后的 detach/continuation、IPC resolve、persist first-write-wins 与 renderer store 对齐,定向单测与 desktop typecheck 通过。无 P0/P1。

@MagicLizi
MagicLizi merged commit 67afe49 into main Aug 23, 2026
25 of 27 checks passed
@MagicLizi
MagicLizi deleted the dash/fix-codex-ask-user-detached branch August 23, 2026 14:36
@MagicLizi

Copy link
Copy Markdown
Contributor

合了。提问卡以前会在 turn 结束后还空等,现在回答能正确接到下一拍 continuation,这个每天都会踩到。

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

Labels

touches:core 改动碰到架构核心路径(review-pr 自动维护,仅展示) touches:product-ui 改动碰到产品 / UI 面(review-pr 自动维护,仅展示)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants