From a8023c259876dc68b37d486ba8208f39c59f388d Mon Sep 17 00:00:00 2001 From: hunteraraujo Date: Wed, 6 Sep 2023 12:15:57 -0700 Subject: [PATCH] Fix empty user chats --- frontend/lib/viewmodels/chat_viewmodel.dart | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/frontend/lib/viewmodels/chat_viewmodel.dart b/frontend/lib/viewmodels/chat_viewmodel.dart index baf8e6543..f85c9d5ea 100644 --- a/frontend/lib/viewmodels/chat_viewmodel.dart +++ b/frontend/lib/viewmodels/chat_viewmodel.dart @@ -120,13 +120,17 @@ class ChatViewModel with ChangeNotifier { Step executedStep = Step.fromMap(executedStepResponse); // Create a Chat object for the user message - final userChat = Chat( - id: executedStep.stepId, - taskId: executedStep.taskId, - message: executedStep.input, - timestamp: DateTime.now(), - messageType: MessageType.user, - ); + if (executedStep.input.isNotEmpty) { + final userChat = Chat( + id: executedStep.stepId, + taskId: executedStep.taskId, + message: executedStep.input, + timestamp: DateTime.now(), + messageType: MessageType.user, + ); + + _chats.add(userChat); + } // Create a Chat object for the agent message final agentChat = Chat( @@ -137,8 +141,6 @@ class ChatViewModel with ChangeNotifier { messageType: MessageType.agent, jsonResponse: executedStepResponse); - // Add the user and agent chats to the list - _chats.add(userChat); _chats.add(agentChat); // Notify UI of the new chats