Skip to content

chat: surface out-of-band subagent approvals - #336317

Merged
Justin Chen (justschen) merged 5 commits into
mainfrom
agents/fix-subagent-rendering-issues
Sep 16, 2026
Merged

Justin Chen (justschen) merged 5 commits into
mainfrom
agents/fix-subagent-rendering-issues

Conversation

@justschen

Copy link
Copy Markdown
Collaborator

Summary

Make pending subagent approvals discoverable independently of where their original launch response is rendered, while preserving the existing confirmation UI.

  • Discover pending tool invocations from the chat view model instead of relying on a mounted transcript row to populate the input confirmation carousel.
  • Surface approvals from earlier responses in the Sessions list, preserving current-request precedence and the original tool callback. Single-choice file approvals are supported; multi-choice file operations remain in the full chat UI.
  • Keep the original subagent pill's pending/active approval highlight and the usual confirmation card with Allow/Skip. Do not add an "action needs your approval" heading, duplicate launch pill, or generic out-of-band shimmer. Ordinary current-request confirmation presentation is preserved.
  • Route Accept/Skip commands to the selected carousel item, preserve each item's rendering context, and clean up stale entries when models change.
  • Restore edited terminal commands, including extracted directory prefixes, when recreating an approval after switching chats. Observe request-edit entry/exit directly so a pending approval appears immediately when editing ends.

Investigation findings

The apparent hangs included several distinct cases:

  1. Offscreen approval — addressed here. A retained subagent continued publishing into its original parent response. The pending invocation and confirmation callback existed in the frontend model, but that historical response was outside the virtualized viewport. Revealing it exposed the existing Allow button. Carousel discovery depended on rendering that row, and the Sessions-list approval model only inspected the latest response. The session-level inputNeeded watcher handles owned client-tool execution, not independent rendering of SDK-native shell/file approvals.
  2. Reported failure after Allow — not established by the original export. That capture ended with two independent approvals pending and did not contain the reported final Allow action. This patch tests correct callback/selection behavior but does not claim to resolve every provider-side post-approval stall.
  3. Large subagent fan-out — not addressed here. A later capture contained 40 attempted launches: 32 succeeded and eight were rejected by that runtime's 32-concurrent-agent limit. All 32 eventually published child-start events. Earlier Resource not found subscriptions preceded delayed child startup; the remaining 18 requested reviews were not hidden running agents.
  4. Foreground completion while a background shell remains alive — not addressed here. A separate capture showed successful task_complete, completed tool calls, and delivered final Markdown, but no protocol chat/turnComplete while an attached preview server remained running. That completion-boundary issue is tracked separately in agentHost: finish foreground turns independently of background work #336083.

Related rendering work: #335899. This PR does not change SDK/CLI versions, runtime concurrency limits, child-start timing, or foreground completion semantics.

Validation

  • npm run gulp compile-client — passed, zero errors.
  • Full hygiene for all 14 changed files — passed; pre-commit hygiene also passed.
  • Focused Electron suites for AgentSessionApprovalModel, ChatListRenderer, ChatSubagentContentPart, and Sessions-list chat rows — 263 passing, 1 existing pending.
  • Regressions cover completed historical responses, independent Sessions-list Allow buttons, retained-pill highlighting, no extra heading/shimmer, model removal/rebinding, command edits across chat switches, and cancelling request editing without further progress.
  • Real browser interaction with the actual chat list, input, terminal editors, and confirmation controls in Dark/Light themes. The original launch stayed unmounted while both approvals appeared; revealing it showed both pills highlighted. Allow cleared only the selected approval/highlight, then the remaining mock approval completed independently. No real shell commands or LLM calls were executed by the mock approvals. Preview processes were stopped after testing.

Manual validation

Open the existing Component Explorer Server task and select chat/agent-lifecycle/chatAgentLifecycle/OffscreenSubagentApprovals (Dark or Light):

  1. The conversation starts on a later request with the original launch offscreen.
  2. Select Request Offscreen Approvals. Both approvals should be available above the input with the existing card style, without an extra count heading or shimmer.
  3. Select Show Original Agent. Both retained pills should indicate pending approval; the active approval retains its existing emphasis.
  4. Select Allow, or use Accept Selected / Skip Selected. Only that invocation should resolve; the other remains pending.
  5. Approve the remaining mock check. Its continuation is recorded and the carousel clears.

The fixture's shortcut shim dispatches the real Accept/Skip commands; it is not an end-to-end test of the production keybinding resolver. Sessions-list Allow routing is exercised separately with real row controls in the focused tests.

Discover pending approvals independently of virtualized transcript rows and include retained-worker approvals in the Sessions list. Preserve the existing confirmation card and subagent attention styling without adding an out-of-band status heading or shimmer.

