Repository navigation
Conversation
Assisted-by: Cindy (https://cindy.app) Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e34068be0a
ℹ️ 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".
| await this.trackPersistence( | ||
| dispatchBoundary, this.deps.storage.upsert(acceptedState), | ||
| () => this.deps.persistUserMessage?.(sessionId, state.objective, { goalObjective: { updated: false } }), |
There was a problem hiding this comment.
Preserve the objective message's pre-dispatch ordering
When the provider emits output or finishes before session.send() returns, the Host can persist the assistant response before this objective message is created. This is the fast-terminal scenario already exercised by batch4f-goal.test.mjs. Because goal-runtime.ts supplies no createdAt, writeMessageRow() timestamps the objective at insertion time, and chatHistoryReader.ts orders messages by creation time and rowid. Consequently, reopening the conversation displays the goal-setting user message after the response it prompted. Preserve a pre-dispatch timestamp or reserve the message's ordering before dispatch while still deferring its publication until acceptance.
Useful? React with 👍 / 👎.
zqchris
left a comment
There was a problem hiding this comment.
Auto-approved by Chris’s trusted-author rule for makecindy/cindy. This is an automated approval.
Confidence Score: 3/5
[Medium impact] The PR expands Goal execution to client mode on the local Host. 合并前需要修复首轮保存失败后的 Goal 归属丢失,以及输入解锁后目标不再推进的问题。 FindingsFix with agent prompt### Issue 1
apps/desktop/src/main/goal-host/controller.ts:3004-3008
首轮已被模型受理后,如果 `session_goals` 或目标消息写入失败,`firstAccepted` 仍为 false,`startGoal` 会通过 `stopSession` 删除监听和续跑状态。但输入协调器已收到 `noteAccepted`,不会取消模型回合。用户会看到设置失败,模型却继续工作;若只有目标消息写入失败,还会留下无人推进的 active Goal。
请分开记录“模型已受理”和“保存完成”。保存失败时保留可重试的写入及 Goal 归属,或明确停止已受理的回合。
### Issue 2
apps/host/src/agent/input-queue.mjs:269-271
Host 只在回合结算后调用 `goalInputIdle`,没有在输入锁解除时唤醒 Goal。如果续跑计时器触发时仍有交互锁,`ensureInputReady` 返回 false,这次续跑机会就被消耗掉。之后 `setInteractionLock(..., false)` 只更新队列,没有新回合触发唤醒,Goal 会一直停在 active。
桌面原实现会在队列不再阻塞时通知 Goal。请为 Host 补上同样的解锁唤醒,并保留未结算回合的检查。
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
|
| await this.trackPersistence( | ||
| dispatchBoundary, this.deps.storage.upsert(acceptedState), | ||
| () => this.deps.persistUserMessage?.(sessionId, state.objective, { goalObjective: { updated: false } }), | ||
| ); | ||
| firstAccepted = true; |
There was a problem hiding this comment.
首轮已被模型受理后,如果 session_goals 或目标消息写入失败,firstAccepted 仍为 false,startGoal 会通过 stopSession 删除监听和续跑状态。但输入协调器已收到 noteAccepted,不会取消模型回合。用户会看到设置失败,模型却继续工作;若只有目标消息写入失败,还会留下无人推进的 active Goal。
请分开记录“模型已受理”和“保存完成”。保存失败时保留可重试的写入及 Goal 归属,或明确停止已受理的回合。
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop/src/main/goal-host/controller.ts
Line: 3004-3008
Comment:
**保存失败后模型仍在运行**
首轮已被模型受理后,如果 `session_goals` 或目标消息写入失败,`firstAccepted` 仍为 false,`startGoal` 会通过 `stopSession` 删除监听和续跑状态。但输入协调器已收到 `noteAccepted`,不会取消模型回合。用户会看到设置失败,模型却继续工作;若只有目标消息写入失败,还会留下无人推进的 active Goal。
请分开记录“模型已受理”和“保存完成”。保存失败时保留可重试的写入及 Goal 归属,或明确停止已受理的回合。
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| if (settled && !closing && !profileHold && isCurrent()) { | ||
| if (goalTurn) executor.confirmGoalSettlement(id, goalTurn); | ||
| else if (terminal) deps.goalInputIdle?.(id); |
There was a problem hiding this comment.
Host 只在回合结算后调用 goalInputIdle,没有在输入锁解除时唤醒 Goal。如果续跑计时器触发时仍有交互锁,ensureInputReady 返回 false,这次续跑机会就被消耗掉。之后 setInteractionLock(..., false) 只更新队列,没有新回合触发唤醒,Goal 会一直停在 active。
桌面原实现会在队列不再阻塞时通知 Goal。请为 Host 补上同样的解锁唤醒,并保留未结算回合的检查。
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/host/src/agent/input-queue.mjs
Line: 269-271
Comment:
**解锁后目标不再推进**
Host 只在回合结算后调用 `goalInputIdle`,没有在输入锁解除时唤醒 Goal。如果续跑计时器触发时仍有交互锁,`ensureInputReady` 返回 false,这次续跑机会就被消耗掉。之后 `setInteractionLock(..., false)` 只更新队列,没有新回合触发唤醒,Goal 会一直停在 active。
桌面原实现会在队列不再阻塞时通知 Goal。请为 Host 补上同样的解锁唤醒,并保留未结算回合的检查。
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit e34068b. Configure here.
| if (isCurrentDispatch()) { | ||
| this.emit(acceptedState); | ||
| opts.first.publishTerminal(); | ||
| } |
There was a problem hiding this comment.
Failed set leaves an active Goal
High Severity
The provider send is marked accepted before the Goal row and objective message finish committing. If that later write fails, startGoal treats the attempt as unsuccessful and stopSession only detaches the listener. A committed session_goals row stays active, and the running turn is not abandoned, so the Goal never advances.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit e34068b. Configure here.
Assisted-by: Cindy (https://cindy.app) Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>


这次改了什么
摘要
这是阶段 4(本机桌面界面与后台分离)的 Batch 4F-1。桌面以客户端模式连接本机
cindy-host时,桌面和 Host 都不运行 Goal 控制器,Goal 完全用不了。本批让 Host 成为 Goal 唯一的运行端,客户端模式下可以设置目标并查看状态,窗口关掉后已受理的 Goal 由 Host 继续推进。apps/host/src/agent/goal-runtime.ts)。session_goals只由 Host 写入。maker:goal:get-status:只读,不调用resumeOnOpen。冷启动和打开窗口都只展示已存状态,不认领旧存档、不发轮。maker:goal:set:显式设置目标,是取得续跑资格的唯一入口。参数、回执和限额语义与桌面一致。maker:goal:status-changed:带账号戳。桌面只转发给当前账号的可信窗口,配对 Web 只看到隐藏事件。session_goals的新建、更新、清除共用同一个写入口。构造完 SQL 后复核原 owner、DB、hold 代次和有效期,再在同一同步段执行.run()。ended 写入前还要确认输入运行时没有开始排空或已关闭。切号或 hold 期间的旧回调写不进去,也不发推送。变更类型
feat新功能fix缺陷修复refactor/perf重构或性能优化docs/test/chore文档、测试或工程维护范围
get-status/set两条通道和状态推送,Stop、hold、切号与退役的接线,桌面端在客户端模式下的推送转发,以及通道覆盖清单同步。clear/pause/resume/update四条写口和/goal命令的客户端子集,留给后续批次。runtime-selection.ts入口加了复核,完整修复需要把守卫一路传到messageWrite.ts去重查询之后的 INSERT,留后续。UI 变化
不涉及。复用现有的 Goal 界面和 payload,没有新增文案或组件。
怎么验证的
自动验证
全部使用隔离 HOME、系统默认 TMPDIR、
LANG=zh_CN.UTF-8,取消了LC_ALL、LC_CTYPE和XDT_OFFICIAL_SHARED_PROFILE。HTTP 只走本机回环,使用临时 SQLite 和替身 SDK,没有启动真实 Electron 窗口。作者在
8b9f570a8cdc(基于11fd88a5d3d3)上跑的全量门禁:变基到
f4ed831f8ba9(6A 合入后)之后重跑:新增或改写的测试(工程约定 §3.2),主要在
apps/host/src/ipc-bindings/batch4f-goal.test.mjs,走生产 Host HTTP、生产运行时选路和输入协调器锁序:.run()之前触发 hold、Stop 或真实切换 DB owner:旧库 ended 保持 NULL,turnsUsed 为 0,零 SDK 派发、零 Goal 推送。普通 Stop 的合法 ended 写入正常。TMPDIR的环境复跑 16/16。变异:三轮返修的每处修复都做过真实变异,撤掉后对应用例变红,逐字节复原后再变绿(首轮受理前写 active、Stop 前撤续跑资格、等持久结算、同步 SQL 改回 thenable、派发前代次复核、绕过 route lock、marker 保护、resume 拒绝、drain/scope 守卫等)。
独立复审共 3 轮:
.run()前触发 hold 和真实切换 DB owner),均通过。读写开销:
get-status:每次调用读一次 Goal 行,零写入。set:一次 route lock 内的派发,写一次 Goal 行和一条目标消息。手工验证
不涉及。日常登录会话里不拉起真实窗口,客户端模式的真机走查统一放在 Batch 7。
未执行的验证
风险
风险分类
影响与回滚
maker:goal:get-status、maker:goal:set两条 Host 合同通道,参数和回执沿用桌面原有 payload。状态推送对配对 Web 隐藏。Device Link 和其他 wire 合同不变。session_goals只由持有 profile 的 Host 写,嵌入模式仍由桌面写。提交前检查
git commit -s,见 DCO)和每次通知触发几次 list/扫描/IPC/写事务(读远程数据再写远程调用次数和回包字节),以及隐藏或
卸载后是否停止(见
docs/dev-rules/engineering-conventions.md§8;远程读取同时见docs/dev-rules/server-channel-review.md)apps/docs或说明自动同步会从哪些来源更新。(没有新增入口或文案,只让客户端模式下原有的 Goal 入口可用)Assisted-by: Cindy (https://cindy.app)
Note
High Risk
Touches session input dispatch, durable SQLite writes, and account/hold boundaries for autonomous multi-turn goals—errors could corrupt goal state or allow stale owners to write or continue runs.
Overview
Moves Goal execution to the Host in desktop client mode: new
createHostGoalRuntimewires the sharedGoalControllerthrough the input coordinator’s route lock, turn markers, and owner-scoped synchronous SQL commits.maker:goal:get-statusis read-only observation;maker:goal:setis the only path that starts a goal via newstartGoal, which persists an active row only after the first send is accepted and settles terminals throughwithGoalTurn/ turn reservations.Refactors the controller for Host admission: injectable
onInterventionandpendingHandoff,settleTerminal/afterTurnPersistence, event filtering by session instance and turn generation, andmanagesGoalfor Stop-time pause. Storage and local DB writes gain optionalassertCommit(.run()under the same lease) for goals, messages, handoff consumption, and durable turn end markers.Desktop bootstrap now forwards
maker:goal:status-changedpushes with owner-stamp checks; IPC registry adds themaker-goalcontract family. Goal limit defaults move togoal-host/settings.ts. Extensive Host HTTP integration tests cover hold, account switch, settlement retries, and marker ownership.Reviewed by Cursor Bugbot for commit e34068b. Bugbot is set up for automated code reviews on this repo. Configure here.