@@ -10,7 +10,7 @@ import { parsePatch, applyPatches, ParsedDiff } from 'diff'
1010import path from 'path'
1111import vscode from 'vscode'
1212import { ExportIntent } from '@amzn/codewhisperer-streaming'
13- import { TransformByQReviewStatus , transformByQState , PatchInfo } from '../../models/model'
13+ import { TransformByQReviewStatus , transformByQState , PatchInfo , DescriptionContent } from '../../models/model'
1414import { ExportResultArchiveStructure , downloadExportResultArchive } from '../../../shared/utilities/download'
1515import { getLogger } from '../../../shared/logger'
1616import { telemetry } from '../../../shared/telemetry/telemetry'
@@ -111,9 +111,9 @@ export class PatchFileNode {
111111 readonly patchFilePath : string
112112 children : ProposedChangeNode [ ] = [ ]
113113
114- constructor ( patchFilePath : string ) {
114+ constructor ( description : PatchInfo | undefined = undefined , patchFilePath : string ) {
115115 this . patchFilePath = patchFilePath
116- this . label = path . basename ( patchFilePath )
116+ this . label = description ? description . name : path . basename ( patchFilePath )
117117 }
118118}
119119
@@ -195,7 +195,7 @@ export class DiffModel {
195195 }
196196 } ,
197197 } )
198- const patchFileNode = new PatchFileNode ( diffDescription ? diffDescription . name : pathToDiff )
198+ const patchFileNode = new PatchFileNode ( diffDescription , pathToDiff )
199199 patchFileNode . label = `Patch ${ this . currentPatchIndex + 1 } of ${ totalDiffPatches } : ${ patchFileNode . label } `
200200 patchFileNode . children = changedFiles . flatMap ( ( file ) => {
201201 /* ex. file.oldFileName = 'a/src/java/com/project/component/MyFile.java'
@@ -311,7 +311,8 @@ export class ProposedTransformationExplorer {
311311 } )
312312
313313 const patchFiles : string [ ] = [ ]
314- let patchFilesDescriptions : PatchInfo [ ] | undefined = undefined
314+ let singlePatchFile : string = ''
315+ let patchFilesDescriptions : DescriptionContent | undefined = undefined
315316
316317 const reset = async ( ) => {
317318 await setContext ( 'gumby.transformationProposalReviewInProgress' , false )
@@ -404,7 +405,7 @@ export class ProposedTransformationExplorer {
404405 transformByQState . getChatControllers ( ) ?. transformationFinished . fire ( {
405406 message : `${ CodeWhispererConstants . errorDownloadingDiffChatMessage } The download failed due to: ${ downloadErrorMessage } ` ,
406407 tabID : ChatSessionManager . Instance . getSession ( ) . tabID ,
407- includeStartNewTransformationButton : ' true' ,
408+ includeStartNewTransformationButton : true ,
408409 } )
409410 await setContext ( 'gumby.reviewState' , TransformByQReviewStatus . NotStarted )
410411 getLogger ( ) . error ( `CodeTransformation: ExportResultArchive error = ${ downloadErrorMessage } ` )
@@ -424,19 +425,32 @@ export class ProposedTransformationExplorer {
424425 const files = fs . readdirSync ( path . join ( pathContainingArchive , ExportResultArchiveStructure . PathToPatch ) )
425426 files . forEach ( ( file ) => {
426427 const filePath = path . join ( pathContainingArchive , ExportResultArchiveStructure . PathToPatch , file )
427- if ( file . endsWith ( ' .patch') ) {
428- patchFiles . push ( filePath )
428+ if ( file === 'diff .patch') {
429+ singlePatchFile = filePath
429430 } else if ( file . endsWith ( '.json' ) ) {
430431 const jsonData = fs . readFileSync ( filePath , 'utf-8' )
431432 patchFilesDescriptions = JSON . parse ( jsonData )
432433 }
433434 } )
435+ if ( patchFilesDescriptions !== undefined ) {
436+ for ( const patchInfo of patchFilesDescriptions . content ) {
437+ patchFiles . push (
438+ path . join (
439+ pathContainingArchive ,
440+ ExportResultArchiveStructure . PathToPatch ,
441+ patchInfo . filename
442+ )
443+ )
444+ }
445+ } else {
446+ patchFiles . push ( singlePatchFile )
447+ }
434448
435449 //Because multiple patches are returned once the ZIP is downloaded, we want to show the first one to start
436450 diffModel . parseDiff (
437451 patchFiles [ 0 ] ,
438452 transformByQState . getProjectPath ( ) ,
439- patchFilesDescriptions ? patchFilesDescriptions [ 0 ] : undefined ,
453+ patchFilesDescriptions ? patchFilesDescriptions . content [ 0 ] : undefined ,
440454 patchFiles . length
441455 )
442456
@@ -453,7 +467,7 @@ export class ProposedTransformationExplorer {
453467 transformByQState . getChatControllers ( ) ?. transformationFinished . fire ( {
454468 message : CodeWhispererConstants . viewProposedChangesChatMessage ,
455469 tabID : ChatSessionManager . Instance . getSession ( ) . tabID ,
456- includeStartNewTransformationButton : ' true' ,
470+ includeStartNewTransformationButton : true ,
457471 } )
458472 await vscode . commands . executeCommand ( 'aws.amazonq.transformationHub.summary.reveal' )
459473 } catch ( e : any ) {
@@ -462,7 +476,7 @@ export class ProposedTransformationExplorer {
462476 transformByQState . getChatControllers ( ) ?. transformationFinished . fire ( {
463477 message : `${ CodeWhispererConstants . errorDeserializingDiffChatMessage } ${ deserializeErrorMessage } ` ,
464478 tabID : ChatSessionManager . Instance . getSession ( ) . tabID ,
465- includeStartNewTransformationButton : ' true' ,
479+ includeStartNewTransformationButton : true ,
466480 } )
467481 void vscode . window . showErrorMessage (
468482 `${ CodeWhispererConstants . errorDeserializingDiffNotification } ${ deserializeErrorMessage } `
@@ -484,7 +498,7 @@ export class ProposedTransformationExplorer {
484498 patchFiles . length
485499 ) ,
486500 tabID : ChatSessionManager . Instance . getSession ( ) . tabID ,
487- includeStartNewTransformationButton : ' true' ,
501+ includeStartNewTransformationButton : true ,
488502 } )
489503 } else {
490504 transformByQState . getChatControllers ( ) ?. transformationFinished . fire ( {
@@ -493,7 +507,7 @@ export class ProposedTransformationExplorer {
493507 patchFiles . length
494508 ) ,
495509 tabID : ChatSessionManager . Instance . getSession ( ) . tabID ,
496- includeStartNewTransformationButton : ' false' ,
510+ includeStartNewTransformationButton : false ,
497511 } )
498512 }
499513
@@ -502,7 +516,7 @@ export class ProposedTransformationExplorer {
502516 if ( diffModel . currentPatchIndex < patchFiles . length ) {
503517 const nextPatchFile = patchFiles [ diffModel . currentPatchIndex ]
504518 const nextPatchFileDescription = patchFilesDescriptions
505- ? patchFilesDescriptions [ diffModel . currentPatchIndex ]
519+ ? patchFilesDescriptions . content [ diffModel . currentPatchIndex ]
506520 : undefined
507521 diffModel . parseDiff (
508522 nextPatchFile ,
0 commit comments