Skip to content

Commit a96a73e

Browse files
authored
fix(amazonq): disable Q agentic commands in SageMaker apps
## Problem SageMaker AI and Unified Studio currently in prod uses version `1.32` and with manual upgrade to the newer version `>1.54`, observing agentic prompt added along with new commands `/test, /review, /doc` which are not supported by SageMaker apps ## Solution 1. SageMaker doesnt support currently `/dev, /transform` commands and in addition to that disabling the above listed agentic Q commands that are not supported in SageMaker apps(both SMAI and SMUS). 2. Also disabling the agentic options from quick pick items 3. Skip agentic welcome prompt
1 parent 191c504 commit a96a73e

File tree

9 files changed

+40
-12
lines changed

9 files changed

+40
-12
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Feature",
3+
"description": "SageMaker: Disable the unsupported agentic commands and welcome prompt"
4+
}

packages/amazonq/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,7 @@
434434
},
435435
{
436436
"command": "aws.amazonq.generateUnitTests",
437+
"when": "!aws.isSageMaker",
437438
"group": "cw_chat@5"
438439
},
439440
{
@@ -469,6 +470,7 @@
469470
},
470471
{
471472
"command": "aws.amazonq.exploreAgents",
473+
"when": "!aws.isSageMaker",
472474
"group": "1_help@2"
473475
},
474476
{
@@ -523,7 +525,7 @@
523525
"command": "aws.amazonq.security.scan-statusbar",
524526
"title": "%AWS.command.amazonq.security.scan%",
525527
"category": "%AWS.amazonq.title%",
526-
"enablement": "aws.codewhisperer.connected"
528+
"enablement": "aws.codewhisperer.connected && !aws.isSageMaker"
527529
},
528530
{
529531
"command": "aws.amazonq.refactorCode",
@@ -553,7 +555,7 @@
553555
"command": "aws.amazonq.generateUnitTests",
554556
"title": "%AWS.command.amazonq.generateUnitTests%",
555557
"category": "%AWS.amazonq.title%",
556-
"enablement": "aws.codewhisperer.connected"
558+
"enablement": "aws.codewhisperer.connected && !aws.isSageMaker"
557559
},
558560
{
559561
"command": "aws.amazonq.reconnect",
@@ -757,7 +759,7 @@
757759
"command": "aws.amazonq.exploreAgents",
758760
"title": "%AWS.amazonq.exploreAgents%",
759761
"category": "%AWS.amazonq.title%",
760-
"enablement": "aws.codewhisperer.connected"
762+
"enablement": "aws.codewhisperer.connected && !aws.isSageMaker"
761763
},
762764
{
763765
"command": "aws.amazonq.walkthrough.show",

packages/amazonq/src/extension.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ export async function activateAmazonQCommon(context: vscode.ExtensionContext, is
147147
// Hide the Amazon Q tree in toolkit explorer
148148
await setContext('aws.toolkit.amazonq.dismissed', true)
149149

150+
// set context var to check if its SageMaker AI or not
151+
await setContext('aws.isSageMaker', isSageMaker())
152+
150153
// set context var to check if its SageMaker Unified Studio or not
151154
await setContext('aws.isSageMakerUnifiedStudio', isSageMaker('SMUS'))
152155

packages/core/src/amazonq/webview/generators/webViewContent.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,13 @@ export class WebViewContentGenerator {
7878

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

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

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

8889
return `
8990
<script type="text/javascript" src="${javascriptEntrypoint.toString()}" defer onload="init()"></script>
@@ -92,7 +93,7 @@ export class WebViewContentGenerator {
9293
const init = () => {
9394
createMynahUI(acquireVsCodeApi(), ${
9495
(await AuthUtil.instance.getChatAuthState()).amazonQ === 'connected'
95-
},${featureConfigsString},${welcomeLoadCount},${disclaimerAcknowledged},${disabledCommandsString},${isSMUS});
96+
},${featureConfigsString},${welcomeLoadCount},${disclaimerAcknowledged},${disabledCommandsString},${isSMUS},${isSM});
9697
}
9798
</script>
9899
`

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ export const createMynahUI = (
4949
welcomeCount: number,
5050
disclaimerAcknowledged: boolean,
5151
disabledCommands?: string[],
52-
isSMUS?: boolean
52+
isSMUS?: boolean,
53+
isSM?: boolean
5354
) => {
5455
let disclaimerCardActive = !disclaimerAcknowledged
5556
// eslint-disable-next-line prefer-const
@@ -84,7 +85,10 @@ export const createMynahUI = (
8485
})
8586

8687
const showWelcomePage = () => {
87-
return welcomeCount < welcomeCountThreshold
88+
/*
89+
* skip Agent Capability welcome page for SageMaker cases (SMAI and SMUS) since the commands are not supported
90+
*/
91+
return welcomeCount < welcomeCountThreshold && !isSM
8892
}
8993

9094
const updateWelcomeCount = () => {

packages/core/src/amazonq/webview/ui/tabs/constants.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ const qChatIntroMessage = `Hi, I'm Amazon Q. I can answer your software developm
1010
Ask me to explain, debug, or optimize your code.
1111
You can enter \`/\` to see a list of quick actions. Use \`@\` to add saved prompts, files, folders, or your entire workspace as context.`
1212

13+
/**
14+
* The below intro message is for SageMaker Unified Studio(SMUS) customers only.
15+
* With upcoming release of SMUS, only Q Free Tier is being supported hence the requirement to show this messaging to customers.
16+
* Once Pro Tier is supported with SMUS, the below message will be removed and is only added for the interim
17+
*/
1318
export const qChatIntroMessageForSMUS = `Hi, I'm Amazon Q. I can answer your software development questions.\n\
1419
Ask me to explain, debug, or optimize your code.\n\
1520
You can enter \`/\` to see a list of quick actions. Use \`@\` to add saved prompts, files, folders, or your entire workspace as context.

packages/core/src/auth/auth.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,3 +1115,13 @@ export function hasVendedIamCredentials(isC9?: boolean, isSM?: boolean) {
11151115
isSM ??= isSageMaker()
11161116
return isSM || isC9
11171117
}
1118+
1119+
/**
1120+
* 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)
1121+
* @param isSMUS boolean if SageMaker Unified Studio is host
1122+
* @returns boolean if SMUS
1123+
*/
1124+
export function hasVendedCredentialsFromMetadata(isSMUS?: boolean) {
1125+
isSMUS ??= isSageMaker('SMUS')
1126+
return isSMUS
1127+
}

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,14 @@ import {
2222
switchToAmazonQNode,
2323
createSecurityScan,
2424
} from './codeWhispererNodes'
25-
import { hasVendedIamCredentials } from '../../auth/auth'
25+
import { hasVendedIamCredentials, hasVendedCredentialsFromMetadata } from '../../auth/auth'
2626
import { AuthUtil } from '../util/authUtil'
2727
import { DataQuickPickItem, createQuickPick } from '../../shared/ui/pickerPrompter'
2828
import { CodeScansState, CodeSuggestionsState, vsCodeState } from '../models/model'
2929
import { Commands } from '../../shared/vscode/commands2'
3030
import { createExitButton } from '../../shared/ui/buttons'
3131
import { telemetry } from '../../shared/telemetry/telemetry'
3232
import { getLogger } from '../../shared/logger/logger'
33-
import { isSageMaker } from '../../shared/extensionUtilities'
3433

3534
function getAmazonQCodeWhispererNodes() {
3635
const autoTriggerEnabled = CodeSuggestionsState.instance.isSuggestionsEnabled()
@@ -93,7 +92,7 @@ export function getQuickPickItems(): DataQuickPickItem<string>[] {
9392
// Add settings and signout
9493
createSeparator(),
9594
createSettingsNode(),
96-
...(AuthUtil.instance.isConnected() && !(hasVendedIamCredentials() || isSageMaker('SMUS'))
95+
...(AuthUtil.instance.isConnected() && !hasVendedIamCredentials() && !hasVendedCredentialsFromMetadata()
9796
? [createSignout()]
9897
: []),
9998
]

packages/core/src/shared/extensionUtilities.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ export function isCloud9(flavor: 'classic' | 'codecatalyst' | 'any' = 'any'): bo
175175
* @param appName to identify the proper SM instance
176176
* @returns true if the current system is SageMaker(SMAI or SMUS)
177177
*/
178-
export function isSageMaker(appName: string = 'SMAI'): boolean {
178+
export function isSageMaker(appName: 'SMAI' | 'SMUS' = 'SMAI'): boolean {
179179
switch (appName) {
180180
case 'SMAI':
181181
return vscode.env.appName === sageMakerAppname

0 commit comments

Comments
 (0)