Skip to content

Commit 2d7e9cd

Browse files
authored
Enable @ for chat participants in Agent mode (microsoft#252056)
Fix microsoft#252053
1 parent d6e6775 commit 2d7e9cd

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class SlashCommandCompletions extends Disposable {
7070

7171
this._register(this.languageFeaturesService.completionProvider.register({ scheme: Schemas.vscodeChatInput, hasAccessToAllModels: true }, {
7272
_debugDisplayName: 'globalSlashCommands',
73-
triggerCharacters: ['/'],
73+
triggerCharacters: [chatSubcommandLeader],
7474
provideCompletionItems: async (model: ITextModel, position: Position, _context: CompletionContext, _token: CancellationToken) => {
7575
const widget = this.chatWidgetService.getWidgetByInputUri(model.uri);
7676
if (!widget || !widget.viewModel) {
@@ -158,7 +158,7 @@ class SlashCommandCompletions extends Disposable {
158158
}));
159159
this._register(this.languageFeaturesService.completionProvider.register({ scheme: Schemas.vscodeChatInput, hasAccessToAllModels: true }, {
160160
_debugDisplayName: 'promptSlashCommands',
161-
triggerCharacters: ['/'],
161+
triggerCharacters: [chatSubcommandLeader],
162162
provideCompletionItems: async (model: ITextModel, position: Position, _context: CompletionContext, _token: CancellationToken) => {
163163
const widget = this.chatWidgetService.getWidgetByInputUri(model.uri);
164164
if (!widget || !widget.viewModel) {
@@ -206,7 +206,7 @@ class SlashCommandCompletions extends Disposable {
206206

207207
this._register(this.languageFeaturesService.completionProvider.register({ scheme: Schemas.vscodeChatInput, hasAccessToAllModels: true }, {
208208
_debugDisplayName: 'mcpPromptSlashCommands',
209-
triggerCharacters: ['/'],
209+
triggerCharacters: [chatSubcommandLeader],
210210
provideCompletionItems: async (model: ITextModel, position: Position, _context: CompletionContext, _token: CancellationToken) => {
211211
const widget = this.chatWidgetService.getWidgetByInputUri(model.uri);
212212
if (!widget || !widget.viewModel) {
@@ -259,7 +259,7 @@ class AgentCompletions extends Disposable {
259259

260260
const subCommandProvider: CompletionItemProvider = {
261261
_debugDisplayName: 'chatAgentSubcommand',
262-
triggerCharacters: ['/'],
262+
triggerCharacters: [chatSubcommandLeader],
263263
provideCompletionItems: async (model: ITextModel, position: Position, _context: CompletionContext, token: CancellationToken) => {
264264
const widget = this.chatWidgetService.getWidgetByInputUri(model.uri);
265265
if (!widget || !widget.viewModel) {
@@ -329,7 +329,7 @@ class AgentCompletions extends Disposable {
329329
}
330330

331331
const agents = this.chatAgentService.getAgents()
332-
.filter(a => a.locations.includes(widget.location) && a.modes.includes(widget.input.currentMode));
332+
.filter(a => a.locations.includes(widget.location));
333333

334334
// When the input is only `/`, items are sorted by sortText.
335335
// When typing, filterText is used to score and sort.
@@ -527,6 +527,10 @@ class AssignSelectedAgentAction extends Action2 {
527527
return;
528528
}
529529

530+
if (!arg.agent.modes.includes(arg.widget.input.currentMode)) {
531+
arg.widget.input.setChatMode(arg.agent.modes[0]);
532+
}
533+
530534
arg.widget.lastSelectedAgent = arg.agent;
531535
}
532536
}

0 commit comments

Comments
 (0)