Skip to content

Commit db636a6

Browse files
authored
fix: add chat participant detection proposed API check (#227395)
1 parent 570369c commit db636a6

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

src/vs/platform/extensions/common/extensionsApiProposals.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ const _allApiProposals = {
7373
contribAccessibilityHelpContent: {
7474
proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.contribAccessibilityHelpContent.d.ts',
7575
},
76+
contribChatParticipantDetection: {
77+
proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.contribChatParticipantDetection.d.ts',
78+
},
7679
contribCommentEditorActionsMenu: {
7780
proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.contribCommentEditorActionsMenu.d.ts',
7881
},

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const chatParticipantExtensionPoint = extensionsRegistry.ExtensionsRegistry.regi
6969
type: 'string'
7070
},
7171
disambiguation: {
72-
description: localize('chatParticipantDisambiguation', "Metadata to help with automatically routing user questions to this chat participant."),
72+
description: localize('chatParticipantDisambiguation', "Metadata to help with automatically routing user questions to this chat participant. You must add `contribChatParticipantDetection` to `enabledApiProposals` to use this API."),
7373
type: 'array',
7474
items: {
7575
additionalProperties: false,
@@ -122,7 +122,7 @@ const chatParticipantExtensionPoint = extensionsRegistry.ExtensionsRegistry.regi
122122
type: 'boolean'
123123
},
124124
disambiguation: {
125-
description: localize('chatCommandDisambiguation', "Metadata to help with automatically routing user questions to this chat command."),
125+
description: localize('chatCommandDisambiguation', "Metadata to help with automatically routing user questions to this chat command. You must add `contribChatParticipantDetection` to `enabledApiProposals` to use this API."),
126126
type: 'array',
127127
items: {
128128
additionalProperties: false,
@@ -218,13 +218,25 @@ export class ChatExtensionPointHandler implements IWorkbenchContribution {
218218
description: string;
219219
examples: string[];
220220
}[] = [];
221+
222+
let hasLoggedParticipantDetectionApiWarning = false;
221223
if (providerDescriptor.disambiguation?.length) {
222-
participantsAndCommandsDisambiguation.push(...providerDescriptor.disambiguation);
224+
if (isProposedApiEnabled(extension.description, 'contribChatParticipantDetection')) {
225+
participantsAndCommandsDisambiguation.push(...providerDescriptor.disambiguation);
226+
} else if (!hasLoggedParticipantDetectionApiWarning) {
227+
this.logService.warn(`'${extension.description.identifier.value}' must add API proposal: 'contribChatParticipantDetection' to 'enabledApiProposals' to contribute disambiguation metadata.`);
228+
hasLoggedParticipantDetectionApiWarning = true;
229+
}
223230
}
224231
if (providerDescriptor.commands) {
225232
for (const command of providerDescriptor.commands) {
226233
if (command.disambiguation?.length) {
227-
participantsAndCommandsDisambiguation.push(...command.disambiguation);
234+
if (isProposedApiEnabled(extension.description, 'contribChatParticipantDetection')) {
235+
participantsAndCommandsDisambiguation.push(...command.disambiguation);
236+
} else if (!hasLoggedParticipantDetectionApiWarning) {
237+
this.logService.warn(`'${extension.description.identifier.value}' must add API proposal: 'contribChatParticipantDetection' to 'enabledApiProposals' to contribute disambiguation metadata.`);
238+
hasLoggedParticipantDetectionApiWarning = true;
239+
}
228240
}
229241
}
230242
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
// empty placeholder declaration for the `chatParticipantDetection`-contribution point

0 commit comments

Comments
 (0)