Skip to content

Commit fbeb3a1

Browse files
authored
fix(feature dev): retry message without problem statement #5999
## Problem retry message without problem statement ## Solution Move latestMessage setter call outside of session in controller as it interrupts with retryMessage functionality
1 parent ea5dae5 commit fbeb3a1

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

packages/amazonq/test/unit/amazonqFeatureDev/session/session.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ describe('session', () => {
3737
describe('preloader', () => {
3838
it('emits start chat telemetry', async () => {
3939
const session = await createSession({ messenger, conversationID })
40+
session.latestMessage = 'implement twosum in typescript'
4041

41-
await session.preloader('implement twosum in typescript')
42+
await session.preloader()
4243

4344
assertTelemetry('amazonq_startConversationInvoke', {
4445
amazonqConversationId: conversationID,

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,9 @@ export class FeatureDevController {
366366
getLogger().debug(`${featureName}: Processing message: ${message.message}`)
367367

368368
session = await this.sessionStorage.getSession(message.tabID)
369+
// set latestMessage in session as retry would lose context if function returns early
370+
session.latestMessage = message.message
371+
369372
const authState = await AuthUtil.instance.getChatAuthState()
370373
if (authState.amazonQ !== 'connected') {
371374
await this.messenger.sendAuthNeededExceptionMessage(authState, message.tabID)
@@ -383,7 +386,7 @@ export class FeatureDevController {
383386
return
384387
}
385388

386-
await session.preloader(message.message)
389+
await session.preloader()
387390

388391
if (session.state.phase === DevPhase.CODEGEN) {
389392
await this.onCodeGeneration(session, message.message, message.tabID)

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ export class Session {
5858
/**
5959
* Preload any events that have to run before a chat message can be sent
6060
*/
61-
async preloader(msg: string) {
61+
async preloader() {
6262
if (!this.preloaderFinished) {
63-
await this.setupConversation(msg)
63+
await this.setupConversation()
6464
this.preloaderFinished = true
6565
this.messenger.sendAsyncEventProgress(this.tabID, true, undefined)
6666
await this.proxyClient.sendFeatureDevTelemetryEvent(this.conversationId) // send the event only once per conversation.
@@ -72,10 +72,7 @@ export class Session {
7272
*
7373
* Starts a conversation with the backend and uploads the repo for the LLMs to be able to use it.
7474
*/
75-
private async setupConversation(msg: string) {
76-
// Store the initial message when setting up the conversation so that if it fails we can retry with this message
77-
this._latestMessage = msg
78-
75+
private async setupConversation() {
7976
await telemetry.amazonq_startConversationInvoke.run(async (span) => {
8077
this._conversationId = await this.proxyClient.createConversation()
8178
getLogger().info(logWithConversationId(this.conversationId))
@@ -221,6 +218,10 @@ export class Session {
221218
return this._latestMessage
222219
}
223220

221+
set latestMessage(msg: string) {
222+
this._latestMessage = msg
223+
}
224+
224225
get telemetry() {
225226
return this._telemetry
226227
}

0 commit comments

Comments
 (0)