Skip to content

chat customizations: fix customization provider harness deduplication, grouping, and badges#305810

Merged
joshspicer merged 9 commits intomainfrom
copilot/legal-leech
Mar 27, 2026
Merged

chat customizations: fix customization provider harness deduplication, grouping, and badges#305810
joshspicer merged 9 commits intomainfrom
copilot/legal-leech

Conversation

@joshspicer
Copy link
Copy Markdown
Member

Summary

Fixes several issues with the chatSessionCustomizationProvider API integration in the Chat Customizations editor.

Harness deduplication

When an extension registers a customization provider with the same ID as a hardcoded harness (e.g. "cli", "claude"), the dropdown showed duplicate entries. _getAllHarnesses() now filters out static harnesses that are overridden by external ones with the same ID. Disposing the external harness restores the static one.

Grouping and badges for provider items

External provider items were rendered as a flat list with no group headers or badges. Now:

  • Storage inference: Item URIs are classified as local (workspace) or user based on the active project root and user home directory
  • Instruction enrichment: Instruction items from providers are parsed to extract applyTo frontmatter, producing proper badge/badgeTooltip (e.g. src/vs/platform/agentHost/**) and groupKey for the "Agent Instructions" / "Included Based on Context" / "Loaded on Demand" groups
  • The flat-list early return in filterItems is removed so provider items flow through the same grouping logic as built-in items

API cleanup

Removed workspaceSubpaths from the ChatSessionCustomizationProviderMetadata proposed API and its DTO/protocol chain. Extensions are responsible for contributing only the correct customizations — the host should not filter workspace files on their behalf. The internal IHarnessDescriptor.workspaceSubpaths remains for hardcoded CLI/Claude harnesses.

Files changed

  • customizationHarnessService.ts — dedup logic in _getAllHarnesses()
  • aiCustomizationListWidget.tsfetchItemsFromProvider enrichment, inferStorageFromUri, enrichInstructionItemsFromProvider, removed flat-list early return
  • mainThreadChatAgents2.ts / extHostChatAgents2.ts / extHost.protocol.ts — removed workspaceSubpaths from API chain
  • vscode.proposed.chatSessionCustomizationProvider.d.ts — removed workspaceSubpaths from proposed API
  • customizationHarnessService.test.ts — tests for harness replacement and restore-on-dispose

Copilot AI review requested due to automatic review settings March 27, 2026 20:28
@vs-code-engineering vs-code-engineering bot added this to the Backlog milestone Mar 27, 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 improves the Chat Customizations editor’s integration with chatSessionCustomizationProvider by fixing harness de-duplication, ensuring provider-supplied items participate in the standard grouping/badging UI, and simplifying the proposed API surface.

Changes:

  • De-duplicate static vs. extension-registered harness descriptors when they share the same harness id, and add coverage for replacement/restore behavior.
  • Enrich external provider items with inferred storage plus instruction applyTo parsing so they can be grouped/badged like built-in items (and remove the prior flat-list rendering path).
  • Remove workspaceSubpaths from the proposed ChatSessionCustomizationProviderMetadata API and its DTO/protocol flow.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/vscode-dts/vscode.proposed.chatSessionCustomizationProvider.d.ts Removes workspaceSubpaths from the proposed API metadata surface.
src/vs/workbench/contrib/chat/test/common/customizationHarnessService.test.ts Adds tests covering static harness replacement by an external harness and restoration on dispose.
src/vs/workbench/contrib/chat/common/customizationHarnessService.ts Updates harness enumeration to let external harnesses override static ones by id.
src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationListWidget.ts Infers storage and enriches provider items (esp. instructions) so they flow through existing grouping/badging logic; removes flat-list short-circuit.
src/vs/workbench/api/common/extHostChatAgents2.ts Removes workspaceSubpaths from metadata DTO creation for provider registration.
src/vs/workbench/api/common/extHost.protocol.ts Removes workspaceSubpaths from the cross-boundary metadata DTO interface.
src/vs/workbench/api/browser/mainThreadChatAgents2.ts Stops wiring workspaceSubpaths into the registered harness descriptor for external providers.

joshspicer and others added 2 commits March 27, 2026 13:42
…er API

Extract the instruction classification logic (applyTo parsing, badge
generation, groupKey assignment) into a shared buildInstructionListItem
method used by both the built-in and provider item paths.

Remove the instruction-specific enrichInstructionItemsFromProvider in
favor of inline logic in fetchItemsFromProvider that delegates to the
shared helper.

Add a section to the chat-customizations-editor skill documenting the
chatSessionCustomizationProvider proposed API flow.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ping

Fix disposal fallback: when an external harness that overrides a static
one is disposed, keep the active harness on the same id since the static
harness is restored. Only fall back to all[0] when no harness with that
id remains.

Fix agent instruction grouping: buildInstructionListItem now detects
well-known agent instruction files (AGENTS.md, CLAUDE.md, CLAUDE.local.md,
copilot-instructions.md) and assigns groupKey 'agent-instructions' so
they appear under the correct header for both built-in and provider items.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@joshspicer joshspicer marked this pull request as ready for review March 27, 2026 21:30
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@joshspicer joshspicer enabled auto-merge (squash) March 27, 2026 21:33
Move instruction enrichment from inline in fetchItemsFromProvider to a
post-processing step (enrichProviderInstructionItems) called from
fetchItemsForSection. This avoids touching fetchItemsFromProvider's
mapping logic which #305813 also modifies.

Restore the flat-list early return in filterItems (305813 replaces it
with groupKey-based grouping). Drop our inferStorageFromUri in favor
of the one 305813 adds.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@joshspicer joshspicer changed the title chat: fix customization provider harness deduplication, grouping, and badges chat customizations: fix customization provider harness deduplication, grouping, and badges Mar 27, 2026
dmitrivMS
dmitrivMS previously approved these changes Mar 27, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@joshspicer joshspicer merged commit cb39101 into main Mar 27, 2026
19 checks passed
@joshspicer joshspicer deleted the copilot/legal-leech branch March 27, 2026 22:15
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.

4 participants