fix: update chat slash commands to include GitHub Copilot targets and enhance attachment handling#303643
Merged
DonJayamanne merged 2 commits intomainfrom Mar 22, 2026
Merged
fix: update chat slash commands to include GitHub Copilot targets and enhance attachment handling#303643DonJayamanne merged 2 commits intomainfrom
DonJayamanne merged 2 commits intomainfrom
Conversation
… enhance attachment handling This may not be the right way to handle this... but look, slash commands that are silent like `/clear`, `/fork`, `/debug`, `/models` are not attachments. They're simply another way to invoke a command simple as that. This code originally gated those showing up in completions AND actually working (parser changes) on whether or not the chatSession supported PromptAttachments. This refactors that to allow silent commands to go through even if that's not defined. 2nd. This change then caused allllll these permissiony commands to show up for Claude even though that UX doesn't exist for Claude so I have hard coded the target only because the when clause is also hard coded here: https://github.com/microsoft/vscode/blob/5ce6509b44ef4567da385254af426dc6ca79deae/src/vs/workbench/contrib/chat/browser/actions/chatExecuteActions.ts#L480 With these 2 changes, Claude gets a few more slash commands: * `/clear` * `/fork` * `/debug` * `/models` (and Copilot CLI gets this one too since I removed the hardcoded target)
justschen
previously approved these changes
Mar 20, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors how chat slash commands are parsed and suggested so that “silent” (UI/client-side) commands can still work even when the active/locked chat session does not support prompt attachments, and it adjusts targeting so certain permission-related commands don’t appear for unsupported targets (e.g. Claude).
Changes:
- Update
ChatRequestParserto allow silent slash commands to parse even whensupportsPromptAttachmentsis false. - Adjust slash command completions filtering to only require
supportsPromptAttachmentsfor commands that aren’t silent. - Update some slash command
targets(and remove/modelstarget restriction) to better control visibility across targets.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/vs/workbench/contrib/chat/common/requestParser/chatRequestParser.ts | Alters slash command parsing rules for agent/locked-agent contexts, allowing silent commands without prompt attachments. |
| src/vs/workbench/contrib/chat/browser/widget/input/editor/chatInputCompletions.ts | Updates completion filtering logic so silent commands can still be suggested without prompt attachment support. |
| src/vs/workbench/contrib/chat/browser/chatSlashCommands.ts | Adjusts targets for permission commands and removes target restriction for /models to change which sessions see these commands. |
Comments suppressed due to low confidence (2)
src/vs/workbench/contrib/chat/common/requestParser/chatRequestParser.ts:248
- Spelling/grammar in the new comments: “If there is an agent, we let” reads incomplete (likely needs a colon), and “asume” should be “assume”.
// If there is no agent, we allow any slash command.
// If there is an agent, we let
// * silent ones go through since they are only UI-facing and don't influence chat history
// * slash commands that support prompt attachments, since those are meant to be used in conjunction with an agent and we can assume the agent can handle them.
if (!usedAgent || slashCommand?.silent || capabilities?.supportsPromptAttachments) {
if (slashCommand) {
// Valid standalone slash command
return new ChatRequestSlashCommandPart(slashRange, slashEditorRange, slashCommand);
} else {
// check for with default agent for this location
const defaultAgent = this.agentService.getDefaultAgent(location, context?.mode);
const subCommand = defaultAgent?.slashCommands.find(c => c.name === command);
if (subCommand) {
// Valid default agent subcommand
return new ChatRequestAgentSubcommandPart(slashRange, slashEditorRange, subCommand);
}
}
// if there's no agent or attachments are supported, asume it is a prompt slash command
const isPromptCommand = this.promptsService.isValidSlashCommandName(command);
src/vs/workbench/contrib/chat/common/requestParser/chatRequestParser.ts:234
- The new gating condition only allows standalone slash commands through when
slashCommand.silentis true, but some execute-immediately UI commands (e.g./clear) are not markedsilentand will still be blocked whensupportsPromptAttachmentsis false. If the intent is “client-side/executeImmediately commands should work without prompt attachments”, consider usingexecuteImmediately(orexecuteImmediately || silent) for this check, or ensure the affected commands are markedsilent: true.
const capabilities = context?.attachmentCapabilities ?? usedAgent?.capabilities ?? context?.attachmentCapabilities;
const slashCommands = this.slashCommandService.getCommands(location, context?.mode ?? ChatModeKind.Ask);
const slashCommand = slashCommands.find(c => c.command === command);
// If there is no agent, we allow any slash command.
// If there is an agent, we let
// * silent ones go through since they are only UI-facing and don't influence chat history
// * slash commands that support prompt attachments, since those are meant to be used in conjunction with an agent and we can assume the agent can handle them.
if (!usedAgent || slashCommand?.silent || capabilities?.supportsPromptAttachments) {
if (slashCommand) {
src/vs/workbench/contrib/chat/common/requestParser/chatRequestParser.ts
Outdated
Show resolved
Hide resolved
src/vs/workbench/contrib/chat/browser/widget/input/editor/chatInputCompletions.ts
Show resolved
Hide resolved
DonJayamanne
approved these changes
Mar 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This may not be the right way to handle this... but look, slash commands that are silent like
/clear,/fork,/debug,/modelsare not attachments. They're simply another way to invoke a command simple as that.This code originally gated those showing up in completions AND actually working (parser changes) on whether or not the chatSession supported PromptAttachments. This refactors that to allow silent commands to go through even if that's not defined.
2nd. This change then caused allllll these permissiony commands to show up for Claude even though that UX doesn't exist for Claude so I have hard coded the target only because the when clause is also hard coded here:
vscode/src/vs/workbench/contrib/chat/browser/actions/chatExecuteActions.ts
Line 480 in 5ce6509
With these 2 changes, Claude gets a few more slash commands:
/clear/fork/debug/models(and Copilot CLI gets this one too since I removed the hardcoded target)