Skip to content

feat(desktop): SubAgent 后台会话查看器与思考/工具卡隔离#79

Merged
N123999 merged 7 commits into
mainfrom
feat/desktop-subagent-viewer
Jun 7, 2026
Merged

feat(desktop): SubAgent 后台会话查看器与思考/工具卡隔离#79
N123999 merged 7 commits into
mainfrom
feat/desktop-subagent-viewer

Conversation

@N123999

@N123999 N123999 commented Jun 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • 新增 SubAgent 查看器:点击 run_subagent 工具卡进入与主会话相同 UI 的后台会话页(禁用发送),支持实时刷新与 blocked 时在查看器内审批。
  • host 层从子会话 llmHistory / desktop 投影构建快照,IPC setSubagentViewerTarget 驱动 renderer 数据源切换。
  • 新增子会话 desktop 消息投影与持久化,查看器 Thought 与主 Agent timeline 对齐;已完成会话优先保留含推理行的投影。
  • 修复查看器打开竞态(IPC 完成前 active 导致 auto-close)、Thought 列表 key 冲突,以及子 Agent 工具卡/审批泄漏到主会话(仅 composer 审批卡 + run_subagent 卡)。

Test plan

  • apps/desktop/test/host/subagent-viewer.test.mjs
  • apps/desktop/test/lib/conversation-list-scope.test.mjs
  • apps/desktop/test/lib/subagent-display.test.mjs
  • npm run build:electron
  • 手动:run_subagent → 打开查看器 → Thought 可见;主会话无子工具卡;审批仅在 composer

N123999 added 6 commits June 7, 2026 10:08
新增 archive llmHistory 到 ConversationMessageSnapshot 的转换、setSubagentViewerTarget IPC,并在 buildSnapshot 中注入 subagentViewer。
新增 useSubagentViewer、顶栏 banner、App 消息源切换与 run_subagent 工具卡点击打开查看器。
透传 subagentSessionId 至 pendingToolApproval,提取 PendingApprovalCard,并在查看器内展示匹配的审批 UI。
会话切换、rewind 与 archive 丢失时自动关闭查看器;补充空态文案与 pending 映射单测。
open 在 snapshot 应用后再置 active,避免 auto-close 误关查看器。
主会话与 SubAgent 查看器消息 id 命名空间隔离,切换视图时整表 remount,
防止 Thought 折叠组件因 React key 碰撞逐次堆积。
新增子会话 desktop 消息投影、持久化与查看器消息源解析,使 Thought 与主 Agent timeline 一致;修复 syncPendingToolStates 将子 Agent 审批工具写入主会话,并在委派期间拦截/purge 子工具卡泄漏。
@N123999

N123999 commented Jun 7, 2026

Copy link
Copy Markdown
Collaborator Author

bugbot run

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit db21679. Configure here.

bundle.messageTimeline.clearSubagentStatusLeak(message.id);
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

子代理文本泄漏清理不一致

Medium Severity

本提交为子工具卡泄漏新增了基于 hasInFlightSubagentDelegationInMessages 的清理,但 purgeSubagentLeakTextInCurrentTurn 仍用 hasActiveRunSubagentToolInMessages,且只锚定 preview/runningrun_subagent。在父级 run_subagent 处于 pending-approval 等阶段时,主会话仍可能残留子智能体状态文本,与工具卡被抑制的行为不一致。

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit db21679. Configure here.

private readonly dreamUpdateListeners = new Set<(snapshot: DesktopSnapshot) => void>();
private readonly sessionListUpdateListeners = new Set<() => void>();
private readonly sessionTitleGenerationInFlight = new Set<string>();
private subagentViewerTargetToolCallId: string | null = null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

查看器目标未随会话切换清除

Low Severity

宿主侧 subagentViewerTargetToolCallId 仅由 setSubagentViewerTarget 更新,切换或重置会话时不会自动清空。若渲染端已关闭查看器但 IPC 未完成,或 active 已为 false 而未再发送 null,快照构建仍可能按旧 toolCallId 组装 subagentViewer

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit db21679. Configure here.

purgeSubagentLeakTextInCurrentTurn 与工具行清理共用 hasInFlightSubagentDelegationInMessages 及 pending-approval 锚点;reset/open/delete 会话时清空 subagentViewerTargetToolCallId,避免跨会话残留。
@N123999 N123999 merged commit c74cf0e into main Jun 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant