Skip to content

Commit 0bbefa4

Browse files
authored
Merge pull request aws#7092 from aws/autoMerge/feature/hybridChat
Merge master into feature/hybridChat
2 parents 6b15e9e + f1ced5a commit 0bbefa4

File tree

17 files changed

+189
-54
lines changed

17 files changed

+189
-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: 91 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'
@@ -138,7 +150,27 @@ export async function startLanguageServer(
138150
await activate(client, encryptionKey, resourcePaths.ui)
139151
}
140152

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

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

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)