@@ -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 { TransformationType , TransformByQReviewStatus , transformByQState } 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'
@@ -112,9 +112,9 @@ export class PatchFileNode {
112112 readonly patchFilePath : string
113113 children : ProposedChangeNode [ ] = [ ]
114114
115- constructor ( patchFilePath : string ) {
115+ constructor ( description : PatchInfo | undefined = undefined , patchFilePath : string ) {
116116 this . patchFilePath = patchFilePath
117- this . label = path . basename ( patchFilePath )
117+ this . label = description ? description . name : path . basename ( patchFilePath )
118118 }
119119}
120120
@@ -196,7 +196,7 @@ export class DiffModel {
196196 }
197197 } ,
198198 } )
199- const patchFileNode = new PatchFileNode ( diffDescription ? diffDescription . name : pathToDiff )
199+ const patchFileNode = new PatchFileNode ( diffDescription , pathToDiff )
200200 patchFileNode . label = `Patch ${ this . currentPatchIndex + 1 } of ${ totalDiffPatches } : ${ patchFileNode . label } `
201201 patchFileNode . children = changedFiles . flatMap ( ( file ) => {
202202 /* ex. file.oldFileName = 'a/src/java/com/project/component/MyFile.java'
@@ -312,7 +312,8 @@ export class ProposedTransformationExplorer {
312312 } )
313313
314314 const patchFiles : string [ ] = [ ]
315- let patchFilesDescriptions : PatchInfo [ ] | undefined = undefined
315+ let singlePatchFile : string = ''
316+ let patchFilesDescriptions : DescriptionContent | undefined = undefined
316317
317318 const reset = async ( ) => {
318319 await setContext ( 'gumby.transformationProposalReviewInProgress' , false )
@@ -405,7 +406,7 @@ export class ProposedTransformationExplorer {
405406 transformByQState . getChatControllers ( ) ?. transformationFinished . fire ( {
406407 message : `${ CodeWhispererConstants . errorDownloadingDiffChatMessage } The download failed due to: ${ downloadErrorMessage } ` ,
407408 tabID : ChatSessionManager . Instance . getSession ( ) . tabID ,
408- includeStartNewTransformationButton : ' true' ,
409+ includeStartNewTransformationButton : true ,
409410 } )
410411 await setContext ( 'gumby.reviewState' , TransformByQReviewStatus . NotStarted )
411412 getLogger ( ) . error ( `CodeTransformation: ExportResultArchive error = ${ downloadErrorMessage } ` )
@@ -425,19 +426,32 @@ export class ProposedTransformationExplorer {
425426 const files = fs . readdirSync ( path . join ( pathContainingArchive , ExportResultArchiveStructure . PathToPatch ) )
426427 files . forEach ( ( file ) => {
427428 const filePath = path . join ( pathContainingArchive , ExportResultArchiveStructure . PathToPatch , file )
428- if ( file . endsWith ( ' .patch') ) {
429- patchFiles . push ( filePath )
429+ if ( file === 'diff .patch') {
430+ singlePatchFile = filePath
430431 } else if ( file . endsWith ( '.json' ) ) {
431432 const jsonData = fs . readFileSync ( filePath , 'utf-8' )
432433 patchFilesDescriptions = JSON . parse ( jsonData )
433434 }
434435 } )
436+ if ( patchFilesDescriptions !== undefined ) {
437+ for ( const patchInfo of patchFilesDescriptions . content ) {
438+ patchFiles . push (
439+ path . join (
440+ pathContainingArchive ,
441+ ExportResultArchiveStructure . PathToPatch ,
442+ patchInfo . filename
443+ )
444+ )
445+ }
446+ } else {
447+ patchFiles . push ( singlePatchFile )
448+ }
435449
436450 //Because multiple patches are returned once the ZIP is downloaded, we want to show the first one to start
437451 diffModel . parseDiff (
438452 patchFiles [ 0 ] ,
439453 transformByQState . getProjectPath ( ) ,
440- patchFilesDescriptions ? patchFilesDescriptions [ 0 ] : undefined ,
454+ patchFilesDescriptions ? patchFilesDescriptions . content [ 0 ] : undefined ,
441455 patchFiles . length
442456 )
443457
@@ -454,7 +468,7 @@ export class ProposedTransformationExplorer {
454468 transformByQState . getChatControllers ( ) ?. transformationFinished . fire ( {
455469 message : CodeWhispererConstants . viewProposedChangesChatMessage ,
456470 tabID : ChatSessionManager . Instance . getSession ( ) . tabID ,
457- includeStartNewTransformationButton : ' true' ,
471+ includeStartNewTransformationButton : true ,
458472 } )
459473 await vscode . commands . executeCommand ( 'aws.amazonq.transformationHub.summary.reveal' )
460474 } catch ( e : any ) {
@@ -463,7 +477,7 @@ export class ProposedTransformationExplorer {
463477 transformByQState . getChatControllers ( ) ?. transformationFinished . fire ( {
464478 message : `${ CodeWhispererConstants . errorDeserializingDiffChatMessage } ${ deserializeErrorMessage } ` ,
465479 tabID : ChatSessionManager . Instance . getSession ( ) . tabID ,
466- includeStartNewTransformationButton : ' true' ,
480+ includeStartNewTransformationButton : true ,
467481 } )
468482 void vscode . window . showErrorMessage (
469483 `${ CodeWhispererConstants . errorDeserializingDiffNotification } ${ deserializeErrorMessage } `
@@ -512,7 +526,7 @@ export class ProposedTransformationExplorer {
512526 patchFiles . length
513527 ) ,
514528 tabID : ChatSessionManager . Instance . getSession ( ) . tabID ,
515- includeStartNewTransformationButton : ' true' ,
529+ includeStartNewTransformationButton : true ,
516530 } )
517531 } else {
518532 transformByQState . getChatControllers ( ) ?. transformationFinished . fire ( {
@@ -521,7 +535,7 @@ export class ProposedTransformationExplorer {
521535 patchFiles . length
522536 ) ,
523537 tabID : ChatSessionManager . Instance . getSession ( ) . tabID ,
524- includeStartNewTransformationButton : ' false' ,
538+ includeStartNewTransformationButton : false ,
525539 } )
526540 }
527541
@@ -530,7 +544,7 @@ export class ProposedTransformationExplorer {
530544 if ( diffModel . currentPatchIndex < patchFiles . length ) {
531545 const nextPatchFile = patchFiles [ diffModel . currentPatchIndex ]
532546 const nextPatchFileDescription = patchFilesDescriptions
533- ? patchFilesDescriptions [ diffModel . currentPatchIndex ]
547+ ? patchFilesDescriptions . content [ diffModel . currentPatchIndex ]
534548 : undefined
535549 diffModel . parseDiff (
536550 nextPatchFile ,
0 commit comments