Skip to content

Commit 1b20a6c

Browse files
committed
Merge remote-tracking branch 'origin/master' into HEAD
2 parents 6b15e9e + 1f5f215 commit 1b20a6c

File tree

17 files changed

+192
-54
lines changed

17 files changed

+192
-54
lines changed

aws-toolkit-vscode.code-workspace

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
{
2-
"folders": [
3-
{
4-
"path": "."
5-
},
6-
{
7-
"path": "packages/toolkit"
8-
},
9-
{
10-
"path": "packages/core"
11-
},
12-
{
13-
"path": "packages/amazonq"
14-
}
15-
],
16-
"settings": {
17-
"typescript.tsdk": "node_modules/typescript/lib"
18-
}
19-
}
2+
"folders": [
3+
{
4+
"path": ".",
5+
},
6+
{
7+
"path": "packages/toolkit",
8+
},
9+
{
10+
"path": "packages/core",
11+
},
12+
{
13+
"path": "packages/amazonq",
14+
},
15+
],
16+
"settings": {
17+
"typescript.tsdk": "node_modules/typescript/lib",
18+
},
19+
}

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"date": "2025-04-18",
3+
"version": "1.60.0",
4+
"entries": [
5+
{
6+
"type": "Bug Fix",
7+
"description": "Users might be bound to a customization which they dont have access with the selected profile and it causes service throwing 403 when using inline suggestion and chat features"
8+
}
9+
]
10+
}

packages/amazonq/.changes/next-release/Bug Fix-a6e9ce99-842b-4d64-b9b0-967383d7acb9.json

Lines changed: 0 additions & 4 deletions
This file was deleted.
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/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.60.0 2025-04-18
2+
3+
- **Bug Fix** Users might be bound to a customization which they dont have access with the selected profile and it causes service throwing 403 when using inline suggestion and chat features
4+
15
## 1.59.0 2025-04-11
26

37
- **Bug Fix** Code fix line number or file is sometimes not accurate

packages/amazonq/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "amazon-q-vscode",
33
"displayName": "Amazon Q",
44
"description": "The most capable generative AI-powered assistant for building, operating, and transforming software, with advanced capabilities for managing data and AI",
5-
"version": "1.60.0-SNAPSHOT",
5+
"version": "1.61.0-SNAPSHOT",
66
"extensionKind": [
77
"workspace"
88
],

packages/amazonq/src/extension.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
import { AuthUtils, CredentialsStore, LoginManager, initializeAuth } from 'aws-core-vscode/auth'
6+
import { Auth, AuthUtils, CredentialsStore, LoginManager, initializeAuth } from 'aws-core-vscode/auth'
77
import { activate as activateCodeWhisperer, shutdown as shutdownCodeWhisperer } from 'aws-core-vscode/codewhisperer'
88
import { makeEndpointsProvider, registerGenericCommands } from 'aws-core-vscode'
99
import { CommonAuthWebview } from 'aws-core-vscode/login'
@@ -43,6 +43,7 @@ import { registerCommands } from './commands'
4343
import { focusAmazonQPanel } from 'aws-core-vscode/codewhispererChat'
4444
import { activate as activateAmazonqLsp } from './lsp/activation'
4545
import { activate as activateInlineCompletion } from './app/inline/activation'
46+
import { isAmazonInternalOs } from 'aws-core-vscode/shared'
4647

4748
export const amazonQContextPrefix = 'amazonq'
4849