Keep approval callbacks and command edits intact across model switches, and route Accept/Skip to the selected carousel item. Cover historical approvals, request editing, independent confirmations, and pill highlighting with regression tests and an interactive mock fixture.

Co-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings September 15, 2026 19:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Accept Selected bypasses option-specific callbacks, losing required selected-option metadata.

Get a fresh assessment by requesting another Copilot review.

Review tier: Balanced (auto)
Findings: 1 Medium severity

Note

Copilot is running an experiment and ran this review at Balanced.

Open (1)
What changed in this PR

Surfaces offscreen subagent approvals in chat and Sessions while preserving existing confirmation UI and callbacks.

Changes:

  • Discovers pending confirmations directly from chat models.
  • Routes carousel actions to the selected approval and preserves command edits.
  • Adds regression and interactive fixture coverage.
File Description
chatWidget.fixture.ts Extends widget fixture behavior.
chatAgentLifecycle.fixture.ts Adds offscreen-approval scenario.
chatListRenderer.test.ts Tests discovery, routing, editing, and cleanup.
chatSubagentContentPart.test.ts Tests retained-pill highlighting.
agentSessionApprovalModel.test.ts Tests historical Sessions approvals.
chatViewModel.ts Exposes editing-state changes.
chatInputPart.ts Manages model-driven carousel entries.
chatListRenderer.ts Discovers offscreen confirmations.
chatToolConfirmationCarouselPart.ts Preserves per-item factories and removal.
chatTerminalToolConfirmationSubPart.ts Restores edited commands.
chat.shared.contribution.ts Updates setting documentation.
agentSessionApprovalModel.ts Finds approvals across responses.
chatToolActions.ts Targets the active carousel item.
sessionsList.test.ts Tests Sessions-row approval controls.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

github-actions Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Screenshot Changes

Base: 6a932e0f Current: 7691ecc9

Changed (2)

sessions/sessionChatInputToolbar/SessionChatView_ArtifactPillAndPermission/Dark
Before After
before after
sessions/sessionChatInputToolbar/SessionChatView_ArtifactPillAndPermission/Light
Before After
before after

3 insignificant change(s) omitted (≤20 px, Δ≤2). See CI logs for details.

Added (8)

chat/agent-lifecycle/chatAgentLifecycle/OffscreenSubagentApprovals/Dark

current

chat/agent-lifecycle/chatAgentLifecycle/OffscreenSubagentApprovals/Light

current

chat/agent-lifecycle/chatAgentLifecycle/CompletedSectionBeforeSubagents/Dark

current

chat/agent-lifecycle/chatAgentLifecycle/CompletedSectionBeforeSubagents/Light

current

chat/agent-lifecycle/chatAgentLifecycle/CompletedThinkingAfterSubagents/Dark

current

chat/agent-lifecycle/chatAgentLifecycle/CompletedThinkingAfterSubagents/Light

current

chat/agent-lifecycle/chatAgentLifecycle/CompletedAgentReadAfterSubagents/Dark

current

chat/agent-lifecycle/chatAgentLifecycle/CompletedAgentReadAfterSubagents/Light

current

Invoke the active confirmation card's primary action so keyboard acceptance preserves option metadata and respects disabled actions.

Co-authored-by: Copilot <[email protected]>
Retained subagents flickered between working and idle because the host completed a child 250 ms after each SDK model round ended, even when the next round had already started. Completion now confirms against the task list before closing a child turn, re-arms when the confirmation is superseded or fails, and ignores stale task snapshots taken before a child started its next round.

An empty final answer now emits an explicit response-round-ended boundary so the parent's open thinking or tool section settles instead of looking stuck, without claiming the markdown scope for later text. The Working shimmer stays hidden while active subagent pills are the last visible content and returns after other content.

Read agent and Write to agent labels use the canonical agent display name in streaming, ready, completed, and restored history, keeping the execution id as the fallback.

Co-authored-by: Copilot <[email protected]>
@justschen
Justin Chen (justschen) marked this pull request as ready for review September 16, 2026 00:54
@justschen

Copy link
Copy Markdown
Collaborator Author

Copilot resolve the merge conflicts in this pull request

…endering-issues

# Conflicts:
#	src/vs/workbench/contrib/chat/test/browser/widget/chatListRenderer.test.ts

Co-authored-by: justschen <[email protected]>

Copilot AI commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Copilot resolve the merge conflicts in this pull request

Resolved in fb8d716 by merging the latest main, preserving both branches’ test imports and behavior. Transpilation and targeted hygiene passed; focused tests: 380 passing, 1 pending.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants