Skip to content

Commit 73f9786

Browse files
JadenSimonjustinmk3
authored andcommitted
Disable CodeWhisperer within dev environment
1 parent 90441f3 commit 73f9786

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/codewhisperer/explorer/codewhispererNode.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { RootNode } from '../../awsexplorer/localExplorer'
2020
import { isCloud9 } from '../../shared/extensionUtilities'
2121
import { AuthUtil } from '../util/authUtil'
2222
import { getCodeCatalystDevEnvId } from '../../shared/vscode/env'
23+
import { getIcon } from '../../shared/icons'
2324

2425
export class CodeWhispererNode implements RootNode {
2526
private readonly isAvailable = getCodeCatalystDevEnvId() === undefined
@@ -37,6 +38,14 @@ export class CodeWhispererNode implements RootNode {
3738
constructor() {}
3839

3940
public getTreeItem() {
41+
if (!this.isAvailable) {
42+
const item = new vscode.TreeItem('CodeWhisperer (Preview)')
43+
item.description = 'Unavailable in Dev Environment'
44+
item.iconPath = getIcon('vscode-circle-slash')
45+
46+
return item
47+
}
48+
4049
if (!isCloud9()) {
4150
AuthUtil.instance.restore()
4251
}

src/codewhisperer/util/authUtil.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class AuthUtil {
4444

4545
public constructor(public readonly auth = Auth.instance) {
4646
// codewhisperer uses sigv4 creds on C9
47-
if (isCloud9()) {
47+
if (isCloud9() || !this.isAvailable) {
4848
return
4949
}
5050

@@ -71,7 +71,7 @@ export class AuthUtil {
7171

7272
// current active cwspr connection
7373
public get conn() {
74-
return this.secondaryAuth.activeConnection
74+
return this.isAvailable ? this.secondaryAuth.activeConnection : undefined
7575
}
7676

7777
public get isUsingSavedConnection() {

src/credentials/auth.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,7 @@ export const createIamItem = () =>
856856
({
857857
label: codicon`${getIcon('vscode-key')} ${localize('aws.auth.iamItem.label', 'Use IAM Credentials')}`,
858858
data: 'iam',
859+
onClick: () => telemetry.ui_click.emit({ elementId: 'connection_optionIAM' }),
859860
detail: 'Activates working with resources in the Explorer. Not supported by CodeWhisperer. Requires an access key ID and secret access key.',
860861
} as DataQuickPickItem<'iam'>)
861862

0 commit comments

Comments
 (0)