Skip to content

Commit 0fbe5c2

Browse files
authored
chatMode.name is case sensitive, expect when used in the URL handler (microsoft#272549)
1 parent 04c143a commit 0fbe5c2

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

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

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,21 +1268,20 @@ export class ChatSetupContribution extends Disposable implements IWorkbenchContr
12681268
const params = new URLSearchParams(url.query);
12691269
this.telemetryService.publicLog2<WorkbenchActionExecutedEvent, WorkbenchActionExecutedClassification>('workbenchActionExecuted', { id: CHAT_SETUP_ACTION_ID, from: 'url', detail: params.get('referrer') ?? undefined });
12701270

1271-
const modeParam = params.get('agent') ?? params.get('mode');
1272-
let modeToUse: ChatModeKind | string | undefined;
1273-
if (modeParam) {
1274-
// check if the given param is a valid mode ID
1275-
let foundMode = this.chatModeService.findModeById(modeParam);
1276-
if (!foundMode) {
1277-
// if not, check if the given param is a valid mode name, note the name is case insensitive
1278-
foundMode = this.chatModeService.findModeByName(modeParam);
1279-
}
1271+
const agentParam = params.get('agent') ?? params.get('mode');
1272+
if (agentParam) {
1273+
const agents = this.chatModeService.getModes();
1274+
const allAgents = [...agents.builtin, ...agents.custom];
12801275

1281-
if (foundMode) {
1282-
modeToUse = foundMode.id;
1276+
// check if the given param is a valid mode ID
1277+
let foundAgent = allAgents.find(agent => agent.id === agentParam);
1278+
if (!foundAgent) {
1279+
// if not, check if the given param is a valid mode name, note the parameter as name is case insensitive
1280+
const nameLower = agentParam.toLowerCase();
1281+
foundAgent = allAgents.find(agent => agent.name.toLowerCase() === nameLower);
12831282
}
12841283
// execute the command to change the mode in panel, note that the command only supports mode IDs, not names
1285-
await this.commandService.executeCommand(CHAT_SETUP_ACTION_ID, modeToUse);
1284+
await this.commandService.executeCommand(CHAT_SETUP_ACTION_ID, foundAgent?.id);
12861285
return true;
12871286
}
12881287

src/vs/workbench/contrib/chat/common/chatModes.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,7 @@ export class ChatModeService extends Disposable implements IChatModeService {
176176
}
177177

178178
findModeByName(name: string): IChatMode | undefined {
179-
const lowerCasedName = name.toLowerCase();
180-
return this.getBuiltinModes().find(mode => mode.name.toLowerCase() === lowerCasedName) ?? this.getCustomModes().find(mode => mode.name.toLowerCase() === lowerCasedName);
179+
return this.getBuiltinModes().find(mode => mode.name === name) ?? this.getCustomModes().find(mode => mode.name === name);
181180
}
182181

183182
private getBuiltinModes(): IChatMode[] {

0 commit comments

Comments
 (0)