Conversation
首次切到 dormant worker 要等 ~5s:switch_focus 的 IPC/MCP handler 同步 await resumeOrcaWorkerSessionIfMissing,而冷会话要 spawn 整个 agent runtime(Pi 实测 2~3s,含 11 个 MCP server + resume 会话),renderer 的面板切换因此被阻塞。 - switch_focus(IPC 与 MCP)改为 setWorkerFocus + 广播后立即返回,idle worker 的 runtime 预热转后台;worker 历史来自 DB,不需要 live runtime - 新增 orcaWorkerResumeScheduler:per-session 去重 + 与发送路径共用 sendToSession 锁,避免 focus 预热与发送/派活并发双 bootstrap - resumeWorkerSession(派活路径)改走同一调度器;预热失败只告警,不影响 focus 结果 - 更新 orca 架构文档不变量;补调度器单测并同步 source-contract 断言 Signed-off-by: Zhang Yunjin <zhangyunjin@zju.edu.cn>
…c-resume Signed-off-by: Zhang Yunjin <zhangyunjin@zju.edu.cn>
|
review P1:关闭协同 / 归档 / 显式 idle 释放 runtime 后,仍在等锁或冷启动中的 focus 预热会把已归档 worker 重新拉活。 - orcaWorkerResumeScheduler 增加 cancel:等锁中的唤醒直接放弃;已在冷启动的按 isCancelled 在 bootstrap 返回后关掉刚起的 session - resumeOrcaWorkerSessionIfMissing 冷启动前与 bootstrap 后都复核会话仍为 active, 失效则跳过/关闭,fail-closed - disableOrcaInternal(end team)与 OrcaTeamService 的 archiveWorker / idleWorker 释放前先取消待执行唤醒 - 补调度器 cancel 单测与 source-contract 断言;同步架构文档不变量 3a Signed-off-by: Zhang Yunjin <zhangyunjin@zju.edu.cn>
Contributor
Author
|
@greptileai review |
Contributor
|
维护者确认请求:本 PR 命中 rules(审查规则文档变更) 与 arch(核心路径改动 452 行) 两类确认触发,自动流程在维护者确认前不会合并。 需要确认的点:
请维护者直接在本 PR 上 Approve 确认;需要作者修改则 Request Changes 并写明要求。详见讨论 issue:#5210 |
zyjisdog
added a commit
to zyjisdog/cindy
that referenced
this pull request
Sep 28, 2026
Upstream-PR: makecindy#5205 Upstream-PR-Head: a816525 Signed-off-by: Zhang Yunjin <zhangyunjin@zju.edu.cn>
zyjisdog
added a commit
to zyjisdog/cindy
that referenced
this pull request
Sep 29, 2026
Upstream-PR: makecindy#5205 Upstream-PR-Head: a816525 Signed-off-by: Zhang Yunjin <zhangyunjin@zju.edu.cn>
…c-resume 冲突解决:register.ts(resume helper 签名、MCP switchFocus 调度)与 orcaTeamService.ts (idleWorker 的 assertAfterIdle)。上游新增 assertCurrent 插件权威校验,与本 PR 的 isCancelled 取消语义正交,合并保留两者:MCP switchFocus 仍透传 assertCurrent 到后台预热。 Signed-off-by: Zhang Yunjin <zhangyunjin@zju.edu.cn>
Contributor
Author
|
@greptileai review |
合并上游 assertCurrent(插件 authority / 账号边界)后暴露的缝隙:bootstrapSession 已创建 runtime,随后 assertCurrent() 抛错会直接冒泡,跳过原有关闭分支;后台预热只 记日志,刚启动的 worker 留在运行态。 - post-bootstrap 的授权复核包进 try/catch:失败先 closeSession 再原样抛出,保持同步 调用方的冒泡语义,同时不让 runtime 泄漏 - 抽出 closeResumedSession(reason) 统一清理路径(授权失效 / 取消 / 已归档共用) - source-contract 断言锁定「先清理再抛出」的顺序 Signed-off-by: Zhang Yunjin <zhangyunjin@zju.edu.cn>
Contributor
Author
|
@greptileai review |
zyjisdog
added a commit
to zyjisdog/cindy
that referenced
this pull request
Oct 1, 2026
Upstream-PR: makecindy#5205 Upstream-PR-Head: de22e05 Signed-off-by: Zhang Yunjin <zhangyunjin@zju.edu.cn>
上一轮只加了 source-contract 文本断言(toContain + expectOrder),守不住运行期行为: 如果 post-bootstrap 的关闭分支将来真的不再关 runtime,文本断言仍会通过。 - 新增 orcaWorkerResumeCleanup.test.ts:沿用仓库既有的「切源码 + new Function 注入依赖」 手法,真实执行 resumeOrcaWorkerSessionIfMissing - 覆盖四条路径:授权复核在 bootstrap 后失效(关 session 且原错误继续抛)、取消标记在 bootstrap 后为真(关 session 返回 false)、会话在冷启动过程中被归档(关 session)、 健康路径(保留 runtime) - 已做 mutation 验证:分别删掉两条 closeSession 调用,对应用例立刻失败 Signed-off-by: Zhang Yunjin <zhangyunjin@zju.edu.cn>
Contributor
Author
|
@greptileai review |
…c-resume Signed-off-by: Zhang Yunjin <zhangyunjin@zju.edu.cn> # Conflicts: # apps/desktop/src/main/__tests__/makerSendToSessionOrdering.test.ts
zyjisdog
added a commit
to zyjisdog/cindy
that referenced
this pull request
Oct 5, 2026
Upstream-PR: makecindy#5205 Upstream-PR-Head: 650e4f2 Signed-off-by: Zhang Yunjin <zhangyunjin@zju.edu.cn>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
这次改了什么
摘要
协同模式下首次切到 dormant worker 要等
5s:3s,含 11 个 MCP server + resume 会话),renderer 的面板切换要等这条 IPC 返回才发生。第二次切换快,是因为 runtime 已经 live,switch_focus的 IPC / MCP handler 里同步await冷会话的 resume,而冷会话要 spawn 整个 agent runtime(Pi 实测 2resumeOrcaWorkerSessionIfMissing首行maker.getSession命中即返回。本次把 idle worker 的 runtime 预热转后台:
switch_focus在setWorkerFocus+ 广播后立即返回;新增orcaWorkerResumeScheduler做 per-session 去重并复用sendToSession的 per-session 锁,承接 focus 预热与派活路径的 resume,保证同一会话不会被并发 bootstrap 两次(发送先持锁完成懒恢复时,后台 resume 在锁内重查 live 并跳过)。worker 历史来自 DB,展示不需要 live runtime;发送/派活路径本来就有懒恢复,冷启成本从「阻塞切换」移到「后台预热」。变更类型
fix缺陷修复范围
switch_focus(IPC + MCP)改为后台调度 resume,focus 不再等待冷启动orcaWorkerResumeScheduler(per-session 去重 + 与withSendToSessionLock共用锁),派活路径resumeWorkerSession同样接入docs/dev-rules/orca-team-architecture.mdWorker 运行态不变量bootstrapSession返回后复核会话仍 active,失效则关掉刚拉起的 runtimeUI 变化
怎么验证的
自动验证
手工验证
pnpm restart:desktop:remote --region=cn(commit2b37adf65)启动 dev 实例成功:DESKTOP_DEV_VERDICT=ready。未执行的验证
makerSendToSessionOrdering.test.ts存在 upstream 自身的 source-contract 漂移(源码已是pendingAgentSwitchApplyHolder = async (sessionId, signal, selection, beforeApply) =>,断言仍按旧签名匹配),与本 PR 无关;该 tier 不在 unit CI 路径内,upstream main CI 绿。本 PR 对该文件的改动只是其中的 switch_focus 断言。风险
风险分类
影响与回滚
提交前检查
git commit -s)docs/dev-rules/orca-team-architecture.md已同步新增不变量 3a)