From a7606453b16fb06cac48915ebb7fcbd55b12d0eb Mon Sep 17 00:00:00 2001 From: Joyce Er Date: Fri, 22 Nov 2024 12:59:12 -0800 Subject: [PATCH 1/2] fix: don't include slash command disambiguation twice --- .../chat/browser/chatParticipantContributions.ts | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/vs/workbench/contrib/chat/browser/chatParticipantContributions.ts b/src/vs/workbench/contrib/chat/browser/chatParticipantContributions.ts index 9eefdcd1709bb..cb813616ec2f0 100644 --- a/src/vs/workbench/contrib/chat/browser/chatParticipantContributions.ts +++ b/src/vs/workbench/contrib/chat/browser/chatParticipantContributions.ts @@ -212,26 +212,17 @@ export class ChatExtensionPointHandler implements IWorkbenchContribution { continue; } - const participantsAndCommandsDisambiguation: { + const participantsDisambiguation: { category: string; description: string; examples: string[]; }[] = []; if (providerDescriptor.disambiguation?.length) { - participantsAndCommandsDisambiguation.push(...providerDescriptor.disambiguation.map((d) => ({ + participantsDisambiguation.push(...providerDescriptor.disambiguation.map((d) => ({ ...d, category: d.category ?? d.categoryName }))); } - if (providerDescriptor.commands) { - for (const command of providerDescriptor.commands) { - if (command.disambiguation?.length) { - participantsAndCommandsDisambiguation.push(...command.disambiguation.map((d) => ({ - ...d, category: d.category ?? d.categoryName - }))); - } - } - } try { const store = new DisposableStore(); @@ -256,7 +247,7 @@ export class ChatExtensionPointHandler implements IWorkbenchContribution { providerDescriptor.locations.map(ChatAgentLocation.fromRaw) : [ChatAgentLocation.Panel], slashCommands: providerDescriptor.commands ?? [], - disambiguation: coalesce(participantsAndCommandsDisambiguation.flat()), + disambiguation: coalesce(participantsDisambiguation.flat()), } satisfies IChatAgentData)); this._participantRegistrationDisposables.set( From 076b42cc3c9fc92edd539e807b9d321bdefdb92e Mon Sep 17 00:00:00 2001 From: Joyce Er Date: Fri, 22 Nov 2024 13:06:18 -0800 Subject: [PATCH 2/2] fix: disambiguation request should receive participants for that location only --- src/vs/workbench/contrib/chat/common/chatAgents.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/vs/workbench/contrib/chat/common/chatAgents.ts b/src/vs/workbench/contrib/chat/common/chatAgents.ts index b8c595115e58f..e8d88c925987d 100644 --- a/src/vs/workbench/contrib/chat/common/chatAgents.ts +++ b/src/vs/workbench/contrib/chat/common/chatAgents.ts @@ -502,9 +502,11 @@ export class ChatAgentService extends Disposable implements IChatAgentService { } const participants = this.getAgents().reduce((acc, a) => { - acc.push({ participant: a.id, disambiguation: a.disambiguation ?? [] }); - for (const command of a.slashCommands) { - acc.push({ participant: a.id, command: command.name, disambiguation: command.disambiguation ?? [] }); + if (a.locations.includes(options.location)) { + acc.push({ participant: a.id, disambiguation: a.disambiguation ?? [] }); + for (const command of a.slashCommands) { + acc.push({ participant: a.id, command: command.name, disambiguation: command.disambiguation ?? [] }); + } } return acc; }, []);