From caae43bc9b8625296b2d45cd280d08620b8ee82f Mon Sep 17 00:00:00 2001 From: Lucas Oliveira <62335616+lucaseduoli@users.noreply.github.com> Date: Tue, 16 Jul 2024 14:26:55 -0300 Subject: [PATCH] fix: empty input message on empty streaming (#2729) Fixed streaming bug where it shows a message before starting streaming --- src/frontend/src/constants/constants.ts | 2 ++ .../components/chatView/chatMessage/index.tsx | 15 ++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/frontend/src/constants/constants.ts b/src/frontend/src/constants/constants.ts index 1de79a737..9642859f0 100644 --- a/src/frontend/src/constants/constants.ts +++ b/src/frontend/src/constants/constants.ts @@ -853,6 +853,8 @@ export const TITLE_ERROR_UPDATING_COMPONENT = export const EMPTY_INPUT_SEND_MESSAGE = "No input message provided."; +export const EMPTY_OUTPUT_SEND_MESSAGE = "Message empty."; + export const TABS_ORDER = [ "run curl", "python api", 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 ff1650f71..0638e3c38 100644 --- a/src/frontend/src/modals/IOModal/components/chatView/chatMessage/index.tsx +++ b/src/frontend/src/modals/IOModal/components/chatView/chatMessage/index.tsx @@ -9,7 +9,10 @@ import Robot from "../../../../../assets/robot.png"; import CodeTabsComponent from "../../../../../components/codeTabsComponent"; import IconComponent from "../../../../../components/genericIconComponent"; import SanitizedHTMLWrapper from "../../../../../components/sanitizedHTMLWrapper"; -import { EMPTY_INPUT_SEND_MESSAGE } from "../../../../../constants/constants"; +import { + EMPTY_INPUT_SEND_MESSAGE, + EMPTY_OUTPUT_SEND_MESSAGE, +} from "../../../../../constants/constants"; import useAlertStore from "../../../../../stores/alertStore"; import useFlowStore from "../../../../../stores/flowStore"; import { chatMessagePropsType } from "../../../../../types/components"; @@ -251,8 +254,8 @@ export default function ChatMessage({ }, }} > - {chatMessage === "" - ? EMPTY_INPUT_SEND_MESSAGE + {chatMessage === "" && !chat.stream_url + ? EMPTY_OUTPUT_SEND_MESSAGE : chatMessage} ), @@ -286,10 +289,8 @@ export default function ChatMessage({ className={cn( "prose word-break-break-word dark:prose-invert", chatMessage !== "" - ? EMPTY_INPUT_SEND_MESSAGE - : chatMessage - ? "text-primary" - : "text-chat-trigger-disabled", + ? "text-primary" + : "text-chat-trigger-disabled", )} > {promptOpen