Render cloud task history from typed session events#318646
Conversation
- 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.
There was a problem hiding this comment.
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.tsexposingResponseEventRenderContext,appendResponsePartsForEvent,flushPendingAssistantMessage, andcreateResponseEventRenderContext. - Refactor
buildChatHistoryFromEventsto delegate response-part rendering to the shared helper; rewritebuildTaskResponseTurnto drive typed events through it with acustom_agent.*→subagent.*remap and last-final-message filter. - Inject
ILogServiceintoChatSessionContentBuilder(and update all construction sites + tests); bump@vscode/copilot-apifrom^0.4.0to^0.4.1across 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
- 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
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
extensions/copilot/src/extension/chatSessions/common/sessionEventRenderer.ts. Owns the per-turn state (ResponseEventRenderContext) and dispatchesassistant.message/assistant.message_delta/tool.execution_*/subagent.*/session.error/abortevents intoChatResponseTurn2parts.copilotCLITools.buildChatHistoryFromEventsnow delegates the response-part rendering to the shared helper. Turn-boundary logic (user.messagehandling, mode instructions, model id tracking) stays in the CLI builder. Net change incopilotCLITools.tsis+25 / -135lines — pure extraction, no behavior change.copilotCloudSessionContentBuilder.buildTaskResponseTurncalls the shared renderer too, with a small remap fromcustom_agent.*→subagent.*(both follow the same CMC OpenAPI schema; only the names differ).assistant.messageevents that echo tool input/output (raw diffs, file dumps). Keep only the last top-levelassistant.messagewith non-empty content; tool rows render the rest.ILogServicethroughChatSessionContentBuilderso the shared renderer can log MCP block conversion errors.Notes
@vscode/copilot-apipackage that ships the discriminatedAgentTaskSessionEventunion. Until that's bumped, expect compile errors againstevent.datain the cloud builder — those will go away with the next package update.mainaside from the shared helper indirection.Test plan