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": "Bug Fix",
"description": "Some users not signaled they needed to select a Region Profile to get features working"
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { parse } from '@aws-sdk/util-arn-parser'
import { isAwsError, ToolkitError } from '../../shared/errors'
import { telemetry } from '../../shared/telemetry/telemetry'
import { localize } from '../../shared/utilities/vsCodeUtils'
import { Commands } from '../../shared/vscode/commands2'

// TODO: is there a better way to manage all endpoint strings in one place?
export const defaultServiceConfig: CodeWhispererConfig = {
Expand Down Expand Up @@ -226,6 +227,9 @@ export class RegionProfileManager {

// persist to state
await this.persistSelectRegionProfile()

// Force status bar to reflect this change in state
await Commands.tryExecute('aws.amazonq.refreshStatusBar')
}

restoreProfileSelection = once(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ export class InlineCompletionService {
/** Updates the status bar to represent the latest CW state */
refreshStatusBar() {
if (AuthUtil.instance.isConnectionValid()) {
if (AuthUtil.instance.requireProfileSelection()) {
return this.setState('needsProfile')
}
return this.setState('ok')
} else if (AuthUtil.instance.isConnectionExpired()) {
return this.setState('expired')
Expand All @@ -193,6 +196,10 @@ export class InlineCompletionService {
await this.statusBar.setState('notConnected')
break
}
case 'needsProfile': {
await this.statusBar.setState('needsProfile')
break
}
}
}
}
Expand All @@ -203,6 +210,7 @@ const states = {
ok: 'ok',
expired: 'expired',
notConnected: 'notConnected',
needsProfile: 'needsProfile',
} as const

export class CodeWhispererStatusBar {
Expand Down Expand Up @@ -245,6 +253,7 @@ export class CodeWhispererStatusBar {
statusBar.backgroundColor = new vscode.ThemeColor('statusBarItem.warningBackground')
break
}
case 'needsProfile':
case 'notConnected':
statusBar.text = codicon` ${getIcon('vscode-chrome-close')} ${title}`
statusBar.backgroundColor = new vscode.ThemeColor('statusBarItem.errorBackground')
Expand Down
15 changes: 10 additions & 5 deletions packages/core/src/codewhisperer/ui/codeWhispererNodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
selectRegionProfileCommand,
} from '../commands/basicCommands'
import { CodeWhispererCommandDeclarations } from '../commands/gettingStartedPageCommands'
import { CodeScansState, codeScanState } from '../models/model'
import { CodeScansState, codeScanState, RegionProfile } from '../models/model'
import { getNewCustomizationsAvailable, getSelectedCustomization } from '../util/customizationUtil'
import { cwQuickPickSource } from '../commands/types'
import { AuthUtil } from '../util/authUtil'
Expand Down Expand Up @@ -138,12 +138,16 @@ export function createSelectCustomization(): DataQuickPickItem<'selectCustomizat
} as DataQuickPickItem<'selectCustomization'>
}

export function createSelectRegionProfileNode(): DataQuickPickItem<'selectRegionProfile'> {
const selectedRegionProfile = AuthUtil.instance.regionProfileManager.activeRegionProfile
export function createSelectRegionProfileNode(
profile: RegionProfile | undefined
): DataQuickPickItem<'selectRegionProfile'> {
const selectedRegionProfile = profile

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

return {
data: 'selectRegionProfile',
Expand All @@ -152,6 +156,7 @@ export function createSelectRegionProfileNode(): DataQuickPickItem<'selectRegion
await selectRegionProfileCommand.execute(placeholder, cwQuickPickSource)
},
description: description,
picked: profile === undefined,
}
}

Expand Down
9 changes: 8 additions & 1 deletion packages/core/src/codewhisperer/ui/statusBarMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,14 @@ function getAmazonQCodeWhispererNodes() {
}

export function getQuickPickItems(): DataQuickPickItem<string>[] {
const isUsingEnterpriseSso = AuthUtil.instance.isValidEnterpriseSsoInUse()
const regionProfile = AuthUtil.instance.regionProfileManager.activeRegionProfile

const children = [
// If the user has signed in but not selected a region, we strongly indicate they need to select
// a profile, otherwise features will not work.
...(isUsingEnterpriseSso && !regionProfile ? [createSelectRegionProfileNode(undefined)] : []),

...getAmazonQCodeWhispererNodes(),

// Generic Nodes
Expand All @@ -97,7 +104,7 @@ export function getQuickPickItems(): DataQuickPickItem<string>[] {
// Add settings and signout
createSeparator(),
createSettingsNode(),
...(AuthUtil.instance.isValidEnterpriseSsoInUse() ? [createSelectRegionProfileNode()] : []),
...(isUsingEnterpriseSso && regionProfile ? [createSelectRegionProfileNode(regionProfile)] : []),
...(AuthUtil.instance.isConnected() && !hasVendedIamCredentials() && !hasVendedCredentialsFromMetadata()
? [createSignout()]
: []),
Expand Down
Loading