diff --git a/src/components/chat/components/duo_chat_message/duo_chat_message.spec.js b/src/components/chat/components/duo_chat_message/duo_chat_message.spec.js index fb1dddc94398502bde7ec9bee8e9972b61b543a5..8675e08866178c05adeb515dae811c1b2442a279 100644 --- a/src/components/chat/components/duo_chat_message/duo_chat_message.spec.js +++ b/src/components/chat/components/duo_chat_message/duo_chat_message.spec.js @@ -843,6 +843,36 @@ describe('DuoChatMessage', () => { } ); }); + + describe('when a message is from agentic chat', () => { + const agenticChatMessage = { + ...MOCK_USER_PROMPT_MESSAGE, + status: 'success', + contentHtml: 'foo bar', + }; + + it('hydrates the message with GFM when status is "success"', async () => { + createComponent({ + message: agenticChatMessage, + }); + await nextTick(); + expect(renderGFM).toHaveBeenCalled(); + }); + + it.each([['foo'], [''], [undefined]])( + 'does not hydrate the message with GFM when status is "%s"', + async (status) => { + createComponent({ + message: { + ...agenticChatMessage, + status, + }, + }); + await nextTick(); + expect(renderGFM).not.toHaveBeenCalled(); + } + ); + }); }); describe('copy message functionality', () => { diff --git a/src/components/chat/components/duo_chat_message/duo_chat_message.vue b/src/components/chat/components/duo_chat_message/duo_chat_message.vue index 26f5bdec93e5d174e1e5470ba3b9c9949f078b8e..a21939b9f90191ad70ea653c4ad4ef89d35f50e2 100644 --- a/src/components/chat/components/duo_chat_message/duo_chat_message.vue +++ b/src/components/chat/components/duo_chat_message/duo_chat_message.vue @@ -121,6 +121,14 @@ export default { }; }, computed: { + isDoneStreaming() { + // Agentic chat format + if (Object.hasOwn(this.message, 'status')) { + return this.message.status === 'success'; + } + // Classic chat format + return !this.isChunk; + }, isChunk() { return typeof this.message.chunkId === 'number'; }, @@ -250,8 +258,10 @@ export default { } }, hydrateContentWithGFM() { - if (!this.isChunk && this.$refs.content) { - this.$nextTick(this.renderGFM(this.$refs.content)); + if (this.isDoneStreaming && this.$refs.content) { + this.$nextTick(() => { + this.renderGFM(this.$refs.content); + }); } this.detectScrollableCodeBlocks(); }, diff --git a/src/components/chat/components/duo_chat_message/message_types/message_base.vue b/src/components/chat/components/duo_chat_message/message_types/message_base.vue index 9a9db601b17b151c42f360bef387b88166f9df11..e3899df9dce81bf259ba75e58d46bb53ecdd5b06 100644 --- a/src/components/chat/components/duo_chat_message/message_types/message_base.vue +++ b/src/components/chat/components/duo_chat_message/message_types/message_base.vue @@ -60,7 +60,9 @@ export default { methods: { hydrateContentWithGFM() { if (this.$refs.content) { - this.$nextTick(this.renderGFM(this.$refs.content, this.message.role)); + this.$nextTick(() => { + this.renderGFM(this.$refs.content, this.message.role); + }); } }, },