Skip to content

config(amazonq): disable auto-review by default #7058

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 19, 2025
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": "bugfix",
"description": "/review: disable auto-review by default"
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
pollScanJobStatus,
SecurityScanTimedOutError,
CodeWhispererConstants,
CodeScansState,
} from 'aws-core-vscode/codewhisperer'
import { timeoutUtils } from 'aws-core-vscode/shared'
import assert from 'assert'
Expand Down Expand Up @@ -281,6 +282,7 @@ describe('securityScanHandler', function () {
shouldAdvanceTime: true,
})
sinon.stub(timeoutUtils, 'sleep').resolves()
sinon.stub(CodeScansState.instance, 'isScansEnabled').returns(true)
})

afterEach(function () {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/codewhisperer/models/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ export class CodeScansState {
return (this.#instance ??= new this())
}

protected constructor(fallback: boolean = true) {
protected constructor(fallback: boolean = false) {
this.#fallback = fallback
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,36 +193,36 @@ describe('CodeWhisperer-basicCommands', function () {
codeScansState = new TestCodeScansState()
})

it('has auto scans enabled by default', async function () {
it('has auto scans disabled by default', async function () {
targetCommand = testCommand(toggleCodeScans, codeScansState)
assert.strictEqual(codeScansState.isScansEnabled(), true)
assert.strictEqual(codeScansState.isScansEnabled(), false)
})

it('toggles states as expected', async function () {
targetCommand = testCommand(toggleCodeScans, codeScansState)
assert.strictEqual(codeScansState.isScansEnabled(), true)
await targetCommand.execute(placeholder, cwQuickPickSource)
assert.strictEqual(codeScansState.isScansEnabled(), false)
await targetCommand.execute(placeholder, cwQuickPickSource)
assert.strictEqual(codeScansState.isScansEnabled(), true)
await targetCommand.execute(placeholder, cwQuickPickSource)
assert.strictEqual(codeScansState.isScansEnabled(), false)
await targetCommand.execute(placeholder, cwQuickPickSource)
assert.strictEqual(codeScansState.isScansEnabled(), true)
})

it('setScansEnabled() works as expected', async function () {
// initially true
assert.strictEqual(codeScansState.isScansEnabled(), true)

await codeScansState.setScansEnabled(false)
// initially false
assert.strictEqual(codeScansState.isScansEnabled(), false)

// set new state to current state
await codeScansState.setScansEnabled(false)
assert.strictEqual(codeScansState.isScansEnabled(), false)
await codeScansState.setScansEnabled(true)
assert.strictEqual(codeScansState.isScansEnabled(), true)

// set to opposite state
// set new state to current state
await codeScansState.setScansEnabled(true)
assert.strictEqual(codeScansState.isScansEnabled(), true)

// set to opposite state
await codeScansState.setScansEnabled(false)
assert.strictEqual(codeScansState.isScansEnabled(), false)
})

it('triggers event listener when toggled', async function () {
Expand All @@ -239,28 +239,28 @@ describe('CodeWhisperer-basicCommands', function () {
assert.strictEqual(eventListener.callCount, 1)
})

it('emits aws_modifySetting event on user toggling autoScans - deactivate', async function () {
it('emits aws_modifySetting event on user toggling autoScans - activate', async function () {
targetCommand = testCommand(toggleCodeScans, codeScansState)
await targetCommand.execute(placeholder, cwQuickPickSource)

assert.strictEqual(codeScansState.isScansEnabled(), false)
assert.strictEqual(codeScansState.isScansEnabled(), true)
assertTelemetryCurried('aws_modifySetting')({
settingId: CodeWhispererConstants.autoScansConfig.settingId,
settingState: CodeWhispererConstants.autoScansConfig.deactivated,
settingState: CodeWhispererConstants.autoScansConfig.activated,
})
})

it('emits aws_modifySetting event on user toggling autoScans -- activate', async function () {
codeScansState = new TestCodeScansState(false)
assert.strictEqual(codeScansState.isScansEnabled(), false)
it('emits aws_modifySetting event on user toggling autoScans -- deactivate', async function () {
codeScansState = new TestCodeScansState(true)
assert.strictEqual(codeScansState.isScansEnabled(), true)

targetCommand = testCommand(toggleCodeScans, codeScansState)
await targetCommand.execute(placeholder, cwQuickPickSource)

assert.strictEqual(codeScansState.isScansEnabled(), true)
assert.strictEqual(codeScansState.isScansEnabled(), false)
assertTelemetryCurried('aws_modifySetting')({
settingId: CodeWhispererConstants.autoScansConfig.settingId,
settingState: CodeWhispererConstants.autoScansConfig.activated,
settingState: CodeWhispererConstants.autoScansConfig.deactivated,
})
})

Expand Down
Loading