From 6f8beb894f581215a3c9faaf1757bc01fd5d6a4a Mon Sep 17 00:00:00 2001 From: Cristhian Zanforlin Lousa Date: Tue, 10 Sep 2024 16:43:09 -0300 Subject: [PATCH] feat: improve user chat input to display spacements (#3687) feat: Refactor chatMessage component for improved readability and performance Co-authored-by: anovazzi1 --- .../components/chatView/chatMessage/index.tsx | 51 ++++++++----------- 1 file changed, 20 insertions(+), 31 deletions(-) diff --git a/src/frontend/src/modals/IOModal/components/chatView/chatMessage/index.tsx b/src/frontend/src/modals/IOModal/components/chatView/chatMessage/index.tsx index 1d1ccafe0..3123c8ff0 100644 --- a/src/frontend/src/modals/IOModal/components/chatView/chatMessage/index.tsx +++ b/src/frontend/src/modals/IOModal/components/chatView/chatMessage/index.tsx @@ -126,18 +126,16 @@ export default function ChatMessage({ } }, [lastMessage]); + const decodedMessage = decodeURIComponent(chatMessage ?? ""); + const isEmpty = decodedMessage?.trim() === ""; + return ( <> -
+
{useMemo( () => - chatMessage === "" && lockChat ? ( + isEmpty && lockChat ? ( - {chatMessage === "" && !chat.stream_url + {isEmpty && !chat.stream_url ? EMPTY_OUTPUT_SEND_MESSAGE : chatMessage} @@ -294,18 +292,13 @@ export default function ChatMessage({ Display Prompt {promptOpen @@ -337,25 +330,21 @@ export default function ChatMessage({ } return

{parts}

; }) - : chatMessage === "" + : isEmpty ? EMPTY_INPUT_SEND_MESSAGE : chatMessage}
) : (
- - {chatMessage === "" ? EMPTY_INPUT_SEND_MESSAGE : chatMessage} - + {isEmpty ? EMPTY_INPUT_SEND_MESSAGE : decodedMessage} +
{chat.files && (
{chat.files.map((file, index) => { @@ -375,7 +364,7 @@ export default function ChatMessage({
)}
-
+
); }