feat(codex): choose implementation model at plan approval - #3267
feat(codex): choose implementation model at plan approval#3267Beautyl0ve wants to merge 1 commit into
Conversation
Signed-off-by: Beautyl0ve <74452755+Beautyl0ve@users.noreply.github.com>
|
| Filename | Overview |
|---|---|
| apps/desktop/src/main/maker-ipc/planReviewModelApproval.ts | 新增 exact-request 保留、事务排序、失败回滚和 CAS 式批准协调器,未发现阻塞问题。 |
| apps/desktop/src/main/maker-ipc/register.ts | 将模型热切换、路由与上下文复核、持久化及计划批准整合为主进程事务。 |
| apps/desktop/src/main/maker-ipc/runtimeSetModel.ts | 增加 requireHotSwitch 模式,拒绝关闭、重建、跨路由或延迟切换。 |
| apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx | 增加选择器资格判断、请求级选择状态和原子审批入口。 |
| apps/desktop/src/renderer/components/new-chat/PlanActionCard.tsx | 增加模型选择器和异步防重复提交,但旧请求回调可错误解锁新请求。 |
| apps/desktop/src/renderer/components/new-chat/ModelSelector.tsx | 新增 provider 限定范围,并沿用既有模型资格与能力派生逻辑。 |
| apps/desktop/src/preload/preload.ts | 新增窄化的本机计划审批模型切换桥接方法。 |
Sequence Diagram
sequenceDiagram
participant U as 用户
participant R as Renderer
participant M as Main IPC
participant S as Codex Session
participant D as Session DB
U->>R: 选择实现模型并批准
R->>M: approvePlanReviewWithModel
M->>M: 保留并复核 exact request
M->>S: 热切模型、effort、Fast Mode
M->>D: 持久化完整选择
M->>M: 再次校验并批准计划
alt 任一步骤失败或请求已替换
M->>S: 恢复运行时快照
M->>D: 恢复数据库快照
M-->>R: 保持计划 pending 并返回错误
else 成功
M-->>R: 批准完成
end
Prompt To Fix All With AI
### Issue 1
apps/desktop/src/renderer/components/new-chat/PlanActionCard.tsx:108-117
**旧请求回调重置新提交锁**
如果请求 A 的审批仍在等待时计划卡切换到请求 B,A 随后返回 `false` 或 rejection 会无条件清除 B 正在使用的 `submittedRef`。这会在 B 的审批仍在途时重新启用按钮,允许用户发起重复 IPC,并触发 `in_flight` / `PRECONDITION_FAILED` 错误和误导性的失败提示。
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "feat(codex): choose implementation model..." | Re-trigger Greptile
| void Promise.resolve(result) | ||
| .then((accepted) => { | ||
| if (accepted !== false) return; | ||
| submittedRef.current = false; | ||
| setSubmitted(false); | ||
| }) | ||
| .catch(() => { | ||
| submittedRef.current = false; | ||
| setSubmitted(false); | ||
| }); |
There was a problem hiding this comment.
如果请求 A 的审批仍在等待时计划卡切换到请求 B,A 随后返回 false 或 rejection 会无条件清除 B 正在使用的 submittedRef。这会在 B 的审批仍在途时重新启用按钮,允许用户发起重复 IPC,并触发 in_flight / PRECONDITION_FAILED 错误和误导性的失败提示。
Context Used: 使用和PR描述相同的语言进行评论 (source)
Knowledge Base Used: Desktop renderer experience
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop/src/renderer/components/new-chat/PlanActionCard.tsx
Line: 108-117
Comment:
**旧请求回调重置新提交锁**
如果请求 A 的审批仍在等待时计划卡切换到请求 B,A 随后返回 `false` 或 rejection 会无条件清除 B 正在使用的 `submittedRef`。这会在 B 的审批仍在途时重新启用按钮,允许用户发起重复 IPC,并触发 `in_flight` / `PRECONDITION_FAILED` 错误和误导性的失败提示。
**Context Used:** 使用和PR描述相同的语言进行评论 ([source](https://app.greptile.com/review/custom-context?memory=instruction-0))
**Knowledge Base Used:** [Desktop renderer experience](https://app.greptile.com/xindong/-/custom-context/knowledge-base/makecindy/cindy/-/docs/desktop-renderer-experience.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.|
@Beautyl0ve 👋 这个 PR 还有 1 条 review conversation 没 resolve(apps/desktop/src/renderer/components/new-chat/PlanActionCard.tsx),auto-review 因此暂时跳过、没法继续审查 / 合并。 如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。 |
|
@Beautyl0ve 👋 这个 PR 目前与 请在本地 merge 最新的 |
|
这个 PR 会改用户能看见的计划批准交互(选择实现模型),已按维护者确认门拦住,讨论 issue:#3305 请维护者在本 PR 上 Approve 放行;若要改,请 Request Changes。作者这边先不用再推来「催合并」——球在维护者手里。 |
|
命中 UI 路径(apps/desktop/src/renderer/components/new-chat/ModelSelector.tsx / apps/desktop/src/renderer/components/new-chat/PlanActionCard.tsx / apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx 等)但 description 未附界面效果证据——建议补充改动后效果:截图/录屏,或改动后界面的 HTML 页面(```html 代码块、.html 附件或在线预览链接),便于确认界面符合 DESIGN.md 设计规范 |
Draft PR —
feat(codex): choose implementation model at plan approval这次改了什么
摘要
This is a focused local Codex slice of #2840. During
plan_review, the usercan choose which model should execute the approved plan without leaving the plan
card. Browsing the selector does not mutate the live session.
Approval is guarded in main as one transaction: reserve the exact pending request,
snapshot and revalidate the live provider/credential route and target context capacity,
hot-switch model plus effort/Fast Mode, persist the complete selection, revalidate the
same request, and only then approve it. Runtime, persistence, stale-request, unsafe
context shrink, or rollback failures keep the plan pending; a request that once exposed
the selector cannot silently downgrade to ordinary approval after eligibility disappears.
变更类型
feat新功能fix缺陷修复refactor/perf重构或性能优化docs/test/chore文档、测试或工程维护范围
plan_review的实现模型选择器;同一显式 provider / credentialfamily 的即时 hot-switch;exact-request reservation / revalidation;runtime + effort +
Fast Mode + persistence 的事务与回滚;资格漂移 fail-closed;回归测试与五语种文案。
需要 close/rebuild/defer 的切换;修改共享
InteractionDecision;完成 feat: plan 模式执行确认弹窗支持选择模型 #2840 的其他 Agent。maker:set-model调用保持兼容。UI 变化
无截图:当前未启动完整桌面应用做交互录屏。本 PR 复用现有
ModelSelector、计划卡 token和 popover 行为,没有引入新颜色或独立选择器样式。
docs/design-rules/DESIGN.md§4「Select & Dropdown」复用统一模型行契约;§10「Theme System & Token Reference」继续消费现有 token;§14.2「Focus Management」继续
使用既有 ModelSelector popover 的焦点管理。
怎么验证的
自动验证
基于审计基线
mainc723fd3crebase 后,在最终签署提交99de412f0的代码树上执行:在最终签署提交
99de412f0上,使用仓库固定的 pnpm 10.33.2 和正常 Windows文件权限补跑了正式提交门禁:
此前一次受限环境中的探索性 related run 错误扩大了测试范围,并因无法写入固定
D:\tmp产生 77 个 EPERM,另触发 21 个无关旧 fixture 失败;该结果已被上述仓库正式门禁取代,不再作为本 PR 的当前验证结果。
手工验证
未执行完整 Cindy 桌面端真实账户 smoke test;没有切换真实模型或产生外部 API 调用。
未执行的验证
maker:set-model的 28 项 runtime 测试和 ordering contract 覆盖。风险
风险分类
影响与回滚
plan_review。普通批准、反馈、编辑、取消及其他 Agent 仍走原通道。exact
requestId、provider route 与 credential family。close/rebuild/defer 在任何 mutation前被拒绝。
snapshot,并保留计划待审批;rollback 自身失败会明确报内部错误且仍不批准计划。
数据格式变更。
只修 provider 标签,#3035
只处理新任务配置继承;merged #3033
提供选择器基础,均不实现本 PR 的审批时执行模型事务。
589a244b2;相对本分支共同基线的两个提交只改apps/mobile和 XAI usage 文件,与本 PR 的 model/plan-review/i18n 路径零交集。git merge-tree --write-tree origin/main HEAD生成9ebaed4d,无冲突。99de412f0(本分支)与a3d292a129(Cindy feat: feature(orca): 协同 Worker 请求授权时没有提醒,希望对齐对话模式 #2532)做了
git merge-tree --write-tree,合并树102b70d0成功;共同文件maker-ipc/register.ts同时保留 plan-model 与 Worker permission 两组语义。提交前检查
git commit -s,见 DCO)