Skip to content

Commit de9ffaa

Browse files
committed
feat: customer pricing details for amazon q
1 parent 3084ae1 commit de9ffaa

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",
@@ -734,6 +739,11 @@
734739
"title": "%AWS.amazonq.learnMore%",
735740
"category": "%AWS.amazonq.title%"
736741
},
742+
{
743+
"command": "aws.amazonq.accountDetails",
744+
"title": "%AWS.amazonq.accountDetails%",
745+
"category": "%AWS.amazonq.title%"
746+
},
737747
{
738748
"command": "amazonq.dev.openMenu",
739749
"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'
@@ -102,7 +104,7 @@ import { isValidResponseError } from './error'
102104
import { decryptResponse, encryptRequest } from '../encryption'
103105
import { getCursorState } from '../utils'
104106
import { focusAmazonQPanel } from './commands'
105-
import { ChatMessage } from '@aws/language-server-runtimes/server-interface'
107+
import { ChatMessage, SUBSCRIPTION_UPGRADE_NOTIFICATION_METHOD } from '@aws/language-server-runtimes/server-interface'
106108
import { CommentUtils } from 'aws-core-vscode/utils'
107109

108110
export function registerActiveEditorChangeListener(languageClient: LanguageClient) {
@@ -253,6 +255,18 @@ export function registerMessageListeners(
253255
}
254256
break
255257
}
258+
case SUBSCRIPTION_UPGRADE_NOTIFICATION_METHOD: {
259+
languageClient.info('[VSCode Client] Subscription upgrade clicked')
260+
try {
261+
// Forward the upgrade request to Flare
262+
languageClient.sendNotification(subscriptionUpgradeNotificationType.method, message.params)
263+
} catch (e) {
264+
languageClient.error(
265+
`[VSCode Client] Failed to send subscription upgrade notification: ${(e as Error).message}`
266+
)
267+
}
268+
break
269+
}
256270
case DISCLAIMER_ACKNOWLEDGED: {
257271
void AmazonQPromptSettings.instance.update('amazonQChatDisclaimer', true)
258272
break
@@ -701,6 +715,46 @@ export function registerMessageListeners(
701715
params: params,
702716
})
703717
})
718+
719+
// Handle subscription details response from Flare
720+
languageClient.onNotification(subscriptionDetailsNotificationType.method, (params) => {
721+
languageClient.info(`[VSCode Client] Received subscription details: ${JSON.stringify(params)}`)
722+
// Forward the subscription details to the Chat UI
723+
void provider.webview?.postMessage({
724+
command: subscriptionDetailsNotificationType.method,
725+
params: params,
726+
})
727+
})
728+
// TODO: After implementing the "Upgrade" feature, test its functionality in the Account Details tab.
729+
// Handle window/showDocument requests from Flare for subscription upgrade
730+
languageClient.onRequest<ShowDocumentParams, ShowDocumentResult>(
731+
ShowDocumentRequest.method,
732+
async (params: ShowDocumentParams): Promise<ShowDocumentParams | ResponseError<ShowDocumentResult>> => {
733+
try {
734+
const uri = vscode.Uri.parse(params.uri)
735+
736+
if (params.external) {
737+
languageClient.info(`[VSCode Client] Opening external URL for subscription upgrade: ${params.uri}`)
738+
// Open the URL in the external browser
739+
await vscode.env.openExternal(uri)
740+
741+
// Return success to indicate the URL was opened
742+
return params
743+
}
744+
745+
// If not external, handle as a regular document
746+
const doc = await vscode.workspace.openTextDocument(uri)
747+
await vscode.window.showTextDocument(doc, { preview: false })
748+
return params
749+
} catch (e) {
750+
languageClient.error(`[VSCode Client] Failed to open subscription upgrade URL: ${(e as Error).message}`)
751+
return new ResponseError(
752+
LSPErrorCodes.RequestFailed,
753+
`Failed to open subscription upgrade URL: ${(e as Error).message}`
754+
)
755+
}
756+
}
757+
)
704758
}
705759

706760
function isServerEvent(command: string) {

packages/amazonq/src/lsp/client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ export async function startLanguageServer(
169169
reroute: true,
170170
modelSelection: true,
171171
workspaceFilePath: vscode.workspace.workspaceFile?.fsPath,
172+
subscriptionDetails: true,
172173
codeReviewInChat: false,
173174
},
174175
window: {

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.111",
475-
"@aws/language-server-runtimes-types": "^0.1.47",
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
@@ -354,6 +354,7 @@
354354
"AWS.amazonq.security": "Code Issues",
355355
"AWS.amazonq.login": "Login",
356356
"AWS.amazonq.learnMore": "Learn More About Amazon Q",
357+
"AWS.amazonq.accountDetails": "Account details",
357358
"AWS.amazonq.exploreAgents": "Explore Agent Capabilities",
358359
"AWS.amazonq.welcomeWalkthrough": "Welcome Walkthrough",
359360
"AWS.amazonq.codewhisperer.title": "Amazon Q",

0 commit comments

Comments
 (0)