Skip to content

Commit 0976111

Browse files
committed
Adding cwsprChatCodeBlockIndex and cwsprChatTotalCodeBlocks to the Copy and Insert at Cursor events
1 parent ad9c553 commit 0976111

File tree

8 files changed

+79
-15
lines changed

8 files changed

+79
-15
lines changed

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/cwc/controller/chat/telemetry/TelemetryHelper.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,9 @@ class TelemetryHelper(private val context: AmazonQAppInitContext, private val se
190190
cwsprChatAcceptedCharactersLength = message.code.length,
191191
cwsprChatInteractionTarget = message.insertionTargetType,
192192
cwsprChatHasReference = null,
193-
credentialStartUrl = getStartUrl(context.project)
193+
credentialStartUrl = getStartUrl(context.project),
194+
cwsprChatCodeBlockIndex = message.codeBlockIndex,
195+
cwsprChatTotalCodeBlocks = message.totalCodeBlocks
194196
)
195197
ChatInteractWithMessageEvent.builder().apply {
196198
conversationId(getConversationId(message.tabId).orEmpty())
@@ -209,7 +211,9 @@ class TelemetryHelper(private val context: AmazonQAppInitContext, private val se
209211
cwsprChatAcceptedCharactersLength = message.code.length,
210212
cwsprChatInteractionTarget = message.insertionTargetType,
211213
cwsprChatHasReference = null,
212-
credentialStartUrl = getStartUrl(context.project)
214+
credentialStartUrl = getStartUrl(context.project),
215+
cwsprChatCodeBlockIndex = message.codeBlockIndex,
216+
cwsprChatTotalCodeBlocks = message.totalCodeBlocks
213217
)
214218
ChatInteractWithMessageEvent.builder().apply {
215219
conversationId(getConversationId(message.tabId).orEmpty())

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/cwc/messages/CwcMessage.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ sealed interface IncomingCwcMessage : CwcMessage {
6767
val messageId: String,
6868
val code: String,
6969
val insertionTargetType: String?,
70+
val eventId: String?,
71+
val codeBlockIndex: Int?,
72+
val totalCodeBlocks: Int?
7073
) : IncomingCwcMessage
7174

7275
data class InsertCodeAtCursorPosition(
@@ -75,6 +78,9 @@ sealed interface IncomingCwcMessage : CwcMessage {
7578
val code: String,
7679
val insertionTargetType: String?,
7780
val codeReference: List<CodeReference>?,
81+
val eventId: String?,
82+
val codeBlockIndex: Int?,
83+
val totalCodeBlocks: Int?
7884
) : IncomingCwcMessage
7985

8086
data class TriggerTabIdReceived(

plugins/amazonq/mynah-ui/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/amazonq/mynah-ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"lintfix": "eslint -c .eslintrc.js --fix --ext .ts ."
1313
},
1414
"dependencies": {
15-
"@aws/mynah-ui-chat": "npm:@aws/mynah-ui@4.4.2",
15+
"@aws/mynah-ui-chat": "npm:@aws/mynah-ui@4.5.6",
1616
"@types/node": "^14.18.5",
1717
"fs-extra": "^10.0.1",
1818
"ts-node": "^10.7.0",

plugins/amazonq/mynah-ui/src/mynah-ui/ui/apps/cwChatConnector.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@ export class Connector {
9292
messageId: string,
9393
code?: string,
9494
type?: 'selection' | 'block',
95-
codeReference?: CodeReference[]
95+
codeReference?: CodeReference[],
96+
eventId?: string,
97+
codeBlockIndex?: number,
98+
totalCodeBlocks?: number
9699
): void => {
97100
this.sendMessageToExtension({
98101
tabID: tabID,
@@ -102,6 +105,9 @@ export class Connector {
102105
tabType: 'cwc',
103106
insertionTargetType: type,
104107
codeReference,
108+
eventId,
109+
codeBlockIndex,
110+
totalCodeBlocks,
105111
})
106112
}
107113

@@ -110,7 +116,10 @@ export class Connector {
110116
messageId: string,
111117
code?: string,
112118
type?: 'selection' | 'block',
113-
codeReference?: CodeReference[]
119+
codeReference?: CodeReference[],
120+
eventId?: string,
121+
codeBlockIndex?: number,
122+
totalCodeBlocks?: number
114123
): void => {
115124
this.sendMessageToExtension({
116125
tabID: tabID,
@@ -120,6 +129,9 @@ export class Connector {
120129
tabType: 'cwc',
121130
insertionTargetType: type,
122131
codeReference,
132+
eventId,
133+
codeBlockIndex,
134+
totalCodeBlocks,
123135
})
124136
}
125137

plugins/amazonq/mynah-ui/src/mynah-ui/ui/connector.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,14 @@ export class Connector {
212212
messageId: string,
213213
code?: string,
214214
type?: 'selection' | 'block',
215-
codeReference?: CodeReference[]
215+
codeReference?: CodeReference[],
216+
eventId?: string,
217+
codeBlockIndex?: number,
218+
totalCodeBlocks?: number
216219
): void => {
217220
switch (this.tabsStorage.getTab(tabID)?.type) {
218221
case 'cwc':
219-
this.cwChatConnector.onCodeInsertToCursorPosition(tabID, messageId, code, type, codeReference)
222+
this.cwChatConnector.onCodeInsertToCursorPosition(tabID, messageId, code, type, codeReference, eventId, codeBlockIndex, totalCodeBlocks)
220223
break
221224
case 'featuredev':
222225
this.featureDevChatConnector.onCodeInsertToCursorPosition(tabID, code, type, codeReference)
@@ -229,11 +232,14 @@ export class Connector {
229232
messageId: string,
230233
code?: string,
231234
type?: 'selection' | 'block',
232-
codeReference?: CodeReference[]
235+
codeReference?: CodeReference[],
236+
eventId?: string,
237+
codeBlockIndex?: number,
238+
totalCodeBlocks?: number
233239
): void => {
234240
switch (this.tabsStorage.getTab(tabID)?.type) {
235241
case 'cwc':
236-
this.cwChatConnector.onCopyCodeToClipboard(tabID, messageId, code, type, codeReference)
242+
this.cwChatConnector.onCopyCodeToClipboard(tabID, messageId, code, type, codeReference, eventId, codeBlockIndex, totalCodeBlocks)
237243
break
238244
case 'featuredev':
239245
this.featureDevChatConnector.onCopyCodeToClipboard(tabID, code, type, codeReference)

plugins/amazonq/mynah-ui/src/mynah-ui/ui/main.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,26 @@ export const createMynahUI = (ideApi: any, featureDevInitEnabled: boolean, codeT
393393
})
394394
},
395395
onCodeInsertToCursorPosition: connector.onCodeInsertToCursorPosition,
396-
onCopyCodeToClipboard: (tabId, messageId, code, type, referenceTrackerInfo) => {
397-
connector.onCopyCodeToClipboard(tabId, messageId, code, type, referenceTrackerInfo)
396+
onCopyCodeToClipboard: (
397+
tabId,
398+
messageId,
399+
code,
400+
type,
401+
referenceTrackerInfo,
402+
eventId,
403+
codeBlockIndex,
404+
totalCodeBlocks
405+
) => {
406+
connector.onCopyCodeToClipboard(
407+
tabId,
408+
messageId,
409+
code,
410+
type,
411+
referenceTrackerInfo,
412+
eventId,
413+
codeBlockIndex,
414+
totalCodeBlocks
415+
)
398416
mynahUI.notify({
399417
type: NotificationType.SUCCESS,
400418
content: 'Selected code is copied to clipboard',

plugins/core/jetbrains-community/resources/telemetryOverride.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,16 @@
165165
"type": "string",
166166
"description": "Identifies the entity within the message that user interacts with."
167167
},
168+
{
169+
"name": "cwsprChatCodeBlockIndex",
170+
"type": "int",
171+
"description": "Index of the code block inside a message in the conversation."
172+
},
173+
{
174+
"name": "cwsprChatTotalCodeBlocks",
175+
"type": "int",
176+
"description": "Total number of code blocks inside a message in the conversation."
177+
},
168178
{
169179
"name": "cwsprChatAcceptedCharactersLength",
170180
"type": "int",
@@ -464,6 +474,14 @@
464474
"type": "cwsprChatInteractionTarget",
465475
"required": false
466476
},
477+
{
478+
"type": "cwsprChatCodeBlockIndex",
479+
"required": false
480+
},
481+
{
482+
"type": "cwsprChatTotalCodeBlocks",
483+
"required": false
484+
},
467485
{
468486
"type": "cwsprChatAcceptedCharactersLength",
469487
"required": false

0 commit comments

Comments
 (0)