Skip to content

Commit c4edcd6

Browse files
committed
Merge remote-tracking branch 'upstream/master' into custom
2 parents 22ad0ce + 7afbc71 commit c4edcd6

File tree

6 files changed

+43
-25
lines changed

6 files changed

+43
-25
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "bugfix",
3+
"description": "/review: disable auto-review by default"
4+
}

packages/amazonq/src/extensionNode.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ async function getAuthState(): Promise<Omit<AuthUserState, 'source'>> {
112112
getLogger().error(`Current Amazon Q connection is not SSO, type is: %s`, currConn?.type)
113113
}
114114

115+
// Pending profile selection state means users already log in with Sso service
116+
if (authState === 'pendingProfileSelection') {
117+
authState = 'connected'
118+
}
119+
115120
return {
116121
authStatus:
117122
authState === 'connected' || authState === 'expired' || authState === 'connectedWithNetworkError'

packages/amazonq/src/lsp/chat/messages.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,17 @@ export function registerMessageListeners(
295295
languageClient.onRequest<ShowDocumentParams, ShowDocumentResult>(
296296
ShowDocumentRequest.method,
297297
async (params: ShowDocumentParams): Promise<ShowDocumentParams | ResponseError<ShowDocumentResult>> => {
298-
const uri = vscode.Uri.parse(params.uri)
299-
const doc = await vscode.workspace.openTextDocument(uri)
300-
await vscode.window.showTextDocument(doc, { preview: false })
301-
return params
298+
try {
299+
const uri = vscode.Uri.parse(params.uri)
300+
const doc = await vscode.workspace.openTextDocument(uri)
301+
await vscode.window.showTextDocument(doc, { preview: false })
302+
return params
303+
} catch (e) {
304+
return new ResponseError(
305+
LSPErrorCodes.RequestFailed,
306+
`Failed to open document: ${(e as Error).message}`
307+
)
308+
}
302309
}
303310
)
304311

packages/amazonq/test/unit/codewhisperer/service/securityScanHandler.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
pollScanJobStatus,
1717
SecurityScanTimedOutError,
1818
CodeWhispererConstants,
19+
CodeScansState,
1920
} from 'aws-core-vscode/codewhisperer'
2021
import { timeoutUtils } from 'aws-core-vscode/shared'
2122
import assert from 'assert'
@@ -281,6 +282,7 @@ describe('securityScanHandler', function () {
281282
shouldAdvanceTime: true,
282283
})
283284
sinon.stub(timeoutUtils, 'sleep').resolves()
285+
sinon.stub(CodeScansState.instance, 'isScansEnabled').returns(true)
284286
})
285287

286288
afterEach(function () {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ export class CodeScansState {
280280
return (this.#instance ??= new this())
281281
}
282282

283-
protected constructor(fallback: boolean = true) {
283+
protected constructor(fallback: boolean = false) {
284284
this.#fallback = fallback
285285
}
286286

packages/core/src/test/codewhisperer/commands/basicCommands.test.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -193,36 +193,36 @@ describe('CodeWhisperer-basicCommands', function () {
193193
codeScansState = new TestCodeScansState()
194194
})
195195

196-
it('has auto scans enabled by default', async function () {
196+
it('has auto scans disabled by default', async function () {
197197
targetCommand = testCommand(toggleCodeScans, codeScansState)
198-
assert.strictEqual(codeScansState.isScansEnabled(), true)
198+
assert.strictEqual(codeScansState.isScansEnabled(), false)
199199
})
200200

201201
it('toggles states as expected', async function () {
202202
targetCommand = testCommand(toggleCodeScans, codeScansState)
203-
assert.strictEqual(codeScansState.isScansEnabled(), true)
204-
await targetCommand.execute(placeholder, cwQuickPickSource)
205203
assert.strictEqual(codeScansState.isScansEnabled(), false)
206204
await targetCommand.execute(placeholder, cwQuickPickSource)
207205
assert.strictEqual(codeScansState.isScansEnabled(), true)
208206
await targetCommand.execute(placeholder, cwQuickPickSource)
209207
assert.strictEqual(codeScansState.isScansEnabled(), false)
208+
await targetCommand.execute(placeholder, cwQuickPickSource)
209+
assert.strictEqual(codeScansState.isScansEnabled(), true)
210210
})
211211

212212
it('setScansEnabled() works as expected', async function () {
213-
// initially true
214-
assert.strictEqual(codeScansState.isScansEnabled(), true)
215-
216-
await codeScansState.setScansEnabled(false)
213+
// initially false
217214
assert.strictEqual(codeScansState.isScansEnabled(), false)
218215

219-
// set new state to current state
220-
await codeScansState.setScansEnabled(false)
221-
assert.strictEqual(codeScansState.isScansEnabled(), false)
216+
await codeScansState.setScansEnabled(true)
217+
assert.strictEqual(codeScansState.isScansEnabled(), true)
222218

223-
// set to opposite state
219+
// set new state to current state
224220
await codeScansState.setScansEnabled(true)
225221
assert.strictEqual(codeScansState.isScansEnabled(), true)
222+
223+
// set to opposite state
224+
await codeScansState.setScansEnabled(false)
225+
assert.strictEqual(codeScansState.isScansEnabled(), false)
226226
})
227227

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

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

246-
assert.strictEqual(codeScansState.isScansEnabled(), false)
246+
assert.strictEqual(codeScansState.isScansEnabled(), true)
247247
assertTelemetryCurried('aws_modifySetting')({
248248
settingId: CodeWhispererConstants.autoScansConfig.settingId,
249-
settingState: CodeWhispererConstants.autoScansConfig.deactivated,
249+
settingState: CodeWhispererConstants.autoScansConfig.activated,
250250
})
251251
})
252252

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

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

260-
assert.strictEqual(codeScansState.isScansEnabled(), true)
260+
assert.strictEqual(codeScansState.isScansEnabled(), false)
261261
assertTelemetryCurried('aws_modifySetting')({
262262
settingId: CodeWhispererConstants.autoScansConfig.settingId,
263-
settingState: CodeWhispererConstants.autoScansConfig.activated,
263+
settingState: CodeWhispererConstants.autoScansConfig.deactivated,
264264
})
265265
})
266266

0 commit comments

Comments
 (0)