Skip to content

fix: customization provider API rendering bugs and sessions window isolation#307745

Merged
joshspicer merged 5 commits intomainfrom
josh/customization-provider-fixes
Apr 6, 2026
Merged

fix: customization provider API rendering bugs and sessions window isolation#307745
joshspicer merged 5 commits intomainfrom
josh/customization-provider-fixes

Conversation

@joshspicer
Copy link
Copy Markdown
Member

Fixes several bugs in the Chat Customizations UI when using the ChatSessionCustomizationProvider API (chat.customizations.providerApi.enabled: true).

Fixes

1. Race condition in loadItems() — sequence counter

Multiple concurrent loadItems() calls overlap when autoruns fire simultaneously (harness registers → availableHarnesses fires, then activeHarness fires, then setSection fires). Without serialization, a slow earlier call (core path) can resolve after the correct provider-path call and overwrite allItems with empty results. A sequence counter ensures only the latest call's result is applied.

2. Missing onDidChangeInstructions subscription

The widget subscribed to onDidChangeCustomAgents, onDidChangeSlashCommands, and onDidChangeSkills but not onDidChangeInstructions. Instruction file discovery completing after the initial load never triggered a widget refresh.

3. Provider onDidChange autorun not re-established

The autorun that subscribes to itemProvider.onDidChange only read activeHarness. If the harness ID was persisted from a previous session, activeHarness never changed when the CLI harness registered, so the subscription was never set up. Now also reads availableHarnesses.

4. Instruction items dropped in filterItemsForProvider

filterItemsForProvider only had storage-based groups (local, user, extension, builtin). Provider-supplied instruction items have semantic groupKey values (context-instructions, on-demand-instructions, agent-instructions) which didn't match any group — causing all instruction items to be silently dropped (allItems: 0). This was a regression from #307226.

5. Sessions window ignores provider API

The sessions window manages its own harnesses via SessionsCustomizationHarnessService and the remoteAgentHost contribution. Extension-contributed harnesses via the provider API should not be registered in the sessions window.

Multiple concurrent loadItems() calls can overlap when autoruns fire
simultaneously. Without serialization, a slow earlier call can resolve
after the correct one and overwrite allItems with stale/empty results.
The sequence counter ensures only the latest call's result is applied.
The list widget subscribed to onDidChangeCustomAgents,
onDidChangeSlashCommands, and onDidChangeSkills but not
onDidChangeInstructions. This meant instruction file discovery
completing after the initial load never triggered a widget refresh.
The autorun that subscribes to itemProvider.onDidChange only read
activeHarness. If the harness ID was persisted from a previous session,
activeHarness never changed when the CLI harness registered, so the
subscription was never set up. Now also reads availableHarnesses to
re-fire when harnesses are added/removed.
filterItemsForProvider only had storage-based groups (local, user,
extension, builtin). Provider-supplied instruction items have semantic
groupKey values like 'context-instructions' and 'on-demand-instructions'
which didn't match any group, causing all instruction items to be
silently dropped (allItems: 0). Add instruction-semantic groups when
the current section is Instructions, matching filterItemsForCore.
The sessions window manages its own harnesses via
SessionsCustomizationHarnessService and the remoteAgentHost
contribution. Extension-contributed harnesses via the provider API
should not be registered in the sessions window.
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 fixes multiple rendering/refresh issues in the AI Customizations UI when using the ChatSessionCustomizationProvider API, and prevents provider API registrations from impacting the Sessions window.

Changes:

  • Prevent stale concurrent loadItems() results from overwriting newer results via a sequence counter.
  • Ensure the customization list refreshes when instruction discovery completes (onDidChangeInstructions) and when new provider harnesses register (re-establish onDidChange subscription).
  • Fix instruction provider grouping so semantic instruction groupKeys are routed into the correct collapsible headers; ignore provider registrations in the Sessions window.
Show a summary per file
File Description
src/vs/workbench/contrib/chat/browser/aiCustomization/aiCustomizationListWidget.ts Fixes list refresh races, adds missing instruction change subscription, re-establishes provider onDidChange subscription, and updates provider grouping for instruction items.
src/vs/workbench/api/browser/mainThreadChatAgents2.ts Prevents customization provider API registration from being applied in Sessions windows by early-returning when isSessionsWindow is true.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 2

@joshspicer joshspicer merged commit ec038bf into main Apr 6, 2026
23 checks passed
@joshspicer joshspicer deleted the josh/customization-provider-fixes branch April 6, 2026 01:49
@vs-code-engineering vs-code-engineering bot added this to the 1.115.0 milestone Apr 6, 2026
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