Skip to content

Commit 2897aee

Browse files
committed
Merge branch 'master' into pTests/moveToInteg
2 parents f5d6c60 + c529794 commit 2897aee

File tree

48 files changed

+346
-182
lines changed

Some content is hidden

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

48 files changed

+346
-182
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 dev handle no change required"
4+
}

packages/amazonq/test/unit/amazonqGumby/humanInTheLoopManager.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ describe('HumanInTheLoopManager', async function () {
3636
)
3737
const outputPathResult = path.join(outputDirectoryPath, 'pom.xml')
3838
assertEqualPaths(newPomFilePath.fsPath, outputPathResult)
39-
const newPomFileContents = await fs.readFileAsString(newPomFilePath.path)
39+
const newPomFileContents = await fs.readFileText(newPomFilePath.path)
4040
assert.strictEqual(
4141
stripStringWhitespace(newPomFileContents),
4242
stripStringWhitespace(`<?xml version="1.0" encoding="UTF-8"?>

packages/amazonq/test/unit/validation.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe('package validations', function () {
2323
*/
2424
it('has synced contributes.icons with core/package.json', async function () {
2525
const corePackageJson = JSON.parse(
26-
await fs.readFileAsString(path.resolve(__dirname, '../../../../core/package.json'))
26+
await fs.readFileText(path.resolve(__dirname, '../../../../core/package.json'))
2727
)
2828
assert.deepStrictEqual(packageJson.contributes.icons, corePackageJson.contributes.icons)
2929
})

packages/core/package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@
273273
"AWS.amazonq.featureDev.error.illegalStateTransition": "Illegal transition between states, restart the conversation",
274274
"AWS.amazonq.featureDev.error.prepareRepoFailedError": "Sorry, I ran into an issue while trying to upload your code. Please try again.",
275275
"AWS.amazonq.featureDev.error.promptRefusalException": "I'm sorry, I can't generate code for your request. Please make sure your message and code files comply with the <a href=\"https://aws.amazon.com/machine-learning/responsible-ai/policy/\">AWS Responsible AI Policy.</a>",
276+
"AWS.amazonq.featureDev.error.noChangeRequiredException": "I’m sorry, I ran into an issue while trying to generate your code.\n\n- `/dev` can generate code to make a change in your project. Provide a detailed description of the new feature or code changes you want to make, including the specifics of what the code should achieve.\n\n- To ask me to explain, debug, or optimize your code, you can close this chat tab to start a new conversation.",
276277
"AWS.amazonq.featureDev.error.zipFileError": "The zip file is corrupted",
277278
"AWS.amazonq.featureDev.error.codeIterationLimitError": "Sorry, you've reached the quota for number of iterations on code generation. You can insert this code in your files or discuss a new plan. For more information on quotas, see the <a href=\"https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/software-dev.html#quotas\" target=\"_blank\">Amazon Q Developer documentation.</a>",
278279
"AWS.amazonq.featureDev.error.tabIdNotFoundError": "I'm sorry, I'm having technical difficulties at the moment. Please try again.",

packages/core/src/amazonq/lsp/lspController.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export class LspController {
133133
}
134134

135135
async getFileSha384(filePath: string): Promise<string> {
136-
const fileBuffer = await fs.readFile(filePath)
136+
const fileBuffer = await fs.readFileBytes(filePath)
137137
const hash = crypto.createHash('sha384')
138138
hash.update(fileBuffer)
139139
return hash.digest('hex')

packages/core/src/amazonq/webview/ui/quickActions/generator.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ export class QuickActionGenerator {
2929
{
3030
command: '/dev',
3131
placeholder: 'Describe your task or issue in as much detail as possible',
32-
description:
33-
'Plan and implement new functionality across multiple files in your workspace.',
32+
description: 'Generate code to make a change in your project',
3433
},
3534
]
3635
: []),

packages/core/src/amazonqFeatureDev/controllers/chat/controller.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
ContentLengthError,
1515
FeatureDevServiceError,
1616
MonthlyConversationLimitError,
17+
NoChangeRequiredException,
1718
PrepareRepoFailedError,
1819
PromptRefusalException,
1920
SelectedFolderNotInWorkspaceFolderError,
@@ -131,6 +132,11 @@ export class FeatureDevController {
131132
this.initialExamples(data)
132133
break
133134
case FollowUpTypes.NewTask:
135+
this.messenger.sendAnswer({
136+
type: 'answer',
137+
tabID: data?.tabID,
138+
message: i18n('AWS.amazonq.featureDev.answer.newTaskChanges'),
139+
})
134140
return this.newTask(data)
135141
case FollowUpTypes.CloseSession:
136142
return this.closeSession(data)
@@ -246,6 +252,15 @@ export class FeatureDevController {
246252
case ZipFileError.errorName:
247253
this.messenger.sendErrorMessage(errorMessage, message.tabID, 0, session?.conversationIdUnsafe, true)
248254
break
255+
case NoChangeRequiredException.errorName:
256+
this.messenger.sendAnswer({
257+
type: 'answer',
258+
tabID: message.tabID,
259+
message: err.message,
260+
canBeVoted: true,
261+
})
262+
// Allow users to re-work the task description.
263+
return this.newTask(message)
249264
case CodeIterationLimitError.errorName:
250265
this.messenger.sendAnswer({
251266
type: 'answer',
@@ -319,7 +334,7 @@ export class FeatureDevController {
319334
await this.onCodeGeneration(session, message.message, message.tabID)
320335
}
321336
} catch (err: any) {
322-
this.processErrorChatMessage(err, message, session)
337+
await this.processErrorChatMessage(err, message, session)
323338
// Lock the chat input until they explicitly click one of the follow ups
324339
this.messenger.sendChatInputEnabled(message.tabID, false)
325340
}
@@ -758,11 +773,7 @@ export class FeatureDevController {
758773
// Re-run the opening flow, where we check auth + create a session
759774
await this.tabOpened(message)
760775

761-
this.messenger.sendAnswer({
762-
type: 'answer',
763-
tabID: message.tabID,
764-
message: i18n('AWS.amazonq.featureDev.answer.newTaskChanges'),
765-
})
776+
this.messenger.sendChatInputEnabled(message.tabID, true)
766777
this.messenger.sendUpdatePlaceholder(message.tabID, i18n('AWS.amazonq.featureDev.placeholder.describe'))
767778
}
768779

packages/core/src/amazonqFeatureDev/errors.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,15 @@ export class PromptRefusalException extends ToolkitError {
6666
}
6767
}
6868

69+
export class NoChangeRequiredException extends ToolkitError {
70+
static errorName = 'NoChangeRequiredException'
71+
constructor() {
72+
super(i18n('AWS.amazonq.featureDev.error.noChangeRequiredException'), {
73+
code: 'NoChangeRequiredException',
74+
})
75+
}
76+
}
77+
6978
export class FeatureDevServiceError extends ToolkitError {
7079
static errorName = 'FeatureDevServiceError'
7180
constructor(message: string, code: string) {

packages/core/src/amazonqFeatureDev/session/sessionState.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ import { telemetry } from '../../shared/telemetry/telemetry'
1313
import { VirtualFileSystem } from '../../shared/virtualFilesystem'
1414
import { VirtualMemoryFile } from '../../shared/virtualMemoryFile'
1515
import { featureDevScheme } from '../constants'
16-
import { FeatureDevServiceError, IllegalStateTransition, PromptRefusalException } from '../errors'
16+
import {
17+
FeatureDevServiceError,
18+
IllegalStateTransition,
19+
NoChangeRequiredException,
20+
PromptRefusalException,
21+
} from '../errors'
1722
import {
1823
CodeGenerationStatus,
1924
CurrentWsFolders,
@@ -208,6 +213,9 @@ abstract class CodeGenBase {
208213
throw new PromptRefusalException()
209214
}
210215
case codegenResult.codeGenerationStatusDetail?.includes('EmptyPatch'): {
216+
if (codegenResult.codeGenerationStatusDetail?.includes('NO_CHANGE_REQUIRED')) {
217+
throw new NoChangeRequiredException()
218+
}
211219
throw new FeatureDevServiceError(
212220
i18n('AWS.amazonq.featureDev.error.codeGen.default'),
213221
'EmptyPatchException'

packages/core/src/auth/credentials/sharedCredentials.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,15 +230,15 @@ async function loadConfigFile(configUri?: vscode.Uri): Promise<ReturnType<typeof
230230
return []
231231
}
232232

233-
return parseIni(await fs.readFileAsString(configUri), configUri)
233+
return parseIni(await fs.readFileText(configUri), configUri)
234234
}
235235

236236
async function loadCredentialsFile(credentialsUri?: vscode.Uri): Promise<ReturnType<typeof parseIni>> {
237237
if (!credentialsUri || !(await fs.exists(credentialsUri))) {
238238
return []
239239
}
240240

241-
return parseIni(await fs.readFileAsString(credentialsUri), credentialsUri)
241+
return parseIni(await fs.readFileText(credentialsUri), credentialsUri)
242242
}
243243

244244
/**

0 commit comments

Comments
 (0)