Update chat output renders api usage

For https://github.com/microsoft/vscode/pull/257898
This commit is contained in:
Matt Bierner
2025-07-25 12:54:48 -07:00
parent e35040f8ec
commit 74b880ad28
2 changed files with 11 additions and 5 deletions

View File

@ -55,6 +55,7 @@
],
"chatOutputRenderer": [
{
"viewType": "vscode-samples.mermaid",
"mimeTypes": [
"application/vnd.chat-output-renderer.mermaid"
]

View File

@ -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');