Skip to content

Commit 500c872

Browse files
committed
fix after merge
1 parent a199d77 commit 500c872

File tree

3 files changed

+978
-32
lines changed

3 files changed

+978
-32
lines changed

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
import { QuickActionCommandGroup } from '@aws/mynah-ui'
1616
import * as path from 'path'
1717
import { globals, isSageMaker, AmazonQPromptSettings, LanguageServerResolver } from 'aws-core-vscode/shared'
18-
import { AuthUtil } from 'aws-core-vscode/codewhisperer'
18+
import { AuthUtil, RegionProfile } from 'aws-core-vscode/codewhisperer'
1919
import { featureConfig } from 'aws-core-vscode/amazonq'
2020

2121
export class AmazonQChatViewProvider implements WebviewViewProvider {
@@ -76,9 +76,23 @@ export class AmazonQChatViewProvider implements WebviewViewProvider {
7676

7777
private async getWebviewContent(mynahUIPath: string, hybridChatConnector: string) {
7878
const featureConfigData = await featureConfig.getFeatureConfigs()
79-
const disabledCommands = isSageMaker() ? `['/dev', '/transform']` : '[]'
79+
80+
const isSM = isSageMaker('SMAI')
81+
const isSMUS = isSageMaker('SMUS')
82+
const disabledCommands = isSM ? `['/dev', '/transform', '/test', '/review', '/doc']` : '[]'
8083
const disclaimerAcknowledged = AmazonQPromptSettings.instance.isPromptEnabled('amazonQChatDisclaimer')
8184
const welcomeCount = globals.globalState.tryGet('aws.amazonq.welcomeChatShowCount', Number, 0)
85+
86+
// only show profile card when the two conditions
87+
// 1. profile count >= 2
88+
// 2. not default (fallback) which has empty arn
89+
let regionProfile: RegionProfile | undefined = AuthUtil.instance.regionProfileManager.activeRegionProfile
90+
if (AuthUtil.instance.regionProfileManager.profiles.length === 1) {
91+
regionProfile = undefined
92+
}
93+
94+
const regionProfileString: string = JSON.stringify(regionProfile)
95+
8296
const entrypoint = process.env.WEBPACK_DEVELOPER_SERVER
8397
? 'http: localhost'
8498
: 'https: file+.vscode-resources.vscode-cdn.net'
@@ -112,7 +126,7 @@ export class AmazonQChatViewProvider implements WebviewViewProvider {
112126
<script type="text/javascript" src="${hybridChatConnector.toString()}"></script>
113127
<script type="text/javascript">
114128
const init = () => {
115-
const hybridChatConnector = new HybridChatAdapter(${(await AuthUtil.instance.getChatAuthState()).amazonQ === 'connected'},${featureConfigData},${welcomeCount},${disclaimerAcknowledged},${disabledCommands})
129+
const hybridChatConnector = new HybridChatAdapter(${(await AuthUtil.instance.getChatAuthState()).amazonQ === 'connected'},${featureConfigData},${welcomeCount},${disclaimerAcknowledged},${regionProfileString},${disabledCommands},${isSMUS},${isSM})
116130
const connectorsConfig = {
117131
quickActionCommands: [hybridChatConnector.initialQuickActions[0]]
118132
}

packages/core/src/amazonq/webview/ui/connectorAdapter.ts

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { isTabType } from './storages/tabsStorage'
99
import { WebviewUIHandler } from './main'
1010
import { FeatureContext } from '../../../shared/featureConfig'
1111
import { TabDataGenerator } from './tabs/generator'
12+
import { RegionProfile } from '../../../codewhisperer/models/model'
1213

1314
export interface ConnectorAdapter {
1415
mynahUI?: MynahUI
@@ -24,8 +25,10 @@ export class HybridChatAdapter implements ConnectorAdapter {
2425
private welcomeCount: number
2526
private disclaimerAcknowledged: boolean
2627
private disabledCommands: string[]
28+
private regionProfile: RegionProfile | undefined
29+
private isSMUS: boolean
30+
private isSM: boolean
2731

28-
// private connector?: Connector
2932
private uiHandler?: WebviewUIHandler
3033

3134
private _mynahUI?: MynahUI
@@ -35,27 +38,36 @@ export class HybridChatAdapter implements ConnectorAdapter {
3538
featureConfigsSerialized: [string, FeatureContext][],
3639
welcomeCount: number,
3740
disclaimerAcknowledged: boolean,
38-
disabledCommands: string[]
41+
regionProfile: RegionProfile | undefined,
42+
disabledCommands: string[],
43+
isSMUS: boolean,
44+
isSM: boolean
3945
) {
4046
this.enableAgents = enableAgents
4147
this.featureConfigsSerialized = featureConfigsSerialized
4248
this.welcomeCount = welcomeCount
4349
this.disclaimerAcknowledged = disclaimerAcknowledged
50+
this.regionProfile = regionProfile
4451
this.disabledCommands = disabledCommands
52+
this.isSMUS = isSMUS
53+
this.isSM = isSM
4554
}
4655

4756
createIdeConnector(mynahUIRef: { mynahUI: MynahUI }, ideApiPostMessage: (msg: any) => void): any {
4857
this.mynahUI = mynahUIRef.mynahUI
4958

50-
this.uiHandler = new WebviewUIHandler(
51-
ideApiPostMessage,
52-
this.mynahUI,
53-
this.enableAgents,
54-
this.featureConfigsSerialized,
55-
this.welcomeCount,
56-
this.disclaimerAcknowledged,
57-
this.disabledCommands
58-
)
59+
this.uiHandler = new WebviewUIHandler({
60+
postMessage: ideApiPostMessage,
61+
mynahUI: this.mynahUI,
62+
enableAgents: this.enableAgents,
63+
featureConfigsSerialized: this.featureConfigsSerialized,
64+
welcomeCount: this.welcomeCount,
65+
disclaimerAcknowledged: this.disclaimerAcknowledged,
66+
regionProfile: this.regionProfile,
67+
disabledCommands: this.disabledCommands,
68+
isSMUS: this.isSMUS,
69+
isSM: this.isSM,
70+
})
5971

6072
/**
6173
* By default its spawed by the same handler that was created in the old mynah ui; we need to swap it with the new one that routes messages

0 commit comments

Comments
 (0)