Skip to content

chat session actions: parse slash command#304225

Merged
aeschli merged 4 commits intomainfrom
aeschli/eager-nightingale-809
Mar 24, 2026
Merged

chat session actions: parse slash command#304225
aeschli merged 4 commits intomainfrom
aeschli/eager-nightingale-809

Conversation

@aeschli
Copy link
Contributor

@aeschli aeschli commented Mar 23, 2026

No description provided.

Copilot AI review requested due to automatic review settings March 23, 2026 18:54
@vs-code-engineering vs-code-engineering bot added this to the 1.114.0 milestone Mar 23, 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 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 slashReg from the common chat request parser so other components can detect slash commands consistently.
  • Updated chat session actions (openSessionWithPrompt and initial prompt sending in openChatSession) 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. in chatVariableEntries or 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);
		}

aeschli and others added 2 commits March 24, 2026 13:01
…s.contribution.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@aeschli aeschli marked this pull request as ready for review March 24, 2026 12:06
@aeschli aeschli enabled auto-merge (squash) March 24, 2026 12:17
@aeschli aeschli merged commit b9f6b79 into main Mar 24, 2026
19 checks passed
@aeschli aeschli deleted the aeschli/eager-nightingale-809 branch March 24, 2026 13:08
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