Skip to content

allow multiple slash commands of the same name but for different session types#312134

Merged
aeschli merged 2 commits intomainfrom
aeschli/excited-fly-710
Apr 23, 2026
Merged

allow multiple slash commands of the same name but for different session types#312134
aeschli merged 2 commits intomainfrom
aeschli/excited-fly-710

Conversation

@aeschli
Copy link
Copy Markdown
Contributor

@aeschli aeschli commented Apr 23, 2026

Co-authored-by: Copilot copilot@github.com

…ion types

Co-authored-by: Copilot <copilot@github.com>
Copilot AI review requested due to automatic review settings April 23, 2026 14:06
@aeschli aeschli enabled auto-merge (squash) April 23, 2026 14:06
@aeschli aeschli self-assigned this Apr 23, 2026
Copy link
Copy Markdown
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 updates the chat slash command registry to allow multiple slash commands with the same command id as long as they target different (non-overlapping) chat session types, and adds tests to validate the new behavior.

Changes:

  • Allow multiple registrations per slash command id, keyed by non-overlapping sessionTypes.
  • Update call sites to check command existence using the current session type.
  • Add unit tests covering non-overlapping, overlapping, and “all session types” registration behavior.
Show a summary per file
File Description
src/vs/workbench/contrib/chat/common/participants/chatSlashCommands.ts Stores multiple commands per id and resolves/guards them by session type.
src/vs/workbench/contrib/chat/common/chatService/chatServiceImpl.ts Uses session type when checking if a slash command exists before executing.
src/vs/workbench/contrib/chat/browser/widget/chatWidget.ts Uses session type when deciding whether a followup subcommand should be treated as a slash command.
src/vs/workbench/contrib/chat/browser/chatSlashCommands.ts Avoids treating same-name commands in other session types as duplicates.
src/vs/workbench/contrib/chat/test/common/chatService/chatService.test.ts Adds coverage for multi-registration rules across session types.

Copilot's findings

Comments suppressed due to low confidence (1)

src/vs/workbench/contrib/chat/common/participants/chatSlashCommands.ts:155

  • This error message is grammatically confusing ("NOT registered") and reads like a leftover debug string. Since this can surface when a user tries an unknown slash command, consider changing it to a clearer phrasing like "No command with id '{id}' is registered" (and similarly for the "NOT resolved" case).
		if (!data) {
			throw new Error(`No command with id ${id} NOT registered`);
		}
  • Files reviewed: 5/5 changed files
  • Comments generated: 2

Comment on lines +108 to 111
const commandsForId = this.getSessionScopedCommands(data.command);
if (commandsForId.some(candidate => this.commandsOverlap(candidate.data, data))) {
throw new Error(`Already registered a command with id ${data.command}}`);
}
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

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

The duplicate-registration error message has an extra } after the command id, which will produce a confusing message (and makes it harder to search/grep for this error). Remove the stray brace and consider quoting the id for clarity.

This issue also appears on line 153 of the same file.

Copilot uses AI. Check for mistakes.
Comment thread src/vs/workbench/contrib/chat/common/participants/chatSlashCommands.ts Outdated
@aeschli aeschli merged commit 34aaaae into main Apr 23, 2026
26 checks passed
@aeschli aeschli deleted the aeschli/excited-fly-710 branch April 23, 2026 14:56
@vs-code-engineering vs-code-engineering Bot added this to the 1.118.0 milestone Apr 23, 2026
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.

3 participants