mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 17:19:48 +01:00
feat: support button titles in chat confirmation api (#221223)
This commit is contained in:
@@ -212,11 +212,11 @@ class ChatAgentResponseStream {
|
||||
_report(dto);
|
||||
return this;
|
||||
},
|
||||
confirmation(title, message, data) {
|
||||
confirmation(title, message, data, buttons) {
|
||||
throwIfDone(this.confirmation);
|
||||
checkProposedApiEnabled(that._extension, 'chatParticipantAdditions');
|
||||
|
||||
const part = new extHostTypes.ChatResponseConfirmationPart(title, message, data);
|
||||
const part = new extHostTypes.ChatResponseConfirmationPart(title, message, data, buttons);
|
||||
const dto = typeConvert.ChatResponseConfirmationPart.from(part);
|
||||
_report(dto);
|
||||
return this;
|
||||
|
||||
@@ -2354,7 +2354,8 @@ export namespace ChatResponseConfirmationPart {
|
||||
kind: 'confirmation',
|
||||
title: part.title,
|
||||
message: part.message,
|
||||
data: part.data
|
||||
data: part.data,
|
||||
buttons: part.buttons
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4377,10 +4377,13 @@ export class ChatResponseConfirmationPart {
|
||||
title: string;
|
||||
message: string;
|
||||
data: any;
|
||||
constructor(title: string, message: string, data: any) {
|
||||
buttons?: string[];
|
||||
|
||||
constructor(title: string, message: string, data: any, buttons?: string[]) {
|
||||
this.title = title;
|
||||
this.message = message;
|
||||
this.data = data;
|
||||
this.buttons = buttons;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+10
-4
@@ -28,10 +28,16 @@ export class ChatConfirmationContentPart extends Disposable implements IChatCont
|
||||
super();
|
||||
|
||||
const element = context.element;
|
||||
const confirmationWidget = this._register(this.instantiationService.createInstance(ChatConfirmationWidget, confirmation.title, confirmation.message, [
|
||||
{ label: localize('accept', "Accept"), data: confirmation.data },
|
||||
{ label: localize('dismiss', "Dismiss"), data: confirmation.data, isSecondary: true },
|
||||
]));
|
||||
const buttons = confirmation.buttons
|
||||
? confirmation.buttons.map(button => ({
|
||||
label: button,
|
||||
data: confirmation.data
|
||||
}))
|
||||
: [
|
||||
{ label: localize('accept', "Accept"), data: confirmation.data },
|
||||
{ label: localize('dismiss', "Dismiss"), data: confirmation.data, isSecondary: true },
|
||||
];
|
||||
const confirmationWidget = this._register(this.instantiationService.createInstance(ChatConfirmationWidget, confirmation.title, confirmation.message, buttons));
|
||||
confirmationWidget.setShowButtons(!confirmation.isUsed);
|
||||
|
||||
this._register(confirmationWidget.onDidClick(async e => {
|
||||
|
||||
@@ -160,6 +160,7 @@ export interface IChatConfirmation {
|
||||
title: string;
|
||||
message: string;
|
||||
data: any;
|
||||
buttons?: string[];
|
||||
isUsed?: boolean;
|
||||
kind: 'confirmation';
|
||||
}
|
||||
|
||||
@@ -59,7 +59,8 @@ declare module 'vscode' {
|
||||
title: string;
|
||||
message: string;
|
||||
data: any;
|
||||
constructor(title: string, message: string, data: any);
|
||||
buttons?: string[];
|
||||
constructor(title: string, message: string, data: any, buttons?: string[]);
|
||||
}
|
||||
|
||||
export type ExtendedChatResponsePart = ChatResponsePart | ChatResponseTextEditPart | ChatResponseDetectedParticipantPart | ChatResponseConfirmationPart;
|
||||
@@ -102,7 +103,7 @@ declare module 'vscode' {
|
||||
* TODO@API should this be MarkdownString?
|
||||
* TODO@API should actually be a more generic function that takes an array of buttons
|
||||
*/
|
||||
confirmation(title: string, message: string, data: any): void;
|
||||
confirmation(title: string, message: string, data: any, buttons?: string[]): void;
|
||||
|
||||
/**
|
||||
* Push a warning to this stream. Short-hand for
|
||||
|
||||
Reference in New Issue
Block a user