@@ -63,6 +63,7 @@ import * as jose from 'jose'
6363import { AmazonQChatViewProvider } from './webviewProvider'
6464import { AuthUtil , ReferenceLogViewProvider } from 'aws-core-vscode/codewhisperer'
6565import { amazonQDiffScheme , AmazonQPromptSettings , messages , openUrl } from 'aws-core-vscode/shared'
66+ import { credentialsValidation } from 'aws-core-vscode/auth'
6667import {
6768 DefaultAmazonQAppInitContext ,
6869 messageDispatcher ,
@@ -72,6 +73,7 @@ import {
7273} from 'aws-core-vscode/amazonq'
7374import { telemetry , TelemetryBase } from 'aws-core-vscode/telemetry'
7475import { isValidResponseError } from './error'
76+ import { focusAmazonQPanel } from './commands'
7577
7678export function registerLanguageServerEventListener ( languageClient : LanguageClient , provider : AmazonQChatViewProvider ) {
7779 languageClient . info (
@@ -328,13 +330,33 @@ export function registerMessageListeners(
328330 }
329331 break
330332 case buttonClickRequestType . method : {
333+ if ( message . params . buttonId === 'paidtier-upgrade-q' ) {
334+ focusAmazonQPanel ( ) . catch ( ( e ) => languageClient . error ( `[VSCode Client] focusAmazonQPanel() failed` ) )
335+
336+ const accountId = await vscode . window . showInputBox ( {
337+ title : 'Upgrade Amazon Q' ,
338+ prompt : 'Enter your 12-digit AWS account ID' ,
339+ placeHolder : '111111111111' ,
340+ validateInput : credentialsValidation . validateAwsAccount ,
341+ } )
342+
343+ if ( accountId ) {
344+ languageClient . sendRequest ( 'workspace/executeCommand' , {
345+ command : 'aws/chat/manageSubscription' ,
346+ arguments : [ accountId ] ,
347+ } )
348+ } else {
349+ languageClient . error ( '[VSCode Client] user canceled or did not input AWS account id' )
350+ }
351+ }
352+
331353 const buttonResult = await languageClient . sendRequest < ButtonClickResult > (
332354 buttonClickRequestType . method ,
333355 message . params
334356 )
335357 if ( ! buttonResult . success ) {
336358 languageClient . error (
337- `[VSCode Client] Failed to execute action associated with button with reason : ${ buttonResult . failureReason } `
359+ `[VSCode Client] Failed to execute button action : ${ buttonResult . failureReason } `
338360 )
339361 }
340362 break
@@ -433,6 +455,8 @@ export function registerMessageListeners(
433455 languageClient . onRequest < ShowDocumentParams , ShowDocumentResult > (
434456 ShowDocumentRequest . method ,
435457 async ( params : ShowDocumentParams ) : Promise < ShowDocumentParams | ResponseError < ShowDocumentResult > > => {
458+ focusAmazonQPanel ( ) . catch ( ( e ) => languageClient . error ( `[VSCode Client] focusAmazonQPanel() failed` ) )
459+
436460 try {
437461 const uri = vscode . Uri . parse ( params . uri )
438462
0 commit comments