diff --git a/chat-client/src/client/chat.ts b/chat-client/src/client/chat.ts index 33ead9a07f..2396e3ac09 100644 --- a/chat-client/src/client/chat.ts +++ b/chat-client/src/client/chat.ts @@ -32,6 +32,7 @@ import { STOP_CHAT_RESPONSE, } from '@aws/chat-client-ui-types' import { + BUTTON_CLICK_REQUEST_METHOD, CHAT_REQUEST_METHOD, CONTEXT_COMMAND_NOTIFICATION_METHOD, CONVERSATION_CLICK_REQUEST_METHOD, @@ -318,6 +319,9 @@ export const createChat = ( stopChatResponse: (tabId: string) => { sendMessageToClient({ command: STOP_CHAT_RESPONSE, params: { tabId } }) }, + sendButtonClickEvent: params => { + sendMessageToClient({ command: BUTTON_CLICK_REQUEST_METHOD, params: params }) + }, } const messager = new Messager(chatApi) diff --git a/chat-client/src/client/messager.ts b/chat-client/src/client/messager.ts index 0ebeb3dd76..b38a107be7 100644 --- a/chat-client/src/client/messager.ts +++ b/chat-client/src/client/messager.ts @@ -21,6 +21,7 @@ import { TriggerType, } from '@aws/chat-client-ui-types' import { + ButtonClickParams, ChatParams, ConversationAction, ConversationClickParams, @@ -91,6 +92,7 @@ export interface OutboundChatApi { onGetSerializedChat(requestId: string, result: GetSerializedChatResult | ErrorResult): void promptInputOptionChange(params: PromptInputOptionChangeParams): void stopChatResponse(tabId: string): void + sendButtonClickEvent(params: ButtonClickParams): void } export class Messager { @@ -225,4 +227,8 @@ export class Messager { onStopChatResponse = (tabId: string): void => { this.chatApi.stopChatResponse(tabId) } + + onButtonClick = (params: ButtonClickParams): void => { + this.chatApi.sendButtonClickEvent(params) + } } diff --git a/chat-client/src/client/mynahUi.test.ts b/chat-client/src/client/mynahUi.test.ts index e53b962c21..b6b3458e51 100644 --- a/chat-client/src/client/mynahUi.test.ts +++ b/chat-client/src/client/mynahUi.test.ts @@ -56,6 +56,7 @@ describe('MynahUI', () => { onGetSerializedChat: sinon.stub(), promptInputOptionChange: sinon.stub(), stopChatResponse: sinon.stub(), + sendButtonClickEvent: sinon.stub(), } messager = new Messager(outboundChatApi) diff --git a/chat-client/src/client/mynahUi.ts b/chat-client/src/client/mynahUi.ts index 13b179717d..6353cb4850 100644 --- a/chat-client/src/client/mynahUi.ts +++ b/chat-client/src/client/mynahUi.ts @@ -13,6 +13,7 @@ import { isValidAuthFollowUpType, } from '@aws/chat-client-ui-types' import { + ButtonClickParams, ChatMessage, ChatResult, ContextCommand, @@ -311,6 +312,13 @@ export const createMynahUi = ( Object.keys(mynahUi.getAllTabs()).forEach(storeTabKey => { mynahUi.updateStore(storeTabKey, { promptInputStickyCard: null }) }) + } else { + const payload: ButtonClickParams = { + tabId, + messageId, + buttonId: action.id, + } + messager.onButtonClick(payload) } }, onContextSelected: (contextItem, tabId) => { diff --git a/chat-client/src/contracts/serverContracts.ts b/chat-client/src/contracts/serverContracts.ts index 4ef588b0ad..c44669ed09 100644 --- a/chat-client/src/contracts/serverContracts.ts +++ b/chat-client/src/contracts/serverContracts.ts @@ -34,6 +34,7 @@ import { TabBarActionParams, GetSerializedChatResult, PROMPT_INPUT_OPTION_CHANGE_METHOD, + BUTTON_CLICK_REQUEST_METHOD, } from '@aws/language-server-runtimes-types' export const TELEMETRY = 'telemetry/event' @@ -59,6 +60,7 @@ export type ServerMessageCommand = | typeof TAB_BAR_ACTION_REQUEST_METHOD | typeof GET_SERIALIZED_CHAT_REQUEST_METHOD | typeof PROMPT_INPUT_OPTION_CHANGE_METHOD + | typeof BUTTON_CLICK_REQUEST_METHOD export interface ServerMessage { command: ServerMessageCommand diff --git a/package-lock.json b/package-lock.json index bf13f9b560..e0450a6416 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3419,6 +3419,7 @@ "resolved": "file:chat-client/lib/aws-mynah-ui-4.31.0-beta.6.tgz", "integrity": "sha512-IctsIHfkM7rmBZQQ8xKf2+fU0SQHo1yFMe59os4Ej9R7MWleLVsQq3DwvebZp0AmxGMVyKwIXkV36CDiQiAwPA==", "hasInstallScript": true, + "license": "Apache License 2.0", "dependencies": { "escape-html": "^1.0.3", "highlight.js": "^11.11.0", diff --git a/server/aws-lsp-codewhisperer/src/language-server/agenticChat/agenticChatController.ts b/server/aws-lsp-codewhisperer/src/language-server/agenticChat/agenticChatController.ts index 438b29bb07..4061341c4d 100644 --- a/server/aws-lsp-codewhisperer/src/language-server/agenticChat/agenticChatController.ts +++ b/server/aws-lsp-codewhisperer/src/language-server/agenticChat/agenticChatController.ts @@ -147,6 +147,7 @@ export class AgenticChatController implements ChatHandlers { } async onButtonClick(params: ButtonClickParams): Promise { + this.#log(`onButtonClick event with params: ${JSON.stringify(params)}`) return { success: false, failureReason: 'not implemented', diff --git a/server/aws-lsp-codewhisperer/src/language-server/agenticChat/qAgenticChatServer.ts b/server/aws-lsp-codewhisperer/src/language-server/agenticChat/qAgenticChatServer.ts index 153388888c..dcc881fd73 100644 --- a/server/aws-lsp-codewhisperer/src/language-server/agenticChat/qAgenticChatServer.ts +++ b/server/aws-lsp-codewhisperer/src/language-server/agenticChat/qAgenticChatServer.ts @@ -140,7 +140,7 @@ export const QAgenticChatServer = chat.onConversationClick(params => { return chatController.onConversationClick(params) }) - + chat.onCreatePrompt((params) => { return chatController.onCreatePrompt(params) }) @@ -157,6 +157,10 @@ export const QAgenticChatServer = return chatController.onPromptInputOptionChange(params) }) + chat.onButtonClick(params => { + return chatController.onButtonClick(params) + }) + logging.log('Q Chat server has been initialized') return () => {