Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

chore: trim markdown text (#7242)

Richard Shiue6bcef33d058e
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/message/ai_markdown_text.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/message/ai_markdown_text.dart
index 42518c2381..f178808390 100644
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/message/ai_markdown_text.dart
+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/message/ai_markdown_text.dart
@@ -52,7 +52,7 @@ class _AppFlowyEditorMarkdownState extends State<_AppFlowyEditorMarkdown> {
void initState() {
super.initState();
- editorState = _parseMarkdown(widget.markdown);
+ editorState = _parseMarkdown(widget.markdown.trim());
scrollController = EditorScrollController(
editorState: editorState,
shrinkWrap: true,
@@ -65,7 +65,7 @@ class _AppFlowyEditorMarkdownState extends State<_AppFlowyEditorMarkdown> {
if (oldWidget.markdown != widget.markdown) {
editorState.dispose();
- editorState = _parseMarkdown(widget.markdown);
+ editorState = _parseMarkdown(widget.markdown.trim());
scrollController.dispose();
scrollController = EditorScrollController(
editorState: editorState,
diff --git a/frontend/rust-lib/flowy-ai/src/chat.rs b/frontend/rust-lib/flowy-ai/src/chat.rs
index 00b41778a2..afefce3e06 100644
--- a/frontend/rust-lib/flowy-ai/src/chat.rs
+++ b/frontend/rust-lib/flowy-ai/src/chat.rs
@@ -279,7 +279,13 @@ impl Chat {
let content = answer_stream_buffer.lock().await.take_content();
let metadata = answer_stream_buffer.lock().await.take_metadata();
let answer = cloud_service
- .create_answer(&workspace_id, &chat_id, &content, question_id, metadata)
+ .create_answer(
+ &workspace_id,
+ &chat_id,
+ content.trim(),
+ question_id,
+ metadata,
+ )
.await?;
save_and_notify_message(uid, &chat_id, &user_service, answer)?;
Ok::<(), FlowyError>(())