Skip to content

Commit c2d3251

Browse files
authored
feat(q-proactive-scan): remove file scans for Builder Id, add timeout limits aws#4712
Problem Change Timeout limits for project scan and File scans. No Auto Scan status bar options for Free Users(BuilderId) and no file scans enabled for Builder Id users. Solution Added Timeout Limits for Project and File Scans. Disabled File scan for BuilderID users. Removed status bar Code scan toggle option for Builder Id Users.
1 parent 8e0e8bb commit c2d3251

File tree

4 files changed

+35
-3
lines changed

4 files changed

+35
-3
lines changed

packages/core/src/codewhisperer/activation.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,12 +282,16 @@ export async function activate(context: ExtContext): Promise<void> {
282282
if (auth.isValidEnterpriseSsoInUse()) {
283283
await notifyNewCustomizations()
284284
}
285+
if (auth.isBuilderIdInUse()) {
286+
await CodeScansState.instance.setScansEnabled(false)
287+
}
285288

286289
function setSubscriptionsForAutoScans() {
287290
// Initial scan when the editor opens for the first time
288291
const editor = vscode.window.activeTextEditor
289292
if (
290293
CodeScansState.instance.isScansEnabled() &&
294+
!auth.isBuilderIdInUse() &&
291295
editor &&
292296
securityScanLanguageContext.isLanguageSupported(editor.document.languageId) &&
293297
editor.document.getText().length > 0
@@ -306,6 +310,7 @@ export async function activate(context: ExtContext): Promise<void> {
306310
vscode.window.onDidChangeActiveTextEditor(editor => {
307311
if (
308312
CodeScansState.instance.isScansEnabled() &&
313+
!auth.isBuilderIdInUse() &&
309314
editor &&
310315
securityScanLanguageContext.isLanguageSupported(editor.document.languageId)
311316
) {
@@ -334,6 +339,7 @@ export async function activate(context: ExtContext): Promise<void> {
334339
const editor = vscode.window.activeTextEditor
335340
if (
336341
CodeScansState.instance.isScansEnabled() &&
342+
!auth.isBuilderIdInUse() &&
337343
editor &&
338344
event.document === editor.document &&
339345
securityScanLanguageContext.isLanguageSupported(editor.document.languageId) &&
@@ -355,6 +361,7 @@ export async function activate(context: ExtContext): Promise<void> {
355361
const editor = vscode.window.activeTextEditor
356362
if (
357363
isScansEnabled &&
364+
!auth.isBuilderIdInUse() &&
358365
editor &&
359366
securityScanLanguageContext.isLanguageSupported(editor.document.languageId) &&
360367
editor.document.getText().length > 0

packages/core/src/codewhisperer/models/constants.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,9 @@ export const codeScanZipExt = '.zip'
233233

234234
export const contextTruncationTimeoutSeconds = 10
235235

236-
export const codeScanJobTimeoutSeconds = 50
236+
export const codeScanJobTimeoutSeconds = 60 * 10 //10 minutes
237+
238+
export const codeFileScanJobTimeoutSeconds = 60 //1 minute
237239

238240
export const projectSizeCalculateTimeoutSeconds = 10
239241

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,11 @@ export async function pollScanJobStatus(
123123
throwIfCancelled(scope)
124124
await sleep(CodeWhispererConstants.codeScanJobPollingIntervalSeconds * 1000)
125125
timer += CodeWhispererConstants.codeScanJobPollingIntervalSeconds
126-
if (timer > CodeWhispererConstants.codeScanJobTimeoutSeconds) {
126+
const timeoutSeconds =
127+
scope === CodeWhispererConstants.CodeAnalysisScope.FILE
128+
? CodeWhispererConstants.codeFileScanJobTimeoutSeconds
129+
: CodeWhispererConstants.codeScanJobTimeoutSeconds
130+
if (timer > timeoutSeconds) {
127131
getLogger().verbose(`Scan job status: ${status}`)
128132
getLogger().verbose(`Scan job timeout.`)
129133
throw new Error('Scan job timeout.')

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

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ function getAmazonQCodeWhispererNodes() {
5151
createFreeTierLimitMet('item'),
5252
createOpenReferenceLog(),
5353
createSeparator('Other Features'),
54-
createAutoScans(autoScansEnabled),
5554
createSecurityScan(),
5655
]
5756
}
@@ -66,6 +65,26 @@ function getAmazonQCodeWhispererNodes() {
6665
amazonq = require('../../amazonq/explorer/amazonQChildrenNodes')
6766
}
6867

68+
if (AuthUtil.instance.isBuilderIdInUse()) {
69+
return [
70+
// CodeWhisperer
71+
createSeparator('Inline Suggestions'),
72+
createAutoSuggestions(autoTriggerEnabled),
73+
...(AuthUtil.instance.isValidEnterpriseSsoInUse() && AuthUtil.instance.isCustomizationFeatureEnabled
74+
? [createSelectCustomization()]
75+
: []),
76+
createOpenReferenceLog(),
77+
createGettingStarted(), // "Learn" node : opens Learn CodeWhisperer page
78+
79+
// Security scans
80+
createSeparator('Security Scans'),
81+
createSecurityScan(),
82+
83+
// Amazon Q + others
84+
createSeparator('Other Features'),
85+
...(amazonq ? [amazonq.switchToAmazonQNode('item')] : []),
86+
]
87+
}
6988
return [
7089
// CodeWhisperer
7190
createSeparator('Inline Suggestions'),

0 commit comments

Comments
 (0)