Skip to content

Commit 58ad02a

Browse files
committed
feat: add button click event
1 parent 7bb66e1 commit 58ad02a

File tree

3 files changed

+45
-16
lines changed

3 files changed

+45
-16
lines changed

package-lock.json

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

packages/amazonq/src/lsp/chat/messages.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ import {
4242
LINK_CLICK_NOTIFICATION_METHOD,
4343
LinkClickParams,
4444
INFO_LINK_CLICK_NOTIFICATION_METHOD,
45+
buttonClickRequestType,
46+
ButtonClickResult,
4547
} from '@aws/language-server-runtimes/protocol'
4648
import { v4 as uuidv4 } from 'uuid'
4749
import * as vscode from 'vscode'
@@ -281,6 +283,17 @@ export function registerMessageListeners(
281283
languageClient.sendNotification(followUpClickNotificationType.method, message.params)
282284
}
283285
break
286+
case buttonClickRequestType.method:
287+
const buttonResult = await languageClient.sendRequest<ButtonClickResult>(
288+
buttonClickRequestType.method,
289+
message.params
290+
)
291+
if (!buttonResult.success) {
292+
languageClient.error(
293+
`[VSCode Client] Failed to execute action associated with button with reason: ${buttonResult.failureReason}`
294+
)
295+
}
296+
break
284297
default:
285298
if (isServerEvent(message.command)) {
286299
languageClient.sendNotification(message.command, message.params)
@@ -459,9 +472,22 @@ async function handleCompleteResult<T>(
459472
tabId: string,
460473
disposable: Disposable
461474
) {
462-
const decryptedMessage =
475+
const decryptedMessage = (
463476
typeof result === 'string' && encryptionKey ? await decodeRequest(result, encryptionKey) : result
477+
) as any
464478

479+
decryptedMessage.additionalMessages[0].buttons = [
480+
{
481+
id: 'reject-shell-command',
482+
text: 'Reject',
483+
icon: 'cancel',
484+
},
485+
{
486+
id: 'run-shell-command',
487+
text: 'Run',
488+
icon: 'play',
489+
},
490+
]
465491
void provider.webview?.postMessage({
466492
command: chatRequestType.method,
467493
params: decryptedMessage,

packages/core/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,8 +443,8 @@
443443
"@aws-sdk/types": "^3.13.1",
444444
"@aws/chat-client": "^0.1.4",
445445
"@aws/chat-client-ui-types": "^0.1.22",
446-
"@aws/language-server-runtimes": "^0.2.58",
447-
"@aws/language-server-runtimes-types": "^0.1.13",
446+
"@aws/language-server-runtimes": "^0.2.70",
447+
"@aws/language-server-runtimes-types": "^0.1.21",
448448
"@cspotcode/source-map-support": "^0.8.1",
449449
"@sinonjs/fake-timers": "^10.0.2",
450450
"@types/adm-zip": "^0.4.34",

0 commit comments

Comments
 (0)