Skip to content

Commit 3404981

Browse files
committed
Merge branch 'feature/hybridChat' into feature/agentic-chat-beta
2 parents 15b7766 + db673c9 commit 3404981

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1148
-271
lines changed

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"date": "2025-04-25",
3+
"version": "1.62.0",
4+
"entries": [
5+
{
6+
"type": "Bug Fix",
7+
"description": "Toast message to warn users if Developer Profile is not selected"
8+
},
9+
{
10+
"type": "Bug Fix",
11+
"description": "Fix users can not log in successfully with 2+ IDE instnaces open due to throttle error throw by the service"
12+
}
13+
]
14+
}

packages/amazonq/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 1.62.0 2025-04-25
2+
3+
- **Bug Fix** Toast message to warn users if Developer Profile is not selected
4+
- **Bug Fix** Fix users can not log in successfully with 2+ IDE instnaces open due to throttle error throw by the service
5+
16
## 1.61.0 2025-04-22
27

38
- **Bug Fix** Some users not signaled they needed to select a Region Profile to get features working

packages/amazonq/package.json

Lines changed: 24 additions & 2 deletions
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": "2.0.0-SNAPSHOT",
5+
"version": "2.0.1-SNAPSHOT",
66
"extensionKind": [
77
"workspace"
88
],
@@ -135,6 +135,10 @@
135135
"amazonQChatPairProgramming": {
136136
"type": "boolean",
137137
"default": false
138+
},
139+
"amazonQSelectDeveloperProfile": {
140+
"type": "boolean",
141+
"default": false
138142
}
139143
},
140144
"additionalProperties": false
@@ -181,7 +185,25 @@
181185
"amazonQ.workspaceIndexMaxSize": {
182186
"type": "number",
183187
"markdownDescription": "%AWS.configuration.description.amazonq.workspaceIndexMaxSize%",
184-
"default": 250,
188+
"default": 2048,
189+
"scope": "application"
190+
},
191+
"amazonQ.workspaceIndexMaxFileSize": {
192+
"type": "number",
193+
"markdownDescription": "%AWS.configuration.description.amazonq.workspaceIndexMaxFileSize%",
194+
"default": 10,
195+
"scope": "application"
196+
},
197+
"amazonQ.workspaceIndexCacheDirPath": {
198+
"type": "string",
199+
"markdownDescription": "%AWS.configuration.description.amazonq.workspaceIndexCacheDirPath%",
200+
"default": null,
201+
"scope": "application"
202+
},
203+
"amazonQ.workspaceIndexIgnoreFilePatterns": {
204+
"type": "array",
205+
"markdownDescription": "%AWS.configuration.description.amazonq.workspaceIndexIgnoreFilePatterns%",
206+
"default": [],
185207
"scope": "application"
186208
},
187209
"amazonQ.ignoredSecurityIssues": {

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

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ export async function activate(languageClient: LanguageClient, encryptionKey: Bu
8585
type: 'customization',
8686
customization: undefinedIfEmpty(getSelectedCustomization().arn),
8787
})
88+
}),
89+
globals.logOutputChannel.onDidChangeLogLevel((logLevel) => {
90+
getLogger('amazonqLsp').info(`Local log level changed to ${logLevel}, notifying LSP`)
91+
void pushConfigUpdate(languageClient, {
92+
type: 'logLevel',
93+
})
8894
})
8995
)
9096
}
@@ -98,16 +104,24 @@ export async function activate(languageClient: LanguageClient, encryptionKey: Bu
98104
* push the given config.
99105
*/
100106
async function pushConfigUpdate(client: LanguageClient, config: QConfigs) {
101-
if (config.type === 'profile') {
102-
await client.sendRequest(updateConfigurationRequestType.method, {
103-
section: 'aws.q',
104-
settings: { profileArn: config.profileArn },
105-
})
106-
} else if (config.type === 'customization') {
107-
client.sendNotification(DidChangeConfigurationNotification.type.method, {
108-
section: 'aws.q',
109-
settings: { customization: config.customization },
110-
})
107+
switch (config.type) {
108+
case 'profile':
109+
await client.sendRequest(updateConfigurationRequestType.method, {
110+
section: 'aws.q',
111+
settings: { profileArn: config.profileArn },
112+
})
113+
break
114+
case 'customization':
115+
client.sendNotification(DidChangeConfigurationNotification.type.method, {
116+
section: 'aws.q',
117+
settings: { customization: config.customization },
118+
})
119+
break
120+
case 'logLevel':
121+
client.sendNotification(DidChangeConfigurationNotification.type.method, {
122+
section: 'aws.logLevel',
123+
})
124+
break
111125
}
112126
}
113127
type ProfileConfig = {
@@ -118,4 +132,7 @@ type CustomizationConfig = {
118132
type: 'customization'
119133
customization: string | undefined
120134
}
121-
type QConfigs = ProfileConfig | CustomizationConfig
135+
type LogLevelConfig = {
136+
type: 'logLevel'
137+
}
138+
type QConfigs = ProfileConfig | CustomizationConfig | LogLevelConfig

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

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
import { Commands, globals } from 'aws-core-vscode/shared'
7-
// import { window } from 'vscode'
7+
import { window } from 'vscode'
88
import { AmazonQChatViewProvider } from './webviewProvider'
99

1010
/**
@@ -13,21 +13,21 @@ import { AmazonQChatViewProvider } from './webviewProvider'
1313
*/
1414
export function registerCommands(provider: AmazonQChatViewProvider) {
1515
globals.context.subscriptions.push(
16-
// registerGenericCommand('aws.amazonq.explainCode', 'Explain', provider),
17-
// registerGenericCommand('aws.amazonq.refactorCode', 'Refactor', provider),
18-
// registerGenericCommand('aws.amazonq.fixCode', 'Fix', provider),
19-
// registerGenericCommand('aws.amazonq.optimizeCode', 'Optimize', provider),
20-
// Commands.register('aws.amazonq.sendToPrompt', (data) => {
21-
// const triggerType = getCommandTriggerType(data)
22-
// const selection = getSelectedText()
16+
registerGenericCommand('aws.amazonq.explainCode', 'Explain', provider),
17+
registerGenericCommand('aws.amazonq.refactorCode', 'Refactor', provider),
18+
registerGenericCommand('aws.amazonq.fixCode', 'Fix', provider),
19+
registerGenericCommand('aws.amazonq.optimizeCode', 'Optimize', provider),
20+
Commands.register('aws.amazonq.sendToPrompt', (data) => {
21+
const triggerType = getCommandTriggerType(data)
22+
const selection = getSelectedText()
2323

24-
// void focusAmazonQPanel().then(() => {
25-
// void provider.webview?.postMessage({
26-
// command: 'sendToPrompt',
27-
// params: { selection: selection, triggerType },
28-
// })
29-
// })
30-
// }),
24+
void focusAmazonQPanel().then(() => {
25+
void provider.webview?.postMessage({
26+
command: 'sendToPrompt',
27+
params: { selection: selection, triggerType },
28+
})
29+
})
30+
}),
3131
Commands.register('aws.amazonq.openTab', () => {
3232
void focusAmazonQPanel().then(() => {
3333
void provider.webview?.postMessage({
@@ -39,36 +39,36 @@ export function registerCommands(provider: AmazonQChatViewProvider) {
3939
)
4040
}
4141

42-
// function getSelectedText(): string {
43-
// const editor = window.activeTextEditor
44-
// if (editor) {
45-
// const selection = editor.selection
46-
// const selectedText = editor.document.getText(selection)
47-
// return selectedText
48-
// }
42+
function getSelectedText(): string {
43+
const editor = window.activeTextEditor
44+
if (editor) {
45+
const selection = editor.selection
46+
const selectedText = editor.document.getText(selection)
47+
return selectedText
48+
}
4949

50-
// return ' '
51-
// }
50+
return ' '
51+
}
5252

53-
// function getCommandTriggerType(data: any): string {
54-
// // data is undefined when commands triggered from keybinding or command palette. Currently no
55-
// // way to differentiate keybinding and command palette, so both interactions are recorded as keybinding
56-
// return data === undefined ? 'hotkeys' : 'contextMenu'
57-
// }
53+
function getCommandTriggerType(data: any): string {
54+
// data is undefined when commands triggered from keybinding or command palette. Currently no
55+
// way to differentiate keybinding and command palette, so both interactions are recorded as keybinding
56+
return data === undefined ? 'hotkeys' : 'contextMenu'
57+
}
5858

59-
// function registerGenericCommand(commandName: string, genericCommand: string, provider: AmazonQChatViewProvider) {
60-
// return Commands.register(commandName, (data) => {
61-
// const triggerType = getCommandTriggerType(data)
62-
// const selection = getSelectedText()
59+
function registerGenericCommand(commandName: string, genericCommand: string, provider: AmazonQChatViewProvider) {
60+
return Commands.register(commandName, (data) => {
61+
const triggerType = getCommandTriggerType(data)
62+
const selection = getSelectedText()
6363

64-
// void focusAmazonQPanel().then(() => {
65-
// void provider.webview?.postMessage({
66-
// command: 'genericCommand',
67-
// params: { genericCommand, selection, triggerType },
68-
// })
69-
// })
70-
// })
71-
// }
64+
void focusAmazonQPanel().then(() => {
65+
void provider.webview?.postMessage({
66+
command: 'genericCommand',
67+
params: { genericCommand, selection, triggerType },
68+
})
69+
})
70+
})
71+
}
7272

7373
/**
7474
* Importing focusAmazonQPanel from aws-core-vscode/amazonq leads to several dependencies down the chain not resolving since AmazonQ chat
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*!
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
import { ChatResult } from '@aws/language-server-runtimes/protocol'
6+
import { ResponseError } from '@aws/language-server-runtimes/protocol'
7+
/**
8+
* Perform a sanity check that the error we got from the LSP can be safely cast to the expected type.
9+
* @param error
10+
* @returns
11+
*/
12+
export function isValidResponseError(error: unknown): error is ResponseError<ChatResult> & { data: ChatResult } {
13+
return (
14+
typeof error === 'object' &&
15+
error !== null &&
16+
'code' in error &&
17+
typeof error.code === 'number' &&
18+
'message' in error &&
19+
typeof error.message === 'string' &&
20+
'data' in error &&
21+
error.data !== undefined
22+
)
23+
}

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

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,14 @@ import * as jose from 'jose'
5959
import { AmazonQChatViewProvider } from './webviewProvider'
6060
import { AuthUtil } from 'aws-core-vscode/codewhisperer'
6161
import { amazonQDiffScheme, AmazonQPromptSettings, messages, openUrl } from 'aws-core-vscode/shared'
62-
import { DefaultAmazonQAppInitContext, messageDispatcher, EditorContentController } from 'aws-core-vscode/amazonq'
62+
import {
63+
DefaultAmazonQAppInitContext,
64+
messageDispatcher,
65+
EditorContentController,
66+
ViewDiffMessage,
67+
} from 'aws-core-vscode/amazonq'
6368
import { telemetry, TelemetryBase } from 'aws-core-vscode/telemetry'
69+
import { isValidResponseError } from './error'
6470

6571
export function registerLanguageServerEventListener(languageClient: LanguageClient, provider: AmazonQChatViewProvider) {
6672
languageClient.info(
@@ -255,22 +261,16 @@ export function registerMessageListeners(
255261
chatDisposable
256262
)
257263
} catch (e) {
258-
languageClient.info(`Error occurred during chat request: ${e}`)
259-
// Use the last partial result if available, append error message
260-
let body = ''
261-
if (!cancellationToken.token.isCancellationRequested) {
262-
body = lastPartialResult?.body
263-
? `${lastPartialResult.body}\n\n ❌ Error: Request failed to complete`
264-
: '❌ An error occurred while processing your request'
265-
}
266-
267-
const errorResult: ChatResult = {
268-
...lastPartialResult,
269-
body,
264+
const errorMsg = `Error occurred during chat request: ${e}`
265+
languageClient.info(errorMsg)
266+
languageClient.info(
267+
`Last result from langauge server: ${JSON.stringify(lastPartialResult, undefined, 2)}`
268+
)
269+
if (!isValidResponseError(e)) {
270+
throw e
270271
}
271-
272272
await handleCompleteResult<ChatResult>(
273-
errorResult,
273+
e.data,
274274
encryptionKey,
275275
provider,
276276
chatParams.tabId,
@@ -454,17 +454,24 @@ export function registerMessageListeners(
454454
new vscode.Position(0, 0),
455455
new vscode.Position(doc.lineCount - 1, doc.lineAt(doc.lineCount - 1).text.length)
456456
)
457-
await ecc.viewDiff(
458-
{
459-
context: {
460-
activeFileContext: { filePath: params.originalFileUri },
461-
focusAreaContext: { selectionInsideExtendedCodeBlock: entireDocumentSelection },
457+
const viewDiffMessage: ViewDiffMessage = {
458+
context: {
459+
activeFileContext: {
460+
filePath: params.originalFileUri,
461+
fileText: params.originalFileContent ?? '',
462+
fileLanguage: undefined,
463+
matchPolicy: undefined,
464+
},
465+
focusAreaContext: {
466+
selectionInsideExtendedCodeBlock: entireDocumentSelection,
467+
codeBlock: '',
468+
extendedCodeBlock: '',
469+
names: undefined,
462470
},
463-
code: params.fileContent ?? '',
464471
},
465-
amazonQDiffScheme,
466-
true
467-
)
472+
code: params.fileContent ?? '',
473+
}
474+
await ecc.viewDiff(viewDiffMessage, amazonQDiffScheme)
468475
})
469476

470477
languageClient.onNotification(chatUpdateNotificationType.method, (params: ChatUpdateParams) => {

0 commit comments

Comments
 (0)