File tree Expand file tree Collapse file tree 2 files changed +17
-13
lines changed Expand file tree Collapse file tree 2 files changed +17
-13
lines changed Original file line number Diff line number Diff line change @@ -77,7 +77,8 @@ export interface TaskLike {
7777 on < K extends keyof TaskEvents > ( event : K , listener : ( ...args : TaskEvents [ K ] ) => void | Promise < void > ) : this
7878 off < K extends keyof TaskEvents > ( event : K , listener : ( ...args : TaskEvents [ K ] ) => void | Promise < void > ) : this
7979
80- setMessageResponse ( text : string , images ?: string [ ] ) : void
80+ approveAsk ( options ?: { text ?: string ; images ?: string [ ] } ) : void
81+ denyAsk ( options ?: { text ?: string ; images ?: string [ ] } ) : void
8182 submitUserMessage ( text : string , images ?: string [ ] ) : void
8283}
8384
Original file line number Diff line number Diff line change @@ -757,27 +757,30 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
757757 this . askResponseImages = images
758758 }
759759
760+ public approveAsk ( { text, images } : { text ?: string ; images ?: string [ ] } = { } ) {
761+ this . handleWebviewAskResponse ( "yesButtonClicked" , text , images )
762+ }
763+
764+ public denyAsk ( { text, images } : { text ?: string ; images ?: string [ ] } = { } ) {
765+ this . handleWebviewAskResponse ( "noButtonClicked" , text , images )
766+ }
767+
760768 public submitUserMessage ( text : string , images ?: string [ ] ) : void {
761769 try {
762- const trimmed = ( text ?? "" ) . trim ( )
763- const imgs = images ?? [ ]
770+ text = ( text ?? "" ) . trim ( )
771+ images = images ?? [ ]
764772
765- if ( ! trimmed && imgs . length === 0 ) {
773+ if ( text . length === 0 && images . length === 0 ) {
766774 return
767775 }
768776
769777 const provider = this . providerRef . deref ( )
770- if ( ! provider ) {
778+
779+ if ( provider ) {
780+ provider . postMessageToWebview ( { type : "invoke" , invoke : "sendMessage" , text, images } )
781+ } else {
771782 console . error ( "[Task#submitUserMessage] Provider reference lost" )
772- return
773783 }
774-
775- void provider . postMessageToWebview ( {
776- type : "invoke" ,
777- invoke : "sendMessage" ,
778- text : trimmed ,
779- images : imgs ,
780- } )
781784 } catch ( error ) {
782785 console . error ( "[Task#submitUserMessage] Failed to submit user message:" , error )
783786 }
You can’t perform that action at this time.
0 commit comments