From 74b880ad28f1b73db49fad1a8ce83b15ddea20c8 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Fri, 25 Jul 2025 12:54:48 -0700 Subject: [PATCH] Update chat output renders api usage For https://github.com/microsoft/vscode/pull/257898 --- chat-output-renderer-sample/package.json | 1 + chat-output-renderer-sample/src/extension.ts | 15 ++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/chat-output-renderer-sample/package.json b/chat-output-renderer-sample/package.json index ac065302..18a18e04 100644 --- a/chat-output-renderer-sample/package.json +++ b/chat-output-renderer-sample/package.json @@ -55,6 +55,7 @@ ], "chatOutputRenderer": [ { + "viewType": "vscode-samples.mermaid", "mimeTypes": [ "application/vnd.chat-output-renderer.mermaid" ] diff --git a/chat-output-renderer-sample/src/extension.ts b/chat-output-renderer-sample/src/extension.ts index f5ebafa3..e1fa8f68 100644 --- a/chat-output-renderer-sample/src/extension.ts +++ b/chat-output-renderer-sample/src/extension.ts @@ -1,6 +1,11 @@ -import * as vscode from 'vscode'; -import { JSDOM } from 'jsdom'; import * as DOMPurify from 'dompurify'; +import { JSDOM } from 'jsdom'; +import * as vscode from 'vscode'; + +/** + * View type that uniquely identifies the Mermaid chat output renderer. + */ +const viewType = 'vscode-samples.mermaid'; /** * Mime type used to identify Mermaid diagram data in chat output. @@ -46,9 +51,9 @@ export function activate(context: vscode.ExtensionContext) { // This will be invoked with the data generated by the tools. // It can also be invoked when rendering old Mermaid diagrams in the chat history. context.subscriptions.push( - vscode.chat.registerChatOutputRenderer(mime, { - async renderChatOutput(data, webview, _ctx, _token) { - const mermaidSource = new TextDecoder().decode(data); + vscode.chat.registerChatOutputRenderer(viewType, { + async renderChatOutput({value}, webview, _ctx, _token) { + const mermaidSource = new TextDecoder().decode(value); // Set the options for the webview const mermaidDist = vscode.Uri.joinPath(context.extensionUri, 'node_modules', 'mermaid', 'dist');