Skip to content

Commit

Permalink
Merge branch 'master' into appComposer/raceConditionFix
Browse files Browse the repository at this point in the history
  • Loading branch information
Hweinstock committed Nov 8, 2024
2 parents 6566d24 + 8113288 commit e196f02
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "Breaking Change",
"description": "Change focus chat keybind to win+alt+i on Windows, cmd+alt+i on macOS, and meta+alt+i on Linux"
}
6 changes: 3 additions & 3 deletions packages/amazonq/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -609,9 +609,9 @@
"keybindings": [
{
"command": "_aws.amazonq.focusChat.keybinding",
"win": "ctrl+win+i",
"mac": "ctrl+cmd+i",
"linux": "ctrl+meta+i"
"win": "win+alt+i",
"mac": "cmd+alt+i",
"linux": "meta+alt+i"
},
{
"command": "aws.amazonq.explainCode",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ export class InlineChatController {
}
}
if (chatEvent.error) {
getLogger().error('generateAssistantResponse stream error: %s', chatEvent.error)
await this.rejectAllChanges(this.task, false)
void vscode.window.showErrorMessage(`Amazon Q: ${chatEvent.error.message}`)
await this.updateTaskAndLenses(this.task, TaskState.Complete)
Expand Down
5 changes: 4 additions & 1 deletion packages/core/src/awsService/ec2/activation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ export async function activate(ctx: ExtContext): Promise<void> {
}),

Commands.register('aws.ec2.openRemoteConnection', async (node?: Ec2Node) => {
await openRemoteConnection(connectionManagers, node)
await telemetry.ec2_connectToInstance.run(async (span) => {
span.record({ ec2ConnectionType: 'remoteWorkspace' })
await openRemoteConnection(connectionManagers, node)
})
}),

Commands.register('aws.ec2.startInstance', async (node?: Ec2Node) => {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/awsService/ec2/sshKeyPair.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export class SshKeyPair {
}
return !(await tryRun('ssh-keygen', ['-t', keyType, '-N', '', '-q', '-f', keyPath], 'yes', 'unknown key type', {
onStdout: overrideKeys,
timeout: new Timeout(5000),
}))
}

Expand Down
48 changes: 48 additions & 0 deletions packages/core/src/test/awsService/ec2/activation.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*!
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
import * as vscode from 'vscode'
import * as sinon from 'sinon'
import { assertTelemetry } from '../../testUtil'
import { Ec2InstanceNode } from '../../../awsService/ec2/explorer/ec2InstanceNode'
import { Ec2ParentNode } from '../../../awsService/ec2/explorer/ec2ParentNode'
import { Ec2Client } from '../../../shared/clients/ec2Client'
import { Ec2Connecter } from '../../../awsService/ec2/model'
import { PollingSet } from '../../../shared/utilities/pollingSet'

describe('ec2 activation', function () {
let testNode: Ec2InstanceNode

before(function () {
const testRegion = 'test-region'
const testPartition = 'test-partition'
// Don't want to be polling here, that is tested in ../ec2ParentNode.test.ts
// disabled here for convenience (avoiding race conditions with timeout)
sinon.stub(PollingSet.prototype, 'start')
const testClient = new Ec2Client(testRegion)
const parentNode = new Ec2ParentNode(testRegion, testPartition, new Ec2Client(testRegion))
testNode = new Ec2InstanceNode(parentNode, testClient, testRegion, testPartition, {
InstanceId: 'testId',
LastSeenStatus: 'status',
})
})

after(function () {
sinon.restore()
})

it('telemetry', async function () {
const terminalStub = sinon.stub(Ec2Connecter.prototype, 'attemptToOpenEc2Terminal')
await vscode.commands.executeCommand('aws.ec2.openTerminal', testNode)

assertTelemetry('ec2_connectToInstance', { ec2ConnectionType: 'ssm' })
terminalStub.restore()

const stopInstanceStub = sinon.stub(Ec2Client.prototype, 'stopInstanceWithCancel')
await vscode.commands.executeCommand('aws.ec2.stopInstance', testNode)

assertTelemetry('ec2_changeState', { ec2InstanceState: 'stop' })
stopInstanceStub.restore()
})
})

0 comments on commit e196f02

Please sign in to comment.