From 4875b2b0c6aeffbc950c8f1326dcde0cfc79ca26 Mon Sep 17 00:00:00 2001 From: Neha Tarakad Date: Fri, 15 Nov 2024 17:13:22 -0800 Subject: [PATCH] addressing minor comments and fixing chat messaging --- packages/amazonq/package.json | 2 +- .../chat/controller/messenger/messenger.ts | 4 +-- .../src/codewhisperer/models/constants.ts | 2 +- .../transformationResultsViewProvider.ts | 36 +++++++++---------- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/packages/amazonq/package.json b/packages/amazonq/package.json index f0478d5f2e0..e63c0ac02b0 100644 --- a/packages/amazonq/package.json +++ b/packages/amazonq/package.json @@ -1095,6 +1095,6 @@ }, "engines": { "npm": "^10.1.0", - "vscode": "^1.68.0" + "vscode": "^1.83.0" } } diff --git a/packages/core/src/amazonqGumby/chat/controller/messenger/messenger.ts b/packages/core/src/amazonqGumby/chat/controller/messenger/messenger.ts index d6314ef587d..a29ee8f4d68 100644 --- a/packages/core/src/amazonqGumby/chat/controller/messenger/messenger.ts +++ b/packages/core/src/amazonqGumby/chat/controller/messenger/messenger.ts @@ -224,11 +224,11 @@ export class Messenger { options: [ { value: JDKVersion.JDK8, - label: JDKVersion.JDK8.toString(), + label: JDKVersion.JDK8, }, { value: JDKVersion.JDK11, - label: JDKVersion.JDK11.toString(), + label: JDKVersion.JDK11, }, { value: JDKVersion.UNSUPPORTED, diff --git a/packages/core/src/codewhisperer/models/constants.ts b/packages/core/src/codewhisperer/models/constants.ts index c479eb12f65..f5366a349ff 100644 --- a/packages/core/src/codewhisperer/models/constants.ts +++ b/packages/core/src/codewhisperer/models/constants.ts @@ -468,7 +468,7 @@ export const jobStartedChatMessage = 'I am starting to transform your code. It can take 10 to 30 minutes to upgrade your code, depending on the size of your project. To monitor progress, go to the Transformation Hub. If I run into any issues, I might pause the transformation to get input from you on how to proceed.' export const userPatchDescriptionChatMessage = ` -I can now divide the transformation results into diff patches if you would like to review and accept each diff with fewer changes: +I can now divide the transformation results into diff patches (if applicable to the app) if you would like to review and accept each diff with fewer changes: • Minimal Compatible Library Upgrade to Java 17: Dependencies to the minimum compatible versions in Java 17, including Springboot, JUnit, and PowerMockito. diff --git a/packages/core/src/codewhisperer/service/transformByQ/transformationResultsViewProvider.ts b/packages/core/src/codewhisperer/service/transformByQ/transformationResultsViewProvider.ts index 6dd6f17d168..bfb05c6f9da 100644 --- a/packages/core/src/codewhisperer/service/transformByQ/transformationResultsViewProvider.ts +++ b/packages/core/src/codewhisperer/service/transformByQ/transformationResultsViewProvider.ts @@ -169,42 +169,34 @@ export class DiffModel { diffDescription: PatchInfo | undefined, totalDiffPatches: number ): PatchFileNode { - console.log('parsing ', pathToDiff) this.patchFileNodes = [] const diffContents = fs.readFileSync(pathToDiff, 'utf8') - console.log('diff contents: ', diffContents) const changedFiles = parsePatch(diffContents) - console.log('changed files: ', changedFiles) // path to the directory containing copy of the changed files in the transformed project const pathToTmpSrcDir = this.copyProject(pathToWorkspace, changedFiles) transformByQState.setProjectCopyFilePath(pathToTmpSrcDir) - console.log('path to tmp src dir: ', pathToTmpSrcDir) applyPatches(changedFiles, { loadFile: function (fileObj, callback) { // load original contents of file const filePath = path.join(pathToWorkspace, fileObj.oldFileName!.substring(2)) - console.log(`loading filePath ${filePath}, exists = ${fs.existsSync(filePath)}`) if (!fs.existsSync(filePath)) { // must be a new file (ex. summary.md), so pass empty string as original contents and do not pass error callback(undefined, '') } else { // must be a modified file (most common), so pass original contents const fileContents = fs.readFileSync(filePath, 'utf-8') - console.log('original contents = ', fileContents) callback(undefined, fileContents) } }, // by now, 'content' contains the changes from the patch patched: function (fileObj, content, callback) { const filePath = path.join(pathToTmpSrcDir, fileObj.newFileName!.substring(2)) - console.log(`about to write ${content} to ${filePath}`) // write changed contents to the copy of the original file (or create a new file) fs.writeFileSync(filePath, content) callback(undefined) }, complete: function (err) { - console.log(`error = ${err}`) if (err) { getLogger().error(`CodeTransformation: ${err} when applying patch`) } else { @@ -438,17 +430,26 @@ export class ProposedTransformationExplorer { pathContainingArchive = path.dirname(pathToArchive) const zip = new AdmZip(pathToArchive) zip.extractAllTo(pathContainingArchive) - console.log('pathContainingArchive = ', pathContainingArchive) const files = fs.readdirSync(path.join(pathContainingArchive, ExportResultArchiveStructure.PathToPatch)) - files.forEach((file) => { - const filePath = path.join(pathContainingArchive, ExportResultArchiveStructure.PathToPatch, file) - if (file === 'diff.patch') { - singlePatchFile = filePath - } else if (file.endsWith('.json')) { - const jsonData = fs.readFileSync(filePath, 'utf-8') - patchFilesDescriptions = JSON.parse(jsonData) + if (files.length === 1) { + singlePatchFile = path.join( + pathContainingArchive, + ExportResultArchiveStructure.PathToPatch, + files[0] + ) + } else { + const jsonFile = files.find((file) => file.endsWith('.json')) + if (!jsonFile) { + throw new Error('Expected JSON file not found') } - }) + const filePath = path.join( + pathContainingArchive, + ExportResultArchiveStructure.PathToPatch, + jsonFile + ) + const jsonData = fs.readFileSync(filePath, 'utf-8') + patchFilesDescriptions = JSON.parse(jsonData) + } if (patchFilesDescriptions !== undefined) { for (const patchInfo of patchFilesDescriptions.content) { patchFiles.push( @@ -488,7 +489,6 @@ export class ProposedTransformationExplorer { await vscode.commands.executeCommand('aws.amazonq.transformationHub.summary.reveal') } catch (e: any) { deserializeErrorMessage = (e as Error).message - console.log('error parsing diff ', deserializeErrorMessage) getLogger().error(`CodeTransformation: ParseDiff error = ${deserializeErrorMessage}`) transformByQState.getChatControllers()?.transformationFinished.fire({ message: `${CodeWhispererConstants.errorDeserializingDiffChatMessage} ${deserializeErrorMessage}`,