Skip to content

Show active background shells in agent chats - #338713

Closed
Anthony Kim (anthonykim1) wants to merge 1 commit into
mainfrom
anthonykim1/background-shell-ui
Closed

Anthony Kim (anthonykim1) wants to merge 1 commit into
mainfrom
anthonykim1/background-shell-ui

Conversation

@anthonykim1

Copy link
Copy Markdown
Contributor

Depends on: microsoft/agent-host-protocol#475
Related: #336348

  • Add a Background Shells pill above the Agents window chat input. It lists the chat's background shells with running or waiting status, attached or detached mode, and live elapsed time, and opens a list even for a single shell.
  • Publish shells from the Copilot Agent Host: whenever session.background_tasks_changed fires or a client starts watching the chat, read session.rpc.tasks.list() and dispatch the new AHP chat/backgroundShellSet and chat/backgroundShellRemoved actions.
  • Keep the list independent of turns. Shells survive steering and turn completion, and leave the list only when they complete, fail, or are cancelled.
  • Reject superseded task-list reads, and keep the last known list when a read fails.
  • While a client watches a chat that has detached shells, call session.rpc.tasks.refresh() before listing, every 5 seconds.
  • Watch shells only while a hydrated chat has subscribers: AgentService._watchChatHistory becomes _watchChatUpdates and also calls the new optional IAgent.watchChatBackgroundShells.
  • Mirror each chat's list into its session chat summary through session/chatUpdated. Lists are per chat, so the same shell ID in two chats doesn't collide.
  • Open a shell's details on row activation (openHoverOnSelect), move keyboard focus into them, and pin them to the bottom of the picker (alignToParentBottom) so they stay above the input.
  • Use the shared chat-input pill placement, which prefers opening above the input.
  • Hand-apply the protocol changes from Expose active background shells in chat state agent-host-protocol#475 without bumping .ahp-version, as d1fdacc did. A full AHP sync can follow once mkdirp: don't try to create fs roots #475 merges.
  • Leave turn completion alone: an attached shell still keeps the turn active (Agent Host chat stays active after response completes while an attached async shell is running #336348).

Still to do in this draft:

  • Show the pill in the editor window's chat too, not only the Agents window.
  • Fix a race where aborting a turn can drop an in-flight shell-list refresh, leaving the list stale until the next task change.

How to test:

  1. In the Agents window, ask Copilot to run sleep 120 with its shell tool in async mode, without detaching.
  2. A 1 Background Shell pill appears above the input. Open it and select the shell to see its status, mode, and elapsed time.
  3. Send another message or let the turn finish: the shell stays listed. When the command exits, it leaves the list. The turn stays active until then, which is existing behavior (Agent Host chat stays active after response completes while an attached async shell is running #336348).

Validation on this branch:

  • npm run typecheck-client: passed.
  • npx eslint --max-warnings=0 on the 31 changed .ts files: passed.
  • ./scripts/test.sh src/vs/platform/actionWidget/test/browser/actionList.test.ts src/vs/workbench/test/browser/chatPills.test.ts src/vs/workbench/contrib/chat/test/browser/chatInputPills.test.ts src/vs/workbench/contrib/chat/test/common/sessionChatPills.test.ts src/vs/sessions/contrib/chat/test/browser/sessionBackgroundShellsControl.test.ts src/vs/sessions/contrib/providers/agentHost/test/browser/localAgentHostSessionsProvider.test.ts: 514 passing, 0 failing.
  • npm run test-node -- --run src/vs/platform/agentHost/test/node/agentService.test.ts --run src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts --run src/vs/platform/agentHost/test/node/agentHostStateManager.test.ts: 1488 passing, 0 failing.

Inspirations from:

Copilot AI balanced review requested due to automatic review settings September 29, 2026 16:29

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

Aborting can discard the only shell refresh, and the editor chat surface remains unwired.

Review effort: Balanced
Findings: 3 Medium severity

Open (3)
What changed in this PR

Adds protocol-backed background-shell visibility to agent chats, including live status UI and task reconciliation.

Changes:

  • Adds AHP background-shell state/actions and session projection.
  • Publishes and refreshes Copilot shell inventories.
  • Adds the Agents window shell pill, details picker, accessibility help, and tests.
File Description
src/​vs/​workbench/​test/​browser/​chatPills.test.ts Tests shell dropdown behavior.
src/​vs/​workbench/​contrib/​chat/​test/​common/​sessionChatPills.test.ts Tests pill visibility defaults.
src/​vs/​workbench/​contrib/​chat/​test/​browser/​chatInputPills.test.ts Tests shell pill presentation.
src/​vs/​workbench/​contrib/​chat/​common/​sessionChatPills.ts Registers the new pill kind.
src/​vs/​workbench/​contrib/​chat/​browser/​sessionChatPillOptions.ts Defines shell pill options.
src/​vs/​workbench/​contrib/​chat/​browser/​chatInputPills.ts Adds the shared shell source.
src/​vs/​workbench/​browser/​chatDropdownPill.ts Supports activation-driven details.
src/​vs/​sessions/​services/​sessions/​common/​session.ts Adds provider-neutral shell metadata.
src/​vs/​sessions/​contrib/​providers/​agentHost/​test/​browser/​localAgentHostSessionsProvider.test.ts Tests per-chat projection.
src/​vs/​sessions/​contrib/​providers/​agentHost/​browser/​baseAgentHostSessionsProvider.ts Projects protocol shell state.
src/​vs/​sessions/​contrib/​chat/​test/​browser/​sessionBackgroundShellsControl.test.ts Tests live shell presentation.
src/​vs/​sessions/​contrib/​chat/​browser/​sessionsChatAccessibilityHelp.ts Documents keyboard interaction.
src/​vs/​sessions/​contrib/​chat/​browser/​sessionChatInputToolbar.ts Wires the Agents window pill.
src/​vs/​sessions/​contrib/​chat/​browser/​sessionBackgroundShellsControl.ts Implements shell rows and details.
src/​vs/​platform/​agentHost/​test/​node/​copilotAgentSession.test.ts Tests reconciliation and polling.
src/​vs/​platform/​agentHost/​test/​node/​agentService.test.ts Tests subscription-scoped watches.
src/​vs/​platform/​agentHost/​test/​node/​agentHostStateManager.test.ts Tests catalog mirroring.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotAgentSession.ts Reads and publishes runtime tasks.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotAgent.ts Manages per-chat shell watches.
src/​vs/​platform/​agentHost/​node/​agentService.ts Starts watches for subscribed chats.
src/​vs/​platform/​agentHost/​node/​agentHostStateManager.ts Mirrors shells into chat summaries.
src/​vs/​platform/​agentHost/​common/​state/​sessionState.ts Maps shell state and summaries.
src/​vs/​platform/​agentHost/​common/​state/​protocol/​version/​registry.ts Versions the new actions.
src/​vs/​platform/​agentHost/​common/​state/​protocol/​common/​actions.ts Registers protocol action types.
src/​vs/​platform/​agentHost/​common/​state/​protocol/​channels-chat/​state.ts Defines protocol shell metadata.
src/​vs/​platform/​agentHost/​common/​state/​protocol/​channels-chat/​reducer.ts Reduces shell set/removal actions.
src/​vs/​platform/​agentHost/​common/​state/​protocol/​channels-chat/​actions.ts Defines shell actions.
src/​vs/​platform/​agentHost/​common/​state/​protocol/​action-origin.generated.ts Updates generated action unions.
src/​vs/​platform/​agentHost/​common/​agent.ts Adds the optional watch API.
src/​vs/​platform/​actionWidget/​test/​browser/​actionList.test.ts Tests live detail panels and layout.
src/​vs/​platform/​actionWidget/​browser/​actionList.ts Adds activated hover panels and bottom alignment.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

this._subagentTaskCompletionSchedulers.clearAndDisposeAll();
this._subagentActivityRevisions.clear();
this._subagentTaskStatusRevision++;
this._backgroundTaskStatusRevision++;
customizations: { sections: this._customizationSections },
browsers: { sections: this._browsers.sections },
subagents: this._backgroundActivities,
backgroundShells,
Comment on lines +666 to +668
readonly status: 'running' | 'idle';
readonly startedAt: string;
readonly attachmentMode: 'attached' | 'detached';
@github-actions

Copy link
Copy Markdown
Contributor

Screenshot Changes

Base: 782165a8 Current: be5efcf8

Changed (1)

sessions/accountMenu/WeeklyLimitOnly/Light
Before After
before after

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

@anthonykim1

Copy link
Copy Markdown
Contributor Author

Replaced by #338723, which uses the background work shape from microsoft/agent-host-protocol#482.

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.

2 participants