diff --git a/packages/amazonq/test/unit/amazonqGumby/transformationResultsHandler.test.ts b/packages/amazonq/test/unit/amazonqGumby/transformationResultsHandler.test.ts index d533eac5420..f9ea15b61c9 100644 --- a/packages/amazonq/test/unit/amazonqGumby/transformationResultsHandler.test.ts +++ b/packages/amazonq/test/unit/amazonqGumby/transformationResultsHandler.test.ts @@ -4,12 +4,13 @@ */ import assert from 'assert' import sinon from 'sinon' -import os from 'os' import { DiffModel, AddedChangeNode, ModifiedChangeNode } from 'aws-core-vscode/codewhisperer/node' import { DescriptionContent } from 'aws-core-vscode/codewhisperer' import path from 'path' import { getTestResourceFilePath } from './amazonQGumbyUtil' import { fs } from 'aws-core-vscode/shared' +// eslint-disable-next-line no-restricted-imports +import { createTestWorkspace } from '../../../../core/dist/src/test/testUtil' describe('DiffModel', function () { let parsedTestDescriptions: DescriptionContent @@ -44,8 +45,6 @@ describe('DiffModel', function () { 1 ) - assert.strictEqual(testDiffModel.patchFileNodes.length, 1) - assert.strictEqual(testDiffModel.patchFileNodes[0].children.length, 1) assert.strictEqual( testDiffModel.patchFileNodes[0].patchFilePath, getTestResourceFilePath('resources/files/addedFile.diff') @@ -59,24 +58,23 @@ describe('DiffModel', function () { it('WHEN parsing a diff patch where a file was modified THEN returns an array representing the modified file', async function () { const testDiffModel = new DiffModel() - const workspacePath = os.tmpdir() + const fileAmount = 1 + const workspaceFolder = await createTestWorkspace(fileAmount, { fileContent: '' }) sinon.replace(fs, 'exists', async (path) => true) await fs.writeFile( - path.join(workspacePath, 'README.md'), + path.join(workspaceFolder.uri.fsPath, 'README.md'), 'This guide walks you through using Gradle to build a simple Java project.' ) testDiffModel.parseDiff( getTestResourceFilePath('resources/files/modifiedFile.diff'), - workspacePath, + workspaceFolder.uri.fsPath, parsedTestDescriptions.content[0], 1 ) - assert.strictEqual(testDiffModel.patchFileNodes.length, 1) - assert.strictEqual(testDiffModel.patchFileNodes[0].children.length, 1) assert.strictEqual( testDiffModel.patchFileNodes[0].patchFilePath, getTestResourceFilePath('resources/files/modifiedFile.diff') @@ -86,30 +84,29 @@ describe('DiffModel', function () { assert.strictEqual(change instanceof ModifiedChangeNode, true) - await fs.delete(path.join(workspacePath, 'README.md'), { recursive: true }) + await fs.delete(path.join(workspaceFolder.uri.fsPath, 'README.md'), { recursive: true }) }) it('WHEN parsing a diff patch where diff.json is not present and a file was modified THEN returns an array representing the modified file', async function () { - const testDiffModel = new DiffModel() + const testDiffModel = new DiffModel() //try to see if you can reuse that test model from above - const workspacePath = os.tmpdir() + const fileAmount = 1 + const workspaceFolder = await createTestWorkspace(fileAmount, { fileContent: '' }) sinon.replace(fs, 'exists', async (path) => true) await fs.writeFile( - path.join(workspacePath, 'README.md'), + path.join(workspaceFolder.uri.fsPath, 'README.md'), 'This guide walks you through using Gradle to build a simple Java project.' ) testDiffModel.parseDiff( getTestResourceFilePath('resources/files/modifiedFile.diff'), - workspacePath, + workspaceFolder.uri.fsPath, undefined, 1 ) - assert.strictEqual(testDiffModel.patchFileNodes.length, 1) - assert.strictEqual(testDiffModel.patchFileNodes[0].children.length, 1) assert.strictEqual( testDiffModel.patchFileNodes[0].patchFilePath, getTestResourceFilePath('resources/files/modifiedFile.diff') @@ -119,6 +116,6 @@ describe('DiffModel', function () { assert.strictEqual(change instanceof ModifiedChangeNode, true) - await fs.delete(path.join(workspacePath, 'README.md'), { recursive: true }) + await fs.delete(path.join(workspaceFolder.uri.fsPath, 'README.md'), { recursive: true }) }) }) diff --git a/packages/core/src/amazonqGumby/chat/controller/controller.ts b/packages/core/src/amazonqGumby/chat/controller/controller.ts index 66ee7aced01..c63207906d8 100644 --- a/packages/core/src/amazonqGumby/chat/controller/controller.ts +++ b/packages/core/src/amazonqGumby/chat/controller/controller.ts @@ -617,7 +617,7 @@ export class GumbyController { this.messenger.sendDependencyVersionsFoundMessage(data.dependencies, data.tabID) } - private async HILDependencySelectionUploaded(data: { tabID: string }) { + private HILDependencySelectionUploaded(data: { tabID: string }) { this.sessionStorage.getSession().conversationState = ConversationState.JOB_SUBMITTED this.messenger.sendHILResumeMessage(data.tabID) } diff --git a/packages/core/src/amazonqGumby/chat/controller/messenger/messenger.ts b/packages/core/src/amazonqGumby/chat/controller/messenger/messenger.ts index a29ee8f4d68..3af24465d4f 100644 --- a/packages/core/src/amazonqGumby/chat/controller/messenger/messenger.ts +++ b/packages/core/src/amazonqGumby/chat/controller/messenger/messenger.ts @@ -230,6 +230,10 @@ export class Messenger { value: JDKVersion.JDK11, label: JDKVersion.JDK11, }, + { + value: JDKVersion.JDK17, + label: JDKVersion.JDK17, + }, { value: JDKVersion.UNSUPPORTED, label: 'Other', diff --git a/packages/core/src/amazonqGumby/chat/controller/messenger/messengerUtils.ts b/packages/core/src/amazonqGumby/chat/controller/messenger/messengerUtils.ts index 7be7100b2c0..a7b15810312 100644 --- a/packages/core/src/amazonqGumby/chat/controller/messenger/messengerUtils.ts +++ b/packages/core/src/amazonqGumby/chat/controller/messenger/messengerUtils.ts @@ -49,6 +49,8 @@ export default class MessengerUtils { javaHomePrompt += ` ${CodeWhispererConstants.macJavaVersionHomeHelpChatMessage(1.8)}` } else if (jdkVersion === JDKVersion.JDK11) { javaHomePrompt += ` ${CodeWhispererConstants.macJavaVersionHomeHelpChatMessage(11)}` + } else if (jdkVersion === JDKVersion.JDK17) { + javaHomePrompt += ` ${CodeWhispererConstants.macJavaVersionHomeHelpChatMessage(17)}` } } else { javaHomePrompt += ` ${CodeWhispererConstants.linuxJavaHomeHelpChatMessage}` diff --git a/packages/core/src/codewhisperer/commands/startTransformByQ.ts b/packages/core/src/codewhisperer/commands/startTransformByQ.ts index 741151d351b..a7af2ab492f 100644 --- a/packages/core/src/codewhisperer/commands/startTransformByQ.ts +++ b/packages/core/src/codewhisperer/commands/startTransformByQ.ts @@ -174,6 +174,8 @@ 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()) { @@ -784,7 +786,6 @@ export async function postTransformationJob() { 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/service/transformByQ/transformApiHandler.ts b/packages/core/src/codewhisperer/service/transformByQ/transformApiHandler.ts index 97437c6bcb1..5be4460c838 100644 --- a/packages/core/src/codewhisperer/service/transformByQ/transformApiHandler.ts +++ b/packages/core/src/codewhisperer/service/transformByQ/transformApiHandler.ts @@ -412,7 +412,6 @@ 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 bfb05c6f9da..b2414a26691 100644 --- a/packages/core/src/codewhisperer/service/transformByQ/transformationResultsViewProvider.ts +++ b/packages/core/src/codewhisperer/service/transformByQ/transformationResultsViewProvider.ts @@ -414,7 +414,6 @@ export class ProposedTransformationExplorer { transformByQState.getChatControllers()?.transformationFinished.fire({ message: `${CodeWhispererConstants.errorDownloadingDiffChatMessage} The download failed due to: ${downloadErrorMessage}`, tabID: ChatSessionManager.Instance.getSession().tabID, - includeStartNewTransformationButton: true, }) await setContext('gumby.reviewState', TransformByQReviewStatus.NotStarted) getLogger().error(`CodeTransformation: ExportResultArchive error = ${downloadErrorMessage}`) @@ -484,7 +483,6 @@ export class ProposedTransformationExplorer { transformByQState.getChatControllers()?.transformationFinished.fire({ message: CodeWhispererConstants.viewProposedChangesChatMessage, tabID: ChatSessionManager.Instance.getSession().tabID, - includeStartNewTransformationButton: true, }) await vscode.commands.executeCommand('aws.amazonq.transformationHub.summary.reveal') } catch (e: any) { @@ -493,7 +491,6 @@ export class ProposedTransformationExplorer { transformByQState.getChatControllers()?.transformationFinished.fire({ message: `${CodeWhispererConstants.errorDeserializingDiffChatMessage} ${deserializeErrorMessage}`, tabID: ChatSessionManager.Instance.getSession().tabID, - includeStartNewTransformationButton: true, }) void vscode.window.showErrorMessage( `${CodeWhispererConstants.errorDeserializingDiffNotification} ${deserializeErrorMessage}` @@ -544,31 +541,17 @@ export class ProposedTransformationExplorer { } //We do this to ensure that the changesAppliedChatMessage is only sent to user when they accept the first diff.patch - if (diffModel.currentPatchIndex === patchFiles.length - 1) { - transformByQState.getChatControllers()?.transformationFinished.fire({ - message: CodeWhispererConstants.changesAppliedChatMessageMultipleDiffs( - diffModel.currentPatchIndex, - patchFiles.length, - patchFilesDescriptions - ? patchFilesDescriptions.content[diffModel.currentPatchIndex].name - : undefined - ), - tabID: ChatSessionManager.Instance.getSession().tabID, - includeStartNewTransformationButton: true, - }) - } else { - transformByQState.getChatControllers()?.transformationFinished.fire({ - message: CodeWhispererConstants.changesAppliedChatMessageMultipleDiffs( - diffModel.currentPatchIndex, - patchFiles.length, - patchFilesDescriptions - ? patchFilesDescriptions.content[diffModel.currentPatchIndex].name - : undefined - ), - tabID: ChatSessionManager.Instance.getSession().tabID, - includeStartNewTransformationButton: false, - }) - } + transformByQState.getChatControllers()?.transformationFinished.fire({ + message: CodeWhispererConstants.changesAppliedChatMessageMultipleDiffs( + diffModel.currentPatchIndex, + patchFiles.length, + patchFilesDescriptions + ? patchFilesDescriptions.content[diffModel.currentPatchIndex].name + : undefined + ), + tabID: ChatSessionManager.Instance.getSession().tabID, + includeStartNewTransformationButton: diffModel.currentPatchIndex === patchFiles.length - 1, + }) // Load the next patch file diffModel.currentPatchIndex++ @@ -607,7 +590,6 @@ export class ProposedTransformationExplorer { transformByQState.getChatControllers()?.transformationFinished.fire({ tabID: ChatSessionManager.Instance.getSession().tabID, - includeStartNewTransformationButton: true, }) telemetry.codeTransform_viewArtifact.emit({