@@ -550,6 +550,11 @@ export class AiAssistancePanel extends UI.Panel.Panel {
550550 if ( isAiAssistancePatchingEnabled ( ) ) {
551551 this . #workspace. addEventListener ( Workspace . Workspace . Events . ProjectAdded , this . #onProjectAddedOrRemoved, this ) ;
552552 this . #workspace. addEventListener ( Workspace . Workspace . Events . ProjectRemoved , this . #onProjectAddedOrRemoved, this ) ;
553+
554+ // @ts -expect-error temporary global function for local testing.
555+ window . aiAssistanceTestPatchPrompt = async ( changeSummary : string ) => {
556+ return await this . #applyPatch( changeSummary ) ;
557+ } ;
553558 }
554559 }
555560
@@ -1029,6 +1034,16 @@ export class AiAssistancePanel extends UI.Panel.Panel {
10291034 if ( ! changeSummary ) {
10301035 throw new Error ( 'Change summary does not exist' ) ;
10311036 }
1037+
1038+ this . #patchSuggestionLoading = true ;
1039+ this . requestUpdate ( ) ;
1040+ const response = await this . #applyPatch( changeSummary ) ;
1041+ this . #patchSuggestion = response ?. type === ResponseType . ANSWER ? response . text : 'Could not update files' ;
1042+ this . #patchSuggestionLoading = false ;
1043+ this . requestUpdate ( ) ;
1044+ }
1045+
1046+ async #applyPatch( changeSummary : string ) : Promise < ResponseData | undefined > {
10321047 if ( ! this . #project) {
10331048 throw new Error ( 'Project does not exist' ) ;
10341049 }
@@ -1037,13 +1052,8 @@ export class AiAssistancePanel extends UI.Panel.Panel {
10371052 serverSideLoggingEnabled : this . #serverSideLoggingEnabled,
10381053 project : this . #project,
10391054 } ) ;
1040- this . #patchSuggestionLoading = true ;
1041- this . requestUpdate ( ) ;
10421055 const responses = await Array . fromAsync ( agent . applyChanges ( changeSummary ) ) ;
1043- const response = responses . at ( - 1 ) ;
1044- this . #patchSuggestion = response ?. type === ResponseType . ANSWER ? response . text : 'Could not update files' ;
1045- this . #patchSuggestionLoading = false ;
1046- this . requestUpdate ( ) ;
1056+ return responses . at ( - 1 ) ;
10471057 }
10481058
10491059 async *
0 commit comments