Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "Feature",
"description": "Add model selection feature"
}
2 changes: 1 addition & 1 deletion packages/amazonq/src/lsp/chat/activation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down
12 changes: 9 additions & 3 deletions packages/amazonq/src/lsp/chat/webviewProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading