Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3602,25 +3602,25 @@
"chat/chatSessions": [
{
"command": "pr.openChanges",
"when": "chatSessionType == copilot-cloud-agent",
"when": "chatSessionType == copilot-cloud-agent && config.githubPullRequests.experimental.chat",
"group": "inline"
},
{
"command": "pr.checkoutChatSessionPullRequest",
"when": "chatSessionType == copilot-cloud-agent",
"when": "chatSessionType == copilot-cloud-agent && config.githubPullRequests.experimental.chat",
"group": "context"
}
],
"chat/input/editing/sessionToolbar": [
{
"command": "pr.checkoutFromDescription",
"group": "navigation@0",
"when": "chatSessionType == copilot-cloud-agent && workspaceFolderCount > 0 && github.vscode-pull-request-github.activated"
"when": "chatSessionType == copilot-cloud-agent && workspaceFolderCount > 0 && github.vscode-pull-request-github.activated && config.githubPullRequests.experimental.chat"
},
{
"command": "pr.applyChangesFromDescription",
"group": "navigation@1",
"when": "chatSessionType == copilot-cloud-agent && workspaceFolderCount > 0 && github.vscode-pull-request-github.activated"
"when": "chatSessionType == copilot-cloud-agent && workspaceFolderCount > 0 && github.vscode-pull-request-github.activated && config.githubPullRequests.experimental.chat"
}
]
},
Expand Down
99 changes: 88 additions & 11 deletions src/@types/vscode.proposed.chatContextProvider.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,45 @@ declare module 'vscode' {
export namespace chat {

/**
* Register a chat context provider. Chat context can be provided:
* - For a resource. Make sure to pass a selector that matches the resource you want to provide context for.
* Providers registered without a selector will not be called for resource-based context.
* - Explicitly. These context items are shown as options when the user explicitly attaches context.
* Register a chat workspace context provider. Workspace context is automatically included in all chat requests.
*
* To ensure your extension is activated when chat context is requested, make sure to include the following activations events:
* - If your extension implements `provideWorkspaceChatContext` or `provideChatContextForResource`, find an activation event which is a good signal to activate.
* Ex: `onLanguage:<languageId>`, `onWebviewPanel:<viewType>`, etc.`
* - If your extension implements `provideChatContextExplicit`, your extension will be automatically activated when the user requests explicit context.
*
* @param id Unique identifier for the provider.
* @param provider The chat workspace context provider.
*/
export function registerChatWorkspaceContextProvider(id: string, provider: ChatWorkspaceContextProvider): Disposable;

/**
* Register a chat explicit context provider. Explicit context items are shown as options when the user explicitly attaches context.
*
* To ensure your extension is activated when chat context is requested, make sure to include the `onChatContextProvider:<id>` activation event in your `package.json`.
*
* @param id Unique identifier for the provider.
* @param provider The chat explicit context provider.
*/
export function registerChatExplicitContextProvider(id: string, provider: ChatExplicitContextProvider): Disposable;

/**
* Register a chat resource context provider. Resource context is provided for a specific resource.
* Make sure to pass a selector that matches the resource you want to provide context for.
*
* To ensure your extension is activated when chat context is requested, make sure to include the `onChatContextProvider:<id>` activation event in your `package.json`.
*
* @param selector Document selector to filter which resources the provider is called for.
* @param id Unique identifier for the provider.
* @param provider The chat resource context provider.
*/
export function registerChatResourceContextProvider(selector: DocumentSelector, id: string, provider: ChatResourceContextProvider): Disposable;

/**
* Register a chat context provider.
*
* @deprecated Use {@link registerChatWorkspaceContextProvider}, {@link registerChatExplicitContextProvider}, or {@link registerChatResourceContextProvider} instead.
*
* @param selector Optional document selector to filter which resources the provider is called for. If omitted, the provider will only be called for explicit context requests.
* @param id Unique identifier for the provider.
* @param provider The chat context provider.
Expand Down Expand Up @@ -57,23 +86,24 @@ declare module 'vscode' {
command?: Command;
}

export interface ChatContextProvider<T extends ChatContextItem = ChatContextItem> {
export interface ChatWorkspaceContextProvider<T extends ChatContextItem = ChatContextItem> {

/**
* An optional event that should be fired when the workspace chat context has changed.
*/
onDidChangeWorkspaceChatContext?: Event<void>;

/**
* TODO @API: should this be a separate provider interface?
*
* Provide a list of chat context items to be included as workspace context for all chat requests.
* This should be used very sparingly to avoid providing useless context and to avoid using up the context window.
* A good example use case is to provide information about which branch the user is working on in a source control context.
*
* @param token A cancellation token.
*/
provideWorkspaceChatContext?(token: CancellationToken): ProviderResult<T[]>;
provideChatContext(token: CancellationToken): ProviderResult<T[]>;
}

export interface ChatExplicitContextProvider<T extends ChatContextItem = ChatContextItem> {

/**
* Provide a list of chat context items that a user can choose from. These context items are shown as options when the user explicitly attaches context.
Expand All @@ -82,7 +112,18 @@ declare module 'vscode' {
*
* @param token A cancellation token.
*/
provideChatContextExplicit?(token: CancellationToken): ProviderResult<T[]>;
provideChatContext(token: CancellationToken): ProviderResult<T[]>;

/**
* If a chat context item is provided without a `value`, this method is called to resolve the `value` for the item.
*
* @param context The context item to resolve.
* @param token A cancellation token.
*/
resolveChatContext(context: T, token: CancellationToken): ProviderResult<ChatContextItem>;
}

export interface ChatResourceContextProvider<T extends ChatContextItem = ChatContextItem> {

/**
* Given a particular resource, provide a chat context item for it. This is used for implicit context (see the settings `chat.implicitContext.enabled` and `chat.implicitContext.suggestedContext`).
Expand All @@ -94,15 +135,51 @@ declare module 'vscode' {
* @param options Options include the resource for which to provide context.
* @param token A cancellation token.
*/
provideChatContextForResource?(options: { resource: Uri }, token: CancellationToken): ProviderResult<T | undefined>;
provideChatContext(options: { resource: Uri }, token: CancellationToken): ProviderResult<T | undefined>;

/**
* If a chat context item is provided without a `value`, from either of the `provide` methods, this method is called to resolve the `value` for the item.
* If a chat context item is provided without a `value`, this method is called to resolve the `value` for the item.
*
* @param context The context item to resolve.
* @param token A cancellation token.
*/
resolveChatContext(context: T, token: CancellationToken): ProviderResult<ChatContextItem>;
}

/**
* @deprecated Use {@link ChatWorkspaceContextProvider}, {@link ChatExplicitContextProvider}, or {@link ChatResourceContextProvider} instead.
*/
export interface ChatContextProvider<T extends ChatContextItem = ChatContextItem> {

/**
* An optional event that should be fired when the workspace chat context has changed.
* @deprecated Use {@link ChatWorkspaceContextProvider.onDidChangeWorkspaceChatContext} instead.
*/
onDidChangeWorkspaceChatContext?: Event<void>;

/**
* Provide a list of chat context items to be included as workspace context for all chat requests.
* @deprecated Use {@link ChatWorkspaceContextProvider.provideChatContext} instead.
*/
provideWorkspaceChatContext?(token: CancellationToken): ProviderResult<T[]>;

/**
* Provide a list of chat context items that a user can choose from.
* @deprecated Use {@link ChatExplicitContextProvider.provideChatContext} instead.
*/
provideChatContextExplicit?(token: CancellationToken): ProviderResult<T[]>;

/**
* Given a particular resource, provide a chat context item for it.
* @deprecated Use {@link ChatResourceContextProvider.provideChatContext} instead.
*/
provideChatContextForResource?(options: { resource: Uri }, token: CancellationToken): ProviderResult<T | undefined>;

/**
* If a chat context item is provided without a `value`, this method is called to resolve the `value` for the item.
* @deprecated Use the `resolveChatContext` method on the specific provider type instead.
*/
resolveChatContext?(context: T, token: CancellationToken): ProviderResult<ChatContextItem>;
}

}
117 changes: 114 additions & 3 deletions src/@types/vscode.proposed.chatParticipantAdditions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,108 @@ declare module 'vscode' {
constructor(title: string, message: string | MarkdownString, data: any, buttons?: string[]);
}

/**
* An option for a question in a carousel.
*/
export interface ChatQuestionOption {
/**
* Unique identifier for the option.
*/
id: string;
/**
* The display label for the option.
*/
label: string;
/**
* The value returned when this option is selected.
*/
value: unknown;
}

/**
* The type of question for a chat question carousel.
*/
export enum ChatQuestionType {
/**
* A free-form text input question.
*/
Text = 1,
/**
* A single-select question with radio buttons.
*/
SingleSelect = 2,
/**
* A multi-select question with checkboxes.
*/
MultiSelect = 3
}

/**
* A question to be displayed in a question carousel.
*/
export class ChatQuestion {
/**
* Unique identifier for the question.
*/
id: string;
/**
* The type of question: Text for free-form input, SingleSelect for radio buttons, MultiSelect for checkboxes.
*/
type: ChatQuestionType;
/**
* The title/header of the question.
*/
title: string;
/**
* Optional detailed message or description for the question.
*/
message?: string | MarkdownString;
/**
* Options for singleSelect or multiSelect questions.
*/
options?: ChatQuestionOption[];
/**
* The id(s) of the default selected option(s).
* For SingleSelect, this should be a single option id.
* For MultiSelect, this can be an array of option ids.
*/
defaultValue?: string | string[];
/**
* Whether to allow free-form text input in addition to predefined options.
* When true, users can provide their own text answer even for SingleSelect or MultiSelect questions.
*/
allowFreeformInput?: boolean;

constructor(
id: string,
type: ChatQuestionType,
title: string,
options?: {
message?: string | MarkdownString;
options?: ChatQuestionOption[];
defaultValue?: string | string[];
allowFreeformInput?: boolean;
}
);
}

