Skip to content

Commit 5d2b3ec

Browse files
authored
fix: return QModelResponse as a response not an error (#1523)
* fix: for QModelResponse we sent the error as a response from Flare not leaving IDE to catch the error and then show on the chat UI * fix: leave a message to notify to do tasks * fix: move the return response in handleErrors to leave the telemetry * fix: remove unused code and delete throw error throttling code * fix: test related q model related response * fix: store the chat response in a variable * fix: change the error message based on new figma design
1 parent b47da11 commit 5d2b3ec

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

server/aws-lsp-codewhisperer/src/language-server/agenticChat/agenticChatController.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,9 +1023,8 @@ describe('AgenticChatController', () => {
10231023
)
10241024

10251025
// These checks will fail if a response error is returned.
1026-
const typedChatResult = chatResult as ResponseError<ChatResult>
1027-
assert.strictEqual(typedChatResult.message, errorMsg)
1028-
assert.strictEqual(typedChatResult.data?.body, errorMsg)
1026+
const typedChatResult = chatResult as ChatResult
1027+
assert.strictEqual(typedChatResult.body, errorMsg)
10291028
})
10301029

10311030
it('truncate input to 500k character ', async function () {

server/aws-lsp-codewhisperer/src/language-server/agenticChat/agenticChatController.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1992,17 +1992,20 @@ export class AgenticChatController implements ChatHandlers {
19921992
// Clear the chat history in the database for this tab
19931993
this.#chatHistoryDb.clearTab(tabId)
19941994
}
1995-
19961995
const errorBody =
19971996
err.code === 'QModelResponse' && requestID
19981997
? `${err.message} \n\nRequest ID: ${requestID} `
19991998
: err.message
2000-
return new ResponseError<ChatResult>(LSPErrorCodes.RequestFailed, err.message, {
1999+
const responseData: ChatResult = {
20012000
type: 'answer',
20022001
body: errorBody,
20032002
messageId: errorMessageId,
20042003
buttons: [],
2005-
})
2004+
}
2005+
if (err.code === 'QModelResponse') {
2006+
return responseData
2007+
}
2008+
return new ResponseError<ChatResult>(LSPErrorCodes.RequestFailed, err.message, responseData)
20062009
}
20072010
this.#features.logging.error(`Unknown Error: ${loggingUtils.formatErr(err)}`)
20082011
return new ResponseError<ChatResult>(LSPErrorCodes.RequestFailed, err.message, {

server/aws-lsp-codewhisperer/src/language-server/chat/chatSessionService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ export class ChatSessionService {
179179
error.message ===
180180
'Encountered unexpectedly high load when processing the request, please try again.'
181181
) {
182-
error.message = ` The model you've selected is temporarily unavailable. Please select Auto or a different model and try again.`
182+
error.message = `The model you selected is temporarily unavailable. Please switch to a different model and try again.`
183183
}
184184
throw error
185185
}

0 commit comments

Comments
 (0)