diff --git a/packages/amazonq/test/unit/amazonqGumby/transformationResultsHandler.test.ts b/packages/amazonq/test/unit/amazonqGumby/transformationResultsHandler.test.ts index 8daeaf5c78d..6fa6fac3215 100644 --- a/packages/amazonq/test/unit/amazonqGumby/transformationResultsHandler.test.ts +++ b/packages/amazonq/test/unit/amazonqGumby/transformationResultsHandler.test.ts @@ -40,12 +40,14 @@ describe('DiffModel', function () { testDiffModel.parseDiff( getTestResourceFilePath('resources/files/addedFile.diff'), workspacePath, - parsedTestDescriptions[0] + parsedTestDescriptions[0], + 1 ) assert.strictEqual(testDiffModel.patchFileNodes.length, 1) assert.strictEqual(testDiffModel.patchFileNodes[0].children.length, 1) assert.strictEqual(testDiffModel.patchFileNodes[0].patchFilePath, parsedTestDescriptions[0].name) + assert(testDiffModel.patchFileNodes[0].label.endsWith(parsedTestDescriptions[0].name)) const change = testDiffModel.patchFileNodes[0].children[0] assert.strictEqual(change instanceof AddedChangeNode, true) @@ -66,12 +68,14 @@ describe('DiffModel', function () { testDiffModel.parseDiff( getTestResourceFilePath('resources/files/modifiedFile.diff'), workspacePath, - parsedTestDescriptions[0] + parsedTestDescriptions[0], + 1 ) assert.strictEqual(testDiffModel.patchFileNodes.length, 1) assert.strictEqual(testDiffModel.patchFileNodes[0].children.length, 1) assert.strictEqual(testDiffModel.patchFileNodes[0].patchFilePath, parsedTestDescriptions[0].name) + assert(testDiffModel.patchFileNodes[0].label.endsWith(parsedTestDescriptions[0].name)) const change = testDiffModel.patchFileNodes[0].children[0] assert.strictEqual(change instanceof ModifiedChangeNode, true) @@ -91,7 +95,12 @@ describe('DiffModel', function () { 'This guide walks you through using Gradle to build a simple Java project.' ) - testDiffModel.parseDiff(getTestResourceFilePath('resources/files/modifiedFile.diff'), workspacePath, undefined) + testDiffModel.parseDiff( + getTestResourceFilePath('resources/files/modifiedFile.diff'), + workspacePath, + undefined, + 1 + ) assert.strictEqual(testDiffModel.patchFileNodes.length, 1) assert.strictEqual(testDiffModel.patchFileNodes[0].children.length, 1) @@ -99,6 +108,7 @@ describe('DiffModel', function () { testDiffModel.patchFileNodes[0].patchFilePath, getTestResourceFilePath('resources/files/modifiedFile.diff') ) + assert(testDiffModel.patchFileNodes[0].label.endsWith('modifiedFile.diff')) const change = testDiffModel.patchFileNodes[0].children[0] assert.strictEqual(change instanceof ModifiedChangeNode, true) diff --git a/packages/core/src/amazonqGumby/chat/controller/controller.ts b/packages/core/src/amazonqGumby/chat/controller/controller.ts index 676252b57c1..e83bc1c7d39 100644 --- a/packages/core/src/amazonqGumby/chat/controller/controller.ts +++ b/packages/core/src/amazonqGumby/chat/controller/controller.ts @@ -454,11 +454,15 @@ export class GumbyController { await this.prepareProjectForSubmission(message) } - private transformationFinished(data: { message: string | undefined; tabID: string }) { + private transformationFinished(data: { + message: string | undefined + tabID: string + includeStartNewTransformationButton: string + }) { this.resetTransformationChatFlow() // at this point job is either completed, partially_completed, cancelled, or failed if (data.message) { - this.messenger.sendJobFinishedMessage(data.tabID, data.message) + this.messenger.sendJobFinishedMessage(data.tabID, data.message, data.includeStartNewTransformationButton) } } @@ -543,7 +547,11 @@ export class GumbyController { try { await finishHumanInTheLoop() } catch (err: any) { - this.transformationFinished({ tabID: message.tabID, message: (err as Error).message }) + this.transformationFinished({ + tabID: message.tabID, + message: (err as Error).message, + includeStartNewTransformationButton: 'true', + }) } this.messenger.sendStaticTextResponse('end-HIL-early', message.tabID) diff --git a/packages/core/src/amazonqGumby/chat/controller/messenger/messenger.ts b/packages/core/src/amazonqGumby/chat/controller/messenger/messenger.ts index 77c203fdf56..fe25774f78c 100644 --- a/packages/core/src/amazonqGumby/chat/controller/messenger/messenger.ts +++ b/packages/core/src/amazonqGumby/chat/controller/messenger/messenger.ts @@ -178,15 +178,11 @@ export class Messenger { options: [ { value: JDKVersion.JDK8, - label: JDKVersion.JDK8, + label: JDKVersion.JDK8.toString(), }, { value: JDKVersion.JDK11, - label: JDKVersion.JDK11, - }, - { - value: JDKVersion.JDK17, - label: JDKVersion.JDK17, + label: JDKVersion.JDK11.toString(), }, { value: JDKVersion.UNSUPPORTED, @@ -413,13 +409,19 @@ export class Messenger { this.dispatcher.sendCommandMessage(new SendCommandMessage(message.command, message.tabID, message.eventId)) } - public sendJobFinishedMessage(tabID: string, message: string) { + public sendJobFinishedMessage( + tabID: string, + message: string, + includeStartNewTransformationButton: string = 'true' + ) { const buttons: ChatItemButton[] = [] - buttons.push({ - keepCardAfterClick: false, - text: CodeWhispererConstants.startTransformationButtonText, - id: ButtonActions.CONFIRM_START_TRANSFORMATION_FLOW, - }) + if (includeStartNewTransformationButton === 'true') { + buttons.push({ + keepCardAfterClick: false, + text: CodeWhispererConstants.startTransformationButtonText, + id: ButtonActions.CONFIRM_START_TRANSFORMATION_FLOW, + }) + } this.dispatcher.sendChatMessage( new ChatMessage( diff --git a/packages/core/src/amazonqGumby/chat/controller/messenger/messengerUtils.ts b/packages/core/src/amazonqGumby/chat/controller/messenger/messengerUtils.ts index 1b35c7115e3..184637fbc3b 100644 --- a/packages/core/src/amazonqGumby/chat/controller/messenger/messengerUtils.ts +++ b/packages/core/src/amazonqGumby/chat/controller/messenger/messengerUtils.ts @@ -45,8 +45,6 @@ export default class MessengerUtils { javaHomePrompt += ` ${CodeWhispererConstants.macJava8HomeHelpChatMessage}` } else if (jdkVersion === JDKVersion.JDK11) { javaHomePrompt += ` ${CodeWhispererConstants.macJava11HomeHelpChatMessage}` - } else if (jdkVersion === JDKVersion.JDK17) { - javaHomePrompt += ` ${CodeWhispererConstants.macJava17HomeHelpChatMessage}` } } else { javaHomePrompt += ` ${CodeWhispererConstants.linuxJavaHomeHelpChatMessage}` diff --git a/packages/core/src/codewhisperer/commands/startTransformByQ.ts b/packages/core/src/codewhisperer/commands/startTransformByQ.ts index e8d218acf4f..b14c92fbf96 100644 --- a/packages/core/src/codewhisperer/commands/startTransformByQ.ts +++ b/packages/core/src/codewhisperer/commands/startTransformByQ.ts @@ -117,8 +117,6 @@ async function validateJavaHome(): Promise { javaVersionUsedByMaven = JDKVersion.JDK8 } else if (javaVersionUsedByMaven === '11.') { javaVersionUsedByMaven = JDKVersion.JDK11 - } else if (javaVersionUsedByMaven === '17.') { - javaVersionUsedByMaven = JDKVersion.JDK17 } } if (javaVersionUsedByMaven !== transformByQState.getSourceJDKVersion()) { @@ -713,9 +711,11 @@ export async function postTransformationJob() { chatMessage = CodeWhispererConstants.jobPartiallyCompletedChatMessage } - transformByQState - .getChatControllers() - ?.transformationFinished.fire({ message: chatMessage, tabID: ChatSessionManager.Instance.getSession().tabID }) + transformByQState.getChatControllers()?.transformationFinished.fire({ + message: chatMessage, + tabID: ChatSessionManager.Instance.getSession().tabID, + includeStartNewTransformationButton: 'true', + }) const durationInMs = calculateTotalLatency(CodeTransformTelemetryState.instance.getStartTime()) const resultStatusMessage = transformByQState.getStatus() diff --git a/packages/core/src/codewhisperer/models/constants.ts b/packages/core/src/codewhisperer/models/constants.ts index 1af47aad342..76eb4e02c07 100644 --- a/packages/core/src/codewhisperer/models/constants.ts +++ b/packages/core/src/codewhisperer/models/constants.ts @@ -600,9 +600,11 @@ export const viewProposedChangesChatMessage = export const viewProposedChangesNotification = 'Download complete. You can view a summary of the transformation and accept or reject the proposed changes in the Transformation Hub.' -export const changesAppliedChatMessage = 'I applied the changes to your project.' +export const changesAppliedChatMessage = (currentPatchIndex: number, totalPatchFiles: number) => + `I applied the changes in diff patch ${currentPatchIndex + 1} of ${totalPatchFiles} to your project.` -export const changesAppliedNotification = 'Amazon Q applied the changes to your project.' +export const changesAppliedNotification = (currentPatchIndex: number, totalPatchFiles: number) => + `Amazon Q applied the changes in diff patch ${currentPatchIndex + 1} of ${totalPatchFiles} to your project.` export const noOpenProjectsFoundChatMessage = `Sorry, I couldn\'t find a project that I can upgrade. Currently, I can only upgrade Java 8 or Java 11 projects built on Maven. For more information, see the [Amazon Q documentation](${codeTransformPrereqDoc}).` @@ -637,9 +639,6 @@ export const macJava8HomeHelpChatMessage = export const macJava11HomeHelpChatMessage = 'To find the JDK path, run the following command in a new terminal: `/usr/libexec/java_home -v 11`' -export const macJava17HomeHelpChatMessage = - 'To find the JDK path, run the following command in a new terminal: `/usr/libexec/java_home -v 17`' - export const linuxJavaHomeHelpChatMessage = 'To find the JDK path, run the following command in a new terminal: `update-java-alternatives --list`' diff --git a/packages/core/src/codewhisperer/service/transformByQ/transformApiHandler.ts b/packages/core/src/codewhisperer/service/transformByQ/transformApiHandler.ts index 5556ae34f48..f0f74ef5cf1 100644 --- a/packages/core/src/codewhisperer/service/transformByQ/transformApiHandler.ts +++ b/packages/core/src/codewhisperer/service/transformByQ/transformApiHandler.ts @@ -378,6 +378,7 @@ export async function zipCode( transformByQState.getChatControllers()?.transformationFinished.fire({ message: CodeWhispererConstants.projectSizeTooLargeChatMessage, tabID: ChatSessionManager.Instance.getSession().tabID, + includeStartNewTransformationButton: 'true', }) throw new ZipExceedsSizeLimitError() } diff --git a/packages/core/src/codewhisperer/service/transformByQ/transformationResultsViewProvider.ts b/packages/core/src/codewhisperer/service/transformByQ/transformationResultsViewProvider.ts index 56195dd2b69..fc7de456d9e 100644 --- a/packages/core/src/codewhisperer/service/transformByQ/transformationResultsViewProvider.ts +++ b/packages/core/src/codewhisperer/service/transformByQ/transformationResultsViewProvider.ts @@ -107,7 +107,7 @@ export class AddedChangeNode extends ProposedChangeNode { } export class PatchFileNode { - readonly label: string + label: string readonly patchFilePath: string children: ProposedChangeNode[] = [] @@ -157,7 +157,8 @@ export class DiffModel { public parseDiff( pathToDiff: string, pathToWorkspace: string, - diffDescription: PatchInfo | undefined + diffDescription: PatchInfo | undefined, + totalDiffPatches: number ): PatchFileNode { this.patchFileNodes = [] const diffContents = fs.readFileSync(pathToDiff, 'utf8') @@ -195,6 +196,7 @@ export class DiffModel { }, }) const patchFileNode = new PatchFileNode(diffDescription ? diffDescription.name : pathToDiff) + patchFileNode.label = `Patch ${this.currentPatchIndex + 1} of ${totalDiffPatches}: ${patchFileNode.label}` patchFileNode.children = changedFiles.flatMap((file) => { /* ex. file.oldFileName = 'a/src/java/com/project/component/MyFile.java' * ex. file.newFileName = 'b/src/java/com/project/component/MyFile.java' @@ -259,7 +261,7 @@ export class TransformationResultsProvider implements vscode.TreeDataProvider { diffModel.saveChanges() telemetry.ui_click.emit({ elementId: 'transformationHub_acceptChanges' }) - void vscode.window.showInformationMessage(CodeWhispererConstants.changesAppliedNotification) + void vscode.window.showInformationMessage( + CodeWhispererConstants.changesAppliedNotification(diffModel.currentPatchIndex, patchFiles.length) + ) //We do this to ensure that the changesAppliedChatMessage is only sent to user when they accept the first diff.patch - if (diffModel.currentPatchIndex === 0) { + if (diffModel.currentPatchIndex === patchFiles.length - 1) { + transformByQState.getChatControllers()?.transformationFinished.fire({ + message: CodeWhispererConstants.changesAppliedChatMessage( + diffModel.currentPatchIndex, + patchFiles.length + ), + tabID: ChatSessionManager.Instance.getSession().tabID, + includeStartNewTransformationButton: 'true', + }) + } else { transformByQState.getChatControllers()?.transformationFinished.fire({ - message: CodeWhispererConstants.changesAppliedChatMessage, + message: CodeWhispererConstants.changesAppliedChatMessage( + diffModel.currentPatchIndex, + patchFiles.length + ), tabID: ChatSessionManager.Instance.getSession().tabID, + includeStartNewTransformationButton: 'false', }) } @@ -484,7 +504,12 @@ export class ProposedTransformationExplorer { const nextPatchFileDescription = patchFilesDescriptions ? patchFilesDescriptions[diffModel.currentPatchIndex] : undefined - diffModel.parseDiff(nextPatchFile, transformByQState.getProjectPath(), nextPatchFileDescription) + diffModel.parseDiff( + nextPatchFile, + transformByQState.getProjectPath(), + nextPatchFileDescription, + patchFiles.length + ) transformDataProvider.refresh() } else { // All patches have been applied, reset the state