chat - rename setup agent back to original name (#244429)

This commit is contained in:
Benjamin Pasero
2025-03-24 10:24:57 +01:00
committed by GitHub
parent 58d414da2e
commit 38e2bc4e68
2 changed files with 11 additions and 2 deletions

View File

@@ -148,7 +148,7 @@ class SetupChatAgentImplementation extends Disposable implements IChatAgentImple
disposable.add(chatAgentService.registerAgent(id, {
id,
name: 'Copilot', // intentionally not using exact same name as extension to avoid conflict with IChatAgentService.getAgentsByName()
name: `${defaultChat.providerName} Copilot`,
isDefault: true,
isCore: true,
isToolsAgent,

View File

@@ -450,7 +450,16 @@ export class ChatAgentService extends Disposable implements IChatAgentService {
}
getAgentsByName(name: string): IChatAgentData[] {
return this.getAgents().filter(a => a.name === name);
return this._preferExtensionAgents(this.getAgents().filter(a => a.name === name));
}
private _preferExtensionAgents<T extends IChatAgentData>(agents: T[]): T[] {
// We potentially have multiple agents on the same location,
// contributed from core and from extensions.
// This method will prefer the extensions provided agents
// falling back to the original agents array extension agent is found.
const extensionAgents = agents.filter(a => !a.isCore);
return extensionAgents.length > 0 ? extensionAgents : agents;
}
agentHasDupeName(id: string): boolean {