Use 'sessionTypes' to filter chat customizations in UI, 'when' only in promptsService#310999
Merged
Use 'sessionTypes' to filter chat customizations in UI, 'when' only in promptsService#310999
Conversation
…n promptsService Co-authored-by: Copilot <copilot@github.com>
Contributor
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reworks how chat prompt customizations are filtered by moving session-based filtering to sessionTypes (evaluated in UI/consumers) while moving when clause evaluation into PromptsService (evaluated during prompt file listing).
Changes:
- Add optional
when?: stringto prompt file resource/proposed API types and propagate it through prompt file provider results. - Pass the current chat session type into
ComputeAutomaticInstructionsand switch instruction/skill/agent filtering fromwhenexpressions tosessionTypes. - Update UI filtering (mode picker, slash command completions), tests, and Copilot’s contributed prompt metadata to align with the new semantics.
Show a summary per file
| File | Description |
|---|---|
| src/vscode-dts/vscode.proposed.chatPromptFiles.d.ts | Adds when?: string to proposed ChatResource API shape. |
| src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsService.ts | Adds when?: string to provider resource type and introduces matchesSessionType helper. |
| src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsServiceImpl.ts | Propagates when from providers and filters extension prompt files by when inside PromptsService. |
| src/vs/workbench/contrib/chat/common/promptSyntax/computeAutomaticInstructions.ts | Accepts current session type and filters instructions/skills/agents via sessionTypes. |
| src/vs/workbench/contrib/chat/common/chatService/chatServiceImpl.ts | Passes session type into ComputeAutomaticInstructions. |
| src/vs/workbench/contrib/chat/common/tools/builtinTools/runSubagentTool.ts | Passes session type into ComputeAutomaticInstructions for subagent runs. |
| src/vs/workbench/contrib/chat/browser/widget/input/modePickerActionItem.ts | Filters chat modes by sessionTypes using the current session’s type. |
| src/vs/workbench/contrib/chat/browser/widget/input/editor/chatInputCompletions.ts | Filters prompt slash commands by sessionTypes instead of when. |
| src/vs/workbench/contrib/chat/common/chatModes.ts | Persists/rehydrates sessionTypes in cached custom chat mode data. |
| src/vs/workbench/contrib/chat/test/common/promptSyntax/service/promptsService.test.ts | Updates tests to assert when filtering now happens inside PromptsService. |
| src/vs/workbench/contrib/chat/test/common/promptSyntax/computeAutomaticInstructions.test.ts | Updates tests to pass session type and validates session-type filtering behavior. |
| extensions/copilot/package.json | Removes chatSessionType checks from when and uses sessionTypes for session scoping. |
Copilot's findings
- Files reviewed: 11/12 changed files
- Comments generated: 2
Co-authored-by: Copilot <copilot@github.com>
roblourens
previously approved these changes
Apr 17, 2026
Co-authored-by: Copilot <copilot@github.com>
Comment on lines
+551
to
+554
| const when = ContextKeyExpr.deserialize(file.when); | ||
| if (!when) { | ||
| this.logger.warn(`[getExtensionPromptFiles] Ignoring contributed prompt file with invalid when clause: ${file.when}`); | ||
| return false; |
There was a problem hiding this comment.
The warning for invalid when clauses doesn’t include any identifying info about the offending resource (e.g. URI / extension), and the message says “contributed” even though provider-supplied files are also filtered here. Including file.uri (and extension/provider id when available) would make this actionable when debugging invalid clauses from multiple sources.
roblourens
approved these changes
Apr 17, 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.
Fixes #311016