@@ -119,10 +120,13 @@ export async function activateAmazonQCommon(context: vscode.ExtensionContext, is
119120
}
120121
// This contains every lsp agnostic things (auth, security scan, code scan)
121122
await activateCodeWhisperer(extContext as ExtContext)
122-
if (Experiments.instance.get('amazonqLSP', true)) {
123+
if (
124+
(Experiments.instance.get('amazonqLSP', true) || Auth.instance.isInternalAmazonUser()) &&
125+
!isAmazonInternalOs()
126+
) {
127+
// start the Amazon Q LSP for internal users first
123128
await activateAmazonqLsp(context)
124129
}
125-
126130
if (!Experiments.instance.get('amazonqLSPInline', false)) {
127131
await activateInlineCompletion()
128132
}

packages/amazonq/src/lsp/client.ts

Lines changed: 94 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,30 @@
66
import vscode, { env, version } from 'vscode'
77
import * as nls from 'vscode-nls'
88
import * as crypto from 'crypto'
9-
import { LanguageClient, LanguageClientOptions } from 'vscode-languageclient'
9+
import { LanguageClient, LanguageClientOptions, RequestType } from 'vscode-languageclient'
1010
import { InlineCompletionManager } from '../app/inline/completion'
1111
import { AmazonQLspAuth, encryptionKey, notificationTypes } from './auth'
1212
import { AuthUtil } from 'aws-core-vscode/codewhisperer'
13-
import { ConnectionMetadata } from '@aws/language-server-runtimes/protocol'
13+
import {
14+
ConnectionMetadata,
15+
CreateFilesParams,
16+
DeleteFilesParams,
17+
DidChangeWorkspaceFoldersParams,
18+
DidSaveTextDocumentParams,
19+
GetConfigurationFromServerParams,
20+
RenameFilesParams,
21+
ResponseMessage,
22+
updateConfigurationRequestType,
23+
WorkspaceFolder,
24+
} from '@aws/language-server-runtimes/protocol'
1425
import {
1526
Settings,
1627
oidcClientName,
1728
createServerOptions,
1829
globals,
1930
Experiments,
2031
Commands,
32+
oneSecond,
2133
validateNodeExe,
2234
getLogger,
2335
} from 'aws-core-vscode/shared'
@@ -79,6 +91,9 @@ export async function startLanguageServer(
7991
notifications: true,
8092
showSaveFileDialog: true,
8193
},
94+
q: {
95+
developerProfiles: true,
96+
},
8297
},
8398
},
8499
credentials: {
@@ -138,7 +153,27 @@ export async function startLanguageServer(
138153
await activate(client, encryptionKey, resourcePaths.ui)
139154
}
140155

141-
const refreshInterval = auth.startTokenRefreshInterval()
156+
const refreshInterval = auth.startTokenRefreshInterval(10 * oneSecond)
157+
158+
const sendProfileToLsp = async () => {
159+
try {
160+
const result = await client.sendRequest(updateConfigurationRequestType.method, {
161+
section: 'aws.q',
162+
settings: {
163+
profileArn: AuthUtil.instance.regionProfileManager.activeRegionProfile?.arn,
164+
},
165+
})
166+
client.info(
167+
`Client: Updated Amazon Q Profile ${AuthUtil.instance.regionProfileManager.activeRegionProfile?.arn} to Amazon Q LSP`,
168+
result
169+
)
170+
} catch (err) {
171+
client.error('Error when setting Q Developer Profile to Amazon Q LSP', err)
172+
}
173+
}
174+
175+
// send profile to lsp once.
176+
void sendProfileToLsp()
142177

143178
toDispose.push(
144179
AuthUtil.instance.auth.onDidChangeActiveConnection(async () => {
@@ -147,6 +182,62 @@ export async function startLanguageServer(
147182
AuthUtil.instance.auth.onDidDeleteConnection(async () => {
148183
client.sendNotification(notificationTypes.deleteBearerToken.method)
149184
}),
185+
AuthUtil.instance.regionProfileManager.onDidChangeRegionProfile(sendProfileToLsp),
186+
vscode.commands.registerCommand('aws.amazonq.getWorkspaceId', async () => {
187+
const requestType = new RequestType<GetConfigurationFromServerParams, ResponseMessage, Error>(
188+
'aws/getConfigurationFromServer'
189+
)
190+
const workspaceIdResp = await client.sendRequest(requestType.method, {
191+
section: 'aws.q.workspaceContext',
192+
})
193+
return workspaceIdResp
194+
}),
195+
vscode.workspace.onDidCreateFiles((e) => {
196+
client.sendNotification('workspace/didCreateFiles', {
197+
files: e.files.map((it) => {
198+
return { uri: it.fsPath }
199+
}),
200+
} as CreateFilesParams)
201+
}),
202+
vscode.workspace.onDidDeleteFiles((e) => {
203+
client.sendNotification('workspace/didDeleteFiles', {
204+
files: e.files.map((it) => {
205+
return { uri: it.fsPath }
206+
}),
207+
} as DeleteFilesParams)
208+
}),
209+
vscode.workspace.onDidRenameFiles((e) => {
210+
client.sendNotification('workspace/didRenameFiles', {
211+
files: e.files.map((it) => {
212+
return { oldUri: it.oldUri.fsPath, newUri: it.newUri.fsPath }
213+
}),
214+
} as RenameFilesParams)
215+
}),
216+
vscode.workspace.onDidSaveTextDocument((e) => {
217+
client.sendNotification('workspace/didSaveTextDocument', {
218+
textDocument: {
219+
uri: e.uri.fsPath,
220+
},
221+
} as DidSaveTextDocumentParams)
222+
}),
223+
vscode.workspace.onDidChangeWorkspaceFolders((e) => {
224+
client.sendNotification('workspace/didChangeWorkspaceFolder', {
225+
event: {
226+
added: e.added.map((it) => {
227+
return {
228+
name: it.name,
229+
uri: it.uri.fsPath,
230+
} as WorkspaceFolder
231+
}),
232+
removed: e.removed.map((it) => {
233+
return {
234+
name: it.name,
235+
uri: it.uri.fsPath,
236+
} as WorkspaceFolder
237+
}),
238+
},
239+
} as DidChangeWorkspaceFoldersParams)
240+
}),
150241
{ dispose: () => clearInterval(refreshInterval) }
151242
)
152243
})

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 () {

0 commit comments

Comments
 (0)