chat session actions: parse slash command#304225
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts chat session actions to recognize prompt-file slash commands (e.g. /troubleshoot) and attach the corresponding prompt file to the request context, aligning programmatic session creation more closely with the interactive chat widget behavior.
Changes:
- Exported
slashRegfrom the common chat request parser so other components can detect slash commands consistently. - Updated chat session actions (
openSessionWithPromptand initial prompt sending inopenChatSession) to resolve prompt slash commands and attach the corresponding prompt file as context.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/vs/workbench/contrib/chat/common/requestParser/chatRequestParser.ts | Exports slashReg for reuse outside the parser. |
| src/vs/workbench/contrib/chat/browser/chatSessions/chatSessions.contribution.ts | Resolves prompt slash commands and appends the prompt file as an attached context entry before sending requests. |
Comments suppressed due to low confidence (1)
src/vs/workbench/contrib/chat/browser/chatSessions/chatSessions.contribution.ts:1386
- The prompt-slash-command attachment logic here duplicates the existing implementation in
ChatWidget._applyPromptFileIfSet(resolve prompt slash command → compute tool refs →toPromptFileVariableEntry). To avoid these implementations drifting over time, consider extracting a shared helper (e.g. inchatVariableEntriesor a prompt-slash-command utility) and using it from both call sites.
// need to resolve the slash command to get the prompt file
const slashCommand = await promptsService.resolvePromptSlashCommand(slashMatch[1], CancellationToken.None);
if (slashCommand) {
const parseResult = slashCommand.parsedPromptFile;
// add the prompt file to the context
const refs = parseResult.body?.variableReferences.map(({ name, offset }) => ({ name, range: new OffsetRange(offset, offset + name.length + 1) })) ?? [];
const toolReferences = toolsService.toToolReferences(refs);
return toPromptFileVariableEntry(parseResult.uri, PromptFileVariableKind.PromptFile, undefined, true, toolReferences);
}
src/vs/workbench/contrib/chat/browser/chatSessions/chatSessions.contribution.ts
Show resolved
Hide resolved
src/vs/workbench/contrib/chat/browser/chatSessions/chatSessions.contribution.ts
Show resolved
Hide resolved
src/vs/workbench/contrib/chat/browser/chatSessions/chatSessions.contribution.ts
Show resolved
Hide resolved
…s.contribution.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
lszomoru
approved these changes
Mar 24, 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.
No description provided.