Skip to content

Commit 69aae03

Browse files
committed
Generate activation event automatically
1 parent 90a8b49 commit 69aae03

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { generateUuid } from '../../../../base/common/uuid.js';
1313
import * as nls from '../../../../nls.js';
1414
import { ExtensionIdentifier } from '../../../../platform/extensions/common/extensions.js';
1515
import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js';
16-
import { ILogService } from '../../../../platform/log/common/log.js';
1716
import { IWebview, IWebviewService, WebviewContentPurpose } from '../../../contrib/webview/browser/webview.js';
1817
import { IExtensionService } from '../../../services/extensions/common/extensions.js';
1918
import { ExtensionsRegistry } from '../../../services/extensions/common/extensionsRegistry.js';
@@ -52,17 +51,14 @@ export class ChatOutputRendererService extends Disposable implements IChatOutput
5251
}>();
5352

5453
constructor(
55-
@ILogService private readonly _logService: ILogService,
5654
@IWebviewService private readonly _webviewService: IWebviewService,
5755
@IExtensionService private readonly _extensionService: IExtensionService,
5856
) {
5957
super();
60-
this._logService.debug('ChatOutputItemRendererService: Created');
6158
}
6259

6360
registerRenderer(mime: string, renderer: IChatOutputItemRenderer, options: RegisterOptions): IDisposable {
6461
this._renderers.set(mime, { renderer, options });
65-
this._logService.debug(`ChatOutputItemRendererService: Registered renderer for MIME type ${mime}`);
6662
return {
6763
dispose: () => {
6864
this._renderers.delete(mime);
@@ -120,6 +116,13 @@ interface IChatOutputRendererContribution {
120116

121117
ExtensionsRegistry.registerExtensionPoint<IChatOutputRendererContribution[]>({
122118
extensionPoint: 'chatOutputRenderer',
119+
activationEventsGenerator: (contributions: IChatOutputRendererContribution[], result) => {
120+
for (const contrib of contributions) {
121+
for (const mime of contrib.mimeTypes) {
122+
result.push(`onChatOutputRenderer:${mime}`);
123+
}
124+
}
125+
},
123126
jsonSchema: {
124127
description: nls.localize('vscode.extension.contributes.chatOutputRenderer', 'Contributes a renderer for specific MIME types in chat outputs'),
125128
type: 'array',
@@ -139,5 +142,3 @@ ExtensionsRegistry.registerExtensionPoint<IChatOutputRendererContribution[]>({
139142
}
140143
}
141144
});
142-
143-

src/vscode-dts/vscode.proposed.chatOutputRenderer.d.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,18 @@ declare module 'vscode' {
4949
/**
5050
* Registers a new renderer for a given mime type.
5151
*
52-
* Note: make sure to use the `onChatOutputRenderer:mime` activation event in your extension's `package.json` to ensure that the renderer is registered.
52+
* Note: To use this API, you should also add a contribution point in your extension's
53+
* package.json:
5354
*
54-
* TODO:should this be a contribution instead?
55+
* ```json
56+
* "contributes": {
57+
* "chatOutputRenderer": [
58+
* {
59+
* "mimeTypes": ["application/your-mime-type"]
60+
* }
61+
* ]
62+
* }
63+
* ```
5564
*
5665
* @param mime The MIME type of the output that this renderer can handle.
5766
* @param renderer The renderer to register.

0 commit comments

Comments
 (0)