Skip to content

Commit 5c7b029

Browse files
aws-toolkit-automationleigaoljpinkney-awszuoyaofuzixlin7
authored
Merge master into feature/amazonqLSP-auth (#7221)
## Automatic merge failed - Resolve conflicts and push to this PR branch. - **Do not squash-merge** this PR. Use the "Create a merge commit" option to do a regular merge. ## Command line hint To perform the merge from the command line, you could do something like the following (where "origin" is the name of the remote in your local git repo): ``` git stash git fetch --all git checkout origin/feature/amazonqLSP-auth git merge origin/master git commit git push origin HEAD:refs/heads/autoMerge/feature/amazonqLSP-auth ``` --------- Co-authored-by: Lei Gao <[email protected]> Co-authored-by: Josh Pinkney <[email protected]> Co-authored-by: aws-toolkit-automation <> Co-authored-by: zuoyaofu <[email protected]> Co-authored-by: Zoe Lin <[email protected]> Co-authored-by: opieter-aws <[email protected]>
1 parent e08eb59 commit 5c7b029

File tree

19 files changed

+198
-55
lines changed

19 files changed

+198
-55
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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import { registerCommands } from './commands'
4444
import { focusAmazonQPanel } from 'aws-core-vscode/codewhispererChat'
4545
import { activate as activateAmazonqLsp } from './lsp/activation'
4646
import { activate as activateInlineCompletion } from './app/inline/activation'
47+
import { isAmazonInternalOs } from 'aws-core-vscode/shared'
4748

4849
export const amazonQContextPrefix = 'amazonq'
4950

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/src/lsp/client.ts

Lines changed: 93 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,20 @@ import vscode, { env, version } from 'vscode'
77
import * as nls from 'vscode-nls'
88
import * as crypto from 'crypto'
99
import * as jose from 'jose'
10-
import { LanguageClient, LanguageClientOptions } from 'vscode-languageclient'
10+
import { LanguageClient, LanguageClientOptions, RequestType } from 'vscode-languageclient'
1111
import { InlineCompletionManager } from '../app/inline/completion'
1212
import { AuthUtil } from 'aws-core-vscode/codewhisperer'
1313
import {
1414
ConnectionMetadata,
15+
CreateFilesParams,
16+
DeleteFilesParams,
17+
DidChangeWorkspaceFoldersParams,
18+
DidSaveTextDocumentParams,
19+
GetConfigurationFromServerParams,
20+
RenameFilesParams,
21+
ResponseMessage,
22+
updateConfigurationRequestType,
23+
WorkspaceFolder,
1524
GetSsoTokenProgress,
1625
GetSsoTokenProgressToken,
1726
GetSsoTokenProgressType,
@@ -90,6 +99,9 @@ export async function startLanguageServer(
9099
window: {
91100
notifications: true,
92101
},
102+
q: {
103+
developerProfiles: true,
104+
},
93105
},
94106
},
95107
credentials: {
@@ -162,6 +174,26 @@ export async function startLanguageServer(
162174
return
163175
}
164176

177+
const sendProfileToLsp = async () => {
178+
try {
179+
const result = await client.sendRequest(updateConfigurationRequestType.method, {
180+
section: 'aws.q',
181+
settings: {
182+
profileArn: AuthUtil.instance.regionProfileManager.activeRegionProfile?.arn,
183+
},
184+
})
185+
client.info(
186+
`Client: Updated Amazon Q Profile ${AuthUtil.instance.regionProfileManager.activeRegionProfile?.arn} to Amazon Q LSP`,
187+
result
188+
)
189+
} catch (err) {
190+
client.error('Error when setting Q Developer Profile to Amazon Q LSP', err)
191+
}
192+
}
193+
194+
// send profile to lsp once.
195+
void sendProfileToLsp()
196+
165197
void vscode.window.withProgress(
166198
{
167199
cancellable: true,
@@ -182,9 +214,69 @@ export async function startLanguageServer(
182214
Commands.register({ id: 'aws.amazonq.invokeInlineCompletion', autoconnect: true }, async () => {
183215
await vscode.commands.executeCommand('editor.action.inlineSuggest.trigger')
184216
}),
217+
218+
AuthUtil.instance.regionProfileManager.onDidChangeRegionProfile(sendProfileToLsp),
219+
vscode.commands.registerCommand('aws.amazonq.getWorkspaceId', async () => {
220+
const requestType = new RequestType<GetConfigurationFromServerParams, ResponseMessage, Error>(
221+
'aws/getConfigurationFromServer'
222+
)
223+
const workspaceIdResp = await client.sendRequest(requestType.method, {
224+
section: 'aws.q.workspaceContext',
225+
})
226+
return workspaceIdResp
227+
}),
228+
vscode.workspace.onDidCreateFiles((e) => {
229+
client.sendNotification('workspace/didCreateFiles', {
230+
files: e.files.map((it) => {
231+
return { uri: it.fsPath }
232+
}),
233+
} as CreateFilesParams)
234+
}),
235+
vscode.workspace.onDidDeleteFiles((e) => {
236+
client.sendNotification('workspace/didDeleteFiles', {
237+
files: e.files.map((it) => {
238+
return { uri: it.fsPath }
239+
}),
240+
} as DeleteFilesParams)
241+
}),
242+
vscode.workspace.onDidRenameFiles((e) => {
243+
client.sendNotification('workspace/didRenameFiles', {
244+
files: e.files.map((it) => {
245+
return { oldUri: it.oldUri.fsPath, newUri: it.newUri.fsPath }
246+
}),
247+
} as RenameFilesParams)
248+
}),
249+
vscode.workspace.onDidSaveTextDocument((e) => {
250+
client.sendNotification('workspace/didSaveTextDocument', {
251+
textDocument: {
252+
uri: e.uri.fsPath,
253+
},
254+
} as DidSaveTextDocumentParams)
255+
}),
256+
vscode.workspace.onDidChangeWorkspaceFolders((e) => {
257+
client.sendNotification('workspace/didChangeWorkspaceFolder', {
258+
event: {
259+
added: e.added.map((it) => {
260+
return {
261+
name: it.name,
262+
uri: it.uri.fsPath,
263+
} as WorkspaceFolder
264+
}),
265+
removed: e.removed.map((it) => {
266+
return {
267+
name: it.name,
268+
uri: it.uri.fsPath,
269+
} as WorkspaceFolder
270+
}),
271+
},
272+
} as DidChangeWorkspaceFoldersParams)
273+
}),
274+
{ dispose: () => clearInterval(refreshInterval) }
275+
185276
vscode.workspace.onDidCloseTextDocument(async () => {
186277
await vscode.commands.executeCommand('aws.amazonq.rejectCodeSuggestion')
187278
})
279+
188280
)
189281
}
190282

0 commit comments

Comments
 (0)