Skip to content

Commit b02a22d

Browse files
Muzaffer AydinMuzaffer Aydin
authored andcommitted
Merge branch 'master' into muaydin/docdb-polling-bug-fix
2 parents 1f03083 + 02f6d0b commit b02a22d

16 files changed

+134
-52
lines changed

package-lock.json

Lines changed: 10 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
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": "Amazon Q /dev: Fix issue when files are deleted while preparing context"
4+
}
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": "Fix context menu displaying when typing @, even though input is disallowed"
4+
}
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": "Amazon Q can update mvn and gradle build files"
4+
}
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": "Up/down history navigation only triggering on first/last line of prompt input"
4+
}
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": "Amazon Q /test: Fix to redirect /test to generate tests in chat for external files out of workspace scope."
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Feature",
3+
"description": "Amazon Q: new code syntax highlighter for improved accuracy"
4+
}

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@
510510
"@aws-sdk/property-provider": "3.46.0",
511511
"@aws-sdk/smithy-client": "^3.46.0",
512512
"@aws-sdk/util-arn-parser": "^3.46.0",
513-
"@aws/mynah-ui": "^4.21.3",
513+
"@aws/mynah-ui": "^4.21.4",
514514
"@gerhobbelt/gitignore-parser": "^0.2.0-9",
515515
"@iarna/toml": "^2.2.5",
516516
"@smithy/middleware-retry": "^2.3.1",

packages/core/src/amazonqFeatureDev/util/files.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { getLogger } from '../../shared/logger/logger'
1313
import { maxFileSizeBytes } from '../limits'
1414
import { createHash } from 'crypto'
1515
import { CurrentWsFolders } from '../types'
16-
import { ToolkitError } from '../../shared/errors'
16+
import { hasCode, ToolkitError } from '../../shared/errors'
1717
import { AmazonqCreateUpload, Span, telemetry as amznTelemetry } from '../../shared/telemetry/telemetry'
1818
import { TelemetryHelper } from './telemetryHelper'
1919
import { maxRepoSizeBytes } from '../constants'
@@ -39,7 +39,16 @@ export async function prepareRepoData(
3939
const ignoredExtensionMap = new Map<string, number>()
4040

4141
for (const file of files) {
42-
const fileSize = (await fs.stat(file.fileUri)).size
42+
let fileSize
43+
try {
44+
fileSize = (await fs.stat(file.fileUri)).size
45+
} catch (error) {
46+
if (hasCode(error) && error.code === 'ENOENT') {
47+
// No-op: Skip if file does not exist
48+
continue
49+
}
50+
throw error
51+
}
4352
const isCodeFile_ = isCodeFile(file.relativeFilePath)
4453

4554
if (fileSize >= maxFileSizeBytes || !isCodeFile_) {
@@ -58,7 +67,17 @@ export async function prepareRepoData(
5867
totalBytes += fileSize
5968

6069
const zipFolderPath = path.dirname(file.zipFilePath)
61-
zip.addLocalFile(file.fileUri.fsPath, zipFolderPath)
70+
71+
try {
72+
zip.addLocalFile(file.fileUri.fsPath, zipFolderPath)
73+
} catch (error) {
74+
if (error instanceof Error && error.message.includes('File not found')) {
75+
// No-op: Skip if file was deleted or does not exist
76+
// Reference: https://github.com/cthackers/adm-zip/blob/1cd32f7e0ad3c540142a76609bb538a5cda2292f/adm-zip.js#L296-L321
77+
continue
78+
}
79+
throw error
80+
}
6281
}
6382

6483
const iterator = ignoredExtensionMap.entries()

packages/core/src/amazonqTest/chat/controller/controller.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -439,16 +439,21 @@ export class TestController {
439439

440440
const language = await this.getLanguageForFilePath(filePath)
441441
session.fileLanguage = language
442+
const workspaceFolder = vscode.workspace.getWorkspaceFolder(fileEditorToTest.document.uri)
442443

443444
/*
444445
For Re:Invent 2024 we are supporting only java and python for unit test generation, rest of the languages shows the similar experience as CWC
445446
*/
446-
if (language !== 'java' && language !== 'python') {
447-
const unsupportedLanguage = language.charAt(0).toUpperCase() + language.slice(1)
448-
let unsupportedMessage = `<span style="color: #EE9D28;">&#9888;<b>I'm sorry, but /test only supports Python and Java</b><br></span> While ${unsupportedLanguage} is not supported, I will generate a suggestion below. `
449-
// handle the case when language is undefined
450-
if (!unsupportedLanguage) {
451-
unsupportedMessage = `<span style="color: #EE9D28;">&#9888;<b>I'm sorry, but /test only supports Python and Java</b><br></span> I will still generate a suggestion below. `
447+
if (!['java', 'python'].includes(language) || workspaceFolder === undefined) {
448+
let unsupportedMessage: string
449+
const unsupportedLanguage = language ? language.charAt(0).toUpperCase() + language.slice(1) : ''
450+
if (!workspaceFolder) {
451+
// File is outside of workspace
452+
unsupportedMessage = `<span style="color: #EE9D28;">&#9888;<b>I can't generate tests for ${fileName}</b> because the file is outside of workspace scope.<br></span> I can still provide examples, instructions and code suggestions.`
453+
} else if (unsupportedLanguage) {
454+
unsupportedMessage = `<span style="color: #EE9D28;">&#9888;<b>I'm sorry, but /test only supports Python and Java</b><br></span> While ${unsupportedLanguage} is not supported, I will generate a suggestion below.`
455+
} else {
456+
unsupportedMessage = `<span style="color: #EE9D28;">&#9888;<b>I'm sorry, but /test only supports Python and Java</b><br></span> I will still generate a suggestion below.`
452457
}
453458
this.messenger.sendMessage(unsupportedMessage, tabID, 'answer')
454459
await this.onCodeGeneration(session, message.prompt, tabID, fileName, filePath)

0 commit comments

Comments
 (0)