-
Notifications
You must be signed in to change notification settings - Fork 749
feat(amazonq): Implementing the feedback system for internal users to improve unit test generation quality. #6748
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,7 +26,7 @@ import { | |
| import MessengerUtils, { ButtonActions } from './messenger/messengerUtils' | ||
| import { getTelemetryReasonDesc, isAwsError } from '../../../shared/errors' | ||
| import { ChatItemType } from '../../../amazonq/commons/model' | ||
| import { ProgressField } from '@aws/mynah-ui' | ||
| import { ChatItemButton, MynahIcons, ProgressField } from '@aws/mynah-ui' | ||
| import { FollowUpTypes } from '../../../amazonq/commons/types' | ||
| import { | ||
| cancelBuild, | ||
|
|
@@ -63,6 +63,9 @@ import { | |
| } from '../../../codewhisperer/models/constants' | ||
| import { UserWrittenCodeTracker } from '../../../codewhisperer/tracker/userWrittenCodeTracker' | ||
| import { ReferenceLogViewProvider } from '../../../codewhisperer/service/referenceLogViewProvider' | ||
| import { submitFeedback } from '../../../feedback/vue/submitFeedback' | ||
| import { placeholder } from '../../../shared/vscode/commands2' | ||
| import { Auth } from '../../../auth/auth' | ||
|
|
||
| export interface TestChatControllerEventEmitters { | ||
| readonly tabOpened: vscode.EventEmitter<any> | ||
|
|
@@ -299,10 +302,22 @@ export class TestController { | |
| ) | ||
| if (session.stopIteration) { | ||
| // Error from Science | ||
| this.messenger.sendMessage(data.error.uiMessage.replaceAll('```', ''), data.tabID, 'answer') | ||
| this.messenger.sendMessage( | ||
| data.error.uiMessage.replaceAll('```', ''), | ||
| data.tabID, | ||
| 'answer', | ||
| 'testGenErrorMessage', | ||
| this.getFeedbackButtons() | ||
| ) | ||
| } else { | ||
| isCancel | ||
| ? this.messenger.sendMessage(data.error.uiMessage, data.tabID, 'answer') | ||
| ? this.messenger.sendMessage( | ||
| data.error.uiMessage, | ||
| data.tabID, | ||
| 'answer', | ||
| 'testGenErrorMessage', | ||
| this.getFeedbackButtons() | ||
| ) | ||
| : this.sendErrorMessage(data) | ||
| } | ||
| await this.sessionCleanUp() | ||
|
|
@@ -322,7 +337,9 @@ export class TestController { | |
| return this.messenger.sendMessage( | ||
| i18n('AWS.amazonq.featureDev.error.monthlyLimitReached'), | ||
| tabID, | ||
| 'answer' | ||
| 'answer', | ||
| 'testGenErrorMessage', | ||
| this.getFeedbackButtons() | ||
| ) | ||
| } | ||
| if (error.message.includes('Too many requests')) { | ||
|
|
@@ -354,6 +371,7 @@ export class TestController { | |
| // This function handles actions if user clicked on any Button one of these cases will be executed | ||
| private async handleFormActionClicked(data: any) { | ||
| const typedAction = MessengerUtils.stringToEnumValue(ButtonActions, data.action as any) | ||
| let getFeedbackCommentData = '' | ||
| switch (typedAction) { | ||
| case ButtonActions.STOP_TEST_GEN: | ||
| testGenState.setToCancelling() | ||
|
|
@@ -366,6 +384,16 @@ export class TestController { | |
| this.messenger.sendChatInputEnabled(data.tabID, true) | ||
| await this.sessionCleanUp() | ||
| break | ||
| case ButtonActions.PROVIDE_FEEDBACK: | ||
| getFeedbackCommentData = `Q Test Generation: RequestId: ${this.sessionStorage.getSession().startTestGenerationRequestId}` | ||
| void submitFeedback(placeholder, 'Amazon Q', getFeedbackCommentData) | ||
| telemetry.ui_click.emit({ elementId: 'unitTestGeneration_provideFeedback' }) | ||
| this.messenger.sendMessage( | ||
| 'Unit test generation completed. Thanks for providing feedback.', | ||
| data.tabID, | ||
| 'answer' | ||
| ) | ||
| break | ||
| } | ||
| } | ||
| // This function handles actions if user gives any input from the chatInput box | ||
|
|
@@ -395,6 +423,21 @@ export class TestController { | |
| } | ||
| } | ||
|
|
||
| private getFeedbackButtons(): ChatItemButton[] { | ||
| const buttons: ChatItemButton[] = [] | ||
| if (Auth.instance.isInternalAmazonUser()) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tested with external user/Builder Id?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, both @ankit-sharma90 and I tested this scenario. |
||
| buttons.push({ | ||
| keepCardAfterClick: false, | ||
| text: 'How can we make /test better?', | ||
| id: ButtonActions.PROVIDE_FEEDBACK, | ||
| disabled: false, // allow button to be re-clicked | ||
| position: 'outside', | ||
| icon: 'comment' as MynahIcons, | ||
| }) | ||
| } | ||
| return buttons | ||
| } | ||
|
|
||
| /** | ||
| * Start Test Generation and show the code results | ||
| */ | ||
|
|
@@ -897,7 +940,13 @@ export class TestController { | |
|
|
||
| // TODO: Check if there are more cases to endSession if yes create a enum or type for step | ||
| private async endSession(data: any, step: FollowUpTypes) { | ||
| this.messenger.sendMessage('Unit test generation completed.', data.tabID, 'answer') | ||
| this.messenger.sendMessage( | ||
| 'Unit test generation completed.', | ||
| data.tabID, | ||
| 'answer', | ||
| 'testGenEndSessionMessage', | ||
| this.getFeedbackButtons() | ||
| ) | ||
|
|
||
| const session = this.sessionStorage.getSession() | ||
| if (step === FollowUpTypes.RejectCode) { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Can we add Job Id if available?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jobIdmay or may not be available in most of the cases. Taking these things into consideration, I opted out mentioning this as part of ticket process.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah agreed...but thought it would be useful to add in case of availability.