Skip to content

chat: log customization provider results to Agent Debug Logs#307285

Draft
joshspicer wants to merge 3 commits intomainfrom
josh/customization-debug-logging
Draft

chat: log customization provider results to Agent Debug Logs#307285
joshspicer wants to merge 3 commits intomainfrom
josh/customization-debug-logging

Conversation

@joshspicer
Copy link
Copy Markdown
Member

Adds debug event logging for extension-contributed customization providers to the Agent Debug Logs panel.\n\n- Logs each provideChatSessionCustomizations call with item count, type breakdown, and timing\n- Registers a resolve provider for expandable file list details\n- Uses category 'discovery' so events are filtered by the existing "Chat Customization" toggle\n\nDepends on: #307278 (API changes)

Adds a static Plugins instance so extensions can use
ChatSessionCustomizationType.Plugins instead of constructing
new ChatSessionCustomizationType('plugins') manually.
Also adds explicit mapping in mainThread section conversion.
…ider metadata

Inverts the semantics from a blacklist (types to hide) to a whitelist
(types to show). More natural API: providers declare what they support
rather than what they don't. When omitted, all sections are shown.
Adds debug event logging for extension-contributed customization
providers, following the same pattern as PromptsDebugContribution:
- Logs each provideChatSessionCustomizations call with item count,
  type breakdown, and timing
- Registers a resolve provider for expandable file list details
- Uses category 'discovery' so events are filtered by the existing
  'Chat Customization' toggle in Agent Debug Logs
Copilot AI review requested due to automatic review settings April 1, 2026 23:22
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 adds Agent Debug Logs instrumentation for extension-contributed chat session customization providers, and aligns the proposed API surface with the supportedTypes whitelist and the new Plugins customization type.

Changes:

  • Add ChatSessionCustomizationType.Plugins and wire it through ext host types/serialization.
  • Rename provider metadata unsupportedTypessupportedTypes across the proposed d.ts, DTOs, and ext host registration.
  • Log customization provider discovery results (counts, type breakdown, timing) to Agent Debug Logs and register a resolver for expandable file-list details.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/vscode-dts/vscode.proposed.chatSessionCustomizationProvider.d.ts Adds Plugins type and renames metadata capability field to supportedTypes.
src/vs/workbench/api/common/extHostTypes.ts Exposes ChatSessionCustomizationType.Plugins in ext host types.
src/vs/workbench/api/common/extHostChatAgents2.ts Sends supportedTypes to the main thread during provider registration.
src/vs/workbench/api/common/extHost.protocol.ts Updates provider metadata DTO field name to supportedTypes.
src/vs/workbench/api/browser/mainThreadChatAgents2.ts Logs provider results to Agent Debug Logs, adds resolver backing store, and computes hidden sections from supportedTypes.

Comment on lines +635 to 639
const start = Date.now();
const items = await this._proxy.$provideChatSessionCustomizations(handle, token);
const durationInMillis = Date.now() - start;
if (!items) {
return undefined;
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This early return means discovery events aren’t logged when a provider returns undefined (unavailable) even though the PR description says each provideChatSessionCustomizations call is logged. Consider logging a 0/"unavailable" result (and duration) before returning so the debug log shows calls consistently.

Copilot uses AI. Check for mistakes.
Comment on lines +635 to +637
const start = Date.now();
const items = await this._proxy.$provideChatSessionCustomizations(handle, token);
const durationInMillis = Date.now() - start;
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Timing is measured with Date.now() but later formatted with toFixed(1), which will always yield *.0ms and is sensitive to system clock changes. Prefer StopWatch.create(true) (or performance.now) for high-resolution, monotonic timing so the debug logs show accurate durations.

Copilot uses AI. Check for mistakes.
Comment on lines +726 to +731
this._chatDebugService.log(
sessionResource,
`Customization Provider (${label})`,
details,
ChatDebugLogLevel.Info,
{ id: eventId, category: 'discovery' },
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The debug event title/details strings here are user-visible in the Agent Debug Logs UI but are not localized. Other discovery/debug log entries (e.g. prompt discovery) use localize(...); please externalize these strings as well and avoid manual pluralization in the raw template string.

Copilot uses AI. Check for mistakes.
byType.set(item.type, (byType.get(item.type) ?? 0) + 1);
}
const typeSummary = [...byType.entries()].map(([type, count]) => `${count} ${type}`).join(', ');
const details = `${items.length} items (${typeSummary}) in ${durationInMillis.toFixed(1)}ms`;
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a provider returns an empty array, typeSummary becomes an empty string and the log renders as 0 items () .... Handle the empty case to avoid the stray parentheses (and consider omitting the breakdown when there are no items).

Suggested change
const details = `${items.length} items (${typeSummary}) in ${durationInMillis.toFixed(1)}ms`;
const details = typeSummary
? `${items.length} items (${typeSummary}) in ${durationInMillis.toFixed(1)}ms`
: `${items.length} items in ${durationInMillis.toFixed(1)}ms`;

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug

@Agent``

uri: item.uri,
name: item.name,
status: 'loaded' as const,
storage: item.groupKey,
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

storage in IChatDebugFileEntry is meant to represent the storage/source label (and is used for grouping in the discovery renderer). Setting it to item.groupKey is misleading because groupKey is just a UI grouping hint for the customizations editor. Consider omitting storage here (or populating extensionId / a real source label) and, if you want to surface groupKey, include it in the file name/details instead.

Suggested change
storage: item.groupKey,

Copilot uses AI. Check for mistakes.

return {
kind: 'fileList',
discoveryType: 'customization-provider',
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

discoveryType: 'customization-provider' will render in the discovery UI as "Customization-provider" (simple first-letter capitalization) and won’t map to any known discovery settings key. If this should appear as a first-class discovery type, consider either using a renderer-friendly identifier (or adding a special-case label/settings mapping in the discovery renderer) so the UI output is readable and consistent.

Suggested change
discoveryType: 'customization-provider',
discoveryType: 'customizationProvider',

Copilot uses AI. Check for mistakes.
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