Add onDidReceiveChatDebugEvent API to send chat customization events#300617
Add onDidReceiveChatDebugEvent API to send chat customization events#300617vijayupadya merged 4 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a new proposed chatDebug API surface that streams VS Code core-originated chat debug events to extensions in real time, enabling extensions to capture core debug activity (e.g., prompt discovery / skill loading) as it happens.
Changes:
- Add proposed API
vscode.chat.onDidReceiveChatDebugEvent(Event<ChatDebugEvent>). - Forward core events from
IChatDebugService.onDidAddEvent(main thread) to the extension host via a new ExtHost RPC method. - Enrich prompt discovery debug log
detailspayload with file/folder information.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/vscode-dts/vscode.proposed.chatDebug.d.ts | Adds the new proposed vscode.chat.onDidReceiveChatDebugEvent event. |
| src/vs/workbench/contrib/chat/browser/promptsDebugContribution.ts | Expands prompt discovery log details to include file/folder paths to surface in forwarded event payloads. |
| src/vs/workbench/api/common/extHostChatDebug.ts | Adds an ExtHost emitter and RPC handler to receive and re-emit core debug events. |
| src/vs/workbench/api/common/extHost.protocol.ts | Extends the ExtHost shape with $onCoreDebugEvent for main-thread-to-ext-host forwarding. |
| src/vs/workbench/api/common/extHost.api.impl.ts | Wires the proposed vscode.chat.onDidReceiveChatDebugEvent API to the ExtHost event. |
| src/vs/workbench/api/browser/mainThreadChatDebug.ts | Forwards core debug events to the extension host in real time. |
Comments suppressed due to low confidence (1)
src/vs/workbench/contrib/chat/browser/promptsDebugContribution.ts:62
f.uri.path.split('/').pop()can return an empty string (e.g. when the path ends with/). Because??doesn’t treat''as nullish, this would produce blank entries in theloaded/skippedarrays. Consider using a helper that guarantees a non-empty basename (or falling back when the basename is empty).
const loaded = info.files.filter(f => f.status === 'loaded').map(f => f.name ?? f.uri.path.split('/').pop() ?? f.uri.toString());
const skipped = info.files.filter(f => f.status === 'skipped').map(f => f.name ?? f.uri.path.split('/').pop() ?? f.uri.toString());
const folders = info.sourceFolders?.map(sf => sf.uri.path) ?? [];
src/vs/workbench/contrib/chat/browser/promptsDebugContribution.ts
Outdated
Show resolved
Hide resolved
src/vs/workbench/contrib/chat/browser/promptsDebugContribution.ts
Outdated
Show resolved
Hide resolved
| // Enrich details with file paths so they appear in the event | ||
| // payload (e.g. forwarded via onDidReceiveChatDebugEvent to the | ||
| // extension's JSONL file logger). | ||
| let details = entry.details; | ||
| if (entry.discoveryInfo) { |
There was a problem hiding this comment.
The new details enrichment logic isn’t covered by existing tests (e.g. details undefined, formatting, and any truncation behavior you add). Adding a focused unit test in promptsDebugContribution.test.ts would help prevent regressions since this string is now part of the payload forwarded to extensions.
| * Join a list of strings, truncating after {@link MAX_LIST_ITEMS} entries. | ||
| * Full details are available via {@link IChatDebugService.resolveEvent}. | ||
| */ | ||
| function truncateList(items: string[]): string { |
There was a problem hiding this comment.
since this is just for discovery events, maybe no need to truncate?
Add a new proposed API event onDidReceiveChatDebugEvent on vscode.chat that fires when VS Code core logs a debug event (e.g., prompt discovery, skill/instruction loading). This enables extensions to capture core-originated events in real-time.