Skip to content

Commit e0a4e74

Browse files
authored
Merge pull request microsoft#1203 from mjbvz/dev/mjbvz/chatoutputupdate
Update chat output renders api usage
2 parents e35040f + 74b880a commit e0a4e74

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

chat-output-renderer-sample/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
],
5656
"chatOutputRenderer": [
5757
{
58+
"viewType": "vscode-samples.mermaid",
5859
"mimeTypes": [
5960
"application/vnd.chat-output-renderer.mermaid"
6061
]

chat-output-renderer-sample/src/extension.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
import * as vscode from 'vscode';
2-
import { JSDOM } from 'jsdom';
31
import * as DOMPurify from 'dompurify';
2+
import { JSDOM } from 'jsdom';
3+
import * as vscode from 'vscode';
4+
5+
/**
6+
* View type that uniquely identifies the Mermaid chat output renderer.
7+
*/
8+
const viewType = 'vscode-samples.mermaid';
49

510
/**
611
* Mime type used to identify Mermaid diagram data in chat output.
@@ -46,9 +51,9 @@ export function activate(context: vscode.ExtensionContext) {
4651
// This will be invoked with the data generated by the tools.
4752
// It can also be invoked when rendering old Mermaid diagrams in the chat history.
4853
context.subscriptions.push(
49-
vscode.chat.registerChatOutputRenderer(mime, {
50-
async renderChatOutput(data, webview, _ctx, _token) {
51-
const mermaidSource = new TextDecoder().decode(data);
54+
vscode.chat.registerChatOutputRenderer(viewType, {
55+
async renderChatOutput({value}, webview, _ctx, _token) {
56+
const mermaidSource = new TextDecoder().decode(value);
5257

5358
// Set the options for the webview
5459
const mermaidDist = vscode.Uri.joinPath(context.extensionUri, 'node_modules', 'mermaid', 'dist');

0 commit comments

Comments
 (0)