From 20e2d499937d934a2c5025457eea3f9b63acd24b Mon Sep 17 00:00:00 2001 From: Dominic Elm Date: Fri, 26 Jul 2024 11:09:35 +0200 Subject: [PATCH] fix: always parse all assistant messages (#13) --- packages/bolt/app/components/chat/Chat.client.tsx | 2 +- packages/bolt/app/lib/hooks/useMessageParser.ts | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/packages/bolt/app/components/chat/Chat.client.tsx b/packages/bolt/app/components/chat/Chat.client.tsx index a12128f..a8fa27c 100644 --- a/packages/bolt/app/components/chat/Chat.client.tsx +++ b/packages/bolt/app/components/chat/Chat.client.tsx @@ -4,13 +4,13 @@ import { useAnimate } from 'framer-motion'; import { useEffect, useRef, useState } from 'react'; import { cssTransition, toast, ToastContainer } from 'react-toastify'; import { useMessageParser, usePromptEnhancer, useSnapScroll } from '~/lib/hooks'; +import { useChatHistory } from '~/lib/persistence'; import { chatStore } from '~/lib/stores/chat'; import { workbenchStore } from '~/lib/stores/workbench'; import { fileModificationsToHTML } from '~/utils/diff'; import { cubicEasingFn } from '~/utils/easings'; import { createScopedLogger } from '~/utils/logger'; import { BaseChat } from './BaseChat'; -import { useChatHistory } from '~/lib/persistence'; const toastAnimation = cssTransition({ enter: 'animated fadeInRight', diff --git a/packages/bolt/app/lib/hooks/useMessageParser.ts b/packages/bolt/app/lib/hooks/useMessageParser.ts index 324727b..a70fb82 100644 --- a/packages/bolt/app/lib/hooks/useMessageParser.ts +++ b/packages/bolt/app/lib/hooks/useMessageParser.ts @@ -52,14 +52,6 @@ export function useMessageParser() { for (const [index, message] of messages.entries()) { if (message.role === 'assistant') { - /** - * In production, we only parse the last assistant message since previous messages can't change. - * During development they can change, e.g., if the parser gets modified. - */ - if (import.meta.env.PROD && index < messages.length - 1) { - continue; - } - const newParsedContent = messageParser.parse(message.id, message.content); setParsedMessages((prevParsed) => ({