Skip to content

Commit 24b94ed

Browse files
committed
added patch description chat message and working on user input for one or multiple diffs
1 parent 37efba3 commit 24b94ed

File tree

5 files changed

+211
-12
lines changed

5 files changed

+211
-12
lines changed

packages/core/src/amazonqGumby/chat/controller/controller.ts

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,13 @@ export class GumbyController {
199199
// if previous transformation was already running, show correct message to user
200200
switch (this.sessionStorage.getSession().conversationState) {
201201
case ConversationState.JOB_SUBMITTED:
202+
this.messenger.sendAsyncEventProgress(
203+
message.tabID,
204+
true,
205+
undefined,
206+
GumbyNamedMessages.JOB_SUBMISSION_STATUS_MESSAGE
207+
)
208+
this.messenger.sendPatchDescriptionMessage(message.tabID)
202209
this.messenger.sendAsyncEventProgress(
203210
message.tabID,
204211
true,
@@ -352,6 +359,12 @@ export class GumbyController {
352359
case ButtonActions.CANCEL_SKIP_TESTS_FORM:
353360
this.messenger.sendJobFinishedMessage(message.tabID, CodeWhispererConstants.jobCancelledChatMessage)
354361
break
362+
// case ButtonActions.CONFIRM_SELECTIVE_TRANSFORMATION_FORM:
363+
// await this.handleSelectiveTransformationSelection(message)
364+
// break
365+
// case ButtonActions.CANCEL_SELECTIVE_TRANSFORMATION_FORM:
366+
// this.messenger.sendJobFinishedMessage(message.tabID, CodeWhispererConstants.jobCancelledChatMessage)
367+
// break
355368
case ButtonActions.CONFIRM_SQL_CONVERSION_TRANSFORMATION_FORM:
356369
await this.handleUserSQLConversionProjectSelection(message)
357370
break
@@ -360,6 +373,13 @@ export class GumbyController {
360373
break
361374
case ButtonActions.VIEW_TRANSFORMATION_HUB:
362375
await vscode.commands.executeCommand(GumbyCommands.FOCUS_TRANSFORMATION_HUB, CancelActionPositions.Chat)
376+
this.messenger.sendPatchDescriptionMessage(message.tabID)
377+
this.messenger.sendAsyncEventProgress(
378+
message.tabID,
379+
true,
380+
undefined,
381+
GumbyNamedMessages.JOB_SUBMISSION_STATUS_MESSAGE
382+
)
363383
this.messenger.sendJobSubmittedMessage(message.tabID)
364384
break
365385
case ButtonActions.STOP_TRANSFORMATION_JOB:
@@ -406,6 +426,16 @@ export class GumbyController {
406426
await this.validateBuildWithPromptOnError(message)
407427
}
408428

429+
// private async handleSelectiveTransformationSelection(message: any) {
430+
// const selectiveTransformationSelection = message.formSelectedValues['GumbyTransformSelectiveTransformationForm']
431+
// if (selectiveTransformationSelection === CodeWhispererConstants.multipleDiffsMessage) {
432+
// //Dynamically add to zipmanifest
433+
// }
434+
// this.messenger.sendSelectiveTransformationMessage(selectiveTransformationSelection, message.tabID)
435+
// // perform local build
436+
// // await this.validateBuildWithPromptOnError(message)
437+
// }
438+
409439
private async handleUserLanguageUpgradeProjectChoice(message: any) {
410440
await telemetry.codeTransform_submitSelection.run(async () => {
411441
const pathToProject: string = message.formSelectedValues['GumbyTransformLanguageUpgradeProjectForm']
@@ -438,9 +468,9 @@ export class GumbyController {
438468
this.messenger.sendUnrecoverableErrorResponse('unsupported-source-jdk-version', message.tabID)
439469
return
440470
}
441-
442471
await processLanguageUpgradeTransformFormInput(pathToProject, fromJDKVersion, toJDKVersion)
443472
await this.messenger.sendSkipTestsPrompt(message.tabID)
473+
// await this.messenger.sendSelectiveTransformationPrompt(message.tabID)
444474
})
445475
}
446476

@@ -461,6 +491,13 @@ export class GumbyController {
461491

462492
await processSQLConversionTransformFormInput(pathToProject, schema)
463493

494+
this.messenger.sendAsyncEventProgress(
495+
message.tabID,
496+
true,
497+
undefined,
498+
GumbyNamedMessages.JOB_SUBMISSION_STATUS_MESSAGE
499+
)
500+
this.messenger.sendPatchDescriptionMessage(message.tabID)
464501
this.messenger.sendAsyncEventProgress(
465502
message.tabID,
466503
true,
@@ -506,6 +543,13 @@ export class GumbyController {
506543
// give user a non-blocking warning if build file appears to contain absolute paths
507544
await parseBuildFile()
508545

546+
this.messenger.sendAsyncEventProgress(
547+
message.tabID,
548+
true,
549+
undefined,
550+
GumbyNamedMessages.JOB_SUBMISSION_STATUS_MESSAGE
551+
)
552+
this.messenger.sendPatchDescriptionMessage(message.tabID)
509553
this.messenger.sendAsyncEventProgress(
510554
message.tabID,
511555
true,
@@ -603,8 +647,15 @@ export class GumbyController {
603647
this.messenger.sendDependencyVersionsFoundMessage(data.dependencies, data.tabID)
604648
}
605649

606-
private HILDependencySelectionUploaded(data: { tabID: string }) {
650+
private async HILDependencySelectionUploaded(data: { tabID: string }) {
607651
this.sessionStorage.getSession().conversationState = ConversationState.JOB_SUBMITTED
652+
this.messenger.sendPatchDescriptionMessage(data.tabID)
653+
this.messenger.sendAsyncEventProgress(
654+
data.tabID,
655+
true,
656+
undefined,
657+
GumbyNamedMessages.JOB_SUBMISSION_STATUS_MESSAGE
658+
)
608659
this.messenger.sendHILResumeMessage(data.tabID)
609660
}
610661

@@ -662,6 +713,13 @@ export class GumbyController {
662713
} else if (message.error instanceof JobStartError) {
663714
this.resetTransformationChatFlow()
664715
} else if (message.error instanceof TransformationPreBuildError) {
716+
this.messenger.sendPatchDescriptionMessage(message.tabID)
717+
this.messenger.sendAsyncEventProgress(
718+
message.tabID,
719+
true,
720+
undefined,
721+
GumbyNamedMessages.JOB_FAILED_IN_PRE_BUILD
722+
)
665723
this.messenger.sendJobSubmittedMessage(message.tabID, true)
666724
this.messenger.sendAsyncEventProgress(
667725
message.tabID,

packages/core/src/amazonqGumby/chat/controller/messenger/messenger.ts

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,45 @@ export class Messenger {
116116
this.dispatcher.sendAuthenticationUpdate(new AuthenticationUpdateMessage(gumbyEnabled, authenticatingTabIDs))
117117
}
118118

119+
public async sendSelectiveTransformationPrompt(tabID: string) {
120+
const formItems: ChatItemFormItem[] = []
121+
formItems.push({
122+
id: 'GumbyTransformSelectiveTransformationForm',
123+
type: 'select',
124+
title: CodeWhispererConstants.selectiveTransformationFormTitle,
125+
mandatory: true,
126+
options: [
127+
{
128+
value: CodeWhispererConstants.oneDiffMessage,
129+
label: CodeWhispererConstants.oneDiffMessage,
130+
},
131+
{
132+
value: CodeWhispererConstants.multipleDiffsMessage,
133+
label: CodeWhispererConstants.multipleDiffsMessage,
134+
},
135+
],
136+
})
137+
138+
this.dispatcher.sendAsyncEventProgress(
139+
new AsyncEventProgressMessage(tabID, {
140+
inProgress: true,
141+
message: CodeWhispererConstants.selectiveTransformationFormMessage,
142+
})
143+
)
144+
145+
this.dispatcher.sendChatPrompt(
146+
new ChatPrompt(
147+
{
148+
message: 'Proposed Changes Result',
149+
formItems: formItems,
150+
},
151+
'TransformSelectiveTransformationForm',
152+
tabID,
153+
false
154+
)
155+
)
156+
}
157+
119158
public async sendSkipTestsPrompt(tabID: string) {
120159
const formItems: ChatItemFormItem[] = []
121160
formItems.push({
@@ -330,6 +369,33 @@ export class Messenger {
330369
)
331370
}
332371

372+
public sendPatchDescriptionMessage(
373+
tabID: string,
374+
message: string = CodeWhispererConstants.userPatchDescriptionChatMessage
375+
// messageID: string = GumbyNamedMessages.JOB_SUBMISSION_STATUS_MESSAGE
376+
) {
377+
// const patchDescriptionChatMessage = new ChatMessage(
378+
// {
379+
// message,
380+
// messageType: 'ai-prompt',
381+
// messageId: messageID,
382+
// },
383+
// tabID
384+
// )
385+
this.dispatcher.sendAsyncEventProgress(
386+
new AsyncEventProgressMessage(tabID, {
387+
inProgress: true,
388+
message,
389+
})
390+
)
391+
this.dispatcher.sendAsyncEventProgress(
392+
new AsyncEventProgressMessage(tabID, {
393+
inProgress: false,
394+
message: undefined,
395+
})
396+
)
397+
}
398+
333399
public sendJobSubmittedMessage(
334400
tabID: string,
335401
disableJobActions: boolean = false,
@@ -363,7 +429,6 @@ export class Messenger {
363429
},
364430
tabID
365431
)
366-
367432
this.dispatcher.sendChatMessage(jobSubmittedMessage)
368433
}
369434

@@ -575,6 +640,11 @@ export class Messenger {
575640
this.dispatcher.sendChatMessage(new ChatMessage({ message, messageType: 'ai-prompt' }, tabID))
576641
}
577642

643+
public sendSelectiveTransformationMessage(selectiveTransformationSelection: string, tabID: string) {
644+
const message = `Okay, I will create ${selectiveTransformationSelection.toLowerCase()} when building your project.`
645+
this.dispatcher.sendChatMessage(new ChatMessage({ message, messageType: 'ai-prompt' }, tabID))
646+
}
647+
578648
public sendHumanInTheLoopInitialMessage(tabID: string, codeSnippet: string) {
579649
let message = `I was not able to upgrade all dependencies. To resolve it, I will try to find an updated depedency in your local Maven repository. I will need additional information from you to continue.`
580650

@@ -689,6 +759,13 @@ ${codeSnippet}
689759
undefined,
690760
GumbyNamedMessages.JOB_SUBMISSION_WITH_DEPENDENCY_STATUS_MESSAGE
691761
)
762+
this.sendPatchDescriptionMessage(tabID)
763+
this.sendAsyncEventProgress(
764+
tabID,
765+
true,
766+
undefined,
767+
GumbyNamedMessages.JOB_SUBMISSION_WITH_DEPENDENCY_STATUS_MESSAGE
768+
)
692769
this.sendJobSubmittedMessage(
693770
tabID,
694771
false,

packages/core/src/amazonqGumby/chat/controller/messenger/messengerUtils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ export enum ButtonActions {
1818
CANCEL_TRANSFORMATION_FORM = 'gumbyTransformFormCancel', // shared between Language Upgrade & SQL Conversion
1919
CONFIRM_SKIP_TESTS_FORM = 'gumbyTransformSkipTestsFormConfirm',
2020
CANCEL_SKIP_TESTS_FORM = 'gumbyTransformSkipTestsFormCancel',
21+
CONFIRM_SELECTIVE_TRANSFORMATION_FORM = 'gumbyTransformSelectiveTransformationFormConfirm',
22+
CANCEL_SELECTIVE_TRANSFORMATION_FORM = 'gumbyTransformSelectiveTransformationFormCancel',
2123
SELECT_SQL_CONVERSION_METADATA_FILE = 'gumbySQLConversionMetadataTransformFormConfirm',
2224
CONFIRM_DEPENDENCY_FORM = 'gumbyTransformDependencyFormConfirm',
2325
CANCEL_DEPENDENCY_FORM = 'gumbyTransformDependencyFormCancel',

packages/core/src/codewhisperer/models/constants.ts

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6+
import { DescriptionContent } from '..'
7+
68
/**
79
* Automated and manual trigger
810
*/
@@ -22,6 +24,19 @@ export const AWSTemplateKeyWords = ['AWSTemplateFormatVersion', 'Resources', 'AW
2224

2325
export const AWSTemplateCaseInsensitiveKeyWords = ['cloudformation', 'cfn', 'template', 'description']
2426

27+
const patchDescriptions: { [key: string]: string } = {
28+
'Minimal Compatible Library Upgrade to Java 17':
29+
'This diff patch covers the set of upgrades for Springboot, JUnit, and PowerMockito frameworks.',
30+
'Popular Enterprise Specifications and Application Frameworks':
31+
'This diff patch covers the set of upgrades for Jakarta EE 10, Hibernate 6.2, and Micronaut 3.',
32+
'HTTP Client Utilities, Apache Commons Utilities, and Web Frameworks':
33+
'This diff patch covers the set of upgrades for Apache HTTP Client 5, Apache Commons utilities (Collections, IO, Lang, Math), Struts 6.0.',
34+
'Testing Tools and Frameworks':
35+
'This diff patch covers the set of upgrades for ArchUnit, Mockito, TestContainers, Cucumber, and additionally, Jenkins plugins and the Maven Wrapper.',
36+
'Miscellaneous Processing Documentation':
37+
'This diff patch covers a diverse set of upgrades spanning ORMs, XML processing, API documentation, and more.',
38+
}
39+
2540
export const JsonConfigFileNamingConvention = new Set([
2641
'app.json',
2742
'appsettings.json',
@@ -450,6 +465,20 @@ export const codeTransformLocThreshold = 100000
450465
export const jobStartedChatMessage =
451466
'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.'
452467

468+
export const userPatchDescriptionChatMessage = `
469+
I will be dividing my proposed changes into smaller sections. Here is a description of what each section entails:
470+
471+
• Minimal Compatible Library Upgrade to Java 17: This upgrades dependencies to the minimum compatible versions in Java 17. It also includes updated versions of Springboot as well as JUnit and PowerMockito frameworks.
472+
473+
• Popular Enterprise Specifications Application Frameworks: This group aims to migrate to the latest versions of popular enterprise specifications and application frameworks like Jakarta EE 10 (the new javax namespace), Hibernate 6.2 (a widely used ORM), and Micronaut 3 (a modern, lightweight full-stack framework).
474+
475+
• HTTP Client Utilities Web Frameworks: This section targets upgrades for HTTP client libraries (Apache HTTP Client 5), Apache Commons utilities (Collections, IO, Lang, Math), and web frameworks (Struts 6.0). The goal is to modernize these commonly used libraries and frameworks to their latest versions, ensuring compatibility with Java 17.
476+
477+
• Testing Tools Frameworks: This set upgrades targets testing tools and frameworks like ArchUnit, Mockito, TestContainers, and Cucumber. Additionally, it updates build tools like Jenkins plugins and the Maven Wrapper. The goal is to bring the testing ecosystem and build tooling up-to-date with the latest versions and best practices.
478+
479+
• Miscellaneous Processing Documentation: This group covers a diverse set of upgrades spanning ORMs (JpaRepository), XML processing (JAXB namespace), application servers (WebSphere to Liberty migration), API documentation (Swagger to SpringDoc/OpenAPI), and utilities (Okio, OkHttp, LaunchDarkly).
480+
`
481+
453482
export const uploadingCodeStepMessage = 'Upload your code'
454483

455484
export const buildCodeStepMessage = 'Build uploaded code in secure build environment'
@@ -626,11 +655,23 @@ export const viewProposedChangesChatMessage =
626655
export const viewProposedChangesNotification =
627656
'Download complete. You can view a summary of the transformation and accept or reject the proposed changes in the Transformation Hub.'
628657

629-
export const changesAppliedChatMessage = (currentPatchIndex: number, totalPatchFiles: number) =>
630-
`I applied the changes in diff patch ${currentPatchIndex + 1} of ${totalPatchFiles} to your project.`
631-
632-
export const changesAppliedNotification = (currentPatchIndex: number, totalPatchFiles: number) =>
633-
`Amazon Q applied the changes in diff patch ${currentPatchIndex + 1} of ${totalPatchFiles} to your project.`
658+
export const changesAppliedChatMessage = (
659+
currentPatchIndex: number,
660+
totalPatchFiles: number,
661+
description: string | undefined
662+
) =>
663+
description
664+
? `I applied the changes in diff patch ${currentPatchIndex + 1} of ${totalPatchFiles} to your project. ${patchDescriptions[description]} You can make a commit if the diff shows success. If the diff shows partial success, apply and fix the errors, and start a new transformation.`
665+
: 'I applied the changes to your project.'
666+
667+
export const changesAppliedNotification = (
668+
currentPatchIndex: number,
669+
totalPatchFiles: number,
670+
patchFilesDescriptions: DescriptionContent | undefined
671+
) =>
672+
patchFilesDescriptions
673+
? `Amazon Q applied the changes in diff patch ${currentPatchIndex + 1} of ${totalPatchFiles} to your project.`
674+
: 'Amazon Q applied the changes to your project.'
634675

635676
export const noOpenProjectsFoundChatMessage = `I couldn\'t find a project that I can upgrade. Currently, I support Java 8, Java 11, and Java 17 projects built on Maven. Make sure your project is open in the IDE. For more information, see the [Amazon Q documentation](${codeTransformPrereqDoc}).`
636677

@@ -681,15 +722,24 @@ export const chooseTargetVersionFormTitle = 'Choose the target code version'
681722

682723
export const skipUnitTestsFormTitle = 'Choose to skip unit tests'
683724

725+
export const selectiveTransformationFormTitle = 'Choose to receive multiple diffs'
726+
684727
export const skipUnitTestsFormMessage =
685728
'I will build your project using `mvn clean test` by default. If you would like me to build your project without running unit tests, I will use `mvn clean test-compile`.'
686729

730+
export const selectiveTransformationFormMessage =
731+
'Would you like me to produce one diff with all of my proposed changes or divide my proposed changes into smaller sections?'
732+
687733
export const runUnitTestsMessage = 'Run unit tests'
688734

735+
export const oneDiffMessage = 'One diff'
736+
689737
export const doNotSkipUnitTestsBuildCommand = 'clean test'
690738

691739
export const skipUnitTestsMessage = 'Skip unit tests'
692740

741+
export const multipleDiffsMessage = 'Multiple diffs'
742+
693743
export const skipUnitTestsBuildCommand = 'clean test-compile'
694744

695745
export const planTitle = 'Code Transformation plan by Amazon Q'

0 commit comments

Comments
 (0)