Skip to content

Commit 5237216

Browse files
authored
fix(amazonq): chat may hang in ts/js files #4954
Problem Q chat may hang when processing fragments of ts/js code. The Tsx.findNames and Tsx.findNamesWithInExtent functions hang (Promise does not resolve). These functions invoke WASM/rust code. - #4935 - #4810 Solution Remove uses of Tsx.findNames and Tsx.findNamesWithInExtent. The fully qualified names (FQN) library is used to help service build prompts with variable names in user's IDE to reduce hallucinations, but they are not required for normal functionality.
1 parent aa8593c commit 5237216

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
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 Javascript/Typescript code"
4+
}

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

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

6-
import { Java, Python, TypeScript, Tsx } from '@aws/fully-qualified-names'
6+
import { Java, Python } from '@aws/fully-qualified-names'
77
import { extractContextFromJavaImports } from './javaImportReader'
88

99
export async function readImports(text: string, languageId: string): Promise<string[]> {
@@ -15,14 +15,16 @@ export async function readImports(text: string, languageId: string): Promise<str
1515
case 'javascript':
1616
case 'javascriptreact':
1717
case 'typescriptreact':
18-
names = await Tsx.findNames(text)
19-
break
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 []
2022
case 'python':
2123
names = await Python.findNames(text)
2224
break
2325
case 'typescript':
24-
names = await TypeScript.findNames(text)
25-
break
26+
//names = await TypeScript.findNames(text)
27+
return []
2628
}
2729
if (names.fullyQualified === undefined) {
2830
return []

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

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

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

8-
import { Extent, Java, Python, Tsx, TypeScript, Location } from '@aws/fully-qualified-names'
8+
import { Extent, Java, Python, Location } from '@aws/fully-qualified-names'
99
import { FocusAreaContext, FullyQualifiedName } from './model'
1010

1111
const focusAreaCharLimit = 9_000
@@ -235,13 +235,17 @@ export class FocusAreaContextExtractor {
235235
case 'javascript':
236236
case 'javascriptreact':
237237
case 'typescriptreact':
238-
names = await Tsx.findNamesWithInExtent(fileText, extent)
238+
// Disable Tsx.findNamesWithInExtent because promise Tsx.findNamesWithInExtent
239+
// may not resolve and can cause chat to hang
240+
//names = await Tsx.findNamesWithInExtent(fileText, extent)
241+
names = undefined
239242
break
240243
case 'python':
241244
names = await Python.findNamesWithInExtent(fileText, extent)
242245
break
243246
case 'typescript':
244-
names = await TypeScript.findNamesWithInExtent(fileText, extent)
247+
//names = await TypeScript.findNamesWithInExtent(fileText, extent)
248+
names = undefined
245249
break
246250
}
247251

0 commit comments

Comments
 (0)