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": "SageMaker: Disable the unsupported agentic commands and welcome prompt"
}
8 changes: 5 additions & 3 deletions packages/amazonq/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@
},
{
"command": "aws.amazonq.generateUnitTests",
"when": "!aws.isSageMaker",
"group": "cw_chat@5"
},
{
Expand Down Expand Up @@ -469,6 +470,7 @@
},
{
"command": "aws.amazonq.exploreAgents",
"when": "!aws.isSageMaker",
"group": "1_help@2"
},
{
Expand Down Expand Up @@ -523,7 +525,7 @@
"command": "aws.amazonq.security.scan-statusbar",
"title": "%AWS.command.amazonq.security.scan%",
"category": "%AWS.amazonq.title%",
"enablement": "aws.codewhisperer.connected"
"enablement": "aws.codewhisperer.connected && !aws.isSageMaker"
},
{
"command": "aws.amazonq.refactorCode",
Expand Down Expand Up @@ -553,7 +555,7 @@
"command": "aws.amazonq.generateUnitTests",
"title": "%AWS.command.amazonq.generateUnitTests%",
"category": "%AWS.amazonq.title%",
"enablement": "aws.codewhisperer.connected"
"enablement": "aws.codewhisperer.connected && !aws.isSageMaker"
},
{
"command": "aws.amazonq.reconnect",
Expand Down Expand Up @@ -757,7 +759,7 @@
"command": "aws.amazonq.exploreAgents",
"title": "%AWS.amazonq.exploreAgents%",
"category": "%AWS.amazonq.title%",
"enablement": "aws.codewhisperer.connected"
"enablement": "aws.codewhisperer.connected && !aws.isSageMaker"
},
{
"command": "aws.amazonq.walkthrough.show",
Expand Down
3 changes: 3 additions & 0 deletions packages/amazonq/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ export async function activateAmazonQCommon(context: vscode.ExtensionContext, is
// Hide the Amazon Q tree in toolkit explorer
await setContext('aws.toolkit.amazonq.dismissed', true)

// set context var to check if its SageMaker AI or not
await setContext('aws.isSageMaker', isSageMaker())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 This is done for Toolkit here:

if (!isSageMaker()) {
await setContext('aws.isSageMaker', false)
await codecatalyst.activate(extContext)
} else {
await setContext('aws.isSageMaker', true)
}

but currently packages/amazonq/src/extension.ts does not share a "common" startup logic w/ Toolkit, so we need this redundant code here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack, thanks for adding the details Justin


// set context var to check if its SageMaker Unified Studio or not
await setContext('aws.isSageMakerUnifiedStudio', isSageMaker('SMUS'))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,13 @@ export class WebViewContentGenerator {

// Fetch featureConfigs and use it within the script
const featureConfigsString = await this.generateFeatureConfigsData()
const isSM = isSageMaker('SMAI')
const isSMUS = isSageMaker('SMUS')

const disabledCommandsString = isSageMaker() ? `['/dev', '/transform']` : '[]'
const disabledCommandsString = isSM ? `['/dev', '/transform', '/test', '/review', '/doc']` : '[]'
const disclaimerAcknowledged = globals.globalState.tryGet('aws.amazonq.disclaimerAcknowledged', Boolean, false)

const welcomeLoadCount = globals.globalState.tryGet('aws.amazonq.welcomeChatShowCount', Number, 0)
const isSMUS = isSageMaker('SMUS')

return `
<script type="text/javascript" src="${javascriptEntrypoint.toString()}" defer onload="init()"></script>
Expand All @@ -92,7 +93,7 @@ export class WebViewContentGenerator {
const init = () => {
createMynahUI(acquireVsCodeApi(), ${
(await AuthUtil.instance.getChatAuthState()).amazonQ === 'connected'
},${featureConfigsString},${welcomeLoadCount},${disclaimerAcknowledged},${disabledCommandsString},${isSMUS});
},${featureConfigsString},${welcomeLoadCount},${disclaimerAcknowledged},${disabledCommandsString},${isSMUS},${isSM});
}
</script>
`
Expand Down
8 changes: 6 additions & 2 deletions packages/core/src/amazonq/webview/ui/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ export const createMynahUI = (
welcomeCount: number,
disclaimerAcknowledged: boolean,
disabledCommands?: string[],
isSMUS?: boolean
isSMUS?: boolean,
isSM?: boolean
) => {
let disclaimerCardActive = !disclaimerAcknowledged
// eslint-disable-next-line prefer-const
Expand Down Expand Up @@ -84,7 +85,10 @@ export const createMynahUI = (
})

const showWelcomePage = () => {
return welcomeCount < welcomeCountThreshold
/*
* skip Agent Capability welcome page for SageMaker cases (SMAI and SMUS) since the commands are not supported
*/
return welcomeCount < welcomeCountThreshold && !isSM
}

const updateWelcomeCount = () => {
Expand Down
5 changes: 5 additions & 0 deletions packages/core/src/amazonq/webview/ui/tabs/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ const qChatIntroMessage = `Hi, I'm Amazon Q. I can answer your software developm
Ask me to explain, debug, or optimize your code.
You can enter \`/\` to see a list of quick actions. Use \`@\` to add saved prompts, files, folders, or your entire workspace as context.`

/**
* The below intro message is for SageMaker Unified Studio(SMUS) customers only.
* With upcoming release of SMUS, only Q Free Tier is being supported hence the requirement to show this messaging to customers.
* Once Pro Tier is supported with SMUS, the below message will be removed and is only added for the interim
*/
export const qChatIntroMessageForSMUS = `Hi, I'm Amazon Q. I can answer your software development questions.\n\
Ask me to explain, debug, or optimize your code.\n\
You can enter \`/\` to see a list of quick actions. Use \`@\` to add saved prompts, files, folders, or your entire workspace as context.
Expand Down
10 changes: 10 additions & 0 deletions packages/core/src/auth/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1115,3 +1115,13 @@ export function hasVendedIamCredentials(isC9?: boolean, isSM?: boolean) {
isSM ??= isSageMaker()
return isSM || isC9
}

/**
* Returns true if credentials are provided by the metadata files in environment (ex. for IAM via ~/.aws/ and in a future case with SSO, from /cache or /sso)
* @param isSMUS boolean if SageMaker Unified Studio is host
* @returns boolean if SMUS
*/
export function hasVendedCredentialsFromMetadata(isSMUS?: boolean) {
isSMUS ??= isSageMaker('SMUS')
return isSMUS
}
5 changes: 2 additions & 3 deletions packages/core/src/codewhisperer/ui/statusBarMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@ import {
switchToAmazonQNode,
createSecurityScan,
} from './codeWhispererNodes'
import { hasVendedIamCredentials } from '../../auth/auth'
import { hasVendedIamCredentials, hasVendedCredentialsFromMetadata } from '../../auth/auth'
import { AuthUtil } from '../util/authUtil'
import { DataQuickPickItem, createQuickPick } from '../../shared/ui/pickerPrompter'
import { CodeScansState, CodeSuggestionsState, vsCodeState } from '../models/model'
import { Commands } from '../../shared/vscode/commands2'
import { createExitButton } from '../../shared/ui/buttons'
import { telemetry } from '../../shared/telemetry/telemetry'
import { getLogger } from '../../shared/logger/logger'
import { isSageMaker } from '../../shared/extensionUtilities'

function getAmazonQCodeWhispererNodes() {
const autoTriggerEnabled = CodeSuggestionsState.instance.isSuggestionsEnabled()
Expand Down Expand Up @@ -93,7 +92,7 @@ export function getQuickPickItems(): DataQuickPickItem<string>[] {
// Add settings and signout
createSeparator(),
createSettingsNode(),
...(AuthUtil.instance.isConnected() && !(hasVendedIamCredentials() || isSageMaker('SMUS'))
...(AuthUtil.instance.isConnected() && !hasVendedIamCredentials() && !hasVendedCredentialsFromMetadata()
? [createSignout()]
: []),
]
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/shared/extensionUtilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export function isCloud9(flavor: 'classic' | 'codecatalyst' | 'any' = 'any'): bo
* @param appName to identify the proper SM instance
* @returns true if the current system is SageMaker(SMAI or SMUS)
*/
export function isSageMaker(appName: string = 'SMAI'): boolean {
export function isSageMaker(appName: 'SMAI' | 'SMUS' = 'SMAI'): boolean {
switch (appName) {
case 'SMAI':
return vscode.env.appName === sageMakerAppname
Expand Down
Loading