diff --git a/packages/amazonq/.changes/next-release/Feature-35bcb9ac-0cc5-456f-8159-765a6deb3b47.json b/packages/amazonq/.changes/next-release/Feature-35bcb9ac-0cc5-456f-8159-765a6deb3b47.json new file mode 100644 index 00000000000..2ca333a9f64 --- /dev/null +++ b/packages/amazonq/.changes/next-release/Feature-35bcb9ac-0cc5-456f-8159-765a6deb3b47.json @@ -0,0 +1,4 @@ +{ + "type": "Feature", + "description": "Add model selection feature" +} diff --git a/packages/amazonq/src/lsp/chat/activation.ts b/packages/amazonq/src/lsp/chat/activation.ts index 5f8d78ec84e..90a0adbc61f 100644 --- a/packages/amazonq/src/lsp/chat/activation.ts +++ b/packages/amazonq/src/lsp/chat/activation.ts @@ -21,7 +21,7 @@ import { pushConfigUpdate } from '../config' export async function activate(languageClient: LanguageClient, encryptionKey: Buffer, mynahUIPath: string) { const disposables = globals.context.subscriptions - const provider = new AmazonQChatViewProvider(mynahUIPath) + const provider = new AmazonQChatViewProvider(mynahUIPath, languageClient) disposables.push( window.registerWebviewViewProvider(AmazonQChatViewProvider.viewType, provider, { diff --git a/packages/amazonq/src/lsp/chat/webviewProvider.ts b/packages/amazonq/src/lsp/chat/webviewProvider.ts index bb190b5eb67..7d51648398d 100644 --- a/packages/amazonq/src/lsp/chat/webviewProvider.ts +++ b/packages/amazonq/src/lsp/chat/webviewProvider.ts @@ -24,6 +24,7 @@ import { import { AuthUtil, RegionProfile } from 'aws-core-vscode/codewhisperer' import { featureConfig } from 'aws-core-vscode/amazonq' import { getAmazonQLspConfig } from '../config' +import { LanguageClient } from 'vscode-languageclient' export class AmazonQChatViewProvider implements WebviewViewProvider { public static readonly viewType = 'aws.amazonq.AmazonQChatView' @@ -36,7 +37,10 @@ export class AmazonQChatViewProvider implements WebviewViewProvider { connectorAdapterPath?: string uiPath?: string - constructor(private readonly mynahUIPath: string) {} + constructor( + private readonly mynahUIPath: string, + private readonly languageClient: LanguageClient + ) {} public async resolveWebviewView( webviewView: WebviewView, @@ -95,6 +99,8 @@ export class AmazonQChatViewProvider implements WebviewViewProvider { const pairProgrammingAcknowledged = !AmazonQPromptSettings.instance.isPromptEnabled('amazonQChatPairProgramming') const welcomeCount = globals.globalState.tryGet('aws.amazonq.welcomeChatShowCount', Number, 0) + const modelSelectionEnabled = + this.languageClient.initializeResult?.awsServerCapabilities?.chatOptions?.modelSelection ?? false // only show profile card when the two conditions // 1. profile count >= 2 @@ -143,14 +149,14 @@ export class AmazonQChatViewProvider implements WebviewViewProvider { const vscodeApi = acquireVsCodeApi() const hybridChatConnector = new HybridChatAdapter(${(await AuthUtil.instance.getChatAuthState()).amazonQ === 'connected'},${featureConfigData},${welcomeCount},${disclaimerAcknowledged},${regionProfileString},${disabledCommands},${isSMUS},${isSM},vscodeApi.postMessage) const commands = [hybridChatConnector.initialQuickActions[0]] - qChat = amazonQChat.createChat(vscodeApi, {disclaimerAcknowledged: ${disclaimerAcknowledged}, pairProgrammingAcknowledged: ${pairProgrammingAcknowledged}, agenticMode: true, quickActionCommands: commands}, hybridChatConnector, ${JSON.stringify(featureConfigData)}); + qChat = amazonQChat.createChat(vscodeApi, {disclaimerAcknowledged: ${disclaimerAcknowledged}, pairProgrammingAcknowledged: ${pairProgrammingAcknowledged}, agenticMode: true, quickActionCommands: commands, modelSelectionEnabled: ${modelSelectionEnabled}}, hybridChatConnector, ${JSON.stringify(featureConfigData)}); } window.addEventListener('message', (event) => { /** * special handler that "simulates" reloading the webview when a profile changes. * required because chat-client relies on initializedResult from the lsp that * are only sent once - * + * * References: * closing tabs: https://github.com/aws/mynah-ui/blob/de736b52f369ba885cd19f33ac86c6f57b4a3134/docs/USAGE.md#removing-a-tab-programmatically- * opening tabs: https://github.com/aws/aws-toolkit-vscode/blob/c22efa03e73b241564c8051c35761eb8620edb83/packages/amazonq/test/e2e/amazonq/framework/framework.ts#L98