diff --git a/packages/core/src/amazonqGumby/chat/controller/controller.ts b/packages/core/src/amazonqGumby/chat/controller/controller.ts index 3b40ad9882f..7e3e799a046 100644 --- a/packages/core/src/amazonqGumby/chat/controller/controller.ts +++ b/packages/core/src/amazonqGumby/chat/controller/controller.ts @@ -432,14 +432,20 @@ export class GumbyController { private promptJavaHome(type: 'source' | 'target', tabID: any) { let jdkVersion = undefined + let currJavaHome = undefined if (type === 'source') { this.sessionStorage.getSession().conversationState = ConversationState.PROMPT_SOURCE_JAVA_HOME jdkVersion = transformByQState.getSourceJDKVersion() + currJavaHome = transformByQState.getPathFromJdkVersion(transformByQState.getSourceJDKVersion()) } else if (type === 'target') { this.sessionStorage.getSession().conversationState = ConversationState.PROMPT_TARGET_JAVA_HOME jdkVersion = transformByQState.getTargetJDKVersion() + currJavaHome = transformByQState.getPathFromJdkVersion(transformByQState.getTargetJDKVersion()) + } + let message = MessengerUtils.createJavaHomePrompt(jdkVersion) + if (currJavaHome) { + message += `\n\ncurrent:\n\n\`${currJavaHome}\`` } - const message = MessengerUtils.createJavaHomePrompt(jdkVersion) this.messenger.sendMessage(message, tabID, 'ai-prompt') this.messenger.sendChatInputEnabled(tabID, true) this.messenger.sendUpdatePlaceholder(tabID, CodeWhispererConstants.enterJavaHomePlaceholder) @@ -640,6 +646,7 @@ export class GumbyController { const pathToJavaHome = extractPath(data.message) if (pathToJavaHome) { transformByQState.setSourceJavaHome(pathToJavaHome) + transformByQState.setJdkVersionToPath(transformByQState.getSourceJDKVersion(), pathToJavaHome) // if source and target JDK versions are the same, just re-use the source JAVA_HOME and start the build if (transformByQState.getTargetJDKVersion() === transformByQState.getSourceJDKVersion()) { transformByQState.setTargetJavaHome(pathToJavaHome) @@ -657,6 +664,7 @@ export class GumbyController { const pathToJavaHome = extractPath(data.message) if (pathToJavaHome) { transformByQState.setTargetJavaHome(pathToJavaHome) + transformByQState.setJdkVersionToPath(transformByQState.getTargetJDKVersion(), pathToJavaHome) await this.prepareLanguageUpgradeProject(data.tabID) // build right after we get target JDK path } else { this.messenger.sendUnrecoverableErrorResponse('invalid-java-home', data.tabID) diff --git a/packages/core/src/amazonqGumby/chat/controller/messenger/messengerUtils.ts b/packages/core/src/amazonqGumby/chat/controller/messenger/messengerUtils.ts index af9f9f47a7b..4df65fe9d1d 100644 --- a/packages/core/src/amazonqGumby/chat/controller/messenger/messengerUtils.ts +++ b/packages/core/src/amazonqGumby/chat/controller/messenger/messengerUtils.ts @@ -37,7 +37,7 @@ export enum GumbyCommands { export default class MessengerUtils { static createJavaHomePrompt = (jdkVersion: JDKVersion | undefined): string => { - let javaHomePrompt = `${CodeWhispererConstants.enterJavaHomeChatMessage} ${jdkVersion}. \n` + let javaHomePrompt = `${CodeWhispererConstants.enterJavaHomeChatMessage} ${jdkVersion}.\n\n` if (os.platform() === 'win32') { javaHomePrompt += CodeWhispererConstants.windowsJavaHomeHelpChatMessage } else if (os.platform() === 'darwin') { diff --git a/packages/core/src/codewhisperer/models/model.ts b/packages/core/src/codewhisperer/models/model.ts index 72483feec51..a993814132d 100644 --- a/packages/core/src/codewhisperer/models/model.ts +++ b/packages/core/src/codewhisperer/models/model.ts @@ -754,6 +754,8 @@ export class TransformByQState { private targetJDKVersion: JDKVersion | undefined = undefined + private jdkVersionToPath: Map = new Map() + private customBuildCommand: string = '' private sourceDB: DB | undefined = undefined @@ -874,6 +876,14 @@ export class TransformByQState { return this.targetJDKVersion } + public getPathFromJdkVersion(version: JDKVersion | undefined) { + if (version) { + return this.jdkVersionToPath.get(version) + } else { + return undefined + } + } + public getSourceDB() { return this.sourceDB } @@ -954,6 +964,12 @@ export class TransformByQState { return this.targetJavaHome } + public setJdkVersionToPath(jdkVersion: JDKVersion | undefined, path: string) { + if (jdkVersion) { + this.jdkVersionToPath.set(jdkVersion, path) + } + } + public getChatControllers() { return this.chatControllers }