From 0471e99a86c04901571cee722db5c8b91b558b15 Mon Sep 17 00:00:00 2001 From: Lucas Oliveira Date: Tue, 11 Jul 2023 19:58:33 -0300 Subject: [PATCH 01/13] Fixed useEffect bug --- src/frontend/src/components/chatComponent/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/frontend/src/components/chatComponent/index.tsx b/src/frontend/src/components/chatComponent/index.tsx index 850837f6b..58c058866 100644 --- a/src/frontend/src/components/chatComponent/index.tsx +++ b/src/frontend/src/components/chatComponent/index.tsx @@ -72,7 +72,7 @@ export default function Chat({ flow }: ChatType) { } prevNodesRef.current = currentNodes; - }, [tabsState, flow.id, nodes]); + }, [tabsState, flow.id]); return ( <> From 2c1203c4377a8f3487da5e80e25dab35c46f9879 Mon Sep 17 00:00:00 2001 From: Lucas Oliveira Date: Tue, 11 Jul 2023 20:20:21 -0300 Subject: [PATCH 02/13] Fixed colors on formModal --- src/frontend/src/index.css | 10 +++++++--- .../src/modals/formModal/chatMessage/index.tsx | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/frontend/src/index.css b/src/frontend/src/index.css index 0c8aa9ca2..7df82c278 100644 --- a/src/frontend/src/index.css +++ b/src/frontend/src/index.css @@ -921,13 +921,13 @@ The cursor: default; property value restores the browser's default cursor style } .form-modal-lock-true { - @apply bg-input text-black + @apply bg-input text-primary } .form-modal-no-input { - @apply bg-input text-center text-black dark:bg-gray-700 dark:text-gray-300 + @apply bg-input text-center text-primary dark:bg-gray-700 dark:text-gray-300 } .form-modal-lock-false { - @apply bg-white text-black + @apply bg-white text-primary } .form-modal-lockchat { @apply form-input focus:ring-ring focus:border-ring block w-full rounded-md border-border p-4 pr-16 custom-scroll sm:text-sm @@ -1080,5 +1080,9 @@ The cursor: default; property value restores the browser's default cursor style @apply font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 } + .chat-message-highlight { + @apply my-1 rounded-md bg-indigo-100 dark:bg-indigo-900 + } + } diff --git a/src/frontend/src/modals/formModal/chatMessage/index.tsx b/src/frontend/src/modals/formModal/chatMessage/index.tsx index d75b901fe..5c318cb17 100644 --- a/src/frontend/src/modals/formModal/chatMessage/index.tsx +++ b/src/frontend/src/modals/formModal/chatMessage/index.tsx @@ -181,7 +181,7 @@ export default function ChatMessage({ // Push div with matched text if (chat.message[match[1]]) { parts.push( - + {chat.message[match[1]]} ); From d15c5636a2da8ac6e36d014730ef634fc3c13081 Mon Sep 17 00:00:00 2001 From: Lucas Oliveira Date: Tue, 11 Jul 2023 20:33:46 -0300 Subject: [PATCH 03/13] Fixed bug on chatMessage --- .../modals/formModal/chatMessage/index.tsx | 65 ++++++++++--------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/src/frontend/src/modals/formModal/chatMessage/index.tsx b/src/frontend/src/modals/formModal/chatMessage/index.tsx index 5c318cb17..8cbf0877c 100644 --- a/src/frontend/src/modals/formModal/chatMessage/index.tsx +++ b/src/frontend/src/modals/formModal/chatMessage/index.tsx @@ -150,8 +150,8 @@ export default function ChatMessage({ ) : ( -
- {template && ( +
+ {template ? ( <> - {promptOpen && - template?.split("\n")?.map((line, index) => { - const regex = /{([^}]+)}/g; - let match; - let parts = []; - let lastIndex = 0; - while ((match = regex.exec(line)) !== null) { - // Push text up to the match - if (match.index !== lastIndex) { - parts.push(line.substring(lastIndex, match.index)); - } - // Push div with matched text - if (chat.message[match[1]]) { - parts.push( - - {chat.message[match[1]]} - - ); - } + {promptOpen + ? template?.split("\n")?.map((line, index) => { + const regex = /{([^}]+)}/g; + let match; + let parts = []; + let lastIndex = 0; + while ((match = regex.exec(line)) !== null) { + // Push text up to the match + if (match.index !== lastIndex) { + parts.push(line.substring(lastIndex, match.index)); + } + // Push div with matched text + if (chat.message[match[1]]) { + parts.push( + + {chat.message[match[1]]} + + ); + } - // Update last index - lastIndex = regex.lastIndex; - } - // Push text after the last match - if (lastIndex !== line.length) { - parts.push(line.substring(lastIndex)); - } - return

{parts}

; - })} + // Update last index + lastIndex = regex.lastIndex; + } + // Push text after the last match + if (lastIndex !== line.length) { + parts.push(line.substring(lastIndex)); + } + return

{parts}

; + }) + : chat.message[chat.chatKey]}
+ ) : ( + {chat.message[chat.chatKey]} )} -
- {chat.message[chat.chatKey]}
)}
From aba0ed40dac534c3095bd808de9eecb7d0f1dc98 Mon Sep 17 00:00:00 2001 From: Lucas Oliveira Date: Tue, 11 Jul 2023 21:06:35 -0300 Subject: [PATCH 04/13] Edit Prompt modal and other generic modals spacing fixed --- src/frontend/src/constants.tsx | 2 +- src/frontend/src/modals/genericModal/index.tsx | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/frontend/src/constants.tsx b/src/frontend/src/constants.tsx index 25c0dc7d5..4a8056879 100644 --- a/src/frontend/src/constants.tsx +++ b/src/frontend/src/constants.tsx @@ -557,4 +557,4 @@ export const USER_PROJECTS_HEADER = "My Collection"; * */ export const HIGHLIGHT_CSS = - "block pl-3 pr-14 py-2 w-full h-full text-sm outline-0 border-0 break-all overflow-y-hidden max-w-[75vw]"; + "block px-3 py-2 w-full h-full text-sm outline-0 border-0 break-all overflow-y-hidden"; diff --git a/src/frontend/src/modals/genericModal/index.tsx b/src/frontend/src/modals/genericModal/index.tsx index 923549e28..1b7b76a40 100644 --- a/src/frontend/src/modals/genericModal/index.tsx +++ b/src/frontend/src/modals/genericModal/index.tsx @@ -197,13 +197,13 @@ export default function GenericModal({
{type === TypeModal.PROMPT && isEdit ? (