Skip to content

Commit

Permalink
fix: add chat participant detection proposed API check (#227395)
Browse files Browse the repository at this point in the history
  • Loading branch information
joyceerhl authored Sep 3, 2024
1 parent 570369c commit db636a6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/vs/platform/extensions/common/extensionsApiProposals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ const _allApiProposals = {
contribAccessibilityHelpContent: {
proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.contribAccessibilityHelpContent.d.ts',
},
contribChatParticipantDetection: {
proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.contribChatParticipantDetection.d.ts',
},
contribCommentEditorActionsMenu: {
proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.contribCommentEditorActionsMenu.d.ts',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const chatParticipantExtensionPoint = extensionsRegistry.ExtensionsRegistry.regi
type: 'string'
},
disambiguation: {
description: localize('chatParticipantDisambiguation', "Metadata to help with automatically routing user questions to this chat participant."),
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."),
type: 'array',
items: {
additionalProperties: false,
Expand Down Expand Up @@ -122,7 +122,7 @@ const chatParticipantExtensionPoint = extensionsRegistry.ExtensionsRegistry.regi
type: 'boolean'
},
disambiguation: {
description: localize('chatCommandDisambiguation', "Metadata to help with automatically routing user questions to this chat command."),
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."),
type: 'array',
items: {
additionalProperties: false,
Expand Down Expand Up @@ -218,13 +218,25 @@ export class ChatExtensionPointHandler implements IWorkbenchContribution {
description: string;
examples: string[];
}[] = [];

let hasLoggedParticipantDetectionApiWarning = false;
if (providerDescriptor.disambiguation?.length) {
participantsAndCommandsDisambiguation.push(...providerDescriptor.disambiguation);
if (isProposedApiEnabled(extension.description, 'contribChatParticipantDetection')) {
participantsAndCommandsDisambiguation.push(...providerDescriptor.disambiguation);
} else if (!hasLoggedParticipantDetectionApiWarning) {
this.logService.warn(`'${extension.description.identifier.value}' must add API proposal: 'contribChatParticipantDetection' to 'enabledApiProposals' to contribute disambiguation metadata.`);
hasLoggedParticipantDetectionApiWarning = true;
}
}
if (providerDescriptor.commands) {
for (const command of providerDescriptor.commands) {
if (command.disambiguation?.length) {
participantsAndCommandsDisambiguation.push(...command.disambiguation);
if (isProposedApiEnabled(extension.description, 'contribChatParticipantDetection')) {
participantsAndCommandsDisambiguation.push(...command.disambiguation);
} else if (!hasLoggedParticipantDetectionApiWarning) {
this.logService.warn(`'${extension.description.identifier.value}' must add API proposal: 'contribChatParticipantDetection' to 'enabledApiProposals' to contribute disambiguation metadata.`);
hasLoggedParticipantDetectionApiWarning = true;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

// empty placeholder declaration for the `chatParticipantDetection`-contribution point

0 comments on commit db636a6

Please sign in to comment.