From 82434a248c92d68e6ffa624b984358566131820a Mon Sep 17 00:00:00 2001 From: hunteraraujo Date: Fri, 20 Oct 2023 08:07:27 -0700 Subject: Disable markdown as it causes crash for some responses --- frontend/lib/views/chat/agent_message_tile.dart | 10 +++++----- frontend/lib/views/chat/user_message_tile.dart | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'frontend') diff --git a/frontend/lib/views/chat/agent_message_tile.dart b/frontend/lib/views/chat/agent_message_tile.dart index 4639b76bd..851af1f06 100644 --- a/frontend/lib/views/chat/agent_message_tile.dart +++ b/frontend/lib/views/chat/agent_message_tile.dart @@ -28,14 +28,13 @@ class _AgentMessageTileState extends State { int artifactsCount = widget.chat.artifacts.length; bool containsMarkdown(String text) { - // Regular expression to detect Markdown patterns including code blocks. + // Regular expression to detect Markdown patterns like headers, bold, links, etc. final RegExp markdownPattern = RegExp( r'(?:\*\*|__).*?(?:\*\*|__)|' + // Bold r'(?:\*|_).*?(?:\*|_)|' + // Italic r'\[.*?\]\(.*?\)|' + // Links r'!\[.*?\]\(.*?\)|' + // Images - r'#{1,6}.*|' + // Headers - r'`.*?`', // Inline Code Blocks + r'#{1,6}.*', // Headers multiLine: true, caseSensitive: false, ); @@ -81,9 +80,10 @@ class _AgentMessageTileState extends State { Expanded( child: Container( padding: const EdgeInsets.fromLTRB(0, 10, 20, 10), - child: hasMarkdown + child: false ? Markdown(data: widget.chat.message) - : Text(widget.chat.message, maxLines: null), + : SelectableText(widget.chat.message, + maxLines: null), ), ), ElevatedButton( diff --git a/frontend/lib/views/chat/user_message_tile.dart b/frontend/lib/views/chat/user_message_tile.dart index a707a6e53..f8c5019db 100644 --- a/frontend/lib/views/chat/user_message_tile.dart +++ b/frontend/lib/views/chat/user_message_tile.dart @@ -54,7 +54,7 @@ class UserMessageTile extends StatelessWidget { // Padding for the text content padding: const EdgeInsets.fromLTRB(0, 10, 20, 10), // Displaying the user message with no max line limit - child: Text( + child: SelectableText( message, maxLines: null, ), -- cgit v1.2.3