Skip to content

Commit 26c7a0f

Browse files
pras0131Paras
andauthored
feat: add LSP extension for sending telemetry for inline chat result action (#408)
* feat: add LSP extension for sending telemetry for inline chat result action * fix: correct formatting * feat: update the naming from logInlineChatResult to inlineChatResult * fix: full variable names, removed timestamp and added doc string for notification type * fix: refactored tha InlineChatResultParams field names --------- Co-authored-by: Paras <pmiparas@amazon.com>
1 parent d631ed2 commit 26c7a0f

File tree

5 files changed

+41
-1
lines changed

5 files changed

+41
-1
lines changed

runtimes/protocol/chat.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ import {
4646
ContextCommandParams,
4747
CREATE_PROMPT_NOTIFICATION_METHOD,
4848
CreatePromptParams,
49+
INLINE_CHAT_RESULT_NOTIFICATION_METHOD,
50+
InlineChatResultParams,
4951
ListConversationsParams,
5052
ListConversationsResult,
5153
LIST_CONVERSATIONS_REQUEST_METHOD,
@@ -130,6 +132,13 @@ export const contextCommandsNotificationType = new ProtocolNotificationType<Cont
130132
export const createPromptNotificationType = new ProtocolNotificationType<CreatePromptParams, void>(
131133
CREATE_PROMPT_NOTIFICATION_METHOD
132134
)
135+
/**
136+
* The inline chat result notification is sent from client to server to notify the action taken by the user
137+
* from the suggested response returned by the server.
138+
*/
139+
export const inlineChatResultNotificationType = new ProtocolNotificationType<InlineChatResultParams, void>(
140+
INLINE_CHAT_RESULT_NOTIFICATION_METHOD
141+
)
133142

134143
// history
135144
export const listConversationsRequestType = new AutoParameterStructuresProtocolRequestType<

runtimes/runtimes/base-runtime.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import {
4141
inlineChatRequestType,
4242
contextCommandsNotificationType,
4343
createPromptNotificationType,
44+
inlineChatResultNotificationType,
4445
listConversationsRequestType,
4546
conversationClickRequestType,
4647
GetSerializedChatParams,
@@ -167,6 +168,7 @@ export const baseRuntime = (connections: { reader: MessageReader; writer: Messag
167168
onFileClicked: handler => lspConnection.onNotification(fileClickNotificationType.method, handler),
168169
sendContextCommands: params => lspConnection.sendNotification(contextCommandsNotificationType.method, params),
169170
onCreatePrompt: handler => lspConnection.onNotification(createPromptNotificationType.method, handler),
171+
onInlineChatResult: handler => lspConnection.onNotification(inlineChatResultNotificationType.method, handler),
170172
onListConversations: handler => lspConnection.onRequest(listConversationsRequestType.method, handler),
171173
onConversationClick: handler => lspConnection.onRequest(conversationClickRequestType.method, handler),
172174
getSerializedChat: params => lspConnection.sendRequest(getSerializedChatRequestType.method, params),

runtimes/runtimes/chat/baseChat.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ import {
4343
contextCommandsNotificationType,
4444
CreatePromptParams,
4545
createPromptNotificationType,
46+
InlineChatResultParams,
47+
inlineChatResultNotificationType,
4648
listConversationsRequestType,
4749
ListConversationsParams,
4850
ListConversationsResult,
@@ -145,6 +147,10 @@ export class BaseChat implements Chat {
145147
this.connection.onNotification(createPromptNotificationType.method, handler)
146148
}
147149

150+
public onInlineChatResult(handler: NotificationHandler<InlineChatResultParams>) {
151+
this.connection.onNotification(inlineChatResultNotificationType.method, handler)
152+
}
153+
148154
public onListConversations(handler: RequestHandler<ListConversationsParams, ListConversationsResult, void>) {
149155
this.connection.onRequest(listConversationsRequestType.method, handler)
150156
}

runtimes/server-interface/chat.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
InlineChatResult,
2525
ContextCommandParams,
2626
CreatePromptParams,
27+
InlineChatResultParams,
2728
ListConversationsParams,
2829
ListConversationsResult,
2930
ConversationClickParams,
@@ -67,4 +68,5 @@ export type Chat = {
6768
chatOptionsUpdate: (params: ChatOptionsUpdateParams) => void
6869
sendContextCommands: (params: ContextCommandParams) => void
6970
onCreatePrompt: (handler: NotificationHandler<CreatePromptParams>) => void
71+
onInlineChatResult: (handler: NotificationHandler<InlineChatResultParams>) => void
7072
}

types/chat.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export const CHAT_OPTIONS_UPDATE_NOTIFICATION_METHOD = 'aws/chat/chatOptionsUpda
2222
// context
2323
export const CONTEXT_COMMAND_NOTIFICATION_METHOD = 'aws/chat/sendContextCommands'
2424
export const CREATE_PROMPT_NOTIFICATION_METHOD = 'aws/chat/createPrompt'
25+
export const INLINE_CHAT_RESULT_NOTIFICATION_METHOD = 'aws/chat/inlineChatResult'
2526
// history
2627
export const LIST_CONVERSATIONS_REQUEST_METHOD = 'aws/chat/listConversations'
2728
export const CONVERSATION_CLICK_REQUEST_METHOD = 'aws/chat/conversationClick'
@@ -327,8 +328,28 @@ export interface CreatePromptParams {
327328
promptName: string
328329
}
329330

330-
// history
331+
export interface ProgrammingLanguage {
332+
languageName: string
333+
}
334+
335+
export type InlineChatUserDecision = 'ACCEPT' | 'REJECT' | 'DISMISS' | string
331336

337+
export interface InlineChatResultParams {
338+
requestId: string
339+
inputLength?: number
340+
selectedLines?: number
341+
suggestionAddedChars?: number
342+
suggestionAddedLines?: number
343+
suggestionDeletedChars?: number
344+
suggestionDeletedLines?: number
345+
codeIntent?: boolean
346+
userDecision?: InlineChatUserDecision
347+
responseStartLatency?: number
348+
responseEndLatency?: number
349+
programmingLanguage?: ProgrammingLanguage
350+
}
351+
352+
// history
332353
export type TextBasedFilterOption = {
333354
type: 'textarea' | 'textinput'
334355
placeholder?: string

0 commit comments

Comments
 (0)