client/cody: fix usages of addErrorAsAssistantResponse (#53185)

Some callsites were incorrectly wrapping the error in HTML before
calling `addErrorAsAssistantResponse`, which then wraps it in another
error div.

## Test plan

n/a
This commit is contained in:
Robert Lin 2023-06-08 21:18:44 -07:00 committed by GitHub
parent 7a7ed5d470
commit 2a63d0dc6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 6 deletions

View File

@ -138,9 +138,7 @@ export async function createClient({
},
onError(error) {
// Display error message as assistant response
transcript.addErrorAsAssistantResponse(
`<div class="cody-chat-error"><span>Request failed: </span>${error}</div>`
)
transcript.addErrorAsAssistantResponse(error)
isMessageInProgress = false
sendTranscript()
console.error(`Completion request failed: ${error}`)

View File

@ -113,6 +113,12 @@ export class Transcript {
})
}
/**
* Adds a error div to the assistant response. If the assistant has collected
* some response before, we will add the error message after it.
*
* @param errorText The error TEXT to be displayed. Do not wrap it in HTML tags.
*/
public addErrorAsAssistantResponse(errorText: string): void {
const lastInteraction = this.getLastInteraction()
if (!lastInteraction) {

View File

@ -266,9 +266,7 @@ export const useClient = ({
},
onError(error) {
// Display error message as assistant response
transcript.addErrorAsAssistantResponse(
`<div class="cody-chat-error"><span>Request failed: </span>${error}</div>`
)
transcript.addErrorAsAssistantResponse(error)
console.error(`Completion request failed: ${error}`)