/**
* A carousel view for presenting multiple questions inline in the chat.
* The UI is displayed but does not block the chat input.
*/
export class ChatResponseQuestionCarouselPart {
/**
* The questions to display in the carousel.
*/
questions: ChatQuestion[];
/**
* Whether users can skip answering the questions.
*/
allowSkip: boolean;

constructor(questions: ChatQuestion[], allowSkip?: boolean);
}

export class ChatResponseCodeCitationPart {
value: Uri;
license: string;
Expand Down Expand Up @@ -171,8 +273,8 @@ declare module 'vscode' {
pastTenseMessage?: string | MarkdownString;
isConfirmed?: boolean;
isComplete?: boolean;
toolSpecificData?: ChatTerminalToolInvocationData;
fromSubAgent?: boolean;
toolSpecificData?: ChatTerminalToolInvocationData | ChatMcpToolInvocationData;
subAgentInvocationId?: string;
presentation?: 'hidden' | 'hiddenAfterComplete' | undefined;

constructor(toolName: string, toolCallId: string, isError?: boolean);
Expand Down Expand Up @@ -244,7 +346,7 @@ declare module 'vscode' {
constructor(uris: Uri[], callback: () => Thenable<unknown>);
}

export type ExtendedChatResponsePart = ChatResponsePart | ChatResponseTextEditPart | ChatResponseNotebookEditPart | ChatResponseConfirmationPart | ChatResponseCodeCitationPart | ChatResponseReferencePart2 | ChatResponseMovePart | ChatResponseExtensionsPart | ChatResponsePullRequestPart | ChatPrepareToolInvocationPart | ChatToolInvocationPart | ChatResponseMultiDiffPart | ChatResponseThinkingProgressPart | ChatResponseExternalEditPart;
export type ExtendedChatResponsePart = ChatResponsePart | ChatResponseTextEditPart | ChatResponseNotebookEditPart | ChatResponseWorkspaceEditPart | ChatResponseConfirmationPart | ChatResponseCodeCitationPart | ChatResponseReferencePart2 | ChatResponseMovePart | ChatResponseExtensionsPart | ChatResponsePullRequestPart | ChatToolInvocationPart | ChatResponseMultiDiffPart | ChatResponseThinkingProgressPart | ChatResponseExternalEditPart | ChatResponseQuestionCarouselPart;
export class ChatResponseWarningPart {
value: MarkdownString;
constructor(value: string | MarkdownString);
Expand Down Expand Up @@ -408,6 +510,15 @@ declare module 'vscode' {
*/
confirmation(title: string, message: string | MarkdownString, data: any, buttons?: string[]): void;

/**
* Show an inline carousel of questions to gather information from the user.
* This is a blocking call that waits for the user to submit or skip the questions.
* @param questions Array of questions to display to the user
* @param allowSkip Whether the user can skip questions without answering
* @returns A promise that resolves with the user's answers, or undefined if skipped
*/
questionCarousel(questions: ChatQuestion[], allowSkip?: boolean): Thenable<Record<string, unknown> | undefined>;

/**
* Push a warning to this stream. Short-hand for
* `push(new ChatResponseWarningPart(message))`.
Expand Down
2 changes: 1 addition & 1 deletion src/@types/vscode.proposed.chatSessionsProvider.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ declare module 'vscode' {
*
* This is also called on first load to get the initial set of items.
*/
refreshHandler: () => Thenable<void>;
refreshHandler: (token: CancellationToken) => Thenable<void>;

/**
* Fired when an item's archived state changes.
Expand Down