Skip to content

Commit 6484c98

Browse files
zixlin7hayemaxi
andauthored
fix(amazonq): AmazonQ Chat window became unresponsive after prompt (#5408)
* fix(amazonq): AmazonQ Chat window became unresponsive after prompt * remove the code instead of comment out * Update packages/core/src/codewhispererChat/editor/context/focusArea/focusAreaExtractor.ts Co-authored-by: Maxim Hayes <[email protected]> --------- Co-authored-by: Maxim Hayes <[email protected]>
1 parent 121f2ec commit 6484c98

File tree

3 files changed

+11
-55
lines changed

3 files changed

+11
-55
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "Q chat may stop responding after processing Python/Java code"
4+
}

packages/core/src/codewhispererChat/editor/context/file/importReader.ts

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,13 @@
22
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
33
* SPDX-License-Identifier: Apache-2.0
44
*/
5-
6-
import { Java, Python } from '@aws/fully-qualified-names'
75
import { extractContextFromJavaImports } from './javaImportReader'
86

97
export async function readImports(text: string, languageId: string): Promise<string[]> {
10-
let names: any = {}
11-
switch (languageId) {
12-
case 'java':
13-
names = await Java.findNames(text)
14-
break
15-
case 'javascript':
16-
case 'javascriptreact':
17-
case 'typescriptreact':
18-
// Disable Tsx.findNames because promise Tsx.findNames
19-
// may not resolve and can cause chat to hang
20-
//names = await Tsx.findNames(text)
21-
return []
22-
case 'python':
23-
names = await Python.findNames(text)
24-
break
25-
case 'typescript':
26-
//names = await TypeScript.findNames(text)
27-
return []
28-
}
8+
const names: any = {}
9+
// TODO: call findNames from @aws/fully-qualified-names for imports
10+
// after promise not resolving issue is fixed
11+
2912
if (names.fullyQualified === undefined) {
3013
return []
3114
}

packages/core/src/codewhispererChat/editor/context/focusArea/focusAreaExtractor.ts

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import { TextEditor, Selection, TextDocument, Range } from 'vscode'
77

8-
import { Extent, Java, Python, Location } from '@aws/fully-qualified-names'
98
import { FocusAreaContext, FullyQualifiedName } from './model'
109

1110
const focusAreaCharLimit = 9_000
@@ -40,8 +39,9 @@ export class FocusAreaContextExtractor {
4039
importantRange = editor.document.lineAt(importantRange.start.line).range
4140
}
4241

43-
const names = await this.findNamesInRange(editor.document.getText(), importantRange, editor.document.languageId)
44-
42+
// TODO: call findNamesWithInExtent from @aws/fully-qualified-names
43+
// after promise not resolving issue is fixed
44+
const names = {}
4545
const [simpleNames] = this.prepareSimpleNames(names)
4646
const [usedFullyQualifiedNames] = this.prepareFqns(names)
4747

@@ -222,37 +222,6 @@ export class FocusAreaContextExtractor {
222222
return document.getText(range)
223223
}
224224

225-
private async findNamesInRange(fileText: string, selection: Range, languageId: string) {
226-
fileText.replace(/([\uE000-\uF8FF]|\uD83C[\uDF00-\uDFFF]|\uD83D[\uDC00-\uDDFF])/g, '')
227-
const startLocation: Location = new Location(selection.start.line, selection.start.character)
228-
const endLocation: Location = new Location(selection.end.line, selection.end.character)
229-
const extent: Extent = new Extent(startLocation, endLocation)
230-
231-
let names: any = {}
232-
switch (languageId) {
233-
case 'java':
234-
names = await Java.findNamesWithInExtent(fileText, extent)
235-
break
236-
case 'javascript':
237-
case 'javascriptreact':
238-
case 'typescriptreact':
239-
// Disable Tsx.findNamesWithInExtent because promise Tsx.findNamesWithInExtent
240-
// may not resolve and can cause chat to hang
241-
//names = await Tsx.findNamesWithInExtent(fileText, extent)
242-
names = undefined
243-
break
244-
case 'python':
245-
names = await Python.findNamesWithInExtent(fileText, extent)
246-
break
247-
case 'typescript':
248-
//names = await TypeScript.findNamesWithInExtent(fileText, extent)
249-
names = undefined
250-
break
251-
}
252-
253-
return names
254-
}
255-
256225
private prepareFqns(names: any): [FullyQualifiedName[], boolean] {
257226
if (names === undefined || !names.fullyQualified) {
258227
return [[], false]

0 commit comments

Comments
 (0)