Skip to content

[code-review] subagent Complete terminal branch skips onComplete and notifyUpdate: cancel-race success result invisible to UI collectors #2783

Description

@topcheer

文件: internal/subagent/manager.go L1011-1027(terminal 分支)vs L1046-1049(正常路径)

问题描述
Complete() 的 terminal 分支(agent 已被 Cancel 置为终态后 Complete 才到达)只做 result 回填 + closeDone + return,不调用 onComplete、也不调用 notifyUpdate。对照正常路径两者都调。

触发场景
用户在 subagent 流式输出最后一轮按 Esc 取消 → Cancel 置 StatusCancelled(Cancel 本身只发 notifyUpdate 不发 onComplete);runner goroutine 已算完 output,随后调 Complete(id, output, nil) → 走 terminal 分支 → sa.Result 被回填但 UI 无任何事件。

影响

  • internal/tui/repl.go L889-899(subAgentDoneMsg → 系统提示行 + grace cleanup)不触发
  • desktop/wailskit/chat.go L1773 的 onComplete 结果收集器拿不到通知
    结果数据未丢(可经 Wait/查询取回),但事件驱动上层在 cancel-race 场景下感知缺失。

修复建议
terminal 分支在 return 前调用 notifyUpdate(sa)(携带回填后的 result);onComplete 是否补调需按回调幂等性评估,至少 onUpdate 应发出。

严重程度: medium

来源: cron-1 深度审查,独立复核 subagent 确认(发射侧/消费方双端验证)

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions