@@ -61,6 +61,7 @@ import * as jose from 'jose'
6161import { AmazonQChatViewProvider } from './webviewProvider'
6262import { AuthUtil , ReferenceLogViewProvider } from 'aws-core-vscode/codewhisperer'
6363import { amazonQDiffScheme , AmazonQPromptSettings , messages , openUrl } from 'aws-core-vscode/shared'
64+ import { credentialsValidation } from 'aws-core-vscode/auth'
6465import {
6566 DefaultAmazonQAppInitContext ,
6667 messageDispatcher ,
@@ -70,6 +71,7 @@ import {
7071} from 'aws-core-vscode/amazonq'
7172import { telemetry , TelemetryBase } from 'aws-core-vscode/telemetry'
7273import { isValidResponseError } from './error'
74+ import { focusAmazonQPanel } from './commands'
7375
7476export function registerLanguageServerEventListener ( languageClient : LanguageClient , provider : AmazonQChatViewProvider ) {
7577 languageClient . info (
@@ -326,13 +328,33 @@ export function registerMessageListeners(
326328 }
327329 break
328330 case buttonClickRequestType . method : {
331+ if ( message . params . buttonId === 'paidtier-upgrade-q' ) {
332+ focusAmazonQPanel ( ) . catch ( ( e ) => languageClient . error ( `[VSCode Client] focusAmazonQPanel() failed` ) )
333+
334+ const accountId = await vscode . window . showInputBox ( {
335+ title : 'Upgrade Amazon Q' ,
336+ prompt : 'Enter your 12-digit AWS account ID' ,
337+ placeHolder : '111111111111' ,
338+ validateInput : credentialsValidation . validateAwsAccount ,
339+ } )
340+
341+ if ( accountId ) {
342+ languageClient . sendRequest ( 'workspace/executeCommand' , {
343+ command : 'aws/chat/manageSubscription' ,
344+ arguments : [ accountId ] ,
345+ } )
346+ } else {
347+ languageClient . error ( '[VSCode Client] user canceled or did not input AWS account id' )
348+ }
349+ }
350+
329351 const buttonResult = await languageClient . sendRequest < ButtonClickResult > (
330352 buttonClickRequestType . method ,
331353 message . params
332354 )
333355 if ( ! buttonResult . success ) {
334356 languageClient . error (
335- `[VSCode Client] Failed to execute action associated with button with reason : ${ buttonResult . failureReason } `
357+ `[VSCode Client] Failed to execute button action : ${ buttonResult . failureReason } `
336358 )
337359 }
338360 break
@@ -431,6 +453,8 @@ export function registerMessageListeners(
431453 languageClient . onRequest < ShowDocumentParams , ShowDocumentResult > (
432454 ShowDocumentRequest . method ,
433455 async ( params : ShowDocumentParams ) : Promise < ShowDocumentParams | ResponseError < ShowDocumentResult > > => {
456+ focusAmazonQPanel ( ) . catch ( ( e ) => languageClient . error ( `[VSCode Client] focusAmazonQPanel() failed` ) )
457+
434458 try {
435459 const uri = vscode . Uri . parse ( params . uri )
436460
0 commit comments