Skip to content

Commit e73a386

Browse files
committed
feat: customer pricing details for amazon q
1 parent 6c7f040 commit e73a386

File tree

7 files changed

+104
-21
lines changed

7 files changed

+104
-21
lines changed

package-lock.json

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

packages/amazonq/package.json

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -388,20 +388,25 @@
388388
"when": "view == aws.amazonq.AmazonQChatView",
389389
"group": "0_topAmazonQ@1"
390390
},
391+
{
392+
"command": "aws.amazonq.accountDetails",
393+
"when": "(view == aws.amazonq.AmazonQChatView) && aws.codewhisperer.connected && !aws.isSageMakerUnifiedStudio && aws.amazonq.connectedSsoIdc == true",
394+
"group": "1_amazonQ@1"
395+
},
391396
{
392397
"command": "aws.amazonq.selectRegionProfile",
393398
"when": "view == aws.amazonq.AmazonQChatView && aws.amazonq.connectedSsoIdc == true",
394-
"group": "1_amazonQ@1"
399+
"group": "1_amazonQ@2"
395400
},
396401
{
397402
"command": "aws.amazonq.manageSubscription",
398403
"when": "(view == aws.amazonq.AmazonQChatView) && aws.codewhisperer.connected",
399-
"group": "1_amazonQ@2"
404+
"group": "1_amazonQ@3"
400405
},
401406
{
402407
"command": "aws.amazonq.learnMore",
403408
"when": "view =~ /^aws\\.amazonq/",
404-
"group": "1_amazonQ@3"
409+
"group": "1_amazonQ@4"
405410
},
406411
{
407412
"command": "aws.amazonq.signout",
@@ -709,6 +714,11 @@
709714
"title": "%AWS.amazonq.learnMore%",
710715
"category": "%AWS.amazonq.title%"
711716
},
717+
{
718+
"command": "aws.amazonq.accountDetails",
719+
"title": "%AWS.amazonq.accountDetails%",
720+
"category": "%AWS.amazonq.title%"
721+
},
712722
{
713723
"command": "amazonq.dev.openMenu",
714724
"title": "Open Developer Menu",

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { activate as registerLegacyChatListeners } from '../../app/chat/activati
1717
import { DefaultAmazonQAppInitContext } from 'aws-core-vscode/amazonq'
1818
import { AuthUtil, getSelectedCustomization } from 'aws-core-vscode/codewhisperer'
1919
import { pushConfigUpdate } from '../config'
20+
import { SUBSCRIPTION_SHOW_COMMAND_METHOD } from '@aws/language-server-runtimes/server-interface'
2021

2122
export async function activate(languageClient: LanguageClient, encryptionKey: Buffer, mynahUIPath: string) {
2223
const disposables = globals.context.subscriptions
@@ -90,6 +91,22 @@ export async function activate(languageClient: LanguageClient, encryptionKey: Bu
9091
getLogger('amazonqLsp').error('failed request: aws/chat/manageSubscription: %O', e)
9192
})
9293
}),
94+
/*
95+
Forward the subscription details request to language server directly
96+
This triggers the onShowSubscription() method in the language server
97+
*/
98+
Commands.register('aws.amazonq.accountDetails', () => {
99+
getLogger('amazonqLsp').info(
100+
`[VSCode Client]: Sending subscription details [${SUBSCRIPTION_SHOW_COMMAND_METHOD}] event notification`
101+
)
102+
languageClient
103+
.sendRequest('workspace/executeCommand', {
104+
command: SUBSCRIPTION_SHOW_COMMAND_METHOD,
105+
})
106+
.catch((e) => {
107+
getLogger('amazonqLsp').error('Failed to send subscription details request: : %O', e)
108+
})
109+
}),
93110
globals.logOutputChannel.onDidChangeLogLevel((logLevel) => {
94111
getLogger('amazonqLsp').info(`Local log level changed to ${logLevel}, notifying LSP`)
95112
void pushConfigUpdate(languageClient, {

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

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ import {
6666
ShowOpenDialogParams,
6767
openFileDialogRequestType,
6868
OpenFileDialogResult,
69+
subscriptionDetailsNotificationType,
70+
subscriptionUpgradeNotificationType,
6971
} from '@aws/language-server-runtimes/protocol'
7072
import { v4 as uuidv4 } from 'uuid'
7173
import * as vscode from 'vscode'
@@ -94,7 +96,7 @@ import { isValidResponseError } from './error'
9496
import { decryptResponse, encryptRequest } from '../encryption'
9597
import { getCursorState } from '../utils'
9698
import { focusAmazonQPanel } from './commands'
97-
import { ChatMessage } from '@aws/language-server-runtimes/server-interface'
99+
import { ChatMessage, SUBSCRIPTION_UPGRADE_NOTIFICATION_METHOD } from '@aws/language-server-runtimes/server-interface'
98100

99101
export function registerActiveEditorChangeListener(languageClient: LanguageClient) {
100102
let debounceTimer: NodeJS.Timeout | undefined
@@ -244,6 +246,18 @@ export function registerMessageListeners(
244246
}
245247
break
246248
}
249+
case SUBSCRIPTION_UPGRADE_NOTIFICATION_METHOD: {
250+
languageClient.info('[VSCode Client] Subscription upgrade clicked')
251+
try {
252+
// Forward the upgrade request to Flare
253+
languageClient.sendNotification(subscriptionUpgradeNotificationType.method, message.params)
254+
} catch (e) {
255+
languageClient.error(
256+
`[VSCode Client] Failed to send subscription upgrade notification: ${(e as Error).message}`
257+
)
258+
}
259+
break
260+
}
247261
case DISCLAIMER_ACKNOWLEDGED: {
248262
void AmazonQPromptSettings.instance.update('amazonQChatDisclaimer', true)
249263
break
@@ -653,6 +667,46 @@ export function registerMessageListeners(
653667
params: params,
654668
})
655669
})
670+
671+
// Handle subscription details response from Flare
672+
languageClient.onNotification(subscriptionDetailsNotificationType.method, (params) => {
673+
languageClient.info(`[VSCode Client] Received subscription details: ${JSON.stringify(params)}`)
674+
// Forward the subscription details to the Chat UI
675+
void provider.webview?.postMessage({
676+
command: subscriptionDetailsNotificationType.method,
677+
params: params,
678+
})
679+
})
680+
// TODO: After implementing the "Upgrade" feature, test its functionality in the Account Details tab.
681+
// Handle window/showDocument requests from Flare for subscription upgrade
682+
languageClient.onRequest<ShowDocumentParams, ShowDocumentResult>(
683+
ShowDocumentRequest.method,
684+
async (params: ShowDocumentParams): Promise<ShowDocumentParams | ResponseError<ShowDocumentResult>> => {
685+
try {
686+
const uri = vscode.Uri.parse(params.uri)
687+
688+
if (params.external) {
689+
languageClient.info(`[VSCode Client] Opening external URL for subscription upgrade: ${params.uri}`)
690+
// Open the URL in the external browser
691+
await vscode.env.openExternal(uri)
692+
693+
// Return success to indicate the URL was opened
694+
return params
695+
}
696+
697+
// If not external, handle as a regular document
698+
const doc = await vscode.workspace.openTextDocument(uri)
699+
await vscode.window.showTextDocument(doc, { preview: false })
700+
return params
701+
} catch (e) {
702+
languageClient.error(`[VSCode Client] Failed to open subscription upgrade URL: ${(e as Error).message}`)
703+
return new ResponseError(
704+
LSPErrorCodes.RequestFailed,
705+
`Failed to open subscription upgrade URL: ${(e as Error).message}`
706+
)
707+
}
708+
}
709+
)
656710
}
657711

658712
function isServerEvent(command: string) {

packages/amazonq/src/lsp/client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ export async function startLanguageServer(
168168
reroute: true,
169169
modelSelection: true,
170170
workspaceFilePath: vscode.workspace.workspaceFile?.fsPath,
171+
subscriptionDetails: true,
171172
},
172173
window: {
173174
notifications: true,

packages/core/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -470,9 +470,9 @@
470470
"devDependencies": {
471471
"@aws-sdk/types": "^3.13.1",
472472
"@aws/chat-client": "^0.1.4",
473-
"@aws/chat-client-ui-types": "^0.1.47",
474-
"@aws/language-server-runtimes": "^0.2.102",
475-
"@aws/language-server-runtimes-types": "^0.1.43",
473+
"@aws/chat-client-ui-types": "^0.1.55",
474+
"@aws/language-server-runtimes": "^0.2.112",
475+
"@aws/language-server-runtimes-types": "^0.1.49",
476476
"@cspotcode/source-map-support": "^0.8.1",
477477
"@sinonjs/fake-timers": "^10.0.2",
478478
"@types/adm-zip": "^0.4.34",

packages/core/package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@
353353
"AWS.amazonq.security": "Code Issues",
354354
"AWS.amazonq.login": "Login",
355355
"AWS.amazonq.learnMore": "Learn More About Amazon Q",
356+
"AWS.amazonq.accountDetails": "Account details",
356357
"AWS.amazonq.exploreAgents": "Explore Agent Capabilities",
357358
"AWS.amazonq.welcomeWalkthrough": "Welcome Walkthrough",
358359
"AWS.amazonq.codewhisperer.title": "Amazon Q",

0 commit comments

Comments
 (0)