Support for creating new chat with metadata#268236
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for creating new chat sessions with metadata by introducing a new command and updating the chat session infrastructure to handle metadata throughout the chat lifecycle.
- Adds a new action
OpenNewChatSessionEditorWithMetadatato create chat editors with custom metadata - Updates chat session types and interfaces to properly type metadata as
Record<string, any> - Enhances the chat session service to extract and pass metadata from existing editors when resolving sessions
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/vs/workbench/contrib/chat/browser/actions/chatSessionActions.ts | Adds new OpenNewChatSessionEditorWithMetadata action class |
| src/vs/workbench/contrib/chat/browser/chat.contribution.ts | Registers the new metadata action and updates imports |
| src/vs/workbench/contrib/chat/browser/chatEditor.ts | Extends IChatEditorOptions interface to include optional metadata field |
| src/vs/workbench/contrib/chat/browser/chatSessions.contribution.ts | Updates metadata type definition and adds metadata extraction logic |
| for (const editor of group.editors) { | ||
| if (editor instanceof ChatEditorInput) { | ||
| try { | ||
| if (editor.sessionId === request.sessionId) { |
There was a problem hiding this comment.
The metadata assignment should be placed after the null check for editor.options. If editor.options is undefined, accessing editor.options.metadata will throw a runtime error.
| if (editor.sessionId === request.sessionId) { | |
| if (editor.sessionId === request.sessionId && editor.options) { |
| }); | ||
| } | ||
|
|
||
| async run(accessor: ServicesAccessor, chatSessionType: string, metadata: Record<string, any>) { |
There was a problem hiding this comment.
The chatSessionType and metadata parameters lack input validation. Consider adding validation to ensure chatSessionType is not empty and metadata is a valid object to prevent runtime errors.
| request, | ||
| prompt: request.message, | ||
| history, | ||
| metadata |
|
@osortega Moving to 1.113 since does not look like a candidate. Please make sure to stay on top of your issue's and PR's target milestone in the future as we need to end endgame on Monday at zero |
Related to: #268219
This adds a new command to support creating new chats with metadata