diff --git a/src/vs/workbench/contrib/chat/browser/chatParticipantContributions.ts b/src/vs/workbench/contrib/chat/browser/chatParticipantContributions.ts index 0737a42073e..5bc5791eb7a 100644 --- a/src/vs/workbench/contrib/chat/browser/chatParticipantContributions.ts +++ b/src/vs/workbench/contrib/chat/browser/chatParticipantContributions.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { Action } from 'vs/base/common/actions'; -import { isNonEmptyArray } from 'vs/base/common/arrays'; +import { coalesce, isNonEmptyArray } from 'vs/base/common/arrays'; import { Codicon } from 'vs/base/common/codicons'; import { Disposable, DisposableMap, DisposableStore, IDisposable, toDisposable } from 'vs/base/common/lifecycle'; import * as strings from 'vs/base/common/strings'; @@ -240,6 +240,22 @@ export class ChatExtensionPointHandler implements IWorkbenchContribution { store.add(this.registerDefaultParticipantView(providerDescriptor)); } + const participantsAndCommandsDisambiguation: { + categoryName: string; + description: string; + examples: string[]; + }[] = []; + if (providerDescriptor.disambiguation?.length) { + participantsAndCommandsDisambiguation.push(...providerDescriptor.disambiguation); + } + if (providerDescriptor.commands) { + for (const command of providerDescriptor.commands) { + if (command.disambiguation?.length) { + participantsAndCommandsDisambiguation.push(...command.disambiguation); + } + } + } + store.add(this._chatAgentService.registerAgent( providerDescriptor.id, { @@ -261,7 +277,7 @@ export class ChatExtensionPointHandler implements IWorkbenchContribution { providerDescriptor.locations.map(ChatAgentLocation.fromRaw) : [ChatAgentLocation.Panel], slashCommands: providerDescriptor.commands ?? [], - disambiguation: providerDescriptor.disambiguation ?? [], + disambiguation: coalesce(participantsAndCommandsDisambiguation.flat()), } satisfies IChatAgentData)); this._participantRegistrationDisposables.set( diff --git a/src/vs/workbench/contrib/chat/common/chatParticipantContribTypes.ts b/src/vs/workbench/contrib/chat/common/chatParticipantContribTypes.ts index 6c1b953f97b..52c4fa89292 100644 --- a/src/vs/workbench/contrib/chat/common/chatParticipantContribTypes.ts +++ b/src/vs/workbench/contrib/chat/common/chatParticipantContribTypes.ts @@ -10,6 +10,7 @@ export interface IRawChatCommandContribution { isSticky?: boolean; when?: string; defaultImplicitVariables?: string[]; + disambiguation?: { categoryName: string; description: string; examples: string[] }[]; } export type RawChatParticipantLocation = 'panel' | 'terminal' | 'notebook'; @@ -26,7 +27,7 @@ export interface IRawChatParticipantContribution { commands?: IRawChatCommandContribution[]; defaultImplicitVariables?: string[]; locations?: RawChatParticipantLocation[]; - disambiguation: { categoryName: string; description: string; examples: string[] }[]; + disambiguation?: { categoryName: string; description: string; examples: string[] }[]; } /**