Skip to content

fix: update chat slash commands to include GitHub Copilot targets and enhance attachment handling#303643

Merged
DonJayamanne merged 2 commits intomainfrom
tyler/decisive-antelope
Mar 22, 2026
Merged

fix: update chat slash commands to include GitHub Copilot targets and enhance attachment handling#303643
DonJayamanne merged 2 commits intomainfrom
tyler/decisive-antelope

Conversation

@TylerLeonhardt
Copy link
Member

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:

ChatContextKeys.lockedCodingAgentId.isEqualTo(AgentSessionProviders.Background),

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)

… 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)
Copilot AI review requested due to automatic review settings March 20, 2026 23:35
@TylerLeonhardt TylerLeonhardt self-assigned this Mar 20, 2026
@vs-code-engineering vs-code-engineering bot added this to the 1.113.0 milestone Mar 20, 2026
justschen
justschen previously approved these changes Mar 20, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ChatRequestParser to allow silent slash commands to parse even when supportsPromptAttachments is false.
  • Adjust slash command completions filtering to only require supportsPromptAttachments for commands that aren’t silent.
  • Update some slash command targets (and remove /models target 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.silent is true, but some execute-immediately UI commands (e.g. /clear) are not marked silent and will still be blocked when supportsPromptAttachments is false. If the intent is “client-side/executeImmediately commands should work without prompt attachments”, consider using executeImmediately (or executeImmediately || silent) for this check, or ensure the affected commands are marked silent: 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) {

@DonJayamanne DonJayamanne merged commit 6f3bb99 into main Mar 22, 2026
19 checks passed
@DonJayamanne DonJayamanne deleted the tyler/decisive-antelope branch March 22, 2026 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants