Skip to content

Commit 657d641

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

File tree

7 files changed

+119
-21
lines changed

7 files changed

+119
-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: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,22 @@ export async function activate(languageClient: LanguageClient, encryptionKey: Bu
9090
getLogger('amazonqLsp').error('failed request: aws/chat/manageSubscription: %O', e)
9191
})
9292
}),
93+
/*
94+
Forward the subscription details request to language server directly
95+
This triggers the onShowSubscription() method in the language server
96+
*/
97+
Commands.register('aws.amazonq.accountDetails', () => {
98+
getLogger('amazonqLsp').info(
99+
'[VSCode Client]: Sending subscription details [aws/chat/subscription/show] event notification'
100+
)
101+
languageClient
102+
.sendRequest('workspace/executeCommand', {
103+
command: 'aws/chat/subscription/show',
104+
})
105+
.catch((e) => {
106+
getLogger('amazonqLsp').error('Failed to send subscription details request: : %O', e)
107+
})
108+
}),
93109
globals.logOutputChannel.onDidChangeLogLevel((logLevel) => {
94110
getLogger('amazonqLsp').info(`Local log level changed to ${logLevel}, notifying LSP`)
95111
void pushConfigUpdate(languageClient, {

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

Lines changed: 71 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
@@ -126,6 +128,22 @@ export function registerLanguageServerEventListener(languageClient: LanguageClie
126128
)
127129

128130
const chatOptions = languageClient.initializeResult?.awsServerCapabilities?.chatOptions
131+
/*
132+
Set subscriptionDetails based on request
133+
Set to false if subscriptionDetails is not in the request
134+
Set to true if subscriptionDetails is true in the request
135+
Set to false otherwise
136+
*/
137+
if (chatOptions) {
138+
languageClient.info(
139+
'Subscription details capability:',
140+
`Server:${languageClient.initializeResult?.awsServerCapabilities?.chatOptions?.subscriptionDetails}`
141+
)
142+
143+
const requestSubscriptionDetails =
144+
languageClient.initializeResult?.awsServerCapabilities?.chatOptions?.subscriptionDetails
145+
chatOptions.subscriptionDetails = requestSubscriptionDetails === true
146+
}
129147

130148
// overide the quick action commands provided by flare server initialization, which doesn't provide the group header
131149
if (chatOptions?.quickActions?.quickActionsCommandGroups?.[0]) {
@@ -244,6 +262,18 @@ export function registerMessageListeners(
244262
}
245263
break
246264
}
265+
case SUBSCRIPTION_UPGRADE_NOTIFICATION_METHOD: {
266+
languageClient.info('[VSCode Client] Subscription upgrade clicked')
267+
try {
268+
// Forward the upgrade request to Flare
269+
languageClient.sendNotification(subscriptionUpgradeNotificationType.method, message.params)
270+
} catch (e) {
271+
languageClient.error(
272+
`[VSCode Client] Failed to send subscription upgrade notification: ${(e as Error).message}`
273+
)
274+
}
275+
break
276+
}
247277
case DISCLAIMER_ACKNOWLEDGED: {
248278
void AmazonQPromptSettings.instance.update('amazonQChatDisclaimer', true)
249279
break
@@ -653,6 +683,46 @@ export function registerMessageListeners(
653683
params: params,
654684
})
655685
})
686+
687+
// Handle subscription details response from Flare
688+
languageClient.onNotification(subscriptionDetailsNotificationType.method, (params) => {
689+
languageClient.info(`[VSCode Client] Received subscription details: ${JSON.stringify(params)}`)
690+
// Forward the subscription details to the Chat UI
691+
void provider.webview?.postMessage({
692+
command: subscriptionDetailsNotificationType.method,
693+
params: params,
694+
})
695+
})
696+
// TODO: After implementing the "Upgrade" feature, test its functionality in the Account Details tab.
697+
// Handle window/showDocument requests from Flare for subscription upgrade
698+
languageClient.onRequest<ShowDocumentParams, ShowDocumentResult>(
699+
ShowDocumentRequest.method,
700+
async (params: ShowDocumentParams): Promise<ShowDocumentParams | ResponseError<ShowDocumentResult>> => {
701+
try {
702+
const uri = vscode.Uri.parse(params.uri)
703+
704+
if (params.external) {
705+
languageClient.info(`[VSCode Client] Opening external URL for subscription upgrade: ${params.uri}`)
706+
// Open the URL in the external browser
707+
await vscode.env.openExternal(uri)
708+
709+
// Return success to indicate the URL was opened
710+
return params
711+
}
712+
713+
// If not external, handle as a regular document
714+
const doc = await vscode.workspace.openTextDocument(uri)
715+
await vscode.window.showTextDocument(doc, { preview: false })
716+
return params
717+
} catch (e) {
718+
languageClient.error(`[VSCode Client] Failed to open subscription upgrade URL: ${(e as Error).message}`)
719+
return new ResponseError(
720+
LSPErrorCodes.RequestFailed,
721+
`Failed to open subscription upgrade URL: ${(e as Error).message}`
722+
)
723+
}
724+
}
725+
)
656726
}
657727

658728
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)