allow multiple slash commands of the same name but for different session types#312134
Merged
allow multiple slash commands of the same name but for different session types#312134
Conversation
…ion types Co-authored-by: Copilot <copilot@github.com>
Contributor
There was a problem hiding this comment.
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}}`); | ||
| } |
There was a problem hiding this comment.
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.
jrieken
approved these changes
Apr 23, 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.
Co-authored-by: Copilot copilot@github.com