Skip to content

Render cloud task history from typed session events#318646

Merged
osortega merged 13 commits into
mainfrom
osortega/dying-ptarmigan
May 28, 2026
Merged

Render cloud task history from typed session events#318646
osortega merged 13 commits into
mainfrom
osortega/dying-ptarmigan

Conversation

@osortega
Copy link
Copy Markdown
Contributor

Renders Copilot Cloud Tasks history through the same session-event pipeline the CLI uses, so tool cards, edits, bash terminal output, search results, subagents and MCP results all look identical across providers.

Changes

  • New shared renderer at extensions/copilot/src/extension/chatSessions/common/sessionEventRenderer.ts. Owns the per-turn state (ResponseEventRenderContext) and dispatches assistant.message / assistant.message_delta / tool.execution_* / subagent.* / session.error / abort events into ChatResponseTurn2 parts.
  • copilotCLITools.buildChatHistoryFromEvents now delegates the response-part rendering to the shared helper. Turn-boundary logic (user.message handling, mode instructions, model id tracking) stays in the CLI builder. Net change in copilotCLITools.ts is +25 / -135 lines — pure extraction, no behavior change.
  • copilotCloudSessionContentBuilder.buildTaskResponseTurn calls the shared renderer too, with a small remap from custom_agent.*subagent.* (both follow the same CMC OpenAPI schema; only the names differ).
  • Match github.com/github/github-ui presentation for cloud tasks: the cloud agent emits intermediate assistant.message events that echo tool input/output (raw diffs, file dumps). Keep only the last top-level assistant.message with non-empty content; tool rows render the rest.
  • Plumb ILogService through ChatSessionContentBuilder so the shared renderer can log MCP block conversion errors.

Notes

  • This depends on the updated @vscode/copilot-api package that ships the discriminated AgentTaskSessionEvent union. Until that's bumped, expect compile errors against event.data in the cloud builder — those will go away with the next package update.
  • CLI behavior is byte-identical to main aside from the shared helper indirection.

Test plan

  • Open an existing Copilot Cloud task session in chat and confirm the history matches the github.com/.../tasks/* view: short tool rows, no raw diff dumps in assistant text, the final summary message at the bottom.
  • Open a Copilot CLI session and confirm tool rendering, edit diffs, terminal output, subagent groups and MCP results all still look the same.

osortega added 4 commits May 26, 2026 18:06
- Extract shared session-event-to-chat-parts renderer into
  chatSessions/common/sessionEventRenderer.ts so both the Copilot CLI
  and Cloud Tasks providers produce identical tool/text formatting.
- Render Task API history via the shared renderer, remapping
  custom_agent.* to the equivalent subagent.* names so tool cards,
  bash terminal output, edits, search results, MCP results and
  subagent groups all render the same way they do in the CLI.
- Match github.com/github/github-ui presentation by suppressing
  intermediate assistant.message events that echo tool input/output
  and only rendering the final summary message per turn.
Copilot AI review requested due to automatic review settings May 27, 2026 23:19
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Extracts response-event-to-ChatResponseTurn2 rendering out of the CLI history builder into a shared module so the Copilot Cloud Tasks history can render through the same pipeline (tool cards, edit diffs, terminal output, subagents, MCP results). The CLI builder still owns turn boundaries / request-turn construction and now delegates the response side to the shared helper; the cloud task builder swaps its stub state/model/branch summary for the same typed-event rendering, with a small custom_agent.*subagent.* name remap, last-message-only filtering for cloud, and ILogService plumbed in to log MCP conversion failures. Also bumps @vscode/copilot-api to ^0.4.1 to pick up the discriminated AgentTaskSessionEvent union.

Changes:

  • Introduce shared sessionEventRenderer.ts exposing ResponseEventRenderContext, appendResponsePartsForEvent, flushPendingAssistantMessage, and createResponseEventRenderContext.
  • Refactor buildChatHistoryFromEvents to delegate response-part rendering to the shared helper; rewrite buildTaskResponseTurn to drive typed events through it with a custom_agent.*subagent.* remap and last-final-message filter.
  • Inject ILogService into ChatSessionContentBuilder (and update all construction sites + tests); bump @vscode/copilot-api from ^0.4.0 to ^0.4.1 across all manifests/lockfiles.
Show a summary per file
File Description
extensions/copilot/src/extension/chatSessions/common/sessionEventRenderer.ts New shared renderer for response-side session events.
extensions/copilot/src/extension/chatSessions/copilotcli/common/copilotCLITools.ts Delegate response-part rendering to the shared renderer; keep turn-boundary handling.
extensions/copilot/src/extension/chatSessions/vscode-node/copilotCloudSessionContentBuilder.ts Replace stub task summary with event-driven rendering via the shared helper; add custom_agent.* remap and inject ILogService.
extensions/copilot/src/extension/chatSessions/vscode-node/copilotCloudSessionsProvider.ts Pass this.logService to all ChatSessionContentBuilder constructions.
extensions/copilot/src/extension/chatSessions/vscode-node/test/copilotCloudSessionsProvider.spec.ts Update test to pass TestLogService to the builder.
package.json / package-lock.json Bump @vscode/copilot-api to ^0.4.1.
remote/package.json / remote/package-lock.json Bump @vscode/copilot-api to ^0.4.1.
extensions/copilot/package.json / package-lock.json Bump @vscode/copilot-api to ^0.4.1.
extensions/copilot/chat-lib/package.json / package-lock.json Bump @vscode/copilot-api to ^0.4.1.

Copilot's findings

Files not reviewed (3)
  • extensions/copilot/chat-lib/package-lock.json: Language not supported
  • extensions/copilot/package-lock.json: Language not supported
  • remote/package-lock.json: Language not supported
  • Files reviewed: 9/13 changed files
  • Comments generated: 2

Comment thread extensions/copilot/src/extension/chatSessions/common/sessionEventRenderer.ts Outdated
osortega added 2 commits May 27, 2026 16:42
- Inject CLI tool-event handlers (processStart/processComplete/
  enrichSubagent/isEditToolCall/getEditedUris) into the shared
  renderer via a ToolEventHandlers<T> bundle, so common/sessionEventRenderer
  no longer imports from copilotcli/. Layering now only flows one way.
- Flush buffered assistant.message_delta chunks at the top of the
  CLI loop for non-message events so the session.model_change /
  assistant.usage guards see streamed text exactly the way the
  pre-extraction code did.
# Conflicts:
#	extensions/copilot/chat-lib/package-lock.json
#	extensions/copilot/chat-lib/package.json
#	extensions/copilot/package-lock.json
#	extensions/copilot/package.json
#	package-lock.json
#	package.json
#	remote/package-lock.json
#	remote/package.json
@osortega osortega marked this pull request as ready for review May 27, 2026 23:48
@osortega osortega closed this May 27, 2026
@osortega osortega reopened this May 27, 2026
dmitrivMS
dmitrivMS previously approved these changes May 28, 2026
@osortega osortega marked this pull request as draft May 28, 2026 17:00
@osortega osortega marked this pull request as ready for review May 28, 2026 17:34
@osortega osortega merged commit d53d505 into main May 28, 2026
25 checks passed
@osortega osortega deleted the osortega/dying-ptarmigan branch May 28, 2026 17:59
@vs-code-engineering vs-code-engineering Bot added this to the 1.123.0 milestone May 28, 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.

4 participants