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.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
chore: polish chat UI (#5533)
Nathan.foooe2ce27471826
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_bloc.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_bloc.dartindex 6adc99ad87..82840db5d9 100644--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_bloc.dart+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_bloc.dart@@ -377,6 +377,7 @@ class ChatBloc extends Bloc<ChatEvent, ChatState> {"chatId": chatId,},id: streamMessageId,+ createdAt: DateTime.now().millisecondsSinceEpoch,text: '',);}@@ -393,7 +394,7 @@ class ChatBloc extends Bloc<ChatEvent, ChatState> {author: User(id: message.authorId),id: messageId,text: message.content,- createdAt: message.createdAt.toInt(),+ createdAt: message.createdAt.toInt() * 1000,);}}diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_user_message_bloc.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_user_message_bloc.dartindex d75b0533e2..cae2b28c30 100644--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_user_message_bloc.dart+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_user_message_bloc.dart@@ -1,5 +1,7 @@-import 'package:appflowy_backend/protobuf/flowy-document/protobuf.dart';+import 'package:appflowy_backend/dispatch/dispatch.dart';+import 'package:appflowy_backend/log.dart';import 'package:appflowy_backend/protobuf/flowy-user/protobuf.dart';+import 'package:fixnum/fixnum.dart';import 'package:flutter_bloc/flutter_bloc.dart';import 'package:flutter_chat_types/flutter_chat_types.dart';import 'package:freezed_annotation/freezed_annotation.dart';@@ -13,9 +15,23 @@ class ChatUserMessageBloc}) : super(ChatUserMessageState.initial(message)) {on<ChatUserMessageEvent>((event, emit) async {- await event.when(- initial: () async {},- update: (userProfile, deviceId, states) {},+ event.when(+ initial: () {+ final payload =+ WorkspaceMemberIdPB(uid: Int64.parseInt(message.author.id));+ UserEventGetMemberInfo(payload).send().then((result) {+ if (!isClosed) {+ result.fold((member) {+ add(ChatUserMessageEvent.didReceiveMemberInfo(member));+ }, (err) {+ Log.error("Error getting member info: $err");+ });+ }+ });+ },+ didReceiveMemberInfo: (WorkspaceMemberPB memberInfo) {+ emit(state.copyWith(member: memberInfo));+ },);},);@@ -25,11 +41,9 @@ class ChatUserMessageBloc@freezedclass ChatUserMessageEvent with _$ChatUserMessageEvent {const factory ChatUserMessageEvent.initial() = Initial;- const factory ChatUserMessageEvent.update(- UserProfilePB userProfile,- String deviceId,- DocumentAwarenessStatesPB states,- ) = Update;+ const factory ChatUserMessageEvent.didReceiveMemberInfo(+ WorkspaceMemberPB memberInfo,+ ) = _MemberInfo;}@freezeddiff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/message/ai_text_message.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/message/ai_text_message.dartindex d2fa1b155c..0eb4dde938 100644--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/message/ai_text_message.dart+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/message/ai_text_message.dart@@ -134,7 +134,10 @@ class ChatAITextMessageWidget extends StatelessWidget {PreConfig(padding: const EdgeInsets.all(14),decoration: BoxDecoration(- color: Theme.of(context).colorScheme.surfaceContainerHighest,+ color: Theme.of(context)+ .colorScheme+ .surfaceContainerHighest+ .withOpacity(0.6),borderRadius: const BorderRadius.all(Radius.circular(8.0),),@@ -156,7 +159,10 @@ class ChatAITextMessageWidget extends StatelessWidget {height: 1.5,),),- BlockquoteConfig.darkConfig,+ BlockquoteConfig(+ sideColor: AFThemeExtension.of(context).lightGreyHover,+ textColor: AFThemeExtension.of(context).textColor,+ ),],);}diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/message/user_text_message.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/message/user_text_message.dartindex ba5254408d..3709cdd413 100644--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/message/user_text_message.dart+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/message/user_text_message.dart@@ -53,7 +53,8 @@ class TextMessageText extends StatelessWidget {fontSize: 16,fontWeight: FontWeight.w500,lineHeight: 1.5,- maxLines: 2000,+ maxLines: null,+ selectable: true,color: AFThemeExtension.of(context).textColor,);}diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/user_message_bubble.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/user_message_bubble.dartindex 3e1e4e6c24..9adf3d593b 100644--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/user_message_bubble.dart+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/user_message_bubble.dart@@ -29,7 +29,8 @@ class ChatUserMessageBubble extends StatelessWidget {Theme.of(context).colorScheme.surfaceContainerHighest;return BlocProvider(- create: (context) => ChatUserMessageBloc(message: message),+ create: (context) => ChatUserMessageBloc(message: message)+ ..add(const ChatUserMessageEvent.initial()),child: BlocBuilder<ChatUserMessageBloc, ChatUserMessageState>(builder: (context, state) {return Row(diff --git a/frontend/appflowy_flutter/packages/flowy_infra_ui/lib/style_widget/text.dart b/frontend/appflowy_flutter/packages/flowy_infra_ui/lib/style_widget/text.dartindex 5a62dc049e..b5c164bda7 100644--- a/frontend/appflowy_flutter/packages/flowy_infra_ui/lib/style_widget/text.dart+++ b/frontend/appflowy_flutter/packages/flowy_infra_ui/lib/style_widget/text.dart@@ -160,11 +160,13 @@ class FlowyText extends StatelessWidget {);if (selectable) {- child = SelectableText(- text,- maxLines: maxLines,- textAlign: textAlign,- style: textStyle,+ child = IntrinsicHeight(+ child: SelectableText(+ text,+ maxLines: maxLines,+ textAlign: textAlign,+ style: textStyle,+ ),);} else {child = Text(diff --git a/frontend/appflowy_tauri/src-tauri/Cargo.lock b/frontend/appflowy_tauri/src-tauri/Cargo.lockindex 277f884e74..5f50aa7f0d 100644--- a/frontend/appflowy_tauri/src-tauri/Cargo.lock+++ b/frontend/appflowy_tauri/src-tauri/Cargo.lock@@ -172,7 +172,7 @@ checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da"[[package]]name = "app-error"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ff4384fbd07a4b7394a9af8c9159cd65715d3471#ff4384fbd07a4b7394a9af8c9159cd65715d3471"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["anyhow","bincode",@@ -192,7 +192,7 @@ dependencies = [[[package]]name = "appflowy-ai-client"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ff4384fbd07a4b7394a9af8c9159cd65715d3471#ff4384fbd07a4b7394a9af8c9159cd65715d3471"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["anyhow","bytes",@@ -203,20 +203,6 @@ dependencies = ["thiserror",]-[[package]]-name = "appflowy-cloud-billing-client"-version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud-Billing-Client?rev=9f9c2d1ad180987a31d18c6c067a56a5fa1f6da6#9f9c2d1ad180987a31d18c6c067a56a5fa1f6da6"-dependencies = [- "client-api",- "reqwest",- "serde",- "serde_json",- "shared-entity",- "tokio",- "yrs",-]-[[package]]name = "appflowy_tauri"version = "0.0.0"@@ -786,7 +772,7 @@ dependencies = [[[package]]name = "client-api"version = "0.2.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ff4384fbd07a4b7394a9af8c9159cd65715d3471#ff4384fbd07a4b7394a9af8c9159cd65715d3471"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["again","anyhow",@@ -833,7 +819,7 @@ dependencies = [[[package]]name = "client-websocket"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ff4384fbd07a4b7394a9af8c9159cd65715d3471#ff4384fbd07a4b7394a9af8c9159cd65715d3471"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["futures-channel","futures-util",@@ -1073,7 +1059,7 @@ dependencies = [[[package]]name = "collab-rt-entity"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ff4384fbd07a4b7394a9af8c9159cd65715d3471#ff4384fbd07a4b7394a9af8c9159cd65715d3471"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["anyhow","bincode",@@ -1098,7 +1084,7 @@ dependencies = [[[package]]name = "collab-rt-protocol"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ff4384fbd07a4b7394a9af8c9159cd65715d3471#ff4384fbd07a4b7394a9af8c9159cd65715d3471"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["anyhow","async-trait",@@ -1344,7 +1330,7 @@ dependencies = ["cssparser-macros","dtoa-short","itoa 1.0.6",- "phf 0.11.2",+ "phf 0.8.0","smallvec",]@@ -1455,7 +1441,7 @@ checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308"[[package]]name = "database-entity"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ff4384fbd07a4b7394a9af8c9159cd65715d3471#ff4384fbd07a4b7394a9af8c9159cd65715d3471"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["anyhow","app-error",@@ -1872,6 +1858,7 @@ dependencies = [name = "flowy-chat-pub"version = "0.1.0"dependencies = [+ "bytes","client-api","flowy-error","futures",@@ -2262,7 +2249,6 @@ name = "flowy-server"version = "0.1.0"dependencies = ["anyhow",- "appflowy-cloud-billing-client","bytes","chrono","client-api",@@ -2876,7 +2862,7 @@ dependencies = [[[package]]name = "gotrue"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ff4384fbd07a4b7394a9af8c9159cd65715d3471#ff4384fbd07a4b7394a9af8c9159cd65715d3471"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["anyhow","futures-util",@@ -2893,7 +2879,7 @@ dependencies = [[[package]]name = "gotrue-entity"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ff4384fbd07a4b7394a9af8c9159cd65715d3471#ff4384fbd07a4b7394a9af8c9159cd65715d3471"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["anyhow","app-error",@@ -3325,7 +3311,7 @@ dependencies = [[[package]]name = "infra"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ff4384fbd07a4b7394a9af8c9159cd65715d3471#ff4384fbd07a4b7394a9af8c9159cd65715d3471"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["anyhow","reqwest",@@ -4830,7 +4816,7 @@ checksum = "c55e02e35260070b6f716a2423c2ff1c3bb1642ddca6f99e1f26d06268a0e2d2"dependencies = ["bytes","heck 0.4.1",- "itertools 0.11.0",+ "itertools 0.10.5","log","multimap","once_cell",@@ -4851,7 +4837,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "efb6c9a1dd1def8e2124d17e83a20af56f1570d6c2d2bd9e266ccb768df3840e"dependencies = ["anyhow",- "itertools 0.11.0",+ "itertools 0.10.5","proc-macro2","quote","syn 2.0.47",@@ -5815,7 +5801,7 @@ dependencies = [[[package]]name = "shared-entity"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ff4384fbd07a4b7394a9af8c9159cd65715d3471#ff4384fbd07a4b7394a9af8c9159cd65715d3471"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["anyhow","app-error",diff --git a/frontend/appflowy_tauri/src-tauri/Cargo.toml b/frontend/appflowy_tauri/src-tauri/Cargo.tomlindex ed266154e6..431a37d895 100644--- a/frontend/appflowy_tauri/src-tauri/Cargo.toml+++ b/frontend/appflowy_tauri/src-tauri/Cargo.toml@@ -52,7 +52,7 @@ collab-user = { version = "0.2" }# Run the script:# scripts/tool/update_client_api_rev.sh new_rev_id# ⚠️⚠️⚠️️-client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "9d3d28ad8937712cc688c20be7c0ee6e4d14a168" }+client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "430e3e15c9a1dc6aba2a9599d17d946a61ac7cae" }[dependencies]serde_json.workspace = truediff --git a/frontend/appflowy_web/wasm-libs/Cargo.lock b/frontend/appflowy_web/wasm-libs/Cargo.lockindex 183530fefd..a67f568f0a 100644--- a/frontend/appflowy_web/wasm-libs/Cargo.lock+++ b/frontend/appflowy_web/wasm-libs/Cargo.lock@@ -216,7 +216,7 @@ checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da"[[package]]name = "app-error"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ff4384fbd07a4b7394a9af8c9159cd65715d3471#ff4384fbd07a4b7394a9af8c9159cd65715d3471"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["anyhow","bincode",@@ -236,7 +236,7 @@ dependencies = [[[package]]name = "appflowy-ai-client"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ff4384fbd07a4b7394a9af8c9159cd65715d3471#ff4384fbd07a4b7394a9af8c9159cd65715d3471"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["anyhow","bytes",@@ -247,20 +247,6 @@ dependencies = ["thiserror",]-[[package]]-name = "appflowy-cloud-billing-client"-version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud-Billing-Client?rev=9f9c2d1ad180987a31d18c6c067a56a5fa1f6da6#9f9c2d1ad180987a31d18c6c067a56a5fa1f6da6"-dependencies = [- "client-api",- "reqwest",- "serde",- "serde_json",- "shared-entity",- "tokio",- "yrs",-]-[[package]]name = "arc-swap"version = "1.7.1"@@ -576,7 +562,7 @@ dependencies = [[[package]]name = "client-api"version = "0.2.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ff4384fbd07a4b7394a9af8c9159cd65715d3471#ff4384fbd07a4b7394a9af8c9159cd65715d3471"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["again","anyhow",@@ -623,7 +609,7 @@ dependencies = [[[package]]name = "client-websocket"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ff4384fbd07a4b7394a9af8c9159cd65715d3471#ff4384fbd07a4b7394a9af8c9159cd65715d3471"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["futures-channel","futures-util",@@ -801,7 +787,7 @@ dependencies = [[[package]]name = "collab-rt-entity"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ff4384fbd07a4b7394a9af8c9159cd65715d3471#ff4384fbd07a4b7394a9af8c9159cd65715d3471"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["anyhow","bincode",@@ -826,7 +812,7 @@ dependencies = [[[package]]name = "collab-rt-protocol"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ff4384fbd07a4b7394a9af8c9159cd65715d3471#ff4384fbd07a4b7394a9af8c9159cd65715d3471"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["anyhow","async-trait",@@ -995,7 +981,7 @@ dependencies = ["cssparser-macros","dtoa-short","itoa",- "phf 0.11.2",+ "phf 0.8.0","smallvec",]@@ -1040,7 +1026,7 @@ checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5"[[package]]name = "database-entity"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ff4384fbd07a4b7394a9af8c9159cd65715d3471#ff4384fbd07a4b7394a9af8c9159cd65715d3471"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["anyhow","app-error",@@ -1320,6 +1306,7 @@ dependencies = [name = "flowy-chat-pub"version = "0.1.0"dependencies = [+ "bytes","client-api","flowy-error","futures",@@ -1546,7 +1533,6 @@ name = "flowy-server"version = "0.1.0"dependencies = ["anyhow",- "appflowy-cloud-billing-client","bytes","chrono","client-api",@@ -1901,7 +1887,7 @@ dependencies = [[[package]]name = "gotrue"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ff4384fbd07a4b7394a9af8c9159cd65715d3471#ff4384fbd07a4b7394a9af8c9159cd65715d3471"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["anyhow","futures-util",@@ -1918,7 +1904,7 @@ dependencies = [[[package]]name = "gotrue-entity"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ff4384fbd07a4b7394a9af8c9159cd65715d3471#ff4384fbd07a4b7394a9af8c9159cd65715d3471"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["anyhow","app-error",@@ -2219,7 +2205,7 @@ dependencies = [[[package]]name = "infra"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ff4384fbd07a4b7394a9af8c9159cd65715d3471#ff4384fbd07a4b7394a9af8c9159cd65715d3471"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["anyhow","reqwest",@@ -2936,7 +2922,7 @@ version = "0.8.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "3dfb61232e34fcb633f43d12c58f83c1df82962dcdfa565a4e866ffc17dafe12"dependencies = [- "phf_macros 0.8.0",+ "phf_macros","phf_shared 0.8.0","proc-macro-hack",]@@ -2956,7 +2942,6 @@ version = "0.11.2"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc"dependencies = [- "phf_macros 0.11.2","phf_shared 0.11.2",]@@ -3024,19 +3009,6 @@ dependencies = ["syn 1.0.109",]-[[package]]-name = "phf_macros"-version = "0.11.2"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "3444646e286606587e49f3bcf1679b8cef1dc2c5ecc29ddacaffc305180d464b"-dependencies = [- "phf_generator 0.11.2",- "phf_shared 0.11.2",- "proc-macro2",- "quote",- "syn 2.0.48",-]-[[package]]name = "phf_shared"version = "0.8.0"@@ -3921,7 +3893,7 @@ dependencies = [[[package]]name = "shared-entity"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ff4384fbd07a4b7394a9af8c9159cd65715d3471#ff4384fbd07a4b7394a9af8c9159cd65715d3471"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["anyhow","app-error",diff --git a/frontend/appflowy_web/wasm-libs/Cargo.toml b/frontend/appflowy_web/wasm-libs/Cargo.tomlindex 1562e0b0ed..24b745fd0a 100644--- a/frontend/appflowy_web/wasm-libs/Cargo.toml+++ b/frontend/appflowy_web/wasm-libs/Cargo.toml@@ -55,7 +55,7 @@ yrs = "0.18.8"# Run the script:# scripts/tool/update_client_api_rev.sh new_rev_id# ⚠️⚠️⚠️️-client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "9d3d28ad8937712cc688c20be7c0ee6e4d14a168" }+client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "430e3e15c9a1dc6aba2a9599d17d946a61ac7cae" }[profile.dev]opt-level = 0diff --git a/frontend/appflowy_web_app/src-tauri/Cargo.lock b/frontend/appflowy_web_app/src-tauri/Cargo.lockindex 844f7d57c2..e3589d8718 100644--- a/frontend/appflowy_web_app/src-tauri/Cargo.lock+++ b/frontend/appflowy_web_app/src-tauri/Cargo.lock@@ -163,7 +163,7 @@ checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247"[[package]]name = "app-error"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ff4384fbd07a4b7394a9af8c9159cd65715d3471#ff4384fbd07a4b7394a9af8c9159cd65715d3471"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["anyhow","bincode",@@ -183,7 +183,7 @@ dependencies = [[[package]]name = "appflowy-ai-client"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ff4384fbd07a4b7394a9af8c9159cd65715d3471#ff4384fbd07a4b7394a9af8c9159cd65715d3471"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["anyhow","bytes",@@ -746,7 +746,7 @@ dependencies = [[[package]]name = "client-api"version = "0.2.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ff4384fbd07a4b7394a9af8c9159cd65715d3471#ff4384fbd07a4b7394a9af8c9159cd65715d3471"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["again","anyhow",@@ -793,7 +793,7 @@ dependencies = [[[package]]name = "client-websocket"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ff4384fbd07a4b7394a9af8c9159cd65715d3471#ff4384fbd07a4b7394a9af8c9159cd65715d3471"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["futures-channel","futures-util",@@ -1042,7 +1042,7 @@ dependencies = [[[package]]name = "collab-rt-entity"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ff4384fbd07a4b7394a9af8c9159cd65715d3471#ff4384fbd07a4b7394a9af8c9159cd65715d3471"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["anyhow","bincode",@@ -1067,7 +1067,7 @@ dependencies = [[[package]]name = "collab-rt-protocol"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ff4384fbd07a4b7394a9af8c9159cd65715d3471#ff4384fbd07a4b7394a9af8c9159cd65715d3471"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["anyhow","async-trait",@@ -1428,7 +1428,7 @@ checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5"[[package]]name = "database-entity"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ff4384fbd07a4b7394a9af8c9159cd65715d3471#ff4384fbd07a4b7394a9af8c9159cd65715d3471"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["anyhow","app-error",@@ -1895,6 +1895,7 @@ dependencies = [name = "flowy-chat-pub"version = "0.1.0"dependencies = [+ "bytes","client-api","flowy-error","futures",@@ -2248,6 +2249,7 @@ dependencies = ["flowy-codegen","flowy-derive","flowy-error",+ "flowy-folder","flowy-notification","flowy-search-pub","flowy-sqlite",@@ -2934,7 +2936,7 @@ dependencies = [[[package]]name = "gotrue"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ff4384fbd07a4b7394a9af8c9159cd65715d3471#ff4384fbd07a4b7394a9af8c9159cd65715d3471"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["anyhow","futures-util",@@ -2951,7 +2953,7 @@ dependencies = [[[package]]name = "gotrue-entity"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ff4384fbd07a4b7394a9af8c9159cd65715d3471#ff4384fbd07a4b7394a9af8c9159cd65715d3471"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["anyhow","app-error",@@ -3388,7 +3390,7 @@ dependencies = [[[package]]name = "infra"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ff4384fbd07a4b7394a9af8c9159cd65715d3471#ff4384fbd07a4b7394a9af8c9159cd65715d3471"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["anyhow","reqwest",@@ -5894,7 +5896,7 @@ dependencies = [[[package]]name = "shared-entity"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ff4384fbd07a4b7394a9af8c9159cd65715d3471#ff4384fbd07a4b7394a9af8c9159cd65715d3471"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["anyhow","app-error",@@ -6873,9 +6875,9 @@ checksum = "c7c4ceeeca15c8384bbc3e011dbd8fccb7f068a440b752b7d9b32ceb0ca0e2e8"[[package]]name = "tokio"-version = "1.36.0"+version = "1.38.0"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931"+checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a"dependencies = ["backtrace","bytes",@@ -6893,9 +6895,9 @@ dependencies = [[[package]]name = "tokio-macros"-version = "2.2.0"+version = "2.3.0"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b"+checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a"dependencies = ["proc-macro2","quote",diff --git a/frontend/appflowy_web_app/src-tauri/Cargo.toml b/frontend/appflowy_web_app/src-tauri/Cargo.tomlindex 99da587196..597dfb2fb4 100644--- a/frontend/appflowy_web_app/src-tauri/Cargo.toml+++ b/frontend/appflowy_web_app/src-tauri/Cargo.toml@@ -52,7 +52,7 @@ collab-user = { version = "0.2" }# Run the script:# scripts/tool/update_client_api_rev.sh new_rev_id# ⚠️⚠️⚠️️-client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "9d3d28ad8937712cc688c20be7c0ee6e4d14a168" }+client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "430e3e15c9a1dc6aba2a9599d17d946a61ac7cae" }[dependencies]serde_json.workspace = truediff --git a/frontend/rust-lib/Cargo.lock b/frontend/rust-lib/Cargo.lockindex 5e3d4f75de..2bbf911d5c 100644--- a/frontend/rust-lib/Cargo.lock+++ b/frontend/rust-lib/Cargo.lock@@ -163,7 +163,7 @@ checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da"[[package]]name = "app-error"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=9d3d28ad8937712cc688c20be7c0ee6e4d14a168#9d3d28ad8937712cc688c20be7c0ee6e4d14a168"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["anyhow","bincode",@@ -183,7 +183,7 @@ dependencies = [[[package]]name = "appflowy-ai-client"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=9d3d28ad8937712cc688c20be7c0ee6e4d14a168#9d3d28ad8937712cc688c20be7c0ee6e4d14a168"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["anyhow","bytes",@@ -664,7 +664,7 @@ dependencies = [[[package]]name = "client-api"version = "0.2.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=9d3d28ad8937712cc688c20be7c0ee6e4d14a168#9d3d28ad8937712cc688c20be7c0ee6e4d14a168"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["again","anyhow",@@ -711,7 +711,7 @@ dependencies = [[[package]]name = "client-websocket"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=9d3d28ad8937712cc688c20be7c0ee6e4d14a168#9d3d28ad8937712cc688c20be7c0ee6e4d14a168"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["futures-channel","futures-util",@@ -920,7 +920,7 @@ dependencies = [[[package]]name = "collab-rt-entity"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=9d3d28ad8937712cc688c20be7c0ee6e4d14a168#9d3d28ad8937712cc688c20be7c0ee6e4d14a168"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["anyhow","bincode",@@ -945,7 +945,7 @@ dependencies = [[[package]]name = "collab-rt-protocol"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=9d3d28ad8937712cc688c20be7c0ee6e4d14a168#9d3d28ad8937712cc688c20be7c0ee6e4d14a168"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["anyhow","async-trait",@@ -1265,7 +1265,7 @@ checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308"[[package]]name = "database-entity"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=9d3d28ad8937712cc688c20be7c0ee6e4d14a168#9d3d28ad8937712cc688c20be7c0ee6e4d14a168"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["anyhow","app-error",@@ -1677,6 +1677,7 @@ dependencies = [name = "flowy-chat-pub"version = "0.1.0"dependencies = [+ "bytes","client-api","flowy-error","futures",@@ -2531,7 +2532,7 @@ dependencies = [[[package]]name = "gotrue"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=9d3d28ad8937712cc688c20be7c0ee6e4d14a168#9d3d28ad8937712cc688c20be7c0ee6e4d14a168"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["anyhow","futures-util",@@ -2548,7 +2549,7 @@ dependencies = [[[package]]name = "gotrue-entity"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=9d3d28ad8937712cc688c20be7c0ee6e4d14a168#9d3d28ad8937712cc688c20be7c0ee6e4d14a168"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["anyhow","app-error",@@ -2913,7 +2914,7 @@ dependencies = [[[package]]name = "infra"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=9d3d28ad8937712cc688c20be7c0ee6e4d14a168#9d3d28ad8937712cc688c20be7c0ee6e4d14a168"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["anyhow","reqwest",@@ -4997,7 +4998,7 @@ dependencies = [[[package]]name = "shared-entity"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=9d3d28ad8937712cc688c20be7c0ee6e4d14a168#9d3d28ad8937712cc688c20be7c0ee6e4d14a168"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=430e3e15c9a1dc6aba2a9599d17d946a61ac7cae#430e3e15c9a1dc6aba2a9599d17d946a61ac7cae"dependencies = ["anyhow","app-error",diff --git a/frontend/rust-lib/Cargo.toml b/frontend/rust-lib/Cargo.tomlindex cf4dc6fcbc..684fed94f0 100644--- a/frontend/rust-lib/Cargo.toml+++ b/frontend/rust-lib/Cargo.toml@@ -94,7 +94,7 @@ yrs = "0.18.8"# Run the script.add_workspace_members:# scripts/tool/update_client_api_rev.sh new_rev_id# ⚠️⚠️⚠️️-client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "9d3d28ad8937712cc688c20be7c0ee6e4d14a168" }+client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "430e3e15c9a1dc6aba2a9599d17d946a61ac7cae" }[profile.dev]opt-level = 1diff --git a/frontend/rust-lib/flowy-chat-pub/Cargo.toml b/frontend/rust-lib/flowy-chat-pub/Cargo.tomlindex 0cfdae0ec9..f320fb2133 100644--- a/frontend/rust-lib/flowy-chat-pub/Cargo.toml+++ b/frontend/rust-lib/flowy-chat-pub/Cargo.toml@@ -9,4 +9,5 @@ edition = "2021"lib-infra = { workspace = true }flowy-error = { workspace = true }client-api = { workspace = true }+bytes.workspace = truefutures.workspace = true\ No newline at end of filediff --git a/frontend/rust-lib/flowy-chat-pub/src/cloud.rs b/frontend/rust-lib/flowy-chat-pub/src/cloud.rsindex f8b81c250a..8ab60069a5 100644--- a/frontend/rust-lib/flowy-chat-pub/src/cloud.rs+++ b/frontend/rust-lib/flowy-chat-pub/src/cloud.rs@@ -1,3 +1,4 @@+use bytes::Bytes;pub use client_api::entity::ai_dto::{RelatedQuestion, RepeatedRelatedQuestion, StringOrMessage};pub use client_api::entity::{ChatAuthorType, ChatMessage, ChatMessageType, MessageCursor, QAChatMessage, RepeatedChatMessage,@@ -9,7 +10,7 @@ use lib_infra::async_trait::async_trait;use lib_infra::future::FutureResult;pub type ChatMessageStream = BoxStream<'static, Result<ChatMessage, AppResponseError>>;-pub type StreamAnswer = BoxStream<'static, Result<StringOrMessage, AppResponseError>>;+pub type StreamAnswer = BoxStream<'static, Result<Bytes, AppResponseError>>;#[async_trait]pub trait ChatCloudService: Send + Sync + 'static {fn create_chat(diff --git a/frontend/rust-lib/flowy-chat/src/chat.rs b/frontend/rust-lib/flowy-chat/src/chat.rsindex 0f81c92c28..cb32c342c8 100644--- a/frontend/rust-lib/flowy-chat/src/chat.rs+++ b/frontend/rust-lib/flowy-chat/src/chat.rs@@ -5,9 +5,7 @@ use crate::manager::ChatUserService;use crate::notification::{send_notification, ChatNotification};use crate::persistence::{insert_chat_messages, select_chat_messages, ChatMessageTable};use allo_isolate::Isolate;-use flowy_chat_pub::cloud::{- ChatCloudService, ChatMessage, ChatMessageType, MessageCursor, StringOrMessage,-};+use flowy_chat_pub::cloud::{ChatCloudService, ChatMessage, ChatMessageType, MessageCursor};use flowy_error::{FlowyError, FlowyResult};use flowy_sqlite::DBConnection;use futures::{SinkExt, StreamExt};@@ -122,30 +120,14 @@ impl Chat {Ok(mut stream) => {while let Some(message) = stream.next().await {match message {- Ok(message) => match message {- StringOrMessage::Left(s) => {- if stop_stream.load(std::sync::atomic::Ordering::Relaxed) {- send_notification(&chat_id, ChatNotification::FinishStreaming).send();- trace!("[Chat] stop streaming message");- let answer = cloud_service- .save_answer(- &workspace_id,- &chat_id,- &stream_buffer.lock().await,- question_id,- )- .await?;- Self::save_answer(uid, &chat_id, &user_service, answer)?;- break;- }- stream_buffer.lock().await.push_str(&s);- let _ = text_sink.send(format!("data:{}", s)).await;- },- StringOrMessage::Right(answer) => {- trace!("[Chat] received final answer: {:?}", answer);- send_notification(&chat_id, ChatNotification::FinishStreaming).send();- Self::save_answer(uid, &chat_id, &user_service, answer)?;- },+ Ok(message) => {+ if stop_stream.load(std::sync::atomic::Ordering::Relaxed) {+ trace!("[Chat] stop streaming message");+ break;+ }+ let s = String::from_utf8(message.to_vec()).unwrap_or_default();+ stream_buffer.lock().await.push_str(&s);+ let _ = text_sink.send(format!("data:{}", s)).await;},Err(err) => {error!("[Chat] failed to stream answer: {}", err);@@ -172,6 +154,18 @@ impl Chat {.send();},}++ send_notification(&chat_id, ChatNotification::FinishStreaming).send();+ let answer = cloud_service+ .save_answer(+ &workspace_id,+ &chat_id,+ &stream_buffer.lock().await,+ question_id,+ )+ .await?;+ Self::save_answer(uid, &chat_id, &user_service, answer)?;+Ok::<(), FlowyError>(())});diff --git a/frontend/rust-lib/flowy-server/src/af_cloud/impls/user/cloud_service_impl.rs b/frontend/rust-lib/flowy-server/src/af_cloud/impls/user/cloud_service_impl.rsindex 4c456f37fa..dc82ad3e17 100644--- a/frontend/rust-lib/flowy-server/src/af_cloud/impls/user/cloud_service_impl.rs+++ b/frontend/rust-lib/flowy-server/src/af_cloud/impls/user/cloud_service_impl.rs@@ -11,6 +11,7 @@ use client_api::entity::workspace_dto::{};use client_api::entity::{AFRole, AFWorkspace, AFWorkspaceInvitation, AuthProvider, CollabParams, CreateCollabParams,+ QueryWorkspaceMember,};use client_api::entity::{QueryCollab, QueryCollabParams};use client_api::{Client, ClientConfiguration};@@ -502,6 +503,34 @@ where})}+ fn get_workspace_member_info(+ &self,+ workspace_id: &str,+ uid: i64,+ ) -> FutureResult<WorkspaceMember, FlowyError> {+ let try_get_client = self.server.try_get_client();+ let workspace_id = workspace_id.to_string();+ FutureResult::new(async move {+ let client = try_get_client?;+ let params = QueryWorkspaceMember {+ workspace_id: workspace_id.to_string(),+ uid,+ };+ let member = client.get_workspace_member(params).await?;+ let role = match member.role {+ AFRole::Owner => Role::Owner,+ AFRole::Member => Role::Member,+ AFRole::Guest => Role::Guest,+ };+ Ok(WorkspaceMember {+ email: member.email,+ role,+ name: member.name,+ avatar_url: member.avatar_url,+ })+ })+ }+fn get_workspace_subscriptions(&self) -> FutureResult<Vec<WorkspaceSubscription>, FlowyError> {let try_get_client = self.server.try_get_client();FutureResult::new(async move {diff --git a/frontend/rust-lib/flowy-user-pub/src/cloud.rs b/frontend/rust-lib/flowy-user-pub/src/cloud.rsindex 0400c8ba51..ccfc3f88b0 100644--- a/frontend/rust-lib/flowy-user-pub/src/cloud.rs+++ b/frontend/rust-lib/flowy-user-pub/src/cloud.rs@@ -1,7 +1,6 @@use collab_entity::{CollabObject, CollabType};use flowy_error::{internal_error, ErrorCode, FlowyError};use lib_infra::box_any::BoxAny;-use lib_infra::conditional_send_sync_trait;use lib_infra::future::FutureResult;use serde::{Deserialize, Serialize};use serde_json::Value;@@ -53,12 +52,7 @@ impl Display for UserCloudConfig {}}-conditional_send_sync_trait! {- "This trait is intended for implementation by providers that offer cloud-based services for users.- It includes methods for handling authentication tokens, enabling/disabling synchronization,- setting network reachability, managing encryption secrets, and accessing user-specific cloud services.";-- UserCloudServiceProvider {+pub trait UserCloudServiceProvider: Send + Sync {/// Sets the authentication token for the cloud service.////// # Arguments@@ -113,8 +107,8 @@ conditional_send_sync_trait! {/// # Returns/// A `String` representing the service URL.fn service_url(&self) -> String;- }}+/// Provide the generic interface for the user cloud service/// The user cloud service is responsible for the user authentication and user profile management#[allow(unused_variables)]@@ -278,6 +272,14 @@ pub trait UserCloudService: Send + Sync + 'static {FutureResult::new(async { Err(FlowyError::not_support()) })}+ fn get_workspace_member_info(+ &self,+ workspace_id: &str,+ uid: i64,+ ) -> FutureResult<WorkspaceMember, FlowyError> {+ FutureResult::new(async { Err(FlowyError::not_support()) })+ }+fn get_workspace_subscriptions(&self) -> FutureResult<Vec<WorkspaceSubscription>, FlowyError> {FutureResult::new(async { Err(FlowyError::not_support()) })}diff --git a/frontend/rust-lib/flowy-user/src/entities/workspace.rs b/frontend/rust-lib/flowy-user/src/entities/workspace.rsindex 1af4f2b020..d860385de0 100644--- a/frontend/rust-lib/flowy-user/src/entities/workspace.rs+++ b/frontend/rust-lib/flowy-user/src/entities/workspace.rs@@ -177,6 +177,12 @@ pub struct UserWorkspaceIdPB {pub workspace_id: String,}+#[derive(ProtoBuf, Default, Clone)]+pub struct WorkspaceMemberIdPB {+ #[pb(index = 1)]+ pub uid: i64,+}+#[derive(ProtoBuf, Default, Clone, Validate)]pub struct CreateWorkspacePB {#[pb(index = 1)]diff --git a/frontend/rust-lib/flowy-user/src/event_handler.rs b/frontend/rust-lib/flowy-user/src/event_handler.rsindex 0e225e6416..3f7aa93a61 100644--- a/frontend/rust-lib/flowy-user/src/event_handler.rs+++ b/frontend/rust-lib/flowy-user/src/event_handler.rs@@ -835,3 +835,13 @@ pub async fn get_billing_portal_handler(let url = manager.get_billing_portal_url().await?;data_result_ok(BillingPortalPB { url })}++#[tracing::instrument(level = "debug", skip_all, err)]+pub async fn get_workspace_member_info(+ param: AFPluginData<WorkspaceMemberIdPB>,+ manager: AFPluginState<Weak<UserManager>>,+) -> DataResult<WorkspaceMemberPB, FlowyError> {+ let manager = upgrade_manager(manager)?;+ let member = manager.get_workspace_member_info(param.uid).await?;+ data_result_ok(member.into())+}diff --git a/frontend/rust-lib/flowy-user/src/event_map.rs b/frontend/rust-lib/flowy-user/src/event_map.rsindex 1fa03d7604..c1407254e1 100644--- a/frontend/rust-lib/flowy-user/src/event_map.rs+++ b/frontend/rust-lib/flowy-user/src/event_map.rs@@ -57,7 +57,7 @@ pub fn init(user_manager: Weak<UserManager>) -> AFPlugin {// Workspace member.event(UserEvent::AddWorkspaceMember, add_workspace_member_handler) // deprecated, use invite// instead-+ .event(UserEvent::GetMemberInfo, get_workspace_member_info).event(UserEvent::RemoveWorkspaceMember, delete_workspace_member_handler).event(UserEvent::GetWorkspaceMember, get_workspace_member_handler).event(UserEvent::UpdateWorkspaceMember, update_workspace_member_handler)@@ -77,6 +77,7 @@ pub fn init(user_manager: Weak<UserManager>) -> AFPlugin {.event(UserEvent::CancelWorkspaceSubscription, cancel_workspace_subscription_handler).event(UserEvent::GetWorkspaceUsage, get_workspace_usage_handler).event(UserEvent::GetBillingPortal, get_billing_portal_handler)+}#[derive(Clone, Copy, PartialEq, Eq, Debug, Display, Hash, ProtoBuf_Enum, Flowy_Event)]@@ -251,6 +252,9 @@ pub enum UserEvent {#[event(output = "BillingPortalPB")]GetBillingPortal = 55,++ #[event(input = "WorkspaceMemberIdPB", output = "WorkspaceMemberPB")]+ GetMemberInfo = 56,}pub trait UserStatusCallback: Send + Sync + 'static {diff --git a/frontend/rust-lib/flowy-user/src/user_manager/manager_user_workspace.rs b/frontend/rust-lib/flowy-user/src/user_manager/manager_user_workspace.rsindex f6f0f70720..a94639e620 100644--- a/frontend/rust-lib/flowy-user/src/user_manager/manager_user_workspace.rs+++ b/frontend/rust-lib/flowy-user/src/user_manager/manager_user_workspace.rs@@ -479,6 +479,17 @@ impl UserManager {.await?;Ok(url)}++ #[instrument(level = "debug", skip(self), err)]+ pub async fn get_workspace_member_info(&self, uid: i64) -> FlowyResult<WorkspaceMember> {+ let workspace_id = self.get_session()?.user_workspace.id.clone();+ let member = self+ .cloud_services+ .get_user_service()?+ .get_workspace_member_info(&workspace_id, uid)+ .await?;+ Ok(member)+ }}/// This method is used to save one user workspace to the SQLite database