@@ -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
0 commit comments