Skip to content

feat(amazonq): Customer pricing details for Amazon Q #7732

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 13 additions & 3 deletions packages/amazonq/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -388,20 +388,25 @@
"when": "view == aws.amazonq.AmazonQChatView",
"group": "0_topAmazonQ@1"
},
{
"command": "aws.amazonq.accountDetails",
"when": "(view == aws.amazonq.AmazonQChatView) && aws.codewhisperer.connected",
"group": "1_amazonQ@1"
},
{
"command": "aws.amazonq.selectRegionProfile",
"when": "view == aws.amazonq.AmazonQChatView && aws.amazonq.connectedSsoIdc == true",
"group": "1_amazonQ@1"
"group": "1_amazonQ@2"
},
{
"command": "aws.amazonq.manageSubscription",
"when": "(view == aws.amazonq.AmazonQChatView) && aws.codewhisperer.connected",
"group": "1_amazonQ@2"
"group": "1_amazonQ@3"
},
{
"command": "aws.amazonq.learnMore",
"when": "view =~ /^aws\\.amazonq/",
"group": "1_amazonQ@3"
"group": "1_amazonQ@4"
},
{
"command": "aws.amazonq.signout",
Expand Down Expand Up @@ -729,6 +734,11 @@
"title": "%AWS.amazonq.learnMore%",
"category": "%AWS.amazonq.title%"
},
{
"command": "aws.amazonq.accountDetails",
"title": "%AWS.amazonq.accountDetails%",
"category": "%AWS.amazonq.title%"
},
{
"command": "amazonq.dev.openMenu",
"title": "Open Developer Menu",
Expand Down
17 changes: 17 additions & 0 deletions packages/amazonq/src/lsp/chat/activation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { activate as registerLegacyChatListeners } from '../../app/chat/activati
import { DefaultAmazonQAppInitContext } from 'aws-core-vscode/amazonq'
import { AuthUtil, getSelectedCustomization } from 'aws-core-vscode/codewhisperer'
import { pushConfigUpdate } from '../config'
import { SUBSCRIPTION_SHOW_COMMAND_METHOD } from '@aws/language-server-runtimes/server-interface'

export async function activate(languageClient: LanguageClient, encryptionKey: Buffer, mynahUIPath: string) {
const disposables = globals.context.subscriptions
Expand Down Expand Up @@ -90,6 +91,22 @@ export async function activate(languageClient: LanguageClient, encryptionKey: Bu
getLogger('amazonqLsp').error('failed request: aws/chat/manageSubscription: %O', e)
})
}),
/*
Forward the subscription details request to language server directly
This triggers the onShowSubscription() method in the language server
*/
Commands.register('aws.amazonq.accountDetails', () => {
getLogger('amazonqLsp').info(
`[VSCode Client]: Sending subscription details [${SUBSCRIPTION_SHOW_COMMAND_METHOD}] event notification`
)
languageClient
.sendRequest('workspace/executeCommand', {
command: SUBSCRIPTION_SHOW_COMMAND_METHOD,
})
.catch((e) => {
getLogger('amazonqLsp').error('Failed to send subscription details request: : %O', e)
})
}),
globals.logOutputChannel.onDidChangeLogLevel((logLevel) => {
getLogger('amazonqLsp').info(`Local log level changed to ${logLevel}, notifying LSP`)
void pushConfigUpdate(languageClient, {
Expand Down
56 changes: 55 additions & 1 deletion packages/amazonq/src/lsp/chat/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ import {
ShowOpenDialogParams,
openFileDialogRequestType,
OpenFileDialogResult,
subscriptionDetailsNotificationType,
subscriptionUpgradeNotificationType,
} from '@aws/language-server-runtimes/protocol'
import { v4 as uuidv4 } from 'uuid'
import * as vscode from 'vscode'
Expand Down Expand Up @@ -102,7 +104,7 @@ import { isValidResponseError } from './error'
import { decryptResponse, encryptRequest } from '../encryption'
import { getCursorState } from '../utils'
import { focusAmazonQPanel } from './commands'
import { ChatMessage } from '@aws/language-server-runtimes/server-interface'
import { ChatMessage, SUBSCRIPTION_UPGRADE_NOTIFICATION_METHOD } from '@aws/language-server-runtimes/server-interface'
import { CommentUtils } from 'aws-core-vscode/utils'

export function registerActiveEditorChangeListener(languageClient: LanguageClient) {
Expand Down Expand Up @@ -256,6 +258,18 @@ export function registerMessageListeners(
}
break
}
case SUBSCRIPTION_UPGRADE_NOTIFICATION_METHOD: {
languageClient.info('[VSCode Client] Subscription upgrade clicked')
try {
// Forward the upgrade request to Flare
languageClient.sendNotification(subscriptionUpgradeNotificationType.method, message.params)
} catch (e) {
languageClient.error(
`[VSCode Client] Failed to send subscription upgrade notification: ${(e as Error).message}`
)
}
break
}
case DISCLAIMER_ACKNOWLEDGED: {
void AmazonQPromptSettings.instance.update('amazonQChatDisclaimer', true)
break
Expand Down Expand Up @@ -704,6 +718,46 @@ export function registerMessageListeners(
params: params,
})
})

// Handle subscription details response from Flare
languageClient.onNotification(subscriptionDetailsNotificationType.method, (params) => {
languageClient.info(`[VSCode Client] Received subscription details: ${JSON.stringify(params)}`)
// Forward the subscription details to the Chat UI
void provider.webview?.postMessage({
command: subscriptionDetailsNotificationType.method,
params: params,
})
})
// TODO: After implementing the "Upgrade" feature, test its functionality in the Account Details tab.
// Handle window/showDocument requests from Flare for subscription upgrade
languageClient.onRequest<ShowDocumentParams, ShowDocumentResult>(
ShowDocumentRequest.method,
async (params: ShowDocumentParams): Promise<ShowDocumentParams | ResponseError<ShowDocumentResult>> => {
try {
const uri = vscode.Uri.parse(params.uri)

if (params.external) {
languageClient.info(`[VSCode Client] Opening external URL for subscription upgrade: ${params.uri}`)
// Open the URL in the external browser
await vscode.env.openExternal(uri)

// Return success to indicate the URL was opened
return params
}

// If not external, handle as a regular document
const doc = await vscode.workspace.openTextDocument(uri)
await vscode.window.showTextDocument(doc, { preview: false })
return params
} catch (e) {
languageClient.error(`[VSCode Client] Failed to open subscription upgrade URL: ${(e as Error).message}`)
return new ResponseError(
LSPErrorCodes.RequestFailed,
`Failed to open subscription upgrade URL: ${(e as Error).message}`
)
}
}
)
}

function isServerEvent(command: string) {
Expand Down
1 change: 1 addition & 0 deletions packages/amazonq/src/lsp/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ export async function startLanguageServer(
reroute: true,
modelSelection: true,
workspaceFilePath: vscode.workspace.workspaceFile?.fsPath,
subscriptionDetails: false,
codeReviewInChat: false,
},
window: {
Expand Down
6 changes: 3 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -470,9 +470,9 @@
"devDependencies": {
"@aws-sdk/types": "^3.13.1",
"@aws/chat-client": "^0.1.4",
"@aws/chat-client-ui-types": "^0.1.47",
"@aws/language-server-runtimes": "^0.2.111",
"@aws/language-server-runtimes-types": "^0.1.47",
"@aws/chat-client-ui-types": "^0.1.55",
"@aws/language-server-runtimes": "^0.2.112",
"@aws/language-server-runtimes-types": "^0.1.49",
"@cspotcode/source-map-support": "^0.8.1",
"@sinonjs/fake-timers": "^10.0.2",
"@types/adm-zip": "^0.4.34",
Expand Down
1 change: 1 addition & 0 deletions packages/core/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@
"AWS.amazonq.security": "Code Issues",
"AWS.amazonq.login": "Login",
"AWS.amazonq.learnMore": "Learn More About Amazon Q",
"AWS.amazonq.accountDetails": "Account details",
"AWS.amazonq.welcomeWalkthrough": "Welcome Walkthrough",
"AWS.amazonq.codewhisperer.title": "Amazon Q",
"AWS.amazonq.toggleCodeSuggestion": "Toggle Auto-Suggestions",
Expand Down
Loading