@@ -26,7 +26,7 @@ import {
26
26
import MessengerUtils , { ButtonActions } from './messenger/messengerUtils'
27
27
import { getTelemetryReasonDesc , isAwsError } from '../../../shared/errors'
28
28
import { ChatItemType } from '../../../amazonq/commons/model'
29
- import { ProgressField } from '@aws/mynah-ui'
29
+ import { ChatItemButton , MynahIcons , ProgressField } from '@aws/mynah-ui'
30
30
import { FollowUpTypes } from '../../../amazonq/commons/types'
31
31
import {
32
32
cancelBuild ,
@@ -63,6 +63,9 @@ import {
63
63
} from '../../../codewhisperer/models/constants'
64
64
import { UserWrittenCodeTracker } from '../../../codewhisperer/tracker/userWrittenCodeTracker'
65
65
import { ReferenceLogViewProvider } from '../../../codewhisperer/service/referenceLogViewProvider'
66
+ import { submitFeedback } from '../../../feedback/vue/submitFeedback'
67
+ import { placeholder } from '../../../shared/vscode/commands2'
68
+ import { Auth } from '../../../auth/auth'
66
69
67
70
export interface TestChatControllerEventEmitters {
68
71
readonly tabOpened : vscode . EventEmitter < any >
@@ -354,6 +357,7 @@ export class TestController {
354
357
// This function handles actions if user clicked on any Button one of these cases will be executed
355
358
private async handleFormActionClicked ( data : any ) {
356
359
const typedAction = MessengerUtils . stringToEnumValue ( ButtonActions , data . action as any )
360
+ let getFeedbackCommentData = ''
357
361
switch ( typedAction ) {
358
362
case ButtonActions . STOP_TEST_GEN :
359
363
testGenState . setToCancelling ( )
@@ -366,6 +370,16 @@ export class TestController {
366
370
this . messenger . sendChatInputEnabled ( data . tabID , true )
367
371
await this . sessionCleanUp ( )
368
372
break
373
+ case ButtonActions . PROVIDE_FEEDBACK :
374
+ getFeedbackCommentData = `Q Test Generation: RequestId: ${ this . sessionStorage . getSession ( ) . startTestGenerationRequestId } `
375
+ void submitFeedback ( placeholder , 'Amazon Q' , getFeedbackCommentData )
376
+ telemetry . ui_click . emit ( { elementId : 'unitTestGeneration_provideFeedback' } )
377
+ this . messenger . sendMessage (
378
+ 'Unit test generation completed. Thanks for providing feedback.' ,
379
+ data . tabID ,
380
+ 'answer'
381
+ )
382
+ break
369
383
}
370
384
}
371
385
// This function handles actions if user gives any input from the chatInput box
@@ -897,7 +911,25 @@ export class TestController {
897
911
898
912
// TODO: Check if there are more cases to endSession if yes create a enum or type for step
899
913
private async endSession ( data : any , step : FollowUpTypes ) {
900
- this . messenger . sendMessage ( 'Unit test generation completed.' , data . tabID , 'answer' )
914
+ const buttons : ChatItemButton [ ] = [ ]
915
+ if ( Auth . instance . isInternalAmazonUser ( ) ) {
916
+ buttons . push ( {
917
+ keepCardAfterClick : false ,
918
+ text : 'How can we make /test better?' ,
919
+ id : ButtonActions . PROVIDE_FEEDBACK ,
920
+ disabled : false , // allow button to be re-clicked
921
+ position : 'outside' ,
922
+ icon : 'comment' as MynahIcons ,
923
+ } )
924
+ }
925
+
926
+ this . messenger . sendMessage (
927
+ 'Unit test generation completed.' ,
928
+ data . tabID ,
929
+ 'answer' ,
930
+ 'testGenEndSessionMessage' ,
931
+ buttons
932
+ )
901
933
902
934
const session = this . sessionStorage . getSession ( )
903
935
if ( step === FollowUpTypes . RejectCode ) {
0 commit comments