Skip to content

Commit 0870c2a

Browse files
authored
Hide hooks and other slash commands for contributed sessions (#299088)
1 parent 1274f2b commit 0870c2a

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ export class ChatSlashCommandsContribution extends Disposable {
6262
sortText: 'z3_hooks',
6363
executeImmediately: true,
6464
silent: true,
65-
locations: [ChatAgentLocation.Chat]
65+
locations: [ChatAgentLocation.Chat],
66+
target: Target.VSCode
6667
}, async () => {
6768
await instantiationService.invokeFunction(showConfigureHooksQuickPick);
6869
}));
@@ -72,7 +73,8 @@ export class ChatSlashCommandsContribution extends Disposable {
7273
sortText: 'z3_models',
7374
executeImmediately: true,
7475
silent: true,
75-
locations: [ChatAgentLocation.Chat]
76+
locations: [ChatAgentLocation.Chat],
77+
target: Target.VSCode
7678
}, async () => {
7779
await commandService.executeCommand(OpenModelPickerAction.ID);
7880
}));
@@ -103,7 +105,8 @@ export class ChatSlashCommandsContribution extends Disposable {
103105
sortText: 'z3_agents',
104106
executeImmediately: true,
105107
silent: true,
106-
locations: [ChatAgentLocation.Chat]
108+
locations: [ChatAgentLocation.Chat],
109+
target: Target.VSCode
107110
}, async () => {
108111
await commandService.executeCommand(OpenModePickerAction.ID);
109112
}));
@@ -113,7 +116,8 @@ export class ChatSlashCommandsContribution extends Disposable {
113116
sortText: 'z3_skills',
114117
executeImmediately: true,
115118
silent: true,
116-
locations: [ChatAgentLocation.Chat]
119+
locations: [ChatAgentLocation.Chat],
120+
target: Target.VSCode
117121
}, async () => {
118122
await commandService.executeCommand(CONFIGURE_SKILLS_ACTION_ID);
119123
}));
@@ -123,7 +127,8 @@ export class ChatSlashCommandsContribution extends Disposable {
123127
sortText: 'z3_instructions',
124128
executeImmediately: true,
125129
silent: true,
126-
locations: [ChatAgentLocation.Chat]
130+
locations: [ChatAgentLocation.Chat],
131+
target: Target.VSCode
127132
}, async () => {
128133
await commandService.executeCommand(CONFIGURE_INSTRUCTIONS_ACTION_ID);
129134
}));
@@ -133,7 +138,8 @@ export class ChatSlashCommandsContribution extends Disposable {
133138
sortText: 'z3_prompts',
134139
executeImmediately: true,
135140
silent: true,
136-
locations: [ChatAgentLocation.Chat]
141+
locations: [ChatAgentLocation.Chat],
142+
target: Target.VSCode
137143
}, async () => {
138144
await commandService.executeCommand(CONFIGURE_PROMPTS_ACTION_ID);
139145
}));

src/vs/workbench/contrib/chat/browser/widget/input/editor/chatInputCompletions.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ import { IChatWidget, IChatWidgetService } from '../../../chat.js';
6060
import { resizeImage } from '../../../chatImageUtils.js';
6161
import { ChatDynamicVariableModel } from '../../../attachments/chatDynamicVariables.js';
6262
import { IChatService } from '../../../../common/chatService/chatService.js';
63+
import { getPromptFileType } from '../../../../common/promptSyntax/config/promptFileLocations.js';
64+
import { PromptsType } from '../../../../common/promptSyntax/promptTypes.js';
6365

6466
/**
6567
* Regex matching a slash command word (e.g. `/foo`). Uses `\p{L}` for Unicode
@@ -238,9 +240,20 @@ class SlashCommandCompletions extends Disposable {
238240
// Filter out commands that are not user-invocable (hidden from / menu)
239241
const userInvocableCommands = promptCommands
240242
.filter(c => {
241-
// Exclude extension-provided prompt files for locked agents.
242-
if (widget.lockedAgentId && c.promptPath.extension) {
243-
return false;
243+
if (widget.lockedAgentId) {
244+
// Exclude extension-provided prompt files for locked agents.
245+
if (c.promptPath.extension) {
246+
return false;
247+
}
248+
// Exclude hooks as those don't work in locked agent scenarios.
249+
try {
250+
const promptType = getPromptFileType(c.promptPath.uri);
251+
if (promptType && promptType === PromptsType.hook) {
252+
return false;
253+
}
254+
} catch {
255+
256+
}
244257
}
245258
return true;
246259
})

0 commit comments

Comments
 (0)