Skip to content

Commit af9d735

Browse files
committed
fix(amazonq): show empty response when token was cancelled
1 parent 1b107ab commit af9d735

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

packages/amazonq/src/lsp/chat/messages.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,16 @@ export function registerMessageListeners(
249249
} catch (e) {
250250
languageClient.info(`Error occurred during chat request: ${e}`)
251251
// Use the last partial result if available, append error message
252+
let body = ''
253+
if (!cancellationToken.token.isCancellationRequested) {
254+
body = lastPartialResult?.body
255+
? `${lastPartialResult.body}\n\n ❌ Error: Request failed to complete`
256+
: '❌ An error occurred while processing your request'
257+
}
258+
252259
const errorResult: ChatResult = {
253260
...lastPartialResult,
254-
body: lastPartialResult?.body
255-
? `${lastPartialResult.body}\n\n ❌ Error: Request failed to complete`
256-
: '❌ An error occurred while processing your request',
261+
body,
257262
}
258263

259264
await handleCompleteResult<ChatResult>(

0 commit comments

Comments
 (0)