Skip to content

Enable output renderers for code blocks in chat#316138

Merged
mjbvz merged 1 commit into
mainfrom
dev/mjbvz/unaware-quail
May 13, 2026
Merged

Enable output renderers for code blocks in chat#316138
mjbvz merged 1 commit into
mainfrom
dev/mjbvz/unaware-quail

Conversation

@mjbvz
Copy link
Copy Markdown
Collaborator

@mjbvz mjbvz commented May 12, 2026

For #257761

@mjbvz mjbvz self-assigned this May 12, 2026
Copilot AI review requested due to automatic review settings May 12, 2026 22:36
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

This PR extends the chat output renderer contribution system so extensions can render completed fenced code blocks (by language identifier) using the same webview-based rendering flow that already exists for MIME-typed tool outputs. This aligns with the broader effort in #257761 to allow safe, custom rendering of chat response elements.

Changes:

  • Adds a ChatOutputRenderContext (with codeBlockContext) to the proposed ChatOutputRenderer API surface.
  • Extends chatOutputRenderers contributions and the workbench ChatOutputRendererService to resolve renderers by codeBlockLanguageIdentifiers and render code blocks via a new renderCodeBlock path.
  • Updates chat markdown rendering to invoke contributed code block renderers (including streaming/incomplete-state UI) and adds browser tests; updates the Mermaid built-in extension to contribute the new identifier.
Show a summary per file
File Description
src/vscode-dts/vscode.proposed.chatOutputRenderer.d.ts Introduces render context for renderers and updates the proposed API/docs for code block rendering.
src/vs/workbench/contrib/chat/test/browser/widget/chatContentParts/chatMarkdownContentPart.test.ts Adds coverage for code-block rendering via contributed output renderers (including incomplete fences).
src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatMarkdownContentPart.ts Renders eligible fenced code blocks using contributed output renderers and adds a webview-based code block part.
src/vs/workbench/contrib/chat/browser/chatOutputItemRenderer.ts Extends renderer discovery and rendering to support code block identifiers and passes render context through.
src/vs/workbench/api/common/extHostChatOutputRenderer.ts Threads render context through the ext host renderer call.
src/vs/workbench/api/common/extHost.protocol.ts Adds DTO for render context and updates the ext host protocol signature.
src/vs/workbench/api/browser/mainThreadChatOutputRenderer.ts Passes render context to the ext host and improves handling of re-registrations/logging.
extensions/mermaid-chat-features/package.json Contributes codeBlockLanguageIdentifiers: ["mermaid"] so Mermaid fenced blocks can render via the renderer.

Copilot's findings

Comments suppressed due to low confidence (1)

src/vs/workbench/contrib/chat/browser/chatOutputItemRenderer.ts:134

  • Same grammatical issue as above: "No renderer registered found" should be rephrased for clarity (e.g. "No registered renderer found for code block language identifier …").

		if (!rendererData) {
			throw new Error(`No renderer registered found for code block language identifier: ${languageIdentifier}`);
		}
  • Files reviewed: 7/8 changed files
  • Comments generated: 2

Comment on lines 118 to 121

if (!rendererData) {
throw new Error(`No renderer registered found for mime type: ${mime}`);
}
Comment on lines +695 to +710
const parent = $('.webview-output');
parent.style.maxHeight = '80vh';
parent.style.minHeight = '38px';
this.element.appendChild(parent);

const progressMessage = $('span');
progressMessage.textContent = localize('chat.codeBlockOutputRendering', "Rendering code block...");
const progressPart = this._register(this.instantiationService.createInstance(ChatProgressSubPart, progressMessage, ThemeIcon.modify(Codicon.loading, 'spin'), undefined));
parent.appendChild(progressPart.domNode);
if (!isComplete) {
this.onDidChangeHeight();
return;
}

this.chatOutputRendererService.renderCodeBlock(identifier, new TextEncoder().encode(text), parent, { origin: generateUuid(), title }, this._disposeCts.token).then(renderedItem => {
if (this._disposeCts.token.isCancellationRequested) {
@mjbvz mjbvz merged commit b1ab6f1 into main May 13, 2026
30 checks passed
@mjbvz mjbvz deleted the dev/mjbvz/unaware-quail branch May 13, 2026 17:23
@vs-code-engineering vs-code-engineering Bot added this to the 1.121.0 milestone May 13, 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.

3 participants