File tree Expand file tree Collapse file tree 3 files changed +35
-22
lines changed
amazonqFeatureDev/controllers/chat
test/amazonqFeatureDev/controllers/chat Expand file tree Collapse file tree 3 files changed +35
-22
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,6 @@ import { CodeReference } from './amazonqCommonsConnector'
1010import { FollowUpGenerator } from '../followUps/generator'
1111import { getActions } from '../diffTree/actions'
1212import { DiffTreeFileInfo } from '../diffTree/types'
13- import { telemetry } from '../../../../shared/telemetry'
1413
1514interface ChatPayload {
1615 chatMessage : string
@@ -278,13 +277,10 @@ export class Connector {
278277 }
279278
280279 onStopChatResponse = ( tabID : string ) : void => {
281- telemetry . amazonq_stopCodeGeneration . run ( ( span ) => {
282- span . record ( { tabID } )
283- this . sendMessageToExtension ( {
284- tabID : tabID ,
285- command : 'stop-response' ,
286- tabType : 'featuredev' ,
287- } )
280+ this . sendMessageToExtension ( {
281+ tabID : tabID ,
282+ command : 'stop-response' ,
283+ tabType : 'featuredev' ,
288284 } )
289285 }
290286
Original file line number Diff line number Diff line change @@ -749,21 +749,24 @@ export class FeatureDevController {
749749 }
750750
751751 private async stopResponse ( message : any ) {
752- this . messenger . sendAnswer ( {
753- message : i18n ( 'AWS.amazonq.featureDev.pillText.stoppingCodeGeneration' ) ,
754- type : 'answer-part' ,
755- tabID : message . tabID ,
756- } )
757- this . messenger . sendUpdatePlaceholder (
758- message . tabID ,
759- i18n ( 'AWS.amazonq.featureDev.pillText.stoppingCodeGeneration' )
760- )
761- this . messenger . sendChatInputEnabled ( message . tabID , false )
752+ await telemetry . amazonq_stopCodeGeneration . run ( async ( span ) => {
753+ span . record ( { tabID : message . tabID } )
754+ this . messenger . sendAnswer ( {
755+ message : i18n ( 'AWS.amazonq.featureDev.pillText.stoppingCodeGeneration' ) ,
756+ type : 'answer-part' ,
757+ tabID : message . tabID ,
758+ } )
759+ this . messenger . sendUpdatePlaceholder (
760+ message . tabID ,
761+ i18n ( 'AWS.amazonq.featureDev.pillText.stoppingCodeGeneration' )
762+ )
763+ this . messenger . sendChatInputEnabled ( message . tabID , false )
762764
763- const session = await this . sessionStorage . getSession ( message . tabID )
764- if ( session . state ?. tokenSource ) {
765- session . state ?. tokenSource ?. cancel ( )
766- }
765+ const session = await this . sessionStorage . getSession ( message . tabID )
766+ if ( session . state ?. tokenSource ) {
767+ session . state ?. tokenSource ?. cancel ( )
768+ }
769+ } )
767770 }
768771
769772 private async tabOpened ( message : any ) {
Original file line number Diff line number Diff line change @@ -404,4 +404,18 @@ describe('Controller', () => {
404404 } )
405405 } )
406406 } )
407+
408+ describe ( 'stopResponse' , ( ) => {
409+ it ( 'should emit amazonq_stopCodeGeneration telemetry' , async ( ) => {
410+ const getSessionStub = sinon . stub ( controllerSetup . sessionStorage , 'getSession' ) . resolves ( session )
411+ controllerSetup . emitters . stopResponse . fire ( { tabID, conversationID } )
412+ await waitUntil ( ( ) => {
413+ return Promise . resolve ( getSessionStub . callCount > 0 )
414+ } , { } )
415+ assertTelemetry ( 'amazonq_stopCodeGeneration' , {
416+ tabID : tabID ,
417+ result : 'Succeeded' ,
418+ } )
419+ } )
420+ } )
407421} )
You can’t perform that action at this time.
0 commit comments