Skip to content
9 changes: 9 additions & 0 deletions runtimes/protocol/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ import {
ContextCommandParams,
CREATE_PROMPT_NOTIFICATION_METHOD,
CreatePromptParams,
INLINE_CHAT_RESULT_NOTIFICATION_METHOD,
InlineChatResultParams,
ListConversationsParams,
ListConversationsResult,
LIST_CONVERSATIONS_REQUEST_METHOD,
Expand Down Expand Up @@ -130,6 +132,13 @@ export const contextCommandsNotificationType = new ProtocolNotificationType<Cont
export const createPromptNotificationType = new ProtocolNotificationType<CreatePromptParams, void>(
CREATE_PROMPT_NOTIFICATION_METHOD
)
/**
* The inline chat result notification is sent from client to server to notify the action taken by the user
* from the suggested response returned by the server.
*/
export const inlineChatResultNotificationType = new ProtocolNotificationType<InlineChatResultParams, void>(
INLINE_CHAT_RESULT_NOTIFICATION_METHOD
)

// history
export const listConversationsRequestType = new AutoParameterStructuresProtocolRequestType<
Expand Down
2 changes: 2 additions & 0 deletions runtimes/runtimes/base-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {
inlineChatRequestType,
contextCommandsNotificationType,
createPromptNotificationType,
inlineChatResultNotificationType,
listConversationsRequestType,
conversationClickRequestType,
GetSerializedChatParams,
Expand Down Expand Up @@ -167,6 +168,7 @@ export const baseRuntime = (connections: { reader: MessageReader; writer: Messag
onFileClicked: handler => lspConnection.onNotification(fileClickNotificationType.method, handler),
sendContextCommands: params => lspConnection.sendNotification(contextCommandsNotificationType.method, params),
onCreatePrompt: handler => lspConnection.onNotification(createPromptNotificationType.method, handler),
onInlineChatResult: handler => lspConnection.onNotification(inlineChatResultNotificationType.method, handler),
onListConversations: handler => lspConnection.onRequest(listConversationsRequestType.method, handler),
onConversationClick: handler => lspConnection.onRequest(conversationClickRequestType.method, handler),
getSerializedChat: params => lspConnection.sendRequest(getSerializedChatRequestType.method, params),
Expand Down
6 changes: 6 additions & 0 deletions runtimes/runtimes/chat/baseChat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ import {
contextCommandsNotificationType,
CreatePromptParams,
createPromptNotificationType,
InlineChatResultParams,
inlineChatResultNotificationType,
listConversationsRequestType,
ListConversationsParams,
ListConversationsResult,
Expand Down Expand Up @@ -145,6 +147,10 @@ export class BaseChat implements Chat {
this.connection.onNotification(createPromptNotificationType.method, handler)
}

public onInlineChatResult(handler: NotificationHandler<InlineChatResultParams>) {
this.connection.onNotification(inlineChatResultNotificationType.method, handler)
}

public onListConversations(handler: RequestHandler<ListConversationsParams, ListConversationsResult, void>) {
this.connection.onRequest(listConversationsRequestType.method, handler)
}
Expand Down
2 changes: 2 additions & 0 deletions runtimes/server-interface/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
InlineChatResult,
ContextCommandParams,
CreatePromptParams,
InlineChatResultParams,
ListConversationsParams,
ListConversationsResult,
ConversationClickParams,
Expand Down Expand Up @@ -67,4 +68,5 @@ export type Chat = {
chatOptionsUpdate: (params: ChatOptionsUpdateParams) => void
sendContextCommands: (params: ContextCommandParams) => void
onCreatePrompt: (handler: NotificationHandler<CreatePromptParams>) => void
onInlineChatResult: (handler: NotificationHandler<InlineChatResultParams>) => void
}
23 changes: 22 additions & 1 deletion types/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const CHAT_OPTIONS_UPDATE_NOTIFICATION_METHOD = 'aws/chat/chatOptionsUpda
// context
export const CONTEXT_COMMAND_NOTIFICATION_METHOD = 'aws/chat/sendContextCommands'
export const CREATE_PROMPT_NOTIFICATION_METHOD = 'aws/chat/createPrompt'
export const INLINE_CHAT_RESULT_NOTIFICATION_METHOD = 'aws/chat/inlineChatResult'
// history
export const LIST_CONVERSATIONS_REQUEST_METHOD = 'aws/chat/listConversations'
export const CONVERSATION_CLICK_REQUEST_METHOD = 'aws/chat/conversationClick'
Expand Down Expand Up @@ -327,8 +328,28 @@ export interface CreatePromptParams {
promptName: string
}

// history
export interface ProgrammingLanguage {
languageName: string
}

export type InlineChatUserDecision = 'ACCEPT' | 'REJECT' | 'DISMISS' | string

export interface InlineChatResultParams {
Copy link
Copy Markdown
Contributor

@viktorsaws viktorsaws Apr 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pras0131 please document every new Protocol addition and meaning of all fields in doc strings. It should be very clear what is expected from client to pass here, and we should follow LSP spec example. You can see example of documentation I did in latest PR https://github.com/aws/language-server-runtimes/pull/433/files

It's difficult to reason about all fields in Params without documentation, it is not clear why some fields are needed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can add a doc string to inlineChatResultNotificationType but adding a doc string to all field does not seem to be required here post the renaming of variables to fuller names as they are clearly indicate their purpose.

requestId: string
inputLength?: number
selectedLines?: number
suggestionAddedChars?: number
suggestionAddedLines?: number
suggestionDeletedChars?: number
suggestionDeletedLines?: number
codeIntent?: boolean
userDecision?: InlineChatUserDecision
responseStartLatency?: number
responseEndLatency?: number
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need 2 values for latency? Can client just return computed latency back?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These different values are required while emitting Telemetry for InlineChatEvent.
Structure of InlineChatEvent: link

Sample usage in Eclipse: link

programmingLanguage?: ProgrammingLanguage
}

// history
export type TextBasedFilterOption = {
type: 'textarea' | 'textinput'
placeholder?: string
Expand Down