@@ -48,7 +48,14 @@ export class TransformationHubViewProvider implements vscode.WebviewViewProvider
4848 private lastClickedButton : string = ''
4949 private _extensionUri : vscode . Uri = globals . context . extensionUri
5050 private transformationHistory : HistoryObject [ ] = [ ]
51- constructor ( ) { }
51+ constructor ( ) {
52+ vscode . commands . registerCommand (
53+ 'aws.amazonq.transformationHub.updateContent' ,
54+ ( button : 'job history' | 'plan progress' , startTime ?: number , historyFileUpdated ?: boolean ) => {
55+ return this . updateContent ( button , startTime , historyFileUpdated )
56+ }
57+ )
58+ }
5259 static #instance: TransformationHubViewProvider
5360
5461 public async updateContent (
@@ -150,12 +157,7 @@ export class TransformationHubViewProvider implements vscode.WebviewViewProvider
150157 </head>
151158 <body>
152159 <p><b>Transformation History</b></p>
153- <p>This table lists the most recent jobs that you have run in the past 30 days.
154- To open the diff patch and summary files, click the provided links.
155- Jobs with a status of FAILED may still be in progress.
156- Resume them within 12 hours of starting the job to get an updated job status and artifacts. Click the refresh icon to do so.
157- The diff patch and summary will appear once they are available.
158- </p>
160+ <p>${ CodeWhispererConstants . transformationHistoryTableDescription } </p>
159161 ${
160162 jobsToDisplay . length === 0
161163 ? `<p>${ CodeWhispererConstants . nothingToShowMessage } </p>`
@@ -314,8 +316,11 @@ export class TransformationHubViewProvider implements vscode.WebviewViewProvider
314316 // artifacts should be available to download
315317 jobHistoryPath = await this . retrieveArtifacts ( jobId , projectName )
316318
317- // delete metadata file , if it exists
319+ // delete metadata and zipped code files , if they exist
318320 fs . rmSync ( path . join ( os . homedir ( ) , '.aws' , 'transform' , projectName , jobId , 'metadata.txt' ) , { force : true } )
321+ fs . rmSync ( path . join ( os . homedir ( ) , '.aws' , 'transform' , projectName , jobId , 'zipped-code.zip' ) , {
322+ force : true ,
323+ } )
319324 } else if ( CodeWhispererConstants . validStatesForBuildSucceeded . includes ( status ) ) {
320325 // still in progress on server side
321326 if ( transformByQState . isRunning ( ) ) {
@@ -361,10 +366,10 @@ export class TransformationHubViewProvider implements vscode.WebviewViewProvider
361366 if ( messenger ) {
362367 messenger . sendJobFinishedMessage (
363368 ChatSessionManager . Instance . getSession ( ) . tabID ! ,
364- "Sorry, I couldn't refresh the job. Please try again or start a new transformation."
369+ CodeWhispererConstants . refreshErrorChatMessage
365370 )
366371 }
367- void vscode . window . showErrorMessage ( `There was an error refreshing this job. Job Id: ${ jobId } ` )
372+ void vscode . window . showErrorMessage ( CodeWhispererConstants . refreshErrorNotification ( jobId ) )
368373 return
369374 }
370375
@@ -400,10 +405,10 @@ export class TransformationHubViewProvider implements vscode.WebviewViewProvider
400405 if ( messenger ) {
401406 messenger . sendJobFinishedMessage (
402407 ChatSessionManager . Instance . getSession ( ) . tabID ! ,
403- "Sorry, I couldn't refresh the job. Please try again or start a new transformation."
408+ CodeWhispererConstants . refreshErrorChatMessage
404409 )
405410 }
406- void vscode . window . showErrorMessage ( `There was an error refreshing this job. Job Id: ${ jobId } ` )
411+ void vscode . window . showErrorMessage ( CodeWhispererConstants . refreshErrorNotification ( jobId ) )
407412 this . updateContent ( 'job history' ) // re-enable refresh buttons
408413 return
409414 }
@@ -413,7 +418,7 @@ export class TransformationHubViewProvider implements vscode.WebviewViewProvider
413418 if ( messenger ) {
414419 messenger . sendJobFinishedMessage (
415420 ChatSessionManager . Instance . getSession ( ) . tabID ! ,
416- 'Job refresh completed. Please see the transformation history table for the updated status and artifacts.'
421+ CodeWhispererConstants . refreshCompletedChatMessage
417422 )
418423 }
419424 } else {
@@ -423,15 +428,20 @@ export class TransformationHubViewProvider implements vscode.WebviewViewProvider
423428 // if job failed on backend, mark it to disable the refresh button
424429 status = 'FAILED_BE' // this will be truncated to just 'FAILED' in the table
425430 }
431+ // delete metadata and zipped code files, if they exist
432+ fs . rmSync ( path . join ( os . homedir ( ) , '.aws' , 'transform' , projectName , jobId , 'metadata.txt' ) , { force : true } )
433+ fs . rmSync ( path . join ( os . homedir ( ) , '.aws' , 'transform' , projectName , jobId , 'zipped-code.zip' ) , {
434+ force : true ,
435+ } )
426436 }
427437
428438 if ( status === currentStatus && ! jobHistoryPath ) {
429439 // no changes, no need to update file/table
430- void vscode . window . showInformationMessage ( `No updates. (Job Id: ${ jobId } )` )
440+ void vscode . window . showInformationMessage ( CodeWhispererConstants . refreshNoUpdatesNotification ( jobId ) )
431441 return
432442 }
433443
434- void vscode . window . showInformationMessage ( `Job refresh completed. (Job Id: ${ jobId } )` )
444+ void vscode . window . showInformationMessage ( CodeWhispererConstants . refreshCompletedNotification ( jobId ) )
435445 // update local file and history table
436446 await this . updateHistoryFile ( status , duration , jobHistoryPath , jobId )
437447 }
@@ -473,7 +483,7 @@ export class TransformationHubViewProvider implements vscode.WebviewViewProvider
473483
474484 private async updateHistoryFile ( status : string , duration : string , jobHistoryPath : string , jobId : string ) {
475485 const history : string [ ] [ ] = [ ]
476- const historyLogFilePath = path . join ( os . homedir ( ) , '.aws' , 'transform' , 'transformation-history .tsv' )
486+ const historyLogFilePath = path . join ( os . homedir ( ) , '.aws' , 'transform' , 'transformation_history .tsv' )
477487 if ( fs . existsSync ( historyLogFilePath ) ) {
478488 const historyFile = fs . readFileSync ( historyLogFilePath , { encoding : 'utf8' , flag : 'r' } )
479489 const jobs = historyFile . split ( '\n' )
@@ -920,7 +930,7 @@ export class TransformationHubViewProvider implements vscode.WebviewViewProvider
920930
921931export function readHistoryFile ( ) : HistoryObject [ ] {
922932 const history : HistoryObject [ ] = [ ]
923- const jobHistoryFilePath = path . join ( os . homedir ( ) , '.aws' , 'transform' , 'transformation-history .tsv' )
933+ const jobHistoryFilePath = path . join ( os . homedir ( ) , '.aws' , 'transform' , 'transformation_history .tsv' )
924934 if ( fs . existsSync ( jobHistoryFilePath ) ) {
925935 const historyFile = fs . readFileSync ( jobHistoryFilePath , { encoding : 'utf8' , flag : 'r' } )
926936 const jobs = historyFile . split ( '\n' )
0 commit comments