Skip to content

Commit 8b1cca5

Browse files
Merge master into feature/hybridChat
2 parents 8da7910 + 96e28f4 commit 8b1cca5

File tree

5 files changed

+35
-6
lines changed

5 files changed

+35
-6
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "Some users not signaled they needed to select a Region Profile to get features working"
4+
}

packages/core/src/codewhisperer/region/regionProfileManager.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { parse } from '@aws-sdk/util-arn-parser'
2828
import { isAwsError, ToolkitError } from '../../shared/errors'
2929
import { telemetry } from '../../shared/telemetry/telemetry'
3030
import { localize } from '../../shared/utilities/vsCodeUtils'
31+
import { Commands } from '../../shared/vscode/commands2'
3132

3233
// TODO: is there a better way to manage all endpoint strings in one place?
3334
export const defaultServiceConfig: CodeWhispererConfig = {
@@ -218,6 +219,9 @@ export class RegionProfileManager {
218219

219220
// persist to state
220221
await this.persistSelectRegionProfile()
222+
223+
// Force status bar to reflect this change in state
224+
await Commands.tryExecute('aws.amazonq.refreshStatusBar')
221225
}
222226

223227
restoreProfileSelection = once(async () => {

packages/core/src/codewhisperer/service/inlineCompletionService.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ export class InlineCompletionService {
167167
/** Updates the status bar to represent the latest CW state */
168168
refreshStatusBar() {
169169
if (AuthUtil.instance.isConnectionValid()) {
170+
if (AuthUtil.instance.requireProfileSelection()) {
171+
return this.setState('needsProfile')
172+
}
170173
return this.setState('ok')
171174
} else if (AuthUtil.instance.isConnectionExpired()) {
172175
return this.setState('expired')
@@ -193,6 +196,10 @@ export class InlineCompletionService {
193196
await this.statusBar.setState('notConnected')
194197
break
195198
}
199+
case 'needsProfile': {
200+
await this.statusBar.setState('needsProfile')
201+
break
202+
}
196203
}
197204
}
198205
}
@@ -203,6 +210,7 @@ const states = {
203210
ok: 'ok',
204211
expired: 'expired',
205212
notConnected: 'notConnected',
213+
needsProfile: 'needsProfile',
206214
} as const
207215

208216
export class CodeWhispererStatusBar {
@@ -245,6 +253,7 @@ export class CodeWhispererStatusBar {
245253
statusBar.backgroundColor = new vscode.ThemeColor('statusBarItem.warningBackground')
246254
break
247255
}
256+
case 'needsProfile':
248257
case 'notConnected':
249258
statusBar.text = codicon` ${getIcon('vscode-chrome-close')} ${title}`
250259
statusBar.backgroundColor = new vscode.ThemeColor('statusBarItem.errorBackground')

packages/core/src/codewhisperer/ui/codeWhispererNodes.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
selectRegionProfileCommand,
2222
} from '../commands/basicCommands'
2323
import { CodeWhispererCommandDeclarations } from '../commands/gettingStartedPageCommands'
24-
import { CodeScansState, codeScanState } from '../models/model'
24+
import { CodeScansState, codeScanState, RegionProfile } from '../models/model'
2525
import { getNewCustomizationsAvailable, getSelectedCustomization } from '../util/customizationUtil'
2626
import { cwQuickPickSource } from '../commands/types'
2727
import { AuthUtil } from '../util/authUtil'
@@ -138,12 +138,16 @@ export function createSelectCustomization(): DataQuickPickItem<'selectCustomizat
138138
} as DataQuickPickItem<'selectCustomization'>
139139
}
140140

141-
export function createSelectRegionProfileNode(): DataQuickPickItem<'selectRegionProfile'> {
142-
const selectedRegionProfile = AuthUtil.instance.regionProfileManager.activeRegionProfile
141+
export function createSelectRegionProfileNode(
142+
profile: RegionProfile | undefined
143+
): DataQuickPickItem<'selectRegionProfile'> {
144+
const selectedRegionProfile = profile
143145

144-
const label = 'Change Profile'
146+
const label = profile ? 'Change Profile' : '(Required) Select Profile'
145147
const icon = getIcon('vscode-arrow-swap')
146-
const description = selectedRegionProfile ? `Current profile: ${selectedRegionProfile.name}` : ''
148+
const description = selectedRegionProfile
149+
? `Current profile: ${selectedRegionProfile.name}`
150+
: 'A profile MUST be selected for features to work'
147151

148152
return {
149153
data: 'selectRegionProfile',
@@ -152,6 +156,7 @@ export function createSelectRegionProfileNode(): DataQuickPickItem<'selectRegion
152156
await selectRegionProfileCommand.execute(placeholder, cwQuickPickSource)
153157
},
154158
description: description,
159+
picked: profile === undefined,
155160
}
156161
}
157162

packages/core/src/codewhisperer/ui/statusBarMenu.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,14 @@ function getAmazonQCodeWhispererNodes() {
8585
}
8686

8787
export function getQuickPickItems(): DataQuickPickItem<string>[] {
88+
const isUsingEnterpriseSso = AuthUtil.instance.isValidEnterpriseSsoInUse()
89+
const regionProfile = AuthUtil.instance.regionProfileManager.activeRegionProfile
90+
8891
const children = [
92+
// If the user has signed in but not selected a region, we strongly indicate they need to select
93+
// a profile, otherwise features will not work.
94+
...(isUsingEnterpriseSso && !regionProfile ? [createSelectRegionProfileNode(undefined)] : []),
95+
8996
...getAmazonQCodeWhispererNodes(),
9097

9198
// Generic Nodes
@@ -97,7 +104,7 @@ export function getQuickPickItems(): DataQuickPickItem<string>[] {
97104
// Add settings and signout
98105
createSeparator(),
99106
createSettingsNode(),
100-
...(AuthUtil.instance.isValidEnterpriseSsoInUse() ? [createSelectRegionProfileNode()] : []),
107+
...(isUsingEnterpriseSso && regionProfile ? [createSelectRegionProfileNode(regionProfile)] : []),
101108
...(AuthUtil.instance.isConnected() && !hasVendedIamCredentials() && !hasVendedCredentialsFromMetadata()
102109
? [createSignout()]
103110
: []),

0 commit comments

Comments
 (0)