@@ -55,22 +55,29 @@ export abstract class CodeGenBase {
5555 this . currentCodeGenerationId = config . currentCodeGenerationId || EmptyCodeGenID
5656 }
5757
58- protected abstract handleProgress ( messenger : BaseMessenger , detail ?: string ) : void
58+ protected abstract handleProgress ( messenger : BaseMessenger , action : SessionStateAction , detail ?: string ) : void
5959 protected abstract getScheme ( ) : string
60- protected abstract handleGenerationComplete ( messenger : BaseMessenger , newFileInfo : NewFileInfo [ ] ) : void
60+ protected abstract getTimeoutErrorCode ( ) : string
61+ protected abstract handleGenerationComplete (
62+ messenger : BaseMessenger ,
63+ newFileInfo : NewFileInfo [ ] ,
64+ action : SessionStateAction
65+ ) : void
6166
6267 async generateCode ( {
6368 messenger,
6469 fs,
6570 codeGenerationId,
6671 telemetry : telemetry ,
6772 workspaceFolders,
73+ action,
6874 } : {
6975 messenger : BaseMessenger
7076 fs : VirtualFileSystem
7177 codeGenerationId : string
7278 telemetry : any
7379 workspaceFolders : CurrentWsFolders
80+ action : SessionStateAction
7481 } ) : Promise < {
7582 newFiles : NewFileInfo [ ]
7683 deletedFiles : DeletedFileInfo [ ]
@@ -106,7 +113,7 @@ export abstract class CodeGenBase {
106113 )
107114 telemetry . setNumberOfFilesGenerated ( newFileInfo . length )
108115
109- this . handleGenerationComplete ( messenger , newFileInfo )
116+ this . handleGenerationComplete ( messenger , newFileInfo , action )
110117
111118 return {
112119 newFiles : newFileInfo ,
@@ -119,7 +126,7 @@ export abstract class CodeGenBase {
119126 case CodeGenerationStatus . PREDICT_READY :
120127 case CodeGenerationStatus . IN_PROGRESS : {
121128 if ( codegenResult . codeGenerationStatusDetail ) {
122- this . handleProgress ( messenger , codegenResult . codeGenerationStatusDetail )
129+ this . handleProgress ( messenger , action , codegenResult . codeGenerationStatusDetail )
123130 }
124131 await new Promise ( ( f ) => globals . clock . setTimeout ( f , this . requestDelay ) )
125132 break
@@ -138,7 +145,7 @@ export abstract class CodeGenBase {
138145
139146 if ( ! this . isCancellationRequested ) {
140147 const errorMessage = i18n ( 'AWS.amazonq.featureDev.error.codeGen.timeout' )
141- throw new ToolkitError ( errorMessage , { code : 'CodeGenTimeout' } )
148+ throw new ToolkitError ( errorMessage , { code : this . getTimeoutErrorCode ( ) } )
142149 }
143150
144151 return {
@@ -210,7 +217,11 @@ export abstract class BasePrepareCodeGenState implements SessionState {
210217 )
211218 }
212219
220+ protected abstract preUpload ( action : SessionStateAction ) : void
221+ protected abstract postUpload ( action : SessionStateAction ) : void
222+
213223 async interact ( action : SessionStateAction ) : Promise < SessionStateInteraction > {
224+ this . preUpload ( action )
214225 const uploadId = await telemetry . amazonq_createUpload . run ( async ( span ) => {
215226 span . record ( {
216227 amazonqConversationId : this . config . conversationId ,
@@ -231,6 +242,7 @@ export abstract class BasePrepareCodeGenState implements SessionState {
231242 )
232243
233244 await uploadCode ( uploadUrl , zipFileBuffer , zipFileChecksum , kmsKeyArn )
245+ this . postUpload ( action )
234246
235247 return uploadId
236248 } )
@@ -338,6 +350,7 @@ export abstract class BaseCodeGenState extends CodeGenBase implements SessionSta
338350 codeGenerationId,
339351 telemetry : action . telemetry ,
340352 workspaceFolders : this . config . workspaceFolders ,
353+ action,
341354 } )
342355
343356 if ( codeGeneration && ! action . tokenSource ?. token . isCancellationRequested ) {
0 commit comments