Skip to content

Commit b424faf

Browse files
committed
fix: refactor to avoid double decryption
1 parent b8ec914 commit b424faf

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

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

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -205,17 +205,12 @@ export function registerMessageListeners(
205205
const cancellationToken = new CancellationTokenSource()
206206
chatStreamTokens.set(chatParams.tabId, cancellationToken)
207207

208-
const chatDisposable = languageClient.onProgress(
209-
chatRequestType,
210-
partialResultToken,
211-
(partialResult) => {
212-
// Store the latest partial result
213-
decryptResponse<ChatResult>(partialResult, encryptionKey).then((result) => {
208+
const chatDisposable = languageClient.onProgress(chatRequestType, partialResultToken, (partialResult) =>
209+
handlePartialResult<ChatResult>(partialResult, encryptionKey, provider, chatParams.tabId).then(
210+
(result) => {
214211
lastPartialResult = result
215-
})
216-
217-
void handlePartialResult<ChatResult>(partialResult, encryptionKey, provider, chatParams.tabId)
218-
}
212+
}
213+
)
219214
)
220215

221216
const editor =
@@ -488,6 +483,7 @@ async function handlePartialResult<T extends ChatResult>(
488483
tabId: tabId,
489484
})
490485
}
486+
return decryptedMessage
491487
}
492488

493489
/**

0 commit comments

Comments
 (0)