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.

feat: AI chat UI improvements (#6760)

Richard Shiuebced9327b1cc
diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/home/tab/ai_bubble_button.dart b/frontend/appflowy_flutter/lib/mobile/presentation/home/tab/ai_bubble_button.dart
index a5cb39ffaa..b3f10bbbd2 100644
--- a/frontend/appflowy_flutter/lib/mobile/presentation/home/tab/ai_bubble_button.dart
+++ b/frontend/appflowy_flutter/lib/mobile/presentation/home/tab/ai_bubble_button.dart
@@ -16,15 +16,18 @@ class FloatingAIEntry extends StatelessWidget {
scaleFactor: 0.99,
onTapUp: () => mobileCreateNewAIChatNotifier.value =
mobileCreateNewAIChatNotifier.value + 1,
- child: DecoratedBox(
- decoration: _buildShadowDecoration(context),
- child: Container(
- decoration: _buildWrapperDecoration(context),
- height: 48,
- alignment: Alignment.centerLeft,
- child: Padding(
- padding: const EdgeInsets.only(left: 18),
- child: _buildHintText(context),
+ child: Hero(
+ tag: "ai_chat_prompt",
+ child: DecoratedBox(
+ decoration: _buildShadowDecoration(context),
+ child: Container(
+ decoration: _buildWrapperDecoration(context),
+ height: 48,
+ alignment: Alignment.centerLeft,
+ child: Padding(
+ padding: const EdgeInsets.only(left: 18),
+ child: _buildHintText(context),
+ ),
),
),
),
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_file_bloc.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/application/ai_prompt_input_bloc.dart
similarity index 52%
rename from frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_file_bloc.dart
rename to frontend/appflowy_flutter/lib/plugins/ai_chat/application/ai_prompt_input_bloc.dart
index a01c3b32d5..99a00228c7 100644
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_file_bloc.dart
+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/application/ai_prompt_input_bloc.dart
@@ -5,58 +5,52 @@ import 'package:appflowy/workspace/application/settings/ai/local_llm_listener.da
import 'package:appflowy_backend/dispatch/dispatch.dart';
import 'package:appflowy_backend/log.dart';
import 'package:appflowy_backend/protobuf/flowy-ai/entities.pb.dart';
+import 'package:appflowy_result/appflowy_result.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
-import 'chat_input_bloc.dart';
+part 'ai_prompt_input_bloc.freezed.dart';
-part 'chat_file_bloc.freezed.dart';
+class AIPromptInputBloc extends Bloc<AIPromptInputEvent, AIPromptInputState> {
+ AIPromptInputBloc()
+ : _listener = LocalLLMListener(),
+ super(AIPromptInputState.initial()) {
+ _dispatch();
+ _startListening();
+ _init();
+ }
-class ChatFileBloc extends Bloc<ChatFileEvent, ChatFileState> {
- ChatFileBloc()
- : listener = LocalLLMListener(),
- super(const ChatFileState()) {
- listener.start(
- stateCallback: (pluginState) {
- if (!isClosed) {
- add(ChatFileEvent.updatePluginState(pluginState));
- }
- },
- chatStateCallback: (chatState) {
- if (!isClosed) {
- add(ChatFileEvent.updateChatState(chatState));
- }
- },
- );
+ ChatInputFileMetadata consumeMetadata() {
+ final metadata = {
+ for (final file in state.uploadFiles) file.filePath: file,
+ };
+
+ if (metadata.isNotEmpty) {
+ add(const AIPromptInputEvent.clear());
+ }
+
+ return metadata;
+ }
+
+ final LocalLLMListener _listener;
+
+ @override
+ Future<void> close() async {
+ await _listener.stop();
+ return super.close();
+ }
+
+ void _dispatch() {
+ on<AIPromptInputEvent>(
+ (event, emit) {
+ event.when(
+ newFile: (String filePath, String fileName) {
+ final files = [...state.uploadFiles];
- on<ChatFileEvent>(
- (event, emit) async {
- await event.when(
- initial: () async {
- final result = await AIEventGetLocalAIChatState().send();
- result.fold(
- (chatState) {
- if (!isClosed) {
- add(
- ChatFileEvent.updateChatState(chatState),
- );
- }
- },
- (err) {
- Log.error(err.toString());
- },
- );
- },
- newFile: (String filePath, String fileName) async {
- final files = List<ChatFile>.from(state.uploadFiles);
final newFile = ChatFile.fromFilePath(filePath);
if (newFile != null) {
files.add(newFile);
- emit(
- state.copyWith(
- uploadFiles: files,
- ),
- );
+ emit(state.copyWith(uploadFiles: files));
}
},
updateChatState: (LocalAIChatPB chatState) {
@@ -76,8 +70,8 @@ class ChatFileBloc extends Bloc<ChatFileEvent, ChatFileState> {
fileEnabled && chatState.state == RunningStatePB.Running;
final aiType = chatState.state == RunningStatePB.Running
- ? const AIType.localAI()
- : const AIType.appflowyAI();
+ ? AIType.localAI
+ : AIType.appflowyAI;
emit(
state.copyWith(
@@ -107,48 +101,66 @@ class ChatFileBloc extends Bloc<ChatFileEvent, ChatFileState> {
);
}
- ChatInputFileMetadata consumeMetaData() {
- final metadata = state.uploadFiles.fold(
- <String, ChatFile>{},
- (map, file) => map..putIfAbsent(file.filePath, () => file),
+ void _startListening() {
+ _listener.start(
+ stateCallback: (pluginState) {
+ if (!isClosed) {
+ add(AIPromptInputEvent.updatePluginState(pluginState));
+ }
+ },
+ chatStateCallback: (chatState) {
+ if (!isClosed) {
+ add(AIPromptInputEvent.updateChatState(chatState));
+ }
+ },
);
-
- if (metadata.isNotEmpty) {
- add(const ChatFileEvent.clear());
- }
-
- return metadata;
}
- final LocalLLMListener listener;
-
- @override
- Future<void> close() async {
- await listener.stop();
- return super.close();
+ void _init() {
+ AIEventGetLocalAIChatState().send().fold(
+ (chatState) {
+ if (!isClosed) {
+ add(AIPromptInputEvent.updateChatState(chatState));
+ }
+ },
+ Log.error,
+ );
}
}
@freezed
-class ChatFileEvent with _$ChatFileEvent {
- const factory ChatFileEvent.initial() = Initial;
- const factory ChatFileEvent.newFile(String filePath, String fileName) =
+class AIPromptInputEvent with _$AIPromptInputEvent {
+ const factory AIPromptInputEvent.newFile(String filePath, String fileName) =
_NewFile;
- const factory ChatFileEvent.deleteFile(ChatFile file) = _DeleteFile;
- const factory ChatFileEvent.clear() = _ClearFile;
- const factory ChatFileEvent.updateChatState(LocalAIChatPB chatState) =
- _UpdateChatState;
- const factory ChatFileEvent.updatePluginState(
+ const factory AIPromptInputEvent.deleteFile(ChatFile file) = _DeleteFile;
+ const factory AIPromptInputEvent.clear() = _ClearFile;
+ const factory AIPromptInputEvent.updateChatState(
+ LocalAIChatPB chatState,
+ ) = _UpdateChatState;
+ const factory AIPromptInputEvent.updatePluginState(
LocalAIPluginStatePB chatState,
) = _UpdatePluginState;
}
@freezed
-class ChatFileState with _$ChatFileState {
- const factory ChatFileState({
- @Default(false) bool supportChatWithFile,
+class AIPromptInputState with _$AIPromptInputState {
+ const factory AIPromptInputState({
+ required bool supportChatWithFile,
LocalAIChatPB? chatState,
- @Default([]) List<ChatFile> uploadFiles,
- @Default(AIType.appflowyAI()) AIType aiType,
- }) = _ChatFileState;
+ required List<ChatFile> uploadFiles,
+ required AIType aiType,
+ }) = _AIPromptInputState;
+
+ factory AIPromptInputState.initial() => const AIPromptInputState(
+ supportChatWithFile: false,
+ uploadFiles: [],
+ aiType: AIType.appflowyAI,
+ );
+}
+
+enum AIType {
+ appflowyAI,
+ localAI;
+
+ bool get isLocalAI => this == localAI;
}
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_ai_message_bloc.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_ai_message_bloc.dart
index 19fff60bbf..d0eec2c226 100644
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_ai_message_bloc.dart
+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_ai_message_bloc.dart
@@ -59,9 +59,8 @@ class ChatAIMessageBloc extends Bloc<ChatAIMessageEvent, ChatAIMessageState> {
}
on<ChatAIMessageEvent>(
- (event, emit) async {
- await event.when(
- initial: () async {},
+ (event, emit) {
+ event.when(
updateText: (newText) {
emit(
state.copyWith(
@@ -135,7 +134,6 @@ class ChatAIMessageBloc extends Bloc<ChatAIMessageEvent, ChatAIMessageState> {
@freezed
class ChatAIMessageEvent with _$ChatAIMessageEvent {
- const factory ChatAIMessageEvent.initial() = Initial;
const factory ChatAIMessageEvent.updateText(String text) = _UpdateText;
const factory ChatAIMessageEvent.receiveError(String error) = _ReceiveError;
const factory ChatAIMessageEvent.retry() = _Retry;
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.dart
index f1b6be106a..f3114a8d01 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
@@ -106,7 +106,7 @@ class ChatBloc extends Bloc<ChatEvent, ChatState> {
didLoadPreviousMessages: (List<Message> messages, bool hasMore) {
Log.debug("did load previous messages: ${messages.length}");
final onetimeMessages = _getOnetimeMessages();
- final allMessages = _perminentMessages();
+ final allMessages = _permanentMessages();
final uniqueMessages = {...allMessages, ...messages}.toList()
..sort((a, b) => b.id.compareTo(a.id));
@@ -122,7 +122,7 @@ class ChatBloc extends Bloc<ChatEvent, ChatState> {
},
didLoadLatestMessages: (List<Message> messages) {
final onetimeMessages = _getOnetimeMessages();
- final allMessages = _perminentMessages();
+ final allMessages = _permanentMessages();
final uniqueMessages = {...allMessages, ...messages}.toList()
..sort((a, b) => b.id.compareTo(a.id));
uniqueMessages.insertAll(0, onetimeMessages);
@@ -154,7 +154,7 @@ class ChatBloc extends Bloc<ChatEvent, ChatState> {
final payload = StopStreamPB(chatId: chatId);
await AIEventStopStream(payload).send();
- final allMessages = _perminentMessages();
+ final allMessages = _permanentMessages();
if (state.streamingState != const StreamingState.done()) {
// If the streaming is not started, remove the message from the list
if (!state.answerStream!.hasStarted) {
@@ -175,8 +175,8 @@ class ChatBloc extends Bloc<ChatEvent, ChatState> {
);
}
},
- receveMessage: (Message message) {
- final allMessages = _perminentMessages();
+ receiveMessage: (Message message) {
+ final allMessages = _permanentMessages();
// remove message with the same id
allMessages.removeWhere((element) => element.id == message.id);
allMessages.insert(0, message);
@@ -187,7 +187,7 @@ class ChatBloc extends Bloc<ChatEvent, ChatState> {
);
},
startAnswerStreaming: (Message message) {
- final allMessages = _perminentMessages();
+ final allMessages = _permanentMessages();
allMessages.insert(0, message);
emit(
state.copyWith(
@@ -199,7 +199,7 @@ class ChatBloc extends Bloc<ChatEvent, ChatState> {
},
sendMessage: (String message, Map<String, dynamic>? metadata) async {
unawaited(_startStreamingMessage(message, metadata, emit));
- final allMessages = _perminentMessages();
+ final allMessages = _permanentMessages();
emit(
state.copyWith(
lastSentMessage: null,
@@ -221,16 +221,26 @@ class ChatBloc extends Bloc<ChatEvent, ChatState> {
),
);
},
+ failedSending: () {
+ emit(
+ state.copyWith(
+ messages: _permanentMessages()..removeAt(0),
+ sendingState: const SendMessageState.done(),
+ canSendMessage: true,
+ ),
+ );
+ },
// related question
didReceiveRelatedQuestion: (List<RelatedQuestionPB> questions) {
if (questions.isEmpty) {
return;
}
- final allMessages = _perminentMessages();
+ final allMessages = _permanentMessages();
final message = CustomMessage(
metadata: OnetimeShotType.relatedQuestion.toMap(),
author: const User(id: systemUserId),
+ showStatus: false,
id: systemUserId,
);
allMessages.insert(0, message);
@@ -241,7 +251,7 @@ class ChatBloc extends Bloc<ChatEvent, ChatState> {
),
);
},
- clearReleatedQuestion: () {
+ clearRelatedQuestions: () {
emit(
state.copyWith(
relatedQuestions: [],
@@ -272,7 +282,7 @@ class ChatBloc extends Bloc<ChatEvent, ChatState> {
}
final message = _createTextMessage(pb);
- add(ChatEvent.receveMessage(message));
+ add(ChatEvent.receiveMessage(message));
}
},
chatErrorMessageCallback: (err) {
@@ -325,7 +335,7 @@ class ChatBloc extends Bloc<ChatEvent, ChatState> {
}
// Returns the list of messages that are not include one-time messages.
- List<Message> _perminentMessages() {
+ List<Message> _permanentMessages() {
final allMessages = state.messages.where((element) {
return !(element.metadata?.containsKey(onetimeShotType) == true);
}).toList();
@@ -384,7 +394,7 @@ class ChatBloc extends Bloc<ChatEvent, ChatState> {
questionStream,
metadata,
);
- add(ChatEvent.receveMessage(questionStreamMessage));
+ add(ChatEvent.receiveMessage(questionStreamMessage));
// Stream message to the server
final result = await AIEventStreamMessage(payload).send();
@@ -394,7 +404,7 @@ class ChatBloc extends Bloc<ChatEvent, ChatState> {
add(ChatEvent.finishSending(question));
// final message = _createTextMessage(question);
- // add(ChatEvent.receveMessage(message));
+ // add(ChatEvent.receiveMessage(message));
final streamAnswer =
_createAnswerStreamMessage(answerStream, question.messageId);
@@ -412,10 +422,12 @@ class ChatBloc extends Bloc<ChatEvent, ChatState> {
final error = CustomMessage(
metadata: metadata,
author: const User(id: systemUserId),
+ showStatus: false,
id: systemUserId,
);
- add(ChatEvent.receveMessage(error));
+ add(const ChatEvent.failedSending());
+ add(ChatEvent.receiveMessage(error));
}
},
);
@@ -436,6 +448,7 @@ class ChatBloc extends Bloc<ChatEvent, ChatState> {
"chatId": chatId,
},
id: streamMessageId,
+ showStatus: false,
createdAt: DateTime.now().millisecondsSinceEpoch,
text: '',
);
@@ -462,6 +475,7 @@ class ChatBloc extends Bloc<ChatEvent, ChatState> {
author: User(id: state.userProfile.id.toString()),
metadata: metadata,
id: questionStreamMessageId,
+ showStatus: false,
createdAt: DateTime.now().millisecondsSinceEpoch,
text: '',
);
@@ -480,6 +494,7 @@ class ChatBloc extends Bloc<ChatEvent, ChatState> {
id: messageId,
text: message.content,
createdAt: message.createdAt.toInt() * 1000,
+ showStatus: false,
metadata: {
messageRefSourceJsonStringKey: message.metadata,
},
@@ -498,11 +513,12 @@ class ChatEvent with _$ChatEvent {
}) = _SendMessage;
const factory ChatEvent.finishSending(ChatMessagePB message) =
_FinishSendMessage;
+ const factory ChatEvent.failedSending() = _FailSendMessage;
// receive message
const factory ChatEvent.startAnswerStreaming(Message message) =
_StartAnswerStreaming;
- const factory ChatEvent.receveMessage(Message message) = _ReceiveMessage;
+ const factory ChatEvent.receiveMessage(Message message) = _ReceiveMessage;
const factory ChatEvent.finishAnswerStreaming() = _FinishAnswerStreaming;
// loading messages
@@ -518,7 +534,7 @@ class ChatEvent with _$ChatEvent {
const factory ChatEvent.didReceiveRelatedQuestion(
List<RelatedQuestionPB> questions,
) = _DidReceiveRelatedQueston;
- const factory ChatEvent.clearReleatedQuestion() = _ClearRelatedQuestion;
+ const factory ChatEvent.clearRelatedQuestions() = _ClearRelatedQuestions;
const factory ChatEvent.didUpdateAnswerStream(
AnswerStream stream,
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_entity.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_entity.dart
index c0a2d5bf32..0ef46f5661 100644
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_entity.dart
+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_entity.dart
@@ -1,11 +1,9 @@
import 'dart:io';
-import 'package:appflowy/generated/flowy_svgs.g.dart';
import 'package:appflowy_backend/log.dart';
import 'package:appflowy_backend/protobuf/flowy-ai/entities.pbenum.dart';
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
import 'package:equatable/equatable.dart';
-import 'package:flutter/material.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:path/path.dart' as path;
@@ -100,30 +98,6 @@ class ChatFile extends Equatable {
List<Object?> get props => [filePath];
}
-extension ChatFileTypeExtension on ChatMessageMetaTypePB {
- Widget get icon {
- switch (this) {
- case ChatMessageMetaTypePB.PDF:
- return const FlowySvg(
- FlowySvgs.file_pdf_s,
- color: Color(0xff00BCF0),
- );
- case ChatMessageMetaTypePB.Txt:
- return const FlowySvg(
- FlowySvgs.file_txt_s,
- color: Color(0xff00BCF0),
- );
- case ChatMessageMetaTypePB.Markdown:
- return const FlowySvg(
- FlowySvgs.file_md_s,
- color: Color(0xff00BCF0),
- );
- default:
- return const FlowySvg(FlowySvgs.file_unknown_s);
- }
- }
-}
-
typedef ChatInputFileMetadata = Map<String, ChatFile>;
@freezed
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_input_bloc.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_input_bloc.dart
deleted file mode 100644
index a0cedd2900..0000000000
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_input_bloc.dart
+++ /dev/null
@@ -1,87 +0,0 @@
-import 'dart:async';
-
-import 'package:appflowy/workspace/application/settings/ai/local_llm_listener.dart';
-import 'package:appflowy_backend/dispatch/dispatch.dart';
-import 'package:appflowy_backend/log.dart';
-import 'package:appflowy_backend/protobuf/flowy-ai/entities.pb.dart';
-import 'package:bloc/bloc.dart';
-import 'package:freezed_annotation/freezed_annotation.dart';
-part 'chat_input_bloc.freezed.dart';
-
-class ChatInputStateBloc
- extends Bloc<ChatInputStateEvent, ChatInputStateState> {
- ChatInputStateBloc()
- : listener = LocalLLMListener(),
- super(const ChatInputStateState(aiType: _AppFlowyAI())) {
- listener.start(
- stateCallback: (pluginState) {
- if (!isClosed) {
- add(ChatInputStateEvent.updatePluginState(pluginState));
- }
- },
- );
-
- on<ChatInputStateEvent>(_handleEvent);
- }
-
- final LocalLLMListener listener;
-
- @override
- Future<void> close() async {
- await listener.stop();
- return super.close();
- }
-
- Future<void> _handleEvent(
- ChatInputStateEvent event,
- Emitter<ChatInputStateState> emit,
- ) async {
- await event.when(
- started: () async {
- final result = await AIEventGetLocalAIPluginState().send();
- result.fold(
- (pluginState) {
- if (!isClosed) {
- add(
- ChatInputStateEvent.updatePluginState(pluginState),
- );
- }
- },
- (err) {
- Log.error(err.toString());
- },
- );
- },
- updatePluginState: (pluginState) {
- if (pluginState.state == RunningStatePB.Running) {
- emit(const ChatInputStateState(aiType: _LocalAI()));
- } else {
- emit(const ChatInputStateState(aiType: _AppFlowyAI()));
- }
- },
- );
- }
-}
-
-@freezed
-class ChatInputStateEvent with _$ChatInputStateEvent {
- const factory ChatInputStateEvent.started() = _Started;
- const factory ChatInputStateEvent.updatePluginState(
- LocalAIPluginStatePB pluginState,
- ) = _UpdatePluginState;
-}
-
-@freezed
-class ChatInputStateState with _$ChatInputStateState {
- const factory ChatInputStateState({required AIType aiType}) = _ChatInputState;
-}
-
-@freezed
-class AIType with _$AIType {
- const factory AIType.appflowyAI() = _AppFlowyAI;
- const factory AIType.localAI() = _LocalAI;
-}
-
-extension AITypeX on AIType {
- bool isLocalAI() => this is _LocalAI;
-}
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_input_file_bloc.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_input_file_bloc.dart
index 048c8709b3..31d58eb000 100644
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_input_file_bloc.dart
+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_input_file_bloc.dart
@@ -1,4 +1,3 @@
-
import 'package:appflowy/plugins/ai_chat/application/chat_entity.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
@@ -7,14 +6,11 @@ part 'chat_input_file_bloc.freezed.dart';
class ChatInputFileBloc extends Bloc<ChatInputFileEvent, ChatInputFileState> {
ChatInputFileBloc({
- // ignore: avoid_unused_constructor_parameters
- required String chatId,
required this.file,
}) : super(const ChatInputFileState()) {
on<ChatInputFileEvent>(
(event, emit) async {
- await event.when(
- initial: () async {},
+ event.when(
updateUploadState: (UploadFileIndicator indicator) {
emit(state.copyWith(uploadFileIndicator: indicator));
},
@@ -28,7 +24,6 @@ class ChatInputFileBloc extends Bloc<ChatInputFileEvent, ChatInputFileState> {
@freezed
class ChatInputFileEvent with _$ChatInputFileEvent {
- const factory ChatInputFileEvent.initial() = Initial;
const factory ChatInputFileEvent.updateUploadState(
UploadFileIndicator indicator,
) = _UpdateUploadState;
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_member_bloc.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_member_bloc.dart
index c0f68bb9b3..d1d0898ccc 100644
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_member_bloc.dart
+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_member_bloc.dart
@@ -13,7 +13,6 @@ class ChatMemberBloc extends Bloc<ChatMemberEvent, ChatMemberState> {
on<ChatMemberEvent>(
(event, emit) async {
event.when(
- initial: () {},
receiveMemberInfo: (String id, WorkspaceMemberPB memberInfo) {
final members = Map<String, ChatMember>.from(state.members);
members[id] = ChatMember(info: memberInfo);
@@ -51,7 +50,6 @@ class ChatMemberBloc extends Bloc<ChatMemberEvent, ChatMemberState> {
@freezed
class ChatMemberEvent with _$ChatMemberEvent {
- const factory ChatMemberEvent.initial() = Initial;
const factory ChatMemberEvent.getMemberInfo(
String userId,
) = _GetMemberInfo;
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_message_service.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_message_service.dart
index 1985e41242..d359d36a6c 100644
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_message_service.dart
+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_message_service.dart
@@ -11,7 +11,7 @@ import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
import 'package:nanoid/nanoid.dart';
/// Indicate file source from appflowy document
-const appflowySoruce = "appflowy";
+const appflowySource = "appflowy";
List<ChatFile> fileListFromMessageMetadata(
Map<String, dynamic>? map,
@@ -119,7 +119,7 @@ Future<List<ChatMessageMetaPB>> metadataPBFromMetadata(
name: view.name,
data: pb.text,
dataType: ChatMessageMetaTypePB.Txt,
- source: appflowySoruce,
+ source: appflowySource,
),
);
}, (err) {
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_side_panel_bloc.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_side_panel_bloc.dart
new file mode 100644
index 0000000000..18786c4165
--- /dev/null
+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_side_panel_bloc.dart
@@ -0,0 +1,75 @@
+import 'package:appflowy/plugins/ai_chat/application/chat_entity.dart';
+import 'package:appflowy/workspace/application/view/view_service.dart';
+import 'package:appflowy_backend/log.dart';
+import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
+import 'package:appflowy_result/appflowy_result.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:freezed_annotation/freezed_annotation.dart';
+
+part 'chat_side_panel_bloc.freezed.dart';
+
+class ChatSidePanelBloc extends Bloc<ChatSidePanelEvent, ChatSidePanelState> {
+ ChatSidePanelBloc({
+ required this.chatId,
+ }) : super(const ChatSidePanelState()) {
+ on<ChatSidePanelEvent>(
+ (event, emit) async {
+ await event.when(
+ selectedMetadata: (ChatMessageRefSource metadata) async {
+ emit(
+ state.copyWith(
+ metadata: metadata,
+ indicator: const ChatSidePanelIndicator.loading(),
+ ),
+ );
+ await ViewBackendService.getView(metadata.id).fold(
+ (view) {
+ if (!isClosed) {
+ add(ChatSidePanelEvent.open(view));
+ }
+ },
+ (err) => Log.error("Failed to get view: $err"),
+ );
+ },
+ close: () {
+ emit(state.copyWith(metadata: null, isShowPanel: false));
+ },
+ open: (ViewPB view) {
+ emit(
+ state.copyWith(
+ indicator: ChatSidePanelIndicator.ready(view),
+ isShowPanel: true,
+ ),
+ );
+ },
+ );
+ },
+ );
+ }
+
+ final String chatId;
+}
+
+@freezed
+class ChatSidePanelEvent with _$ChatSidePanelEvent {
+ const factory ChatSidePanelEvent.selectedMetadata(
+ ChatMessageRefSource metadata,
+ ) = _SelectedMetadata;
+ const factory ChatSidePanelEvent.close() = _Close;
+ const factory ChatSidePanelEvent.open(ViewPB view) = _Open;
+}
+
+@freezed
+class ChatSidePanelState with _$ChatSidePanelState {
+ const factory ChatSidePanelState({
+ ChatMessageRefSource? metadata,
+ @Default(ChatSidePanelIndicator.loading()) ChatSidePanelIndicator indicator,
+ @Default(false) bool isShowPanel,
+ }) = _ChatSidePanelState;
+}
+
+@freezed
+class ChatSidePanelIndicator with _$ChatSidePanelIndicator {
+ const factory ChatSidePanelIndicator.ready(ViewPB view) = _Ready;
+ const factory ChatSidePanelIndicator.loading() = _Loading;
+}
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_side_pannel_bloc.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_side_pannel_bloc.dart
deleted file mode 100644
index 83dc4375b0..0000000000
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/application/chat_side_pannel_bloc.dart
+++ /dev/null
@@ -1,85 +0,0 @@
-import 'dart:async';
-
-import 'package:appflowy/plugins/ai_chat/application/chat_entity.dart';
-import 'package:appflowy/workspace/application/view/view_service.dart';
-import 'package:appflowy_backend/log.dart';
-import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
-import 'package:flutter_bloc/flutter_bloc.dart';
-import 'package:freezed_annotation/freezed_annotation.dart';
-
-part 'chat_side_pannel_bloc.freezed.dart';
-
-const double kDefaultSidePannelWidth = 500;
-
-class ChatSidePannelBloc
- extends Bloc<ChatSidePannelEvent, ChatSidePannelState> {
- ChatSidePannelBloc({
- required this.chatId,
- }) : super(const ChatSidePannelState()) {
- on<ChatSidePannelEvent>(
- (event, emit) async {
- await event.when(
- selectedMetadata: (ChatMessageRefSource metadata) async {
- emit(
- state.copyWith(
- metadata: metadata,
- indicator: const ChatSidePannelIndicator.loading(),
- ),
- );
- unawaited(
- ViewBackendService.getView(metadata.id).then(
- (result) {
- result.fold((view) {
- if (!isClosed) {
- add(ChatSidePannelEvent.open(view));
- }
- }, (err) {
- Log.error("Failed to get view: $err");
- });
- },
- ),
- );
- },
- close: () {
- emit(state.copyWith(metadata: null, isShowPannel: false));
- },
- open: (ViewPB view) {
- emit(
- state.copyWith(
- indicator: ChatSidePannelIndicator.ready(view),
- isShowPannel: true,
- ),
- );
- },
- );
- },
- );
- }
-
- final String chatId;
-}
-
-@freezed
-class ChatSidePannelEvent with _$ChatSidePannelEvent {
- const factory ChatSidePannelEvent.selectedMetadata(
- ChatMessageRefSource metadata,
- ) = _SelectedMetadata;
- const factory ChatSidePannelEvent.close() = _Close;
- const factory ChatSidePannelEvent.open(ViewPB view) = _Open;
-}
-
-@freezed
-class ChatSidePannelState with _$ChatSidePannelState {
- const factory ChatSidePannelState({
- ChatMessageRefSource? metadata,
- @Default(ChatSidePannelIndicator.loading())
- ChatSidePannelIndicator indicator,
- @Default(false) bool isShowPannel,
- }) = _ChatSidePannelState;
-}
-
-@freezed
-class ChatSidePannelIndicator with _$ChatSidePannelIndicator {
- const factory ChatSidePannelIndicator.ready(ViewPB view) = _Ready;
- const factory ChatSidePannelIndicator.loading() = _Loading;
-}
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/chat_page.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/chat_page.dart
index 0d991032b6..0dc51991fb 100644
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/chat_page.dart
+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/chat_page.dart
@@ -1,14 +1,9 @@
-import 'dart:math';
-
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/plugins/ai_chat/application/chat_bloc.dart';
import 'package:appflowy/plugins/ai_chat/application/chat_entity.dart';
-import 'package:appflowy/plugins/ai_chat/application/chat_file_bloc.dart';
-import 'package:appflowy/plugins/ai_chat/application/chat_input_bloc.dart';
+import 'package:appflowy/plugins/ai_chat/application/ai_prompt_input_bloc.dart';
import 'package:appflowy/plugins/ai_chat/application/chat_message_stream.dart';
import 'package:appflowy/plugins/ai_chat/presentation/chat_related_question.dart';
-import 'package:appflowy/plugins/ai_chat/presentation/message/ai_message_bubble.dart';
-import 'package:appflowy/plugins/ai_chat/presentation/message/other_user_message_bubble.dart';
import 'package:appflowy/plugins/ai_chat/presentation/message/user_message_bubble.dart';
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
import 'package:appflowy_backend/protobuf/flowy-user/protobuf.dart';
@@ -25,39 +20,17 @@ import 'package:styled_widget/styled_widget.dart';
import 'package:universal_platform/universal_platform.dart';
import 'application/chat_member_bloc.dart';
-import 'application/chat_side_pannel_bloc.dart';
-import 'presentation/chat_input/chat_input.dart';
-import 'presentation/chat_side_pannel.dart';
+import 'application/chat_side_panel_bloc.dart';
+import 'presentation/chat_input/desktop_ai_prompt_input.dart';
+import 'presentation/chat_input/mobile_ai_prompt_input.dart';
+import 'presentation/chat_side_panel.dart';
import 'presentation/chat_theme.dart';
import 'presentation/chat_user_invalid_message.dart';
import 'presentation/chat_welcome_page.dart';
+import 'presentation/layout_define.dart';
import 'presentation/message/ai_text_message.dart';
import 'presentation/message/user_text_message.dart';
-class AIChatUILayout {
- static EdgeInsets get chatPadding =>
- isMobile ? EdgeInsets.zero : const EdgeInsets.symmetric(horizontal: 20);
-
- static EdgeInsets get welcomePagePadding => isMobile
- ? const EdgeInsets.symmetric(horizontal: 20)
- : const EdgeInsets.symmetric(horizontal: 50);
-
- static double get messageWidthRatio => 0.85;
-
- static EdgeInsets safeAreaInsets(BuildContext context) {
- final query = MediaQuery.of(context);
- return isMobile
- ? EdgeInsets.fromLTRB(
- query.padding.left,
- 0,
- query.padding.right,
- query.viewInsets.bottom + query.padding.bottom,
- )
- : const EdgeInsets.symmetric(horizontal: 50) +
- const EdgeInsets.only(bottom: 20);
- }
-}
-
class AIChatPage extends StatelessWidget {
const AIChatPage({
super.key,
@@ -72,62 +45,50 @@ class AIChatPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
- if (userProfile.authenticator == AuthenticatorPB.AppFlowyCloud) {
- return MultiBlocProvider(
- providers: [
- /// [ChatBloc] is used to handle chat messages including send/receive message
- BlocProvider(
- create: (_) => ChatBloc(
- view: view,
- userProfile: userProfile,
- )..add(const ChatEvent.initialLoad()),
- ),
-
- /// [ChatFileBloc] is used to handle file indexing as a chat context
- BlocProvider(
- create: (_) => ChatFileBloc()..add(const ChatFileEvent.initial()),
- ),
-
- /// [ChatInputStateBloc] is used to handle chat input text field state
- BlocProvider(
- create: (_) =>
- ChatInputStateBloc()..add(const ChatInputStateEvent.started()),
- ),
- BlocProvider(create: (_) => ChatSidePannelBloc(chatId: view.id)),
- BlocProvider(create: (_) => ChatMemberBloc()),
- ],
- child: BlocBuilder<ChatFileBloc, ChatFileState>(
- builder: (context, state) {
- return DropTarget(
- onDragDone: (DropDoneDetails detail) async {
- if (state.supportChatWithFile) {
- for (final file in detail.files) {
- context
- .read<ChatFileBloc>()
- .add(ChatFileEvent.newFile(file.path, file.name));
- }
- }
- },
- child: _ChatContentPage(
- view: view,
- userProfile: userProfile,
- ),
- );
- },
+ if (userProfile.authenticator != AuthenticatorPB.AppFlowyCloud) {
+ return Center(
+ child: FlowyText(
+ LocaleKeys.chat_unsupportedCloudPrompt.tr(),
+ fontSize: 20,
),
);
}
- return Center(
- child: FlowyText(
- LocaleKeys.chat_unsupportedCloudPrompt.tr(),
- fontSize: 20,
+ return MultiBlocProvider(
+ providers: [
+ /// [ChatBloc] is used to handle chat messages including send/receive message
+ BlocProvider(
+ create: (_) => ChatBloc(
+ view: view,
+ userProfile: userProfile,
+ )..add(const ChatEvent.initialLoad()),
+ ),
+
+ /// [AIPromptInputBloc] is used to handle the user prompt
+ BlocProvider(create: (_) => AIPromptInputBloc()),
+ BlocProvider(create: (_) => ChatSidePanelBloc(chatId: view.id)),
+ BlocProvider(create: (_) => ChatMemberBloc()),
+ ],
+ child: DropTarget(
+ onDragDone: (DropDoneDetails detail) async {
+ if (context.read<AIPromptInputBloc>().state.supportChatWithFile) {
+ for (final file in detail.files) {
+ context
+ .read<AIPromptInputBloc>()
+ .add(AIPromptInputEvent.newFile(file.path, file.name));
+ }
+ }
+ },
+ child: _ChatContentPage(
+ view: view,
+ userProfile: userProfile,
+ ),
),
);
}
}
-class _ChatContentPage extends StatefulWidget {
+class _ChatContentPage extends StatelessWidget {
const _ChatContentPage({
required this.view,
required this.userProfile,
@@ -136,189 +97,167 @@ class _ChatContentPage extends StatefulWidget {
final UserProfilePB userProfile;
final ViewPB view;
- @override
- State<_ChatContentPage> createState() => _ChatContentPageState();
-}
-
-class _ChatContentPageState extends State<_ChatContentPage> {
- late types.User _user;
-
- @override
- void initState() {
- super.initState();
- _user = types.User(id: widget.userProfile.id.toString());
- }
-
@override
Widget build(BuildContext context) {
- if (widget.userProfile.authenticator == AuthenticatorPB.AppFlowyCloud) {
- if (UniversalPlatform.isDesktop) {
- return BlocSelector<ChatSidePannelBloc, ChatSidePannelState, bool>(
- selector: (state) => state.isShowPannel,
- builder: (context, isShowPannel) {
- return LayoutBuilder(
- builder: (BuildContext context, BoxConstraints constraints) {
- final double chatOffsetX = isShowPannel
- ? 60
- : (constraints.maxWidth > 784
- ? (constraints.maxWidth - 784) / 2.0
- : 60);
-
- final double width = isShowPannel
- ? (constraints.maxWidth - chatOffsetX * 2) * 0.46
- : min(constraints.maxWidth - chatOffsetX * 2, 784);
-
- final double sidePannelOffsetX = chatOffsetX + width;
-
- return Stack(
- alignment: AlignmentDirectional.centerStart,
- children: [
- buildChatWidget()
- .constrained(width: width)
- .positioned(
- top: 0,
- bottom: 0,
- left: chatOffsetX,
- animate: true,
+ if (UniversalPlatform.isDesktop) {
+ return BlocSelector<ChatSidePanelBloc, ChatSidePanelState, bool>(
+ selector: (state) => state.isShowPanel,
+ builder: (context, isShowPanel) {
+ return LayoutBuilder(
+ builder: (BuildContext context, BoxConstraints constraints) {
+ final sidePanelRatio = isShowPanel ? 0.33 : 0.0;
+ final chatWidth = constraints.maxWidth * (1 - sidePanelRatio);
+ final sidePanelWidth =
+ constraints.maxWidth * sidePanelRatio - 1.0;
+
+ return Row(
+ children: [
+ Center(
+ child: buildChatWidget()
+ .constrained(
+ maxWidth: 784,
)
+ .padding(horizontal: 32)
+ .animate(
+ const Duration(milliseconds: 200),
+ Curves.easeOut,
+ ),
+ ).constrained(width: chatWidth),
+ if (isShowPanel) ...[
+ const VerticalDivider(
+ width: 1.0,
+ thickness: 1.0,
+ ),
+ buildChatSidePanel()
+ .constrained(width: sidePanelWidth)
.animate(
const Duration(milliseconds: 200),
Curves.easeOut,
),
- if (isShowPannel)
- buildChatSidePannel()
- .positioned(
- left: sidePannelOffsetX,
- right: 0,
- top: 0,
- bottom: 0,
- animate: true,
- )
- .animate(
- const Duration(milliseconds: 200),
- Curves.easeOut,
- ),
],
- );
- },
- );
- },
- );
- } else {
- return Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Flexible(
- child: ConstrainedBox(
- constraints: const BoxConstraints(maxWidth: 784),
- child: buildChatWidget(),
- ),
- ),
- ],
- );
- }
- }
-
- return Center(
- child: FlowyText(
- LocaleKeys.chat_unsupportedCloudPrompt.tr(),
- fontSize: 20,
- ),
- );
- }
-
- Widget buildChatSidePannel() {
- if (UniversalPlatform.isDesktop) {
- return BlocBuilder<ChatSidePannelBloc, ChatSidePannelState>(
- builder: (context, state) {
- if (state.metadata != null) {
- return const ChatSidePannel();
- } else {
- return const SizedBox.shrink();
- }
+ ],
+ );
+ },
+ );
},
);
} else {
- // TODO(lucas): implement mobile chat side panel
- return const SizedBox.shrink();
+ return Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ Flexible(
+ child: ConstrainedBox(
+ constraints: const BoxConstraints(maxWidth: 784),
+ child: buildChatWidget(),
+ ),
+ ),
+ ],
+ );
}
}
+ Widget buildChatSidePanel() {
+ return BlocBuilder<ChatSidePanelBloc, ChatSidePanelState>(
+ builder: (context, state) {
+ if (state.metadata == null) {
+ return const SizedBox.shrink();
+ }
+ return const ChatSidePanel();
+ },
+ );
+ }
+
Widget buildChatWidget() {
return BlocBuilder<ChatBloc, ChatState>(
- builder: (blocContext, state) => Chat(
- key: ValueKey(widget.view.id),
- messages: state.messages,
- onSendPressed: (_) {
- // We use custom bottom widget for chat input, so
- // do not need to handle this event.
- },
- customBottomWidget: _buildBottom(blocContext),
- user: _user,
- theme: buildTheme(context),
- onEndReached: () async {
- if (state.hasMorePrevMessage &&
- state.loadingPreviousStatus.isFinish) {
- blocContext
- .read<ChatBloc>()
- .add(const ChatEvent.startLoadingPrevMessage());
- }
- },
- emptyState: BlocBuilder<ChatBloc, ChatState>(
- builder: (_, state) => state.initialLoadingStatus.isFinish
- ? Padding(
- padding: AIChatUILayout.welcomePagePadding,
- child: ChatWelcomePage(
- userProfile: widget.userProfile,
- onSelectedQuestion: (question) => blocContext
- .read<ChatBloc>()
- .add(ChatEvent.sendMessage(message: question)),
+ builder: (context, state) {
+ return ScrollConfiguration(
+ behavior: ScrollConfiguration.of(context).copyWith(scrollbars: false),
+ child: BlocBuilder<ChatBloc, ChatState>(
+ builder: (_, state) => state.initialLoadingStatus.isFinish
+ ? Chat(
+ messages: state.messages,
+ dateHeaderBuilder: (_) => const SizedBox.shrink(),
+ onSendPressed: (_) {
+ // We use custom bottom widget for chat input, so
+ // do not need to handle this event.
+ },
+ customBottomWidget: _buildBottom(context),
+ user: types.User(id: userProfile.id.toString()),
+ theme: _buildTheme(context),
+ onEndReached: () async {
+ if (state.hasMorePrevMessage &&
+ state.loadingPreviousStatus.isFinish) {
+ context
+ .read<ChatBloc>()
+ .add(const ChatEvent.startLoadingPrevMessage());
+ }
+ },
+ emptyState: ChatWelcomePage(
+ userProfile: userProfile,
+ onSelectedQuestion: (question) => context
+ .read<ChatBloc>()
+ .add(ChatEvent.sendMessage(message: question)),
+ ),
+ messageWidthRatio: AIChatUILayout.messageWidthRatio,
+ textMessageBuilder: (
+ textMessage, {
+ required messageWidth,
+ required showName,
+ }) =>
+ _buildTextMessage(context, textMessage, state),
+ customMessageBuilder: (message, {required messageWidth}) {
+ final messageType = onetimeMessageTypeFromMeta(
+ message.metadata,
+ );
+
+ if (messageType == OnetimeShotType.invalidSendMesssage) {
+ return ChatInvalidUserMessage(
+ message: message,
+ );
+ }
+ if (messageType == OnetimeShotType.relatedQuestion) {
+ return RelatedQuestionList(
+ relatedQuestions: state.relatedQuestions,
+ onQuestionSelected: (question) {
+ final bloc = context.read<ChatBloc>();
+ bloc
+ ..add(ChatEvent.sendMessage(message: question))
+ ..add(const ChatEvent.clearRelatedQuestions());
+ },
+ );
+ }
+
+ return const SizedBox.shrink();
+ },
+ bubbleBuilder: (
+ child, {
+ required message,
+ required nextMessageInGroup,
+ }) =>
+ _buildBubble(context, message, child),
+ )
+ : const Center(
+ child: CircularProgressIndicator.adaptive(),
),
- )
- : const Center(
- child: CircularProgressIndicator.adaptive(),
- ),
- ),
- messageWidthRatio: AIChatUILayout.messageWidthRatio,
- textMessageBuilder: (
- textMessage, {
- required messageWidth,
- required showName,
- }) =>
- _buildTextMessage(blocContext, textMessage),
- bubbleBuilder: (
- child, {
- required message,
- required nextMessageInGroup,
- }) =>
- _buildBubble(blocContext, message, child, state),
- ),
+ ),
+ );
+ },
);
}
- Widget _buildBubble(
- BuildContext blocContext,
- Message message,
- Widget child,
+ Widget _buildTextMessage(
+ BuildContext context,
+ TextMessage message,
ChatState state,
) {
- if (message.author.id == _user.id) {
- return ChatUserMessageBubble(
- message: message,
- child: child,
+ if (message.author.id == userProfile.id.toString()) {
+ final stream = message.metadata?["$QuestionStream"];
+ return ChatUserMessageWidget(
+ key: ValueKey(message.id),
+ user: message.author,
+ message: stream is QuestionStream ? stream : message.text,
);
} else if (isOtherUserMessage(message)) {
- return OtherUserMessageBubble(
- message: message,
- child: child,
- );
- } else {
- return _buildAIBubble(message, blocContext, state, child);
- }
- }
-
- Widget _buildTextMessage(BuildContext context, TextMessage message) {
- if (message.author.id == _user.id) {
final stream = message.metadata?["$QuestionStream"];
return ChatUserMessageWidget(
key: ValueKey(message.id),
@@ -330,160 +269,115 @@ class _ChatContentPageState extends State<_ChatContentPage> {
final questionId = message.metadata?[messageQuestionIdKey];
final refSourceJsonString =
message.metadata?[messageRefSourceJsonStringKey] as String?;
- return ChatAIMessageWidget(
- user: message.author,
- messageUserId: message.id,
- message: stream is AnswerStream ? stream : message.text,
+
+ return BlocSelector<ChatBloc, ChatState, bool>(
key: ValueKey(message.id),
- questionId: questionId,
- chatId: widget.view.id,
- refSourceJsonString: refSourceJsonString,
- onSelectedMetadata: (ChatMessageRefSource metadata) {
- context.read<ChatSidePannelBloc>().add(
- ChatSidePannelEvent.selectedMetadata(metadata),
- );
+ selector: (state) {
+ final messages = state.messages.where((e) {
+ final oneTimeMessageType = onetimeMessageTypeFromMeta(e.metadata);
+ if (oneTimeMessageType == null) {
+ return true;
+ }
+ if (oneTimeMessageType
+ case OnetimeShotType.relatedQuestion ||
+ OnetimeShotType.sendingMessage ||
+ OnetimeShotType.invalidSendMesssage) {
+ return false;
+ }
+ return true;
+ });
+ return messages.isEmpty ? false : messages.first.id == message.id;
+ },
+ builder: (context, isLastMessage) {
+ return ChatAIMessageWidget(
+ user: message.author,
+ messageUserId: message.id,
+ message: message,
+ stream: stream is AnswerStream ? stream : null,
+ questionId: questionId,
+ chatId: view.id,
+ refSourceJsonString: refSourceJsonString,
+ isLastMessage: isLastMessage,
+ onSelectedMetadata: (metadata) {
+ context
+ .read<ChatSidePanelBloc>()
+ .add(ChatSidePanelEvent.selectedMetadata(metadata));
+ },
+ );
},
);
}
}
- Widget _buildAIBubble(
+ Widget _buildBubble(
+ BuildContext context,
Message message,
- BuildContext blocContext,
- ChatState state,
Widget child,
) {
- final messageType = onetimeMessageTypeFromMeta(
- message.metadata,
- );
-
- if (messageType == OnetimeShotType.invalidSendMesssage) {
- return ChatInvalidUserMessage(
+ if (message.author.id == userProfile.id.toString()) {
+ return ChatUserMessageBubble(
message: message,
+ child: child,
);
- }
-
- if (messageType == OnetimeShotType.relatedQuestion) {
- return RelatedQuestionList(
- onQuestionSelected: (question) {
- blocContext
- .read<ChatBloc>()
- .add(ChatEvent.sendMessage(message: question));
- blocContext
- .read<ChatBloc>()
- .add(const ChatEvent.clearReleatedQuestion());
- },
- chatId: widget.view.id,
- relatedQuestions: state.relatedQuestions,
+ } else if (isOtherUserMessage(message)) {
+ return ChatUserMessageBubble(
+ message: message,
+ isCurrentUser: false,
+ child: child,
);
+ } else {
+ // The bubble is rendered in the child already
+ return child;
}
-
- return ChatAIMessageBubble(
- message: message,
- customMessageType: messageType,
- child: child,
- );
}
Widget _buildBottom(BuildContext context) {
- return ClipRect(
- child: Padding(
- padding: AIChatUILayout.safeAreaInsets(context),
- child: BlocBuilder<ChatInputStateBloc, ChatInputStateState>(
- builder: (context, state) {
- // Show different hint text based on the AI type
- final aiType = state.aiType;
- final hintText = state.aiType.when(
- appflowyAI: () => LocaleKeys.chat_inputMessageHint.tr(),
- localAI: () => LocaleKeys.chat_inputLocalAIMessageHint.tr(),
- );
-
- return Column(
- children: [
- BlocSelector<ChatBloc, ChatState, bool>(
- selector: (state) => state.canSendMessage,
- builder: (context, canSendMessage) {
- return ChatInput(
- aiType: aiType,
- chatId: widget.view.id,
- onSendPressed: (message) {
- context.read<ChatBloc>().add(
- ChatEvent.sendMessage(
- message: message.text,
- metadata: message.metadata,
- ),
- );
- },
- isStreaming: !canSendMessage,
- onStopStreaming: () {
- context
- .read<ChatBloc>()
- .add(const ChatEvent.stopStream());
- },
- hintText: hintText,
- );
+ return Padding(
+ padding: AIChatUILayout.safeAreaInsets(context),
+ child: BlocSelector<ChatBloc, ChatState, bool>(
+ selector: (state) => state.canSendMessage,
+ builder: (context, canSendMessage) {
+ return UniversalPlatform.isDesktop
+ ? DesktopAIPromptInput(
+ chatId: view.id,
+ indicateFocus: true,
+ onSubmitted: (message) {
+ context.read<ChatBloc>().add(
+ ChatEvent.sendMessage(
+ message: message.text,
+ metadata: message.metadata,
+ ),
+ );
},
- ),
- const VSpace(6),
- if (UniversalPlatform.isDesktop)
- Opacity(
- opacity: 0.6,
- child: FlowyText(
- LocaleKeys.chat_aiMistakePrompt.tr(),
- fontSize: 12,
- ),
- ),
- ],
- );
- },
- ),
+ isStreaming: !canSendMessage,
+ onStopStreaming: () {
+ context.read<ChatBloc>().add(const ChatEvent.stopStream());
+ },
+ )
+ : MobileAIPromptInput(
+ chatId: view.id,
+ onSubmitted: (message) {
+ context.read<ChatBloc>().add(
+ ChatEvent.sendMessage(
+ message: message.text,
+ metadata: message.metadata,
+ ),
+ );
+ },
+ isStreaming: !canSendMessage,
+ onStopStreaming: () {
+ context.read<ChatBloc>().add(const ChatEvent.stopStream());
+ },
+ );
+ },
),
);
}
-}
-AFDefaultChatTheme buildTheme(BuildContext context) {
- return AFDefaultChatTheme(
- backgroundColor: AFThemeExtension.of(context).background,
- primaryColor: Theme.of(context).colorScheme.primary,
- secondaryColor: AFThemeExtension.of(context).tint1,
- receivedMessageDocumentIconColor: Theme.of(context).primaryColor,
- receivedMessageCaptionTextStyle: TextStyle(
- color: AFThemeExtension.of(context).textColor,
- fontSize: 16,
- fontWeight: FontWeight.w500,
- height: 1.5,
- ),
- receivedMessageBodyTextStyle: TextStyle(
- color: AFThemeExtension.of(context).textColor,
- fontSize: 16,
- fontWeight: FontWeight.w500,
- height: 1.5,
- ),
- receivedMessageLinkTitleTextStyle: TextStyle(
- color: AFThemeExtension.of(context).textColor,
- fontSize: 16,
- fontWeight: FontWeight.w500,
- height: 1.5,
- ),
- receivedMessageBodyLinkTextStyle: const TextStyle(
- color: Colors.lightBlue,
- fontSize: 16,
- fontWeight: FontWeight.w500,
- height: 1.5,
- ),
- sentMessageBodyTextStyle: TextStyle(
- color: AFThemeExtension.of(context).textColor,
- fontSize: 16,
- fontWeight: FontWeight.w500,
- height: 1.5,
- ),
- sentMessageBodyLinkTextStyle: const TextStyle(
- color: Colors.blue,
- fontSize: 16,
- fontWeight: FontWeight.w500,
- height: 1.5,
- ),
- inputElevation: 2,
- );
+ AFDefaultChatTheme _buildTheme(BuildContext context) {
+ return AFDefaultChatTheme(
+ primaryColor: Theme.of(context).colorScheme.primary,
+ secondaryColor: AFThemeExtension.of(context).tint1,
+ );
+ }
}
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_avatar.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_avatar.dart
index c9f1422900..d9d4594240 100644
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_avatar.dart
+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_avatar.dart
@@ -4,49 +4,34 @@ import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/util/built_in_svgs.dart';
import 'package:appflowy/util/color_generator/color_generator.dart';
import 'package:easy_localization/easy_localization.dart';
-import 'package:flowy_infra/size.dart';
import 'package:flowy_infra_ui/style_widget/text.dart';
import 'package:string_validator/string_validator.dart';
-const defaultAvatarSize = 30.0;
+import 'layout_define.dart';
-class ChatChatUserAvatar extends StatelessWidget {
- const ChatChatUserAvatar({required this.userId, super.key});
-
- final String userId;
-
- @override
- Widget build(BuildContext context) {
- return const ChatBorderedCircleAvatar();
- }
-}
-
-class ChatBorderedCircleAvatar extends StatelessWidget {
- const ChatBorderedCircleAvatar({
+class ChatAIAvatar extends StatelessWidget {
+ const ChatAIAvatar({
super.key,
- this.border = const BorderSide(),
- this.backgroundImage,
- this.child,
});
- final BorderSide border;
- final ImageProvider<Object>? backgroundImage;
- final Widget? child;
-
@override
Widget build(BuildContext context) {
- return SizedBox(
- width: defaultAvatarSize,
- child: CircleAvatar(
- backgroundColor: border.color,
- child: ConstrainedBox(
- constraints: const BoxConstraints.expand(),
- child: CircleAvatar(
- backgroundImage: backgroundImage,
- backgroundColor:
- Theme.of(context).colorScheme.surfaceContainerHighest,
- child: child,
- ),
+ return Container(
+ width: DesktopAIConvoSizes.avatarSize,
+ height: DesktopAIConvoSizes.avatarSize,
+ clipBehavior: Clip.hardEdge,
+ decoration: const BoxDecoration(shape: BoxShape.circle),
+ foregroundDecoration: ShapeDecoration(
+ shape: CircleBorder(
+ side: BorderSide(color: Theme.of(context).colorScheme.outline),
+ ),
+ ),
+ child: const CircleAvatar(
+ backgroundColor: Colors.transparent,
+ child: FlowySvg(
+ FlowySvgs.flowy_logo_s,
+ size: Size.square(16),
+ blendMode: null,
),
),
);
@@ -58,28 +43,35 @@ class ChatUserAvatar extends StatelessWidget {
super.key,
required this.iconUrl,
required this.name,
- this.size = defaultAvatarSize,
- this.isHovering = false,
this.defaultName,
});
final String iconUrl;
final String name;
- final double size;
final String? defaultName;
- // If true, a border will be applied on top of the avatar
- final bool isHovering;
-
@override
Widget build(BuildContext context) {
+ late final Widget child;
if (iconUrl.isEmpty) {
- return _buildEmptyAvatar(context);
+ child = _buildEmptyAvatar(context);
} else if (isURL(iconUrl)) {
- return _buildUrlAvatar(context);
+ child = _buildUrlAvatar(context);
} else {
- return _buildEmojiAvatar(context);
+ child = _buildEmojiAvatar(context);
}
+ return Container(
+ width: DesktopAIConvoSizes.avatarSize,
+ height: DesktopAIConvoSizes.avatarSize,
+ clipBehavior: Clip.hardEdge,
+ decoration: const BoxDecoration(shape: BoxShape.circle),
+ foregroundDecoration: ShapeDecoration(
+ shape: CircleBorder(
+ side: BorderSide(color: Theme.of(context).colorScheme.outline),
+ ),
+ ),
+ child: child,
+ );
}
Widget _buildEmptyAvatar(BuildContext context) {
@@ -96,96 +88,50 @@ class ChatUserAvatar extends StatelessWidget {
.map((element) => element[0].toUpperCase())
.join();
- return Container(
- width: size,
- height: size,
- alignment: Alignment.center,
- decoration: BoxDecoration(
- color: color,
- shape: BoxShape.circle,
- border: isHovering
- ? Border.all(
- color: _darken(color),
- width: 4,
- )
- : null,
- ),
- child: FlowyText.regular(
- nameInitials,
- color: Colors.black,
+ return ColoredBox(
+ color: color,
+ child: Center(
+ child: FlowyText.regular(
+ nameInitials,
+ color: Colors.black,
+ ),
),
);
}
Widget _buildUrlAvatar(BuildContext context) {
- return SizedBox.square(
- dimension: size,
- child: DecoratedBox(
- decoration: BoxDecoration(
- shape: BoxShape.circle,
- border: isHovering
- ? Border.all(
- color: Theme.of(context).colorScheme.secondary,
- width: 4,
- )
- : null,
- ),
- child: ClipRRect(
- borderRadius: Corners.s5Border,
- child: CircleAvatar(
- backgroundColor: Colors.transparent,
- child: Image.network(
- iconUrl,
- fit: BoxFit.cover,
- errorBuilder: (context, error, stackTrace) =>
- _buildEmptyAvatar(context),
- ),
- ),
- ),
+ return CircleAvatar(
+ backgroundColor: Colors.transparent,
+ radius: DesktopAIConvoSizes.avatarSize / 2,
+ child: Image.network(
+ iconUrl,
+ fit: BoxFit.cover,
+ errorBuilder: (context, error, stackTrace) =>
+ _buildEmptyAvatar(context),
),
);
}
Widget _buildEmojiAvatar(BuildContext context) {
- return SizedBox.square(
- dimension: size,
- child: DecoratedBox(
- decoration: BoxDecoration(
- shape: BoxShape.circle,
- border: isHovering
- ? Border.all(
- color: Theme.of(context).colorScheme.primary,
- width: 4,
- )
- : null,
- ),
- child: ClipRRect(
- borderRadius: Corners.s5Border,
- child: CircleAvatar(
- backgroundColor: Colors.transparent,
- child: builtInSVGIcons.contains(iconUrl)
- ? FlowySvg(
- FlowySvgData('emoji/$iconUrl'),
- blendMode: null,
- )
- : FlowyText.emoji(iconUrl),
- ),
- ),
- ),
+ return CircleAvatar(
+ backgroundColor: Colors.transparent,
+ radius: DesktopAIConvoSizes.avatarSize / 2,
+ child: builtInSVGIcons.contains(iconUrl)
+ ? FlowySvg(
+ FlowySvgData('emoji/$iconUrl'),
+ blendMode: null,
+ )
+ : FlowyText.emoji(
+ iconUrl,
+ fontSize: 24, // cannot reduce
+ optimizeEmojiAlign: true,
+ ),
);
}
- /// Return the user name, if the user name is empty,
- /// return the default user name.
+ /// Return the user name.
///
+ /// If the user name is empty, return the default user name.
String _userName(String name, String? defaultName) =>
name.isEmpty ? (defaultName ?? LocaleKeys.defaultUsername.tr()) : name;
-
- /// Used to darken the generated color for the hover border effect.
- /// The color is darkened by 15% - Hence the 0.15 value.
- ///
- Color _darken(Color color) {
- final hsl = HSLColor.fromColor(color);
- return hsl.withLightness((hsl.lightness - 0.15).clamp(0.0, 1.0)).toColor();
- }
}
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_editor_style.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_editor_style.dart
new file mode 100644
index 0000000000..2b4a1200b7
--- /dev/null
+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_editor_style.dart
@@ -0,0 +1,143 @@
+// ref appflowy_flutter/lib/plugins/document/presentation/editor_style.dart
+
+// diff:
+// - text style
+// - heading text style and padding builders
+// - don't listen to document appearance cubit
+//
+
+import 'package:appflowy/mobile/application/page_style/document_page_style_bloc.dart';
+import 'package:appflowy/plugins/document/application/document_appearance_cubit.dart';
+import 'package:appflowy/plugins/document/presentation/editor_style.dart';
+import 'package:appflowy/workspace/application/appearance_defaults.dart';
+import 'package:appflowy/workspace/application/settings/appearance/appearance_cubit.dart';
+import 'package:appflowy/workspace/application/settings/appearance/base_appearance.dart';
+import 'package:appflowy_editor/appflowy_editor.dart';
+import 'package:collection/collection.dart';
+import 'package:flowy_infra/theme_extension.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:google_fonts/google_fonts.dart';
+import 'package:universal_platform/universal_platform.dart';
+
+class ChatEditorStyleCustomizer extends EditorStyleCustomizer {
+ ChatEditorStyleCustomizer({
+ required super.context,
+ required super.padding,
+ super.width,
+ });
+
+ @override
+ EditorStyle desktop() {
+ final theme = Theme.of(context);
+ final afThemeExtension = AFThemeExtension.of(context);
+ final appearanceFont = context.read<AppearanceSettingsCubit>().state.font;
+ final appearance = context.read<DocumentAppearanceCubit>().state;
+ const fontSize = 14.0;
+ String fontFamily = appearance.fontFamily;
+ if (fontFamily.isEmpty && appearanceFont.isNotEmpty) {
+ fontFamily = appearanceFont;
+ }
+
+ return EditorStyle.desktop(
+ padding: padding,
+ maxWidth: width,
+ cursorColor: appearance.cursorColor ??
+ DefaultAppearanceSettings.getDefaultCursorColor(context),
+ selectionColor: appearance.selectionColor ??
+ DefaultAppearanceSettings.getDefaultSelectionColor(context),
+ defaultTextDirection: appearance.defaultTextDirection,
+ textStyleConfiguration: TextStyleConfiguration(
+ lineHeight: 1.4,
+ applyHeightToFirstAscent: true,
+ applyHeightToLastDescent: true,
+ text: baseTextStyle(fontFamily).copyWith(
+ fontSize: fontSize,
+ color: afThemeExtension.onBackground,
+ ),
+ bold: baseTextStyle(fontFamily, fontWeight: FontWeight.bold).copyWith(
+ fontWeight: FontWeight.w600,
+ ),
+ italic: baseTextStyle(fontFamily).copyWith(fontStyle: FontStyle.italic),
+ underline: baseTextStyle(fontFamily).copyWith(
+ decoration: TextDecoration.underline,
+ ),
+ strikethrough: baseTextStyle(fontFamily).copyWith(
+ decoration: TextDecoration.lineThrough,
+ ),
+ href: baseTextStyle(fontFamily).copyWith(
+ color: theme.colorScheme.primary,
+ decoration: TextDecoration.underline,
+ ),
+ code: GoogleFonts.robotoMono(
+ textStyle: baseTextStyle(fontFamily).copyWith(
+ fontSize: fontSize,
+ fontWeight: FontWeight.normal,
+ color: Colors.red,
+ backgroundColor: theme.colorScheme.inverseSurface.withOpacity(0.8),
+ ),
+ ),
+ ),
+ textSpanDecorator: customizeAttributeDecorator,
+ textScaleFactor:
+ context.watch<AppearanceSettingsCubit>().state.textScaleFactor,
+ );
+ }
+
+ @override
+ TextStyle headingStyleBuilder(int level) {
+ final String? fontFamily;
+ final List<double> fontSizes;
+ const fontSize = 14.0;
+
+ fontFamily = context.read<DocumentAppearanceCubit>().state.fontFamily;
+ fontSizes = [
+ fontSize + 12,
+ fontSize + 10,
+ fontSize + 6,
+ fontSize + 2,
+ fontSize,
+ ];
+ return baseTextStyle(fontFamily, fontWeight: FontWeight.w600).copyWith(
+ fontSize: fontSizes.elementAtOrNull(level - 1) ?? fontSize,
+ );
+ }
+
+ @override
+ TextStyle codeBlockStyleBuilder() {
+ final fontFamily =
+ context.read<DocumentAppearanceCubit>().state.codeFontFamily;
+ return baseTextStyle(fontFamily).copyWith(
+ height: 1.4,
+ color: AFThemeExtension.of(context).onBackground,
+ );
+ }
+
+ @override
+ TextStyle calloutBlockStyleBuilder() {
+ if (UniversalPlatform.isMobile) {
+ final afThemeExtension = AFThemeExtension.of(context);
+ final pageStyle = context.read<DocumentPageStyleBloc>().state;
+ final fontFamily = pageStyle.fontFamily ?? defaultFontFamily;
+ final baseTextStyle = this.baseTextStyle(fontFamily);
+ return baseTextStyle.copyWith(
+ color: afThemeExtension.onBackground,
+ );
+ } else {
+ final fontSize = context.read<DocumentAppearanceCubit>().state.fontSize;
+ return baseTextStyle(null).copyWith(
+ fontSize: fontSize,
+ height: 1.5,
+ );
+ }
+ }
+
+ @override
+ TextStyle outlineBlockPlaceholderStyleBuilder() {
+ return TextStyle(
+ fontFamily: defaultFontFamily,
+ height: 1.5,
+ color: AFThemeExtension.of(context).onBackground.withOpacity(0.6),
+ );
+ }
+}
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/ai_prompt_buttons.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/ai_prompt_buttons.dart
new file mode 100644
index 0000000000..7d0fc10e3f
--- /dev/null
+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/ai_prompt_buttons.dart
@@ -0,0 +1,123 @@
+import 'package:flutter/material.dart';
+import 'package:appflowy/generated/flowy_svgs.g.dart';
+import 'package:appflowy/generated/locale_keys.g.dart';
+import 'package:easy_localization/easy_localization.dart';
+import 'package:flowy_infra/theme_extension.dart';
+import 'package:flowy_infra_ui/style_widget/icon_button.dart';
+import 'package:flowy_infra_ui/widget/flowy_tooltip.dart';
+
+import '../layout_define.dart';
+
+enum SendButtonState { enabled, streaming, disabled }
+
+class PromptInputAttachmentButton extends StatelessWidget {
+ const PromptInputAttachmentButton({required this.onTap, super.key});
+
+ final VoidCallback onTap;
+
+ @override
+ Widget build(BuildContext context) {
+ return FlowyTooltip(
+ message: LocaleKeys.chat_uploadFile.tr(),
+ child: SizedBox.square(
+ dimension: DesktopAIPromptSizes.actionBarButtonSize,
+ child: FlowyIconButton(
+ hoverColor: AFThemeExtension.of(context).lightGreyHover,
+ radius: BorderRadius.circular(8),
+ icon: FlowySvg(
+ FlowySvgs.ai_attachment_s,
+ size: const Size.square(16),
+ color: Theme.of(context).iconTheme.color,
+ ),
+ onPressed: onTap,
+ ),
+ ),
+ );
+ }
+}
+
+class PromptInputMentionButton extends StatelessWidget {
+ const PromptInputMentionButton({
+ super.key,
+ required this.buttonSize,
+ required this.iconSize,
+ required this.onTap,
+ });
+
+ final double buttonSize;
+ final double iconSize;
+ final VoidCallback onTap;
+
+ @override
+ Widget build(BuildContext context) {
+ return FlowyTooltip(
+ message: LocaleKeys.chat_clickToMention.tr(),
+ preferBelow: false,
+ child: FlowyIconButton(
+ width: buttonSize,
+ hoverColor: AFThemeExtension.of(context).lightGreyHover,
+ radius: BorderRadius.circular(8),
+ icon: FlowySvg(
+ FlowySvgs.chat_at_s,
+ size: Size.square(iconSize),
+ color: Theme.of(context).iconTheme.color,
+ ),
+ onPressed: onTap,
+ ),
+ );
+ }
+}
+
+class PromptInputSendButton extends StatelessWidget {
+ const PromptInputSendButton({
+ super.key,
+ required this.buttonSize,
+ required this.iconSize,
+ required this.state,
+ required this.onSendPressed,
+ required this.onStopStreaming,
+ });
+
+ final double buttonSize;
+ final double iconSize;
+ final SendButtonState state;
+ final VoidCallback onSendPressed;
+ final VoidCallback onStopStreaming;
+
+ @override
+ Widget build(BuildContext context) {
+ return FlowyIconButton(
+ width: buttonSize,
+ icon: switch (state) {
+ SendButtonState.enabled => FlowySvg(
+ FlowySvgs.ai_send_filled_s,
+ size: Size.square(iconSize),
+ color: Theme.of(context).colorScheme.primary,
+ ),
+ SendButtonState.disabled => FlowySvg(
+ FlowySvgs.ai_send_filled_s,
+ size: Size.square(iconSize),
+ color: Theme.of(context).disabledColor,
+ ),
+ SendButtonState.streaming => FlowySvg(
+ FlowySvgs.ai_stop_filled_s,
+ size: Size.square(iconSize),
+ color: Theme.of(context).colorScheme.primary,
+ ),
+ },
+ onPressed: () {
+ switch (state) {
+ case SendButtonState.enabled:
+ onSendPressed();
+ break;
+ case SendButtonState.streaming:
+ onStopStreaming();
+ break;
+ case SendButtonState.disabled:
+ break;
+ }
+ },
+ hoverColor: Colors.transparent,
+ );
+ }
+}
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/chat_at_button.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/chat_at_button.dart
deleted file mode 100644
index 53741f4431..0000000000
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/chat_at_button.dart
+++ /dev/null
@@ -1,30 +0,0 @@
-import 'package:appflowy/generated/flowy_svgs.g.dart';
-import 'package:appflowy/generated/locale_keys.g.dart';
-import 'package:easy_localization/easy_localization.dart';
-import 'package:flowy_infra/theme_extension.dart';
-import 'package:flowy_infra_ui/style_widget/icon_button.dart';
-import 'package:flowy_infra_ui/widget/flowy_tooltip.dart';
-import 'package:flutter/material.dart';
-
-class ChatInputAtButton extends StatelessWidget {
- const ChatInputAtButton({required this.onTap, super.key});
-
- final VoidCallback onTap;
-
- @override
- Widget build(BuildContext context) {
- return FlowyTooltip(
- message: LocaleKeys.chat_clickToMention.tr(),
- child: FlowyIconButton(
- hoverColor: AFThemeExtension.of(context).lightGreyHover,
- radius: BorderRadius.circular(6),
- icon: FlowySvg(
- FlowySvgs.chat_at_s,
- size: const Size.square(20),
- color: Colors.grey.shade600,
- ),
- onPressed: onTap,
- ),
- );
- }
-}
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/chat_input.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/chat_input.dart
deleted file mode 100644
index 5f7aed9b40..0000000000
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/chat_input.dart
+++ /dev/null
@@ -1,451 +0,0 @@
-import 'package:appflowy/plugins/ai_chat/application/chat_entity.dart';
-import 'package:appflowy/plugins/ai_chat/application/chat_file_bloc.dart';
-import 'package:appflowy/plugins/ai_chat/application/chat_input_action_bloc.dart';
-import 'package:appflowy/plugins/ai_chat/application/chat_input_action_control.dart';
-import 'package:appflowy/plugins/ai_chat/application/chat_input_bloc.dart';
-import 'package:appflowy/plugins/ai_chat/presentation/chat_input/chat_input_file.dart';
-import 'package:appflowy/plugins/ai_chat/presentation/chat_input_action_menu.dart';
-import 'package:appflowy/plugins/document/presentation/editor_plugins/mention/mobile_page_selector_sheet.dart';
-import 'package:appflowy/startup/startup.dart';
-import 'package:appflowy/workspace/application/view/view_ext.dart';
-import 'package:extended_text_field/extended_text_field.dart';
-import 'package:flowy_infra/file_picker/file_picker_service.dart';
-import 'package:flowy_infra/theme_extension.dart';
-import 'package:flowy_infra_ui/flowy_infra_ui.dart';
-import 'package:flutter/foundation.dart';
-import 'package:flutter/material.dart';
-import 'package:flutter/services.dart';
-import 'package:flutter_bloc/flutter_bloc.dart';
-import 'package:flutter_chat_types/flutter_chat_types.dart' as types;
-import 'package:flutter_chat_ui/flutter_chat_ui.dart';
-import 'package:universal_platform/universal_platform.dart';
-
-import 'chat_at_button.dart';
-import 'chat_input_attachment.dart';
-import 'chat_input_span.dart';
-import 'chat_send_button.dart';
-import 'layout_define.dart';
-
-class ChatInput extends StatefulWidget {
- /// Creates [ChatInput] widget.
- const ChatInput({
- super.key,
- this.onAttachmentPressed,
- required this.onSendPressed,
- required this.chatId,
- this.options = const InputOptions(),
- required this.isStreaming,
- required this.onStopStreaming,
- required this.hintText,
- required this.aiType,
- });
-
- final VoidCallback? onAttachmentPressed;
- final void Function(types.PartialText) onSendPressed;
- final void Function() onStopStreaming;
- final InputOptions options;
- final String chatId;
- final bool isStreaming;
- final String hintText;
- final AIType aiType;
-
- @override
- State<ChatInput> createState() => _ChatInputState();
-}
-
-/// [ChatInput] widget state.
-class _ChatInputState extends State<ChatInput> {
- final GlobalKey _textFieldKey = GlobalKey();
- final LayerLink _layerLink = LayerLink();
- late ChatInputActionControl _inputActionControl;
- late FocusNode _inputFocusNode;
- late TextEditingController _textController;
- bool _sendButtonEnabled = false;
-
- @override
- void initState() {
- super.initState();
- _textController = InputTextFieldController();
- _inputFocusNode = FocusNode(
- onKeyEvent: (node, event) {
- if (UniversalPlatform.isDesktop) {
- if (_inputActionControl.canHandleKeyEvent(event)) {
- _inputActionControl.handleKeyEvent(event);
- return KeyEventResult.handled;
- } else {
- return _handleEnterKeyWithoutShift(
- event,
- _textController,
- widget.isStreaming,
- _handleSendPressed,
- );
- }
- } else {
- return KeyEventResult.ignored;
- }
- },
- );
-
- _inputFocusNode.addListener(_updateState);
-
- _inputActionControl = ChatInputActionControl(
- chatId: widget.chatId,
- textController: _textController,
- textFieldFocusNode: _inputFocusNode,
- );
- _inputFocusNode.requestFocus();
- _handleSendButtonVisibilityModeChange();
- }
-
- @override
- void dispose() {
- _inputFocusNode.removeListener(_updateState);
- _inputFocusNode.dispose();
- _textController.dispose();
- _inputActionControl.dispose();
- super.dispose();
- }
-
- void _updateState() => setState(() {});
-
- @override
- Widget build(BuildContext context) {
- return Padding(
- padding: inputPadding,
- // ignore: use_decorated_box
- child: Container(
- decoration: BoxDecoration(
- border: Border.all(
- color: _inputFocusNode.hasFocus
- ? Theme.of(context).colorScheme.primary.withOpacity(0.6)
- : Theme.of(context).colorScheme.secondary,
- ),
- borderRadius: borderRadius,
- ),
- child: Material(
- borderRadius: borderRadius,
- color: color,
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 10),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- if (context.read<ChatFileBloc>().state.uploadFiles.isNotEmpty)
- Padding(
- padding: EdgeInsets.only(
- top: 12,
- bottom: 12,
- left: textPadding.left + sendButtonSize,
- right: textPadding.right,
- ),
- child: BlocBuilder<ChatFileBloc, ChatFileState>(
- builder: (context, state) {
- return ChatInputFile(
- chatId: widget.chatId,
- files: state.uploadFiles,
- onDeleted: (file) => context.read<ChatFileBloc>().add(
- ChatFileEvent.deleteFile(file),
- ),
- );
- },
- ),
- ),
-
- //
- Row(
- children: [
- // TODO(lucas): support mobile
- if (UniversalPlatform.isDesktop &&
- widget.aiType.isLocalAI())
- _attachmentButton(buttonPadding),
-
- // text field
- Expanded(child: _inputTextField(context, textPadding)),
-
- // mention button
- _mentionButton(buttonPadding),
-
- if (UniversalPlatform.isMobile) const HSpace(6.0),
-
- // send button
- _sendButton(buttonPadding),
- ],
- ),
- ],
- ),
- ),
- ),
- ),
- );
- }
-
- void _handleSendButtonVisibilityModeChange() {
- _textController.removeListener(_handleTextControllerChange);
- _sendButtonEnabled =
- _textController.text.trim() != '' || widget.isStreaming;
- _textController.addListener(_handleTextControllerChange);
- }
-
- void _handleSendPressed() {
- final trimmedText = _textController.text.trim();
- if (trimmedText != '') {
- // consume metadata
- final ChatInputMentionMetadata mentionPageMetadata =
- _inputActionControl.consumeMetaData();
- final ChatInputFileMetadata fileMetadata =
- context.read<ChatFileBloc>().consumeMetaData();
-
- // combine metadata
- final Map<String, dynamic> metadata = {}
- ..addAll(mentionPageMetadata)
- ..addAll(fileMetadata);
-
- final partialText = types.PartialText(
- text: trimmedText,
- metadata: metadata,
- );
- widget.onSendPressed(partialText);
- _textController.clear();
- }
- }
-
- void _handleTextControllerChange() {
- if (_textController.value.isComposingRangeValid) {
- return;
- }
- setState(() {
- _sendButtonEnabled = _textController.text.trim() != '';
- });
- }
-
- Widget _inputTextField(BuildContext context, EdgeInsets textPadding) {
- return CompositedTransformTarget(
- link: _layerLink,
- child: Padding(
- padding: textPadding,
- child: ExtendedTextField(
- key: _textFieldKey,
- controller: _textController,
- focusNode: _inputFocusNode,
- decoration: _buildInputDecoration(context),
- keyboardType: TextInputType.multiline,
- textCapitalization: TextCapitalization.sentences,
- minLines: 1,
- maxLines: 10,
- style: _buildTextStyle(context),
- specialTextSpanBuilder: ChatInputTextSpanBuilder(
- inputActionControl: _inputActionControl,
- ),
- onChanged: (text) {
- _handleOnTextChange(context, text);
- },
- ),
- ),
- );
- }
-
- InputDecoration _buildInputDecoration(BuildContext context) {
- return InputDecoration(
- border: InputBorder.none,
- enabledBorder: InputBorder.none,
- hintText: widget.hintText,
- focusedBorder: InputBorder.none,
- hintStyle: TextStyle(
- color: AFThemeExtension.of(context).textColor.withOpacity(0.5),
- ),
- );
- }
-
- TextStyle? _buildTextStyle(BuildContext context) {
- if (!isMobile) {
- return TextStyle(
- color: AFThemeExtension.of(context).textColor,
- fontSize: 15,
- );
- }
-
- return Theme.of(context).textTheme.bodyMedium?.copyWith(
- fontSize: 15,
- height: 1.2,
- );
- }
-
- Future<void> _handleOnTextChange(BuildContext context, String text) async {
- if (!_inputActionControl.onTextChanged(text)) {
- return;
- }
-
- if (UniversalPlatform.isDesktop) {
- ChatActionsMenu(
- anchor: ChatInputAnchor(
- anchorKey: _textFieldKey,
- layerLink: _layerLink,
- ),
- handler: _inputActionControl,
- context: context,
- style: Theme.of(context).brightness == Brightness.dark
- ? const ChatActionsMenuStyle.dark()
- : const ChatActionsMenuStyle.light(),
- ).show();
- } else {
- // if the focus node is on focus, unfocus it for better animation
- // otherwise, the page sheet animation will be blocked by the keyboard
- if (_inputFocusNode.hasFocus) {
- _inputFocusNode.unfocus();
- Future.delayed(const Duration(milliseconds: 100), () async {
- await _referPage(_inputActionControl);
- });
- } else {
- await _referPage(_inputActionControl);
- }
- }
- }
-
- Widget _sendButton(EdgeInsets buttonPadding) {
- return Padding(
- padding: buttonPadding,
- child: SizedBox.square(
- dimension: sendButtonSize,
- child: ChatInputSendButton(
- onSendPressed: () {
- if (!_sendButtonEnabled) {
- return;
- }
-
- if (!widget.isStreaming) {
- widget.onStopStreaming();
- _handleSendPressed();
- }
- },
- onStopStreaming: () => widget.onStopStreaming(),
- isStreaming: widget.isStreaming,
- enabled: _sendButtonEnabled,
- ),
- ),
- );
- }
-
- Widget _attachmentButton(EdgeInsets buttonPadding) {
- return Padding(
- padding: buttonPadding,
- child: SizedBox.square(
- dimension: attachButtonSize,
- child: ChatInputAttachment(
- onTap: () async {
- final path = await getIt<FilePickerService>().pickFiles(
- dialogTitle: '',
- type: FileType.custom,
- allowedExtensions: ["pdf"],
- );
- if (path == null) {
- return;
- }
-
- for (final file in path.files) {
- if (file.path != null) {
- if (mounted) {
- context
- .read<ChatFileBloc>()
- .add(ChatFileEvent.newFile(file.path!, file.name));
- }
- }
- }
- },
- ),
- ),
- );
- }
-
- Widget _mentionButton(EdgeInsets buttonPadding) {
- return Padding(
- padding: buttonPadding,
- child: SizedBox.square(
- dimension: attachButtonSize,
- child: ChatInputAtButton(
- onTap: () {
- _textController.text += '@';
- if (!isMobile) {
- _inputFocusNode.requestFocus();
- }
- _handleOnTextChange(context, _textController.text);
- },
- ),
- ),
- );
- }
-
- Future<void> _referPage(ChatActionHandler handler) async {
- handler.onEnter();
- final selectedView = await showPageSelectorSheet(
- context,
- filter: (view) =>
- view.layout.isDocumentView &&
- !view.isSpace &&
- view.parentViewId.isNotEmpty,
- );
- if (selectedView == null) {
- handler.onExit();
- return;
- }
- handler.onSelected(ViewActionPage(view: selectedView));
- handler.onExit();
- _inputFocusNode.requestFocus();
- }
-
- @override
- void didUpdateWidget(covariant ChatInput oldWidget) {
- super.didUpdateWidget(oldWidget);
- _handleSendButtonVisibilityModeChange();
- }
-}
-
-final isMobile = defaultTargetPlatform == TargetPlatform.android ||
- defaultTargetPlatform == TargetPlatform.iOS;
-
-class ChatInputAnchor extends ChatAnchor {
- ChatInputAnchor({
- required this.anchorKey,
- required this.layerLink,
- });
-
- @override
- final GlobalKey<State<StatefulWidget>> anchorKey;
-
- @override
- final LayerLink layerLink;
-}
-
-/// Handles the key press event for the Enter key without Shift.
-///
-/// This function checks if the Enter key is pressed without either of the Shift keys.
-/// If the conditions are met, it performs the action of sending a message if the
-/// text controller is not in a composing range and if the event is a key down event.
-///
-/// - Returns: A `KeyEventResult` indicating whether the key event was handled or ignored.
-KeyEventResult _handleEnterKeyWithoutShift(
- KeyEvent event,
- TextEditingController textController,
- bool isStreaming,
- void Function() handleSendPressed,
-) {
- if (event.physicalKey == PhysicalKeyboardKey.enter &&
- !HardwareKeyboard.instance.physicalKeysPressed.any(
- (el) => <PhysicalKeyboardKey>{
- PhysicalKeyboardKey.shiftLeft,
- PhysicalKeyboardKey.shiftRight,
- }.contains(el),
- )) {
- if (textController.value.isComposingRangeValid) {
- return KeyEventResult.ignored;
- }
-
- if (event is KeyDownEvent) {
- if (!isStreaming) {
- handleSendPressed();
- }
- }
- return KeyEventResult.handled;
- } else {
- return KeyEventResult.ignored;
- }
-}
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/chat_input_attachment.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/chat_input_attachment.dart
deleted file mode 100644
index 954988da7c..0000000000
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/chat_input_attachment.dart
+++ /dev/null
@@ -1,30 +0,0 @@
-import 'package:flutter/material.dart';
-import 'package:appflowy/generated/flowy_svgs.g.dart';
-import 'package:appflowy/generated/locale_keys.g.dart';
-import 'package:easy_localization/easy_localization.dart';
-import 'package:flowy_infra/theme_extension.dart';
-import 'package:flowy_infra_ui/style_widget/icon_button.dart';
-import 'package:flowy_infra_ui/widget/flowy_tooltip.dart';
-
-class ChatInputAttachment extends StatelessWidget {
- const ChatInputAttachment({required this.onTap, super.key});
-
- final VoidCallback onTap;
-
- @override
- Widget build(BuildContext context) {
- return FlowyTooltip(
- message: LocaleKeys.chat_uploadFile.tr(),
- child: FlowyIconButton(
- hoverColor: AFThemeExtension.of(context).lightGreyHover,
- radius: BorderRadius.circular(6),
- icon: FlowySvg(
- FlowySvgs.ai_attachment_s,
- size: const Size.square(20),
- color: Colors.grey.shade600,
- ),
- onPressed: onTap,
- ),
- );
- }
-}
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/chat_input_file.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/chat_input_file.dart
index ba6170a69a..b0e260fd08 100644
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/chat_input_file.dart
+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/chat_input_file.dart
@@ -1,130 +1,167 @@
import 'package:appflowy/generated/flowy_svgs.g.dart';
+import 'package:appflowy/plugins/ai_chat/application/ai_prompt_input_bloc.dart';
import 'package:appflowy/plugins/ai_chat/application/chat_entity.dart';
import 'package:appflowy/plugins/ai_chat/application/chat_input_file_bloc.dart';
+import 'package:flowy_infra/theme_extension.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
-import 'package:flowy_infra_ui/style_widget/hover.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:styled_widget/styled_widget.dart';
+import '../layout_define.dart';
+
class ChatInputFile extends StatelessWidget {
const ChatInputFile({
+ super.key,
required this.chatId,
- required this.files,
required this.onDeleted,
- super.key,
});
- final List<ChatFile> files;
- final String chatId;
- final Function(ChatFile) onDeleted;
+ final String chatId;
+ final void Function(ChatFile) onDeleted;
@override
Widget build(BuildContext context) {
- final List<Widget> children = files
- .map(
- (file) => ChatFilePreview(
+ return BlocSelector<AIPromptInputBloc, AIPromptInputState, List<ChatFile>>(
+ selector: (state) => state.uploadFiles,
+ builder: (context, files) {
+ if (files.isEmpty) {
+ return const SizedBox.shrink();
+ }
+ return ListView.separated(
+ scrollDirection: Axis.horizontal,
+ padding: DesktopAIPromptSizes.attachedFilesBarPadding -
+ const EdgeInsets.only(top: 6),
+ separatorBuilder: (context, index) => const HSpace(
+ DesktopAIPromptSizes.attachedFilesPreviewSpacing - 6,
+ ),
+ itemCount: files.length,
+ itemBuilder: (context, index) => ChatFilePreview(
chatId: chatId,
- file: file,
- onDeleted: onDeleted,
+ file: files[index],
+ onDeleted: () => onDeleted(files[index]),
),
- )
- .toList();
-
- return Wrap(
- spacing: 6,
- runSpacing: 6,
- children: children,
+ );
+ },
);
}
}
-class ChatFilePreview extends StatelessWidget {
+class ChatFilePreview extends StatefulWidget {
const ChatFilePreview({
required this.chatId,
required this.file,
required this.onDeleted,
super.key,
});
+
final String chatId;
final ChatFile file;
- final Function(ChatFile) onDeleted;
+ final VoidCallback onDeleted;
+
+ @override
+ State<ChatFilePreview> createState() => _ChatFilePreviewState();
+}
+
+class _ChatFilePreviewState extends State<ChatFilePreview> {
+ bool isHover = false;
@override
Widget build(BuildContext context) {
return BlocProvider(
- create: (context) => ChatInputFileBloc(chatId: chatId, file: file)
- ..add(const ChatInputFileEvent.initial()),
+ create: (context) => ChatInputFileBloc(file: widget.file),
child: BlocBuilder<ChatInputFileBloc, ChatInputFileState>(
builder: (context, state) {
- return FlowyHover(
- builder: (context, onHover) {
- return ConstrainedBox(
- constraints: const BoxConstraints(
- maxWidth: 260,
- ),
- child: DecoratedBox(
+ return MouseRegion(
+ onEnter: (_) => setHover(true),
+ onExit: (_) => setHover(false),
+ child: Stack(
+ children: [
+ Container(
+ margin: const EdgeInsetsDirectional.only(top: 6, end: 6),
+ constraints: const BoxConstraints(maxWidth: 240),
decoration: BoxDecoration(
- color:
- Theme.of(context).colorScheme.surfaceContainerHighest,
+ border: Border.all(
+ color: Theme.of(context).dividerColor,
+ ),
borderRadius: BorderRadius.circular(8),
),
- child: Stack(
- clipBehavior: Clip.none,
+ padding: const EdgeInsets.all(8.0),
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
children: [
- Padding(
- padding: const EdgeInsets.symmetric(
- horizontal: 10.0,
- vertical: 14,
+ Container(
+ decoration: BoxDecoration(
+ color: AFThemeExtension.of(context).tint1,
+ borderRadius: BorderRadius.circular(8),
),
- child: Row(
- mainAxisSize: MainAxisSize.min,
+ height: 32,
+ width: 32,
+ child: Center(
+ child: FlowySvg(
+ FlowySvgs.page_m,
+ size: const Size.square(16),
+ color: Theme.of(context).hintColor,
+ ),
+ ),
+ ),
+ const HSpace(8),
+ Flexible(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ mainAxisAlignment: MainAxisAlignment.center,
children: [
- file.fileType.icon,
- const HSpace(6),
- Flexible(
- child: FlowyText(
- file.fileName,
- fontSize: 12,
- maxLines: 6,
- ),
+ FlowyText(
+ widget.file.fileName,
+ fontSize: 12.0,
+ ),
+ FlowyText(
+ widget.file.fileType.name,
+ color: Theme.of(context).hintColor,
+ fontSize: 12.0,
),
],
),
),
- if (onHover)
- _CloseButton(
- onPressed: () => onDeleted(file),
- ).positioned(top: -6, right: -6),
],
),
),
- );
- },
+ if (isHover)
+ _CloseButton(
+ onTap: widget.onDeleted,
+ ).positioned(top: 0, right: 0),
+ ],
+ ),
);
},
),
);
}
+
+ void setHover(bool value) {
+ if (value != isHover) {
+ setState(() => isHover = value);
+ }
+ }
}
class _CloseButton extends StatelessWidget {
- const _CloseButton({required this.onPressed});
- final VoidCallback onPressed;
+ const _CloseButton({required this.onTap});
+
+ final VoidCallback onTap;
@override
Widget build(BuildContext context) {
- return FlowyIconButton(
- width: 24,
- height: 24,
- isSelected: true,
- radius: BorderRadius.circular(12),
- fillColor: Theme.of(context).colorScheme.surfaceContainer,
- icon: const FlowySvg(
- FlowySvgs.close_s,
- size: Size.square(20),
+ return MouseRegion(
+ cursor: SystemMouseCursors.click,
+ child: GestureDetector(
+ onTap: onTap,
+ child: FlowySvg(
+ FlowySvgs.ai_close_filled_s,
+ color: AFThemeExtension.of(context).greyHover,
+ size: const Size.square(16),
+ ),
),
- onPressed: onPressed,
);
}
}
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/chat_input_span.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/chat_input_span.dart
index 1a474c4882..854211d95d 100644
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/chat_input_span.dart
+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/chat_input_span.dart
@@ -65,9 +65,7 @@ class AtText extends SpecialText {
style: textStyle,
recognizer: (TapGestureRecognizer()
..onTap = () {
- if (onTap != null) {
- onTap!(atText);
- }
+ onTap?.call(atText);
}),
);
}
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/chat_send_button.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/chat_send_button.dart
deleted file mode 100644
index 2de77e9362..0000000000
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/chat_send_button.dart
+++ /dev/null
@@ -1,50 +0,0 @@
-import 'package:appflowy/generated/flowy_svgs.g.dart';
-import 'package:flowy_infra/theme_extension.dart';
-import 'package:flowy_infra_ui/style_widget/icon_button.dart';
-import 'package:flutter/material.dart';
-
-class ChatInputSendButton extends StatelessWidget {
- const ChatInputSendButton({
- required this.onSendPressed,
- required this.onStopStreaming,
- required this.isStreaming,
- required this.enabled,
- super.key,
- });
-
- final void Function() onSendPressed;
- final void Function() onStopStreaming;
- final bool isStreaming;
- final bool enabled;
-
- @override
- Widget build(BuildContext context) {
- if (isStreaming) {
- return FlowyIconButton(
- icon: FlowySvg(
- FlowySvgs.ai_stream_stop_s,
- size: const Size.square(20),
- color: Theme.of(context).colorScheme.primary,
- ),
- onPressed: onStopStreaming,
- radius: BorderRadius.circular(18),
- fillColor: AFThemeExtension.of(context).lightGreyHover,
- hoverColor: AFThemeExtension.of(context).lightGreyHover,
- );
- } else {
- return FlowyIconButton(
- fillColor: AFThemeExtension.of(context).lightGreyHover,
- hoverColor: AFThemeExtension.of(context).lightGreyHover,
- radius: BorderRadius.circular(18),
- icon: FlowySvg(
- FlowySvgs.send_s,
- size: const Size.square(14),
- color: enabled
- ? Theme.of(context).colorScheme.primary
- : Colors.grey.shade600,
- ),
- onPressed: onSendPressed,
- );
- }
- }
-}
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/desktop_ai_prompt_input.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/desktop_ai_prompt_input.dart
new file mode 100644
index 0000000000..4f30171752
--- /dev/null
+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/desktop_ai_prompt_input.dart
@@ -0,0 +1,387 @@
+import 'package:appflowy/generated/locale_keys.g.dart';
+import 'package:appflowy/plugins/ai_chat/application/chat_entity.dart';
+import 'package:appflowy/plugins/ai_chat/application/ai_prompt_input_bloc.dart';
+import 'package:appflowy/plugins/ai_chat/application/chat_input_action_control.dart';
+import 'package:appflowy/plugins/ai_chat/presentation/chat_input/chat_input_file.dart';
+import 'package:appflowy/plugins/ai_chat/presentation/chat_input_action_menu.dart';
+import 'package:appflowy/startup/startup.dart';
+import 'package:easy_localization/easy_localization.dart';
+import 'package:extended_text_field/extended_text_field.dart';
+import 'package:flowy_infra/file_picker/file_picker_service.dart';
+import 'package:flowy_infra_ui/flowy_infra_ui.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:flutter_chat_types/flutter_chat_types.dart' as types;
+import 'package:flutter_chat_ui/flutter_chat_ui.dart';
+import 'package:universal_platform/universal_platform.dart';
+
+import 'ai_prompt_buttons.dart';
+import 'chat_input_span.dart';
+import '../layout_define.dart';
+
+class DesktopAIPromptInput extends StatefulWidget {
+ const DesktopAIPromptInput({
+ super.key,
+ required this.chatId,
+ required this.indicateFocus,
+ this.options = const InputOptions(),
+ required this.isStreaming,
+ required this.onStopStreaming,
+ required this.onSubmitted,
+ });
+
+ final String chatId;
+ final bool indicateFocus;
+ final InputOptions options;
+ final bool isStreaming;
+ final void Function() onStopStreaming;
+ final void Function(types.PartialText) onSubmitted;
+
+ @override
+ State<DesktopAIPromptInput> createState() => _DesktopAIPromptInputState();
+}
+
+class _DesktopAIPromptInputState extends State<DesktopAIPromptInput> {
+ final GlobalKey _textFieldKey = GlobalKey();
+ final LayerLink _layerLink = LayerLink();
+
+ late final ChatInputActionControl _inputActionControl;
+ late final FocusNode _inputFocusNode;
+ late final TextEditingController _textController;
+
+ late SendButtonState sendButtonState;
+
+ @override
+ void initState() {
+ super.initState();
+
+ _textController = InputTextFieldController()
+ ..addListener(_handleTextControllerChange);
+
+ _inputFocusNode = FocusNode(
+ onKeyEvent: (node, event) {
+ if (_inputActionControl.canHandleKeyEvent(event)) {
+ _inputActionControl.handleKeyEvent(event);
+ return KeyEventResult.handled;
+ } else {
+ return _handleEnterKeyWithoutShift(
+ event,
+ _textController,
+ widget.isStreaming,
+ _handleSendPressed,
+ );
+ }
+ },
+ )..addListener(() {
+ // refresh border color on focus change
+ if (widget.indicateFocus) {
+ setState(() {});
+ }
+ });
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ _inputFocusNode.requestFocus();
+ });
+
+ _inputActionControl = ChatInputActionControl(
+ chatId: widget.chatId,
+ textController: _textController,
+ textFieldFocusNode: _inputFocusNode,
+ );
+
+ updateSendButtonState();
+ }
+
+ @override
+ void didUpdateWidget(covariant oldWidget) {
+ updateSendButtonState();
+ super.didUpdateWidget(oldWidget);
+ }
+
+ @override
+ void dispose() {
+ _inputFocusNode.dispose();
+ _textController.dispose();
+ _inputActionControl.dispose();
+ super.dispose();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return DecoratedBox(
+ decoration: BoxDecoration(
+ border: Border.all(
+ color: _inputFocusNode.hasFocus && widget.indicateFocus
+ ? Theme.of(context).colorScheme.primary
+ : Theme.of(context).colorScheme.outline,
+ ),
+ borderRadius: DesktopAIPromptSizes.promptFrameRadius,
+ ),
+ child: Column(
+ children: [
+ ConstrainedBox(
+ constraints: BoxConstraints(
+ maxHeight: DesktopAIPromptSizes.attachedFilesBarPadding.vertical +
+ DesktopAIPromptSizes.attachedFilesPreviewHeight,
+ ),
+ child: TextFieldTapRegion(
+ child: ChatInputFile(
+ chatId: widget.chatId,
+ onDeleted: (file) => context
+ .read<AIPromptInputBloc>()
+ .add(AIPromptInputEvent.deleteFile(file)),
+ ),
+ ),
+ ),
+ Stack(
+ children: [
+ ConstrainedBox(
+ constraints: const BoxConstraints(
+ minHeight: DesktopAIPromptSizes.textFieldMinHeight +
+ DesktopAIPromptSizes.actionBarHeight,
+ maxHeight: 300,
+ ),
+ child: _inputTextField(context),
+ ),
+ Positioned.fill(
+ top: null,
+ child: TextFieldTapRegion(
+ child: Container(
+ height: DesktopAIPromptSizes.actionBarHeight,
+ padding: const EdgeInsets.symmetric(horizontal: 8),
+ child: BlocBuilder<AIPromptInputBloc, AIPromptInputState>(
+ builder: (context, state) {
+ return Row(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ // _predefinedFormatButton(),
+ const Spacer(),
+ _mentionButton(),
+ const HSpace(
+ DesktopAIPromptSizes.actionBarButtonSpacing,
+ ),
+ if (UniversalPlatform.isDesktop &&
+ state.supportChatWithFile) ...[
+ _attachmentButton(),
+ const HSpace(
+ DesktopAIPromptSizes.actionBarButtonSpacing,
+ ),
+ ],
+ _sendButton(),
+ ],
+ );
+ },
+ ),
+ ),
+ ),
+ ),
+ ],
+ ),
+ ],
+ ),
+ );
+ }
+
+ void updateSendButtonState() {
+ if (widget.isStreaming) {
+ sendButtonState = SendButtonState.streaming;
+ } else if (_textController.text.trim().isEmpty) {
+ sendButtonState = SendButtonState.disabled;
+ } else {
+ sendButtonState = SendButtonState.enabled;
+ }
+ }
+
+ void _handleSendPressed() {
+ final trimmedText = _textController.text.trim();
+ _textController.clear();
+ if (trimmedText.isEmpty) {
+ return;
+ }
+ // consume metadata
+ final ChatInputMentionMetadata mentionPageMetadata =
+ _inputActionControl.consumeMetaData();
+ final ChatInputFileMetadata fileMetadata =
+ context.read<AIPromptInputBloc>().consumeMetadata();
+
+ // combine metadata
+ final Map<String, dynamic> metadata = {}
+ ..addAll(mentionPageMetadata)
+ ..addAll(fileMetadata);
+
+ final partialText = types.PartialText(
+ text: trimmedText,
+ metadata: metadata,
+ );
+ widget.onSubmitted(partialText);
+ }
+
+ void _handleTextControllerChange() {
+ if (_textController.value.isComposingRangeValid) {
+ return;
+ }
+ setState(() => updateSendButtonState());
+ }
+
+ Widget _inputTextField(BuildContext context) {
+ return CompositedTransformTarget(
+ link: _layerLink,
+ child: BlocBuilder<AIPromptInputBloc, AIPromptInputState>(
+ builder: (context, state) {
+ return ExtendedTextField(
+ key: _textFieldKey,
+ controller: _textController,
+ focusNode: _inputFocusNode,
+ decoration: InputDecoration(
+ border: InputBorder.none,
+ enabledBorder: InputBorder.none,
+ focusedBorder: InputBorder.none,
+ contentPadding: DesktopAIPromptSizes.textFieldContentPadding.add(
+ const EdgeInsets.only(
+ bottom: DesktopAIPromptSizes.actionBarHeight,
+ ),
+ ),
+ hintText: switch (state.aiType) {
+ AIType.appflowyAI => LocaleKeys.chat_inputMessageHint.tr(),
+ AIType.localAI => LocaleKeys.chat_inputLocalAIMessageHint.tr()
+ },
+ hintStyle: Theme.of(context)
+ .textTheme
+ .bodyMedium
+ ?.copyWith(color: Theme.of(context).hintColor),
+ isCollapsed: true,
+ isDense: true,
+ ),
+ keyboardType: TextInputType.multiline,
+ textCapitalization: TextCapitalization.sentences,
+ minLines: 1,
+ maxLines: null,
+ style: Theme.of(context).textTheme.bodyMedium,
+ specialTextSpanBuilder: ChatInputTextSpanBuilder(
+ inputActionControl: _inputActionControl,
+ ),
+ onChanged: (text) {
+ _handleOnTextChange(context, text);
+ },
+ );
+ },
+ ),
+ );
+ }
+
+ Future<void> _handleOnTextChange(BuildContext context, String text) async {
+ if (!_inputActionControl.onTextChanged(text)) {
+ return;
+ }
+
+ ChatActionsMenu(
+ anchor: ChatInputAnchor(
+ anchorKey: _textFieldKey,
+ layerLink: _layerLink,
+ ),
+ handler: _inputActionControl,
+ context: context,
+ style: Theme.of(context).brightness == Brightness.dark
+ ? const ChatActionsMenuStyle.dark()
+ : const ChatActionsMenuStyle.light(),
+ ).show();
+ }
+
+ Widget _mentionButton() {
+ return PromptInputMentionButton(
+ iconSize: DesktopAIPromptSizes.actionBarIconSize,
+ buttonSize: DesktopAIPromptSizes.actionBarButtonSize,
+ onTap: () {
+ _textController.text += '@';
+ if (!_inputFocusNode.hasFocus) {
+ _inputFocusNode.requestFocus();
+ }
+ _handleOnTextChange(context, _textController.text);
+ },
+ );
+ }
+
+ Widget _attachmentButton() {
+ return PromptInputAttachmentButton(
+ onTap: () async {
+ final path = await getIt<FilePickerService>().pickFiles(
+ dialogTitle: '',
+ type: FileType.custom,
+ allowedExtensions: ["pdf", "txt", "md"],
+ );
+
+ if (path == null) {
+ return;
+ }
+
+ for (final file in path.files) {
+ if (file.path != null) {
+ if (mounted) {
+ context
+ .read<AIPromptInputBloc>()
+ .add(AIPromptInputEvent.newFile(file.path!, file.name));
+ }
+ }
+ }
+ },
+ );
+ }
+
+ Widget _sendButton() {
+ return PromptInputSendButton(
+ buttonSize: DesktopAIPromptSizes.actionBarButtonSize,
+ iconSize: DesktopAIPromptSizes.sendButtonSize,
+ state: sendButtonState,
+ onSendPressed: _handleSendPressed,
+ onStopStreaming: widget.onStopStreaming,
+ );
+ }
+}
+
+class ChatInputAnchor extends ChatAnchor {
+ ChatInputAnchor({
+ required this.anchorKey,
+ required this.layerLink,
+ });
+
+ @override
+ final GlobalKey<State<StatefulWidget>> anchorKey;
+
+ @override
+ final LayerLink layerLink;
+}
+
+/// Handles the key press event for the Enter key without Shift.
+///
+/// This function checks if the Enter key is pressed without either of the Shift keys.
+/// If the conditions are met, it performs the action of sending a message if the
+/// text controller is not in a composing range and if the event is a key down event.
+///
+/// - Returns: A `KeyEventResult` indicating whether the key event was handled or ignored.
+KeyEventResult _handleEnterKeyWithoutShift(
+ KeyEvent event,
+ TextEditingController textController,
+ bool isStreaming,
+ void Function() handleSendPressed,
+) {
+ if (event.physicalKey == PhysicalKeyboardKey.enter &&
+ !HardwareKeyboard.instance.physicalKeysPressed.any(
+ (el) => <PhysicalKeyboardKey>{
+ PhysicalKeyboardKey.shiftLeft,
+ PhysicalKeyboardKey.shiftRight,
+ }.contains(el),
+ )) {
+ if (textController.value.isComposingRangeValid) {
+ return KeyEventResult.ignored;
+ }
+
+ if (event is KeyDownEvent) {
+ if (!isStreaming) {
+ handleSendPressed();
+ }
+ }
+ return KeyEventResult.handled;
+ } else {
+ return KeyEventResult.ignored;
+ }
+}
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/layout_define.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/layout_define.dart
deleted file mode 100644
index 74a66d0130..0000000000
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/layout_define.dart
+++ /dev/null
@@ -1,13 +0,0 @@
-import 'package:flutter/material.dart';
-
-import 'chat_input.dart';
-
-const double sendButtonSize = 26;
-const double attachButtonSize = 26;
-const buttonPadding = EdgeInsets.symmetric(horizontal: 2);
-const inputPadding = EdgeInsets.all(6);
-final textPadding = isMobile
- ? const EdgeInsets.only(left: 8.0, right: 4.0)
- : const EdgeInsets.symmetric(horizontal: 16);
-final borderRadius = BorderRadius.circular(30);
-const color = Colors.transparent;
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/mobile_ai_prompt_input.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/mobile_ai_prompt_input.dart
new file mode 100644
index 0000000000..230130a1b7
--- /dev/null
+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/mobile_ai_prompt_input.dart
@@ -0,0 +1,283 @@
+import 'package:appflowy/generated/locale_keys.g.dart';
+import 'package:appflowy/plugins/ai_chat/application/chat_entity.dart';
+import 'package:appflowy/plugins/ai_chat/application/ai_prompt_input_bloc.dart';
+import 'package:appflowy/plugins/ai_chat/application/chat_input_action_bloc.dart';
+import 'package:appflowy/plugins/ai_chat/application/chat_input_action_control.dart';
+import 'package:appflowy/plugins/ai_chat/presentation/chat_input/chat_input_file.dart';
+import 'package:appflowy/plugins/ai_chat/presentation/chat_input_action_menu.dart';
+import 'package:appflowy/plugins/document/presentation/editor_plugins/mention/mobile_page_selector_sheet.dart';
+import 'package:appflowy/workspace/application/view/view_ext.dart';
+import 'package:easy_localization/easy_localization.dart';
+import 'package:extended_text_field/extended_text_field.dart';
+import 'package:flowy_infra_ui/flowy_infra_ui.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:flutter_chat_types/flutter_chat_types.dart' as types;
+import 'package:flutter_chat_ui/flutter_chat_ui.dart';
+
+import 'ai_prompt_buttons.dart';
+import 'chat_input_span.dart';
+import '../layout_define.dart';
+
+class MobileAIPromptInput extends StatefulWidget {
+ const MobileAIPromptInput({
+ super.key,
+ required this.chatId,
+ this.options = const InputOptions(),
+ required this.isStreaming,
+ required this.onStopStreaming,
+ required this.onSubmitted,
+ });
+
+ final String chatId;
+ final InputOptions options;
+ final bool isStreaming;
+ final void Function() onStopStreaming;
+ final void Function(types.PartialText) onSubmitted;
+
+ @override
+ State<MobileAIPromptInput> createState() => _MobileAIPromptInputState();
+}
+
+class _MobileAIPromptInputState extends State<MobileAIPromptInput> {
+ late final ChatInputActionControl _inputActionControl;
+ late final FocusNode _inputFocusNode;
+ late final TextEditingController _textController;
+
+ late SendButtonState sendButtonState;
+
+ @override
+ void initState() {
+ super.initState();
+
+ _textController = InputTextFieldController()
+ ..addListener(_handleTextControllerChange);
+
+ _inputFocusNode = FocusNode();
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ _inputFocusNode.requestFocus();
+ });
+
+ _inputActionControl = ChatInputActionControl(
+ chatId: widget.chatId,
+ textController: _textController,
+ textFieldFocusNode: _inputFocusNode,
+ );
+
+ updateSendButtonState();
+ }
+
+ @override
+ void didUpdateWidget(covariant oldWidget) {
+ updateSendButtonState();
+ super.didUpdateWidget(oldWidget);
+ }
+
+ @override
+ void dispose() {
+ _inputFocusNode.dispose();
+ _textController.dispose();
+ _inputActionControl.dispose();
+ super.dispose();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return Hero(
+ tag: "ai_chat_prompt",
+ child: DecoratedBox(
+ decoration: BoxDecoration(
+ border: Border(
+ top: BorderSide(color: Theme.of(context).colorScheme.outline),
+ ),
+ color: Theme.of(context).colorScheme.surface,
+ boxShadow: const [
+ BoxShadow(
+ blurRadius: 4.0,
+ offset: Offset(0, -2),
+ color: Color.fromRGBO(0, 0, 0, 0.05),
+ ),
+ ],
+ borderRadius: MobileAIPromptSizes.promptFrameRadius,
+ ),
+ child: Column(
+ children: [
+ ConstrainedBox(
+ constraints: BoxConstraints(
+ maxHeight:
+ MobileAIPromptSizes.attachedFilesBarPadding.vertical +
+ MobileAIPromptSizes.attachedFilesPreviewHeight,
+ ),
+ child: ChatInputFile(
+ chatId: widget.chatId,
+ onDeleted: (file) => context
+ .read<AIPromptInputBloc>()
+ .add(AIPromptInputEvent.deleteFile(file)),
+ ),
+ ),
+ Container(
+ constraints: const BoxConstraints(
+ minHeight: MobileAIPromptSizes.textFieldMinHeight,
+ maxHeight: 220,
+ ),
+ padding: const EdgeInsetsDirectional.fromSTEB(0, 8.0, 12.0, 8.0),
+ child: IntrinsicHeight(
+ child: Row(
+ children: [
+ const HSpace(6.0),
+ Expanded(child: _inputTextField(context)),
+ _mentionButton(),
+ const HSpace(6.0),
+ _sendButton(),
+ ],
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ );
+ }
+
+ void updateSendButtonState() {
+ if (widget.isStreaming) {
+ sendButtonState = SendButtonState.streaming;
+ } else if (_textController.text.trim().isEmpty) {
+ sendButtonState = SendButtonState.disabled;
+ } else {
+ sendButtonState = SendButtonState.enabled;
+ }
+ }
+
+ void _handleSendPressed() {
+ final trimmedText = _textController.text.trim();
+ _textController.clear();
+ if (trimmedText.isEmpty) {
+ return;
+ }
+ // consume metadata
+ final ChatInputMentionMetadata mentionPageMetadata =
+ _inputActionControl.consumeMetaData();
+ final ChatInputFileMetadata fileMetadata =
+ context.read<AIPromptInputBloc>().consumeMetadata();
+
+ // combine metadata
+ final Map<String, dynamic> metadata = {}
+ ..addAll(mentionPageMetadata)
+ ..addAll(fileMetadata);
+
+ final partialText = types.PartialText(
+ text: trimmedText,
+ metadata: metadata,
+ );
+ widget.onSubmitted(partialText);
+ }
+
+ void _handleTextControllerChange() {
+ if (_textController.value.isComposingRangeValid) {
+ return;
+ }
+ setState(() => updateSendButtonState());
+ }
+
+ Widget _inputTextField(BuildContext context) {
+ return BlocBuilder<AIPromptInputBloc, AIPromptInputState>(
+ builder: (context, state) {
+ return ExtendedTextField(
+ controller: _textController,
+ focusNode: _inputFocusNode,
+ decoration: _buildInputDecoration(state),
+ keyboardType: TextInputType.multiline,
+ textCapitalization: TextCapitalization.sentences,
+ minLines: 1,
+ maxLines: null,
+ style: Theme.of(context).textTheme.bodyMedium,
+ specialTextSpanBuilder: ChatInputTextSpanBuilder(
+ inputActionControl: _inputActionControl,
+ ),
+ onChanged: (text) {
+ _handleOnTextChange(context, text);
+ },
+ );
+ },
+ );
+ }
+
+ InputDecoration _buildInputDecoration(AIPromptInputState state) {
+ return InputDecoration(
+ border: InputBorder.none,
+ enabledBorder: InputBorder.none,
+ focusedBorder: InputBorder.none,
+ contentPadding: MobileAIPromptSizes.textFieldContentPadding,
+ hintText: switch (state.aiType) {
+ AIType.appflowyAI => LocaleKeys.chat_inputMessageHint.tr(),
+ AIType.localAI => LocaleKeys.chat_inputLocalAIMessageHint.tr()
+ },
+ isCollapsed: true,
+ isDense: true,
+ );
+ }
+
+ Future<void> _handleOnTextChange(BuildContext context, String text) async {
+ if (!_inputActionControl.onTextChanged(text)) {
+ return;
+ }
+
+ // if the focus node is on focus, unfocus it for better animation
+ // otherwise, the page sheet animation will be blocked by the keyboard
+ if (_inputFocusNode.hasFocus) {
+ _inputFocusNode.unfocus();
+ Future.delayed(const Duration(milliseconds: 100), () async {
+ await _referPage(_inputActionControl);
+ });
+ } else {
+ await _referPage(_inputActionControl);
+ }
+ }
+
+ Widget _mentionButton() {
+ return Align(
+ alignment: Alignment.bottomCenter,
+ child: PromptInputMentionButton(
+ iconSize: MobileAIPromptSizes.mentionIconSize,
+ buttonSize: MobileAIPromptSizes.sendButtonSize,
+ onTap: () {
+ _textController.text += '@';
+ if (!_inputFocusNode.hasFocus) {
+ _inputFocusNode.requestFocus();
+ }
+ _handleOnTextChange(context, _textController.text);
+ },
+ ),
+ );
+ }
+
+ Widget _sendButton() {
+ return Align(
+ alignment: Alignment.bottomCenter,
+ child: PromptInputSendButton(
+ buttonSize: MobileAIPromptSizes.sendButtonSize,
+ iconSize: MobileAIPromptSizes.sendButtonSize,
+ onSendPressed: _handleSendPressed,
+ onStopStreaming: widget.onStopStreaming,
+ state: sendButtonState,
+ ),
+ );
+ }
+
+ Future<void> _referPage(ChatActionHandler handler) async {
+ handler.onEnter();
+ final selectedView = await showPageSelectorSheet(
+ context,
+ filter: (view) =>
+ view.layout.isDocumentView &&
+ !view.isSpace &&
+ view.parentViewId.isNotEmpty,
+ );
+ if (selectedView != null) {
+ handler.onSelected(ViewActionPage(view: selectedView));
+ }
+ handler.onExit();
+ _inputFocusNode.requestFocus();
+ }
+}
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input_action_menu.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input_action_menu.dart
index 2378379e6e..d23e966ecd 100644
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input_action_menu.dart
+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input_action_menu.dart
@@ -4,8 +4,7 @@ import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/plugins/ai_chat/application/chat_input_action_bloc.dart';
import 'package:appflowy/plugins/ai_chat/application/chat_input_action_control.dart';
import 'package:easy_localization/easy_localization.dart';
-import 'package:flowy_infra_ui/style_widget/button.dart';
-import 'package:flowy_infra_ui/style_widget/text.dart';
+import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
@@ -151,15 +150,21 @@ class _ActionItem extends StatelessWidget {
: Colors.transparent,
borderRadius: BorderRadius.circular(4.0),
),
- child: FlowyButton(
- leftIcon: item.icon,
- margin: const EdgeInsets.symmetric(horizontal: 6),
- iconPadding: 10.0,
- text: FlowyText.regular(
- lineHeight: 1.0,
- item.title,
+ child: FlowyTooltip(
+ message: item.title,
+ child: FlowyButton(
+ leftIcon: item.icon,
+ margin: const EdgeInsets.symmetric(horizontal: 6),
+ iconPadding: 10.0,
+ text: FlowyText(
+ item.title.isEmpty
+ ? LocaleKeys.document_title_placeholder.tr()
+ : item.title,
+ lineHeight: 1.0,
+ overflow: TextOverflow.ellipsis,
+ ),
+ onTap: onTap,
),
- onTap: onTap,
),
);
}
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_loading.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_loading.dart
index 9c4bd64cb6..b7a1251308 100644
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_loading.dart
+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_loading.dart
@@ -1,69 +1,76 @@
-import 'package:flowy_infra/theme_extension.dart';
-import 'package:flowy_infra_ui/widget/spacing.dart';
+import 'package:appflowy/generated/locale_keys.g.dart';
+import 'package:easy_localization/easy_localization.dart';
+import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flutter/material.dart';
-import 'package:shimmer/shimmer.dart';
+import 'package:flutter_animate/flutter_animate.dart';
+/// An animated generating indicator for an AI response
class ChatAILoading extends StatelessWidget {
- const ChatAILoading({super.key});
+ const ChatAILoading({
+ super.key,
+ this.duration = const Duration(seconds: 1),
+ });
- @override
- Widget build(BuildContext context) {
- return Shimmer.fromColors(
- baseColor: AFThemeExtension.of(context).lightGreyHover,
- highlightColor:
- AFThemeExtension.of(context).lightGreyHover.withOpacity(0.5),
- period: const Duration(seconds: 3),
- child: const ContentPlaceholder(),
- );
- }
-}
-
-class ContentPlaceholder extends StatelessWidget {
- const ContentPlaceholder({super.key});
+ final Duration duration;
@override
Widget build(BuildContext context) {
- return Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16.0),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
+ final slice = Duration(milliseconds: duration.inMilliseconds ~/ 5);
+ return SizedBox(
+ height: 20,
+ child: SeparatedRow(
+ separatorBuilder: () => const HSpace(4),
children: [
- Row(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Container(
- width: 30,
- height: 16.0,
- margin: const EdgeInsets.only(bottom: 8.0),
- decoration: BoxDecoration(
- color: AFThemeExtension.of(context).lightGreyHover,
- borderRadius: BorderRadius.circular(4.0),
- ),
- ),
- const HSpace(10),
- Container(
- width: 100,
- height: 16.0,
- margin: const EdgeInsets.only(bottom: 8.0),
- decoration: BoxDecoration(
- color: AFThemeExtension.of(context).lightGreyHover,
- borderRadius: BorderRadius.circular(4.0),
- ),
- ),
- ],
+ Padding(
+ padding: const EdgeInsetsDirectional.only(end: 4.0),
+ child: FlowyText(
+ LocaleKeys.chat_generatingResponse.tr(),
+ color: Theme.of(context).hintColor,
+ ),
),
- // Container(
- // width: 140,
- // height: 16.0,
- // margin: const EdgeInsets.only(bottom: 8.0),
- // decoration: BoxDecoration(
- // color: AFThemeExtension.of(context).lightGreyHover,
- // borderRadius: BorderRadius.circular(4.0),
- // ),
- // ),
+ buildDot(const Color(0xFF9327FF))
+ .animate(onPlay: (controller) => controller.repeat())
+ .slideY(duration: slice, begin: 0, end: -1)
+ .then()
+ .slideY(begin: -1, end: 1)
+ .then()
+ .slideY(begin: 1, end: 0)
+ .then()
+ .slideY(duration: slice * 2, begin: 0, end: 0),
+ buildDot(const Color(0xFFFB006D))
+ .animate(onPlay: (controller) => controller.repeat())
+ .slideY(duration: slice, begin: 0, end: 0)
+ .then()
+ .slideY(begin: 0, end: -1)
+ .then()
+ .slideY(begin: -1, end: 1)
+ .then()
+ .slideY(begin: 1, end: 0)
+ .then()
+ .slideY(begin: 0, end: 0),
+ buildDot(const Color(0xFFFFCE00))
+ .animate(onPlay: (controller) => controller.repeat())
+ .slideY(duration: slice * 2, begin: 0, end: 0)
+ .then()
+ .slideY(duration: slice, begin: 0, end: -1)
+ .then()
+ .slideY(begin: -1, end: 1)
+ .then()
+ .slideY(begin: 1, end: 0),
],
),
);
}
+
+ Widget buildDot(Color color) {
+ return SizedBox.square(
+ dimension: 4,
+ child: DecoratedBox(
+ decoration: BoxDecoration(
+ color: color,
+ borderRadius: BorderRadius.circular(2),
+ ),
+ ),
+ );
+ }
}
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_popmenu.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_popmenu.dart
deleted file mode 100644
index 6b0b50dcca..0000000000
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_popmenu.dart
+++ /dev/null
@@ -1,70 +0,0 @@
-import 'package:appflowy/generated/locale_keys.g.dart';
-import 'package:appflowy/workspace/presentation/widgets/pop_up_action.dart';
-import 'package:appflowy_popover/appflowy_popover.dart';
-import 'package:easy_localization/easy_localization.dart';
-
-import 'package:flutter/material.dart';
-
-class ChatPopupMenu extends StatefulWidget {
- const ChatPopupMenu({
- super.key,
- required this.onAction,
- required this.builder,
- });
-
- final Function(ChatMessageAction) onAction;
- final Widget Function(BuildContext context) builder;
-
- @override
- State<ChatPopupMenu> createState() => _ChatPopupMenuState();
-}
-
-class _ChatPopupMenuState extends State<ChatPopupMenu> {
- @override
- Widget build(BuildContext context) {
- return PopoverActionList<ChatMessageActionWrapper>(
- asBarrier: true,
- actions: ChatMessageAction.values
- .map((action) => ChatMessageActionWrapper(action))
- .toList(),
- buildChild: (controller) {
- return GestureDetector(
- onLongPress: () {
- controller.show();
- },
- child: widget.builder(context),
- );
- },
- onSelected: (action, controller) async {
- widget.onAction(action.inner);
- controller.close();
- },
- direction: PopoverDirection.bottomWithCenterAligned,
- );
- }
-}
-
-enum ChatMessageAction {
- copy,
-}
-
-class ChatMessageActionWrapper extends ActionCell {
- ChatMessageActionWrapper(this.inner);
-
- final ChatMessageAction inner;
-
- @override
- Widget? leftIcon(Color iconColor) => null;
-
- @override
- String get name => inner.name;
-}
-
-extension ChatMessageActionExtension on ChatMessageAction {
- String get name {
- switch (this) {
- case ChatMessageAction.copy:
- return LocaleKeys.document_plugins_contextMenu_copy.tr();
- }
- }
-}
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_related_question.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_related_question.dart
index 22c8fa90de..9f2fb2350b 100644
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_related_question.dart
+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_related_question.dart
@@ -2,61 +2,46 @@ import 'package:appflowy/generated/flowy_svgs.g.dart';
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy_backend/protobuf/flowy-ai/entities.pb.dart';
import 'package:easy_localization/easy_localization.dart';
+import 'package:flowy_infra_ui/style_widget/button.dart';
import 'package:flowy_infra_ui/style_widget/text.dart';
import 'package:flowy_infra_ui/widget/spacing.dart';
import 'package:flutter/material.dart';
+import 'package:universal_platform/universal_platform.dart';
class RelatedQuestionList extends StatelessWidget {
const RelatedQuestionList({
- required this.chatId,
+ super.key,
required this.onQuestionSelected,
required this.relatedQuestions,
- super.key,
});
- final String chatId;
final Function(String) onQuestionSelected;
final List<RelatedQuestionPB> relatedQuestions;
@override
Widget build(BuildContext context) {
- return ListView.builder(
+ return ListView.separated(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
- itemCount: relatedQuestions.length,
+ itemCount: relatedQuestions.length + 1,
+ padding: const EdgeInsets.only(bottom: 8.0) +
+ (UniversalPlatform.isMobile
+ ? const EdgeInsets.symmetric(horizontal: 16)
+ : EdgeInsets.zero),
+ separatorBuilder: (context, index) => const VSpace(4.0),
itemBuilder: (context, index) {
- final question = relatedQuestions[index];
if (index == 0) {
- return Column(
- children: [
- const Divider(height: 36),
- Padding(
- padding: const EdgeInsets.all(12),
- child: Row(
- children: [
- FlowySvg(
- FlowySvgs.ai_summary_generate_s,
- size: const Size.square(24),
- color: Theme.of(context).colorScheme.primary,
- ),
- const HSpace(6),
- FlowyText(
- LocaleKeys.chat_relatedQuestion.tr(),
- fontSize: 18,
- ),
- ],
- ),
- ),
- const Divider(height: 6),
- RelatedQuestionItem(
- question: question,
- onQuestionSelected: onQuestionSelected,
- ),
- ],
+ return Padding(
+ padding: const EdgeInsets.only(bottom: 4.0),
+ child: FlowyText(
+ LocaleKeys.chat_relatedQuestion.tr(),
+ color: Theme.of(context).hintColor,
+ fontWeight: FontWeight.w600,
+ ),
);
} else {
return RelatedQuestionItem(
- question: question,
+ question: relatedQuestions[index - 1],
onQuestionSelected: onQuestionSelected,
);
}
@@ -65,7 +50,7 @@ class RelatedQuestionList extends StatelessWidget {
}
}
-class RelatedQuestionItem extends StatefulWidget {
+class RelatedQuestionItem extends StatelessWidget {
const RelatedQuestionItem({
required this.question,
required this.onQuestionSelected,
@@ -75,38 +60,23 @@ class RelatedQuestionItem extends StatefulWidget {
final RelatedQuestionPB question;
final Function(String) onQuestionSelected;
- @override
- State<RelatedQuestionItem> createState() => _RelatedQuestionItemState();
-}
-
-class _RelatedQuestionItemState extends State<RelatedQuestionItem> {
- bool _isHovered = false;
-
@override
Widget build(BuildContext context) {
- return MouseRegion(
- onEnter: (_) => setState(() => _isHovered = true),
- onExit: (_) => setState(() => _isHovered = false),
- child: ListTile(
- contentPadding: const EdgeInsets.symmetric(
- horizontal: 12,
- ),
- title: Text(
- widget.question.content,
- style: TextStyle(
- color: _isHovered ? Theme.of(context).colorScheme.primary : null,
- fontSize: 14,
- height: 1.5,
- ),
- ),
- onTap: () {
- widget.onQuestionSelected(widget.question.content);
- },
- trailing: FlowySvg(
- FlowySvgs.add_m,
- color: Theme.of(context).colorScheme.primary,
- ),
+ return FlowyButton(
+ text: FlowyText(
+ question.content,
+ lineHeight: 1.4,
+ overflow: TextOverflow.ellipsis,
+ ),
+ margin: UniversalPlatform.isMobile
+ ? const EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0)
+ : const EdgeInsets.all(8.0),
+ leftIcon: FlowySvg(
+ FlowySvgs.ai_chat_outlined_s,
+ color: Theme.of(context).colorScheme.primary,
+ size: const Size.square(16.0),
),
+ onTap: () => onQuestionSelected(question.content),
);
}
}
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_side_pannel.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_side_panel.dart
similarity index 50%
rename from frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_side_pannel.dart
rename to frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_side_panel.dart
index f3899308ce..7904b44437 100644
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_side_pannel.dart
+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_side_panel.dart
@@ -1,17 +1,17 @@
import 'package:appflowy/generated/flowy_svgs.g.dart';
-import 'package:appflowy/plugins/ai_chat/application/chat_side_pannel_bloc.dart';
+import 'package:appflowy/plugins/ai_chat/application/chat_side_panel_bloc.dart';
import 'package:appflowy/startup/plugin/plugin.dart';
import 'package:appflowy/workspace/application/view/view_ext.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
-class ChatSidePannel extends StatelessWidget {
- const ChatSidePannel({super.key});
+class ChatSidePanel extends StatelessWidget {
+ const ChatSidePanel({super.key});
@override
Widget build(BuildContext context) {
- return BlocBuilder<ChatSidePannelBloc, ChatSidePannelState>(
+ return BlocBuilder<ChatSidePanelBloc, ChatSidePanelState>(
builder: (context, state) {
return state.indicator.when(
loading: () {
@@ -24,26 +24,23 @@ class ChatSidePannel extends StatelessWidget {
final pluginContext = PluginContext();
final child = plugin.widgetBuilder
.buildWidget(context: pluginContext, shrinkWrap: false);
- return Container(
- color: Theme.of(context).colorScheme.surfaceContainerHighest,
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Padding(
- padding: const EdgeInsets.all(8.0),
- child: FlowyIconButton(
- icon: const FlowySvg(FlowySvgs.show_menu_s),
- onPressed: () {
- context
- .read<ChatSidePannelBloc>()
- .add(const ChatSidePannelEvent.close());
- },
- ),
+ return Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Padding(
+ padding: const EdgeInsets.all(8.0),
+ child: FlowyIconButton(
+ icon: const FlowySvg(FlowySvgs.show_menu_s),
+ onPressed: () {
+ context
+ .read<ChatSidePanelBloc>()
+ .add(const ChatSidePanelEvent.close());
+ },
),
- const VSpace(6),
- Expanded(child: child),
- ],
- ),
+ ),
+ const VSpace(6),
+ Expanded(child: child),
+ ],
);
},
);
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_stream_text_field.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_stream_text_field.dart
deleted file mode 100644
index 7589a1b634..0000000000
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_stream_text_field.dart
+++ /dev/null
@@ -1,10 +0,0 @@
-import 'package:flutter/widgets.dart';
-
-class StreamTextField extends StatelessWidget {
- const StreamTextField({super.key});
-
- @override
- Widget build(BuildContext context) {
- return const Placeholder();
- }
-}
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_streaming_error_message.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_streaming_error_message.dart
deleted file mode 100644
index 1f825d3355..0000000000
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_streaming_error_message.dart
+++ /dev/null
@@ -1,83 +0,0 @@
-// import 'package:appflowy/generated/locale_keys.g.dart';
-// import 'package:easy_localization/easy_localization.dart';
-// import 'package:flowy_infra_ui/flowy_infra_ui.dart';
-// import 'package:flutter/material.dart';
-// import 'package:flutter_chat_types/flutter_chat_types.dart';
-
-// class ChatStreamingError extends StatelessWidget {
-// const ChatStreamingError({
-// required this.message,
-// required this.onRetryPressed,
-// super.key,
-// });
-
-// final void Function() onRetryPressed;
-// final Message message;
-// @override
-// Widget build(BuildContext context) {
-// final canRetry = message.metadata?[canRetryKey] != null;
-
-// if (canRetry) {
-// return Column(
-// children: [
-// const Divider(height: 4, thickness: 1),
-// const VSpace(16),
-// Center(
-// child: Column(
-// children: [
-// _aiUnvaliable(),
-// const VSpace(10),
-// _retryButton(),
-// ],
-// ),
-// ),
-// ],
-// );
-// } else {
-// return Center(
-// child: Column(
-// children: [
-// const Divider(height: 20, thickness: 1),
-// Padding(
-// padding: const EdgeInsets.all(8.0),
-// child: FlowyText(
-// LocaleKeys.chat_serverUnavailable.tr(),
-// fontSize: 14,
-// ),
-// ),
-// ],
-// ),
-// );
-// }
-// }
-
-// FlowyButton _retryButton() {
-// return FlowyButton(
-// radius: BorderRadius.circular(20),
-// useIntrinsicWidth: true,
-// text: Padding(
-// padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
-// child: FlowyText(
-// LocaleKeys.chat_regenerateAnswer.tr(),
-// fontSize: 14,
-// ),
-// ),
-// onTap: onRetryPressed,
-// iconPadding: 0,
-// leftIcon: const Icon(
-// Icons.refresh,
-// size: 20,
-// ),
-// );
-// }
-
-// Padding _aiUnvaliable() {
-// return Padding(
-// padding: const EdgeInsets.all(8.0),
-// child: FlowyText(
-// LocaleKeys.chat_aiServerUnavailable.tr(),
-// fontSize: 14,
-// ),
-// );
-// }
-// }
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_theme.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_theme.dart
index 456ac0c184..4a70268424 100644
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_theme.dart
+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_theme.dart
@@ -1,222 +1,85 @@
import 'package:flutter/material.dart';
import 'package:flutter_chat_ui/flutter_chat_ui.dart';
-// For internal usage only. Use values from theme itself.
-
-/// See [ChatTheme.userAvatarNameColors].
-const colors = [
- Color(0xffff6767),
- Color(0xff66e0da),
- Color(0xfff5a2d9),
- Color(0xfff0c722),
- Color(0xff6a85e5),
- Color(0xfffd9a6f),
- Color(0xff92db6e),
- Color(0xff73b8e5),
- Color(0xfffd7590),
- Color(0xffc78ae5),
-];
-
-/// Dark.
-const dark = Color(0xff1f1c38);
-
-/// Error.
-const error = Color(0xffff6767);
-
-/// N0.
-const neutral0 = Color(0xff1d1c21);
-
-/// N1.
-const neutral1 = Color(0xff615e6e);
-
-/// N2.
-const neutral2 = Color(0xff9e9cab);
-
-/// N7.
-const neutral7 = Color(0xffffffff);
-
-/// N7 with opacity.
-const neutral7WithOpacity = Color(0x80ffffff);
-
-/// Primary.
-const primary = Color(0xff6f61e8);
-
-/// Secondary.
-const secondary = Color(0xfff5f5f7);
-
-/// Secondary dark.
-const secondaryDark = Color(0xff2b2250);
-
/// Default chat theme which extends [ChatTheme].
@immutable
class AFDefaultChatTheme extends ChatTheme {
- /// Creates a default chat theme. Use this constructor if you want to
- /// override only a couple of properties, otherwise create a new class
- /// which extends [ChatTheme].
const AFDefaultChatTheme({
- super.attachmentButtonIcon,
- super.attachmentButtonMargin,
- super.backgroundColor = neutral7,
- super.bubbleMargin,
- super.dateDividerMargin = const EdgeInsets.only(
- bottom: 32,
- top: 16,
- ),
- super.dateDividerTextStyle = const TextStyle(
- color: neutral2,
- fontSize: 12,
- fontWeight: FontWeight.w800,
- height: 1.333,
- ),
- super.deliveredIcon,
- super.documentIcon,
- super.emptyChatPlaceholderTextStyle = const TextStyle(
- color: neutral2,
- fontSize: 16,
- fontWeight: FontWeight.w500,
- height: 1.5,
- ),
- super.errorColor = error,
- super.errorIcon,
- super.inputBackgroundColor = neutral0,
- super.inputSurfaceTintColor = neutral0,
- super.inputElevation = 0,
- super.inputBorderRadius = const BorderRadius.vertical(
- top: Radius.circular(20),
- ),
- super.inputContainerDecoration,
- super.inputMargin = EdgeInsets.zero,
- super.inputPadding = const EdgeInsets.fromLTRB(14, 20, 14, 20),
- super.inputTextColor = neutral7,
- super.inputTextCursorColor,
- super.inputTextDecoration = const InputDecoration(
- border: InputBorder.none,
- contentPadding: EdgeInsets.zero,
- isCollapsed: true,
- ),
- super.inputTextStyle = const TextStyle(
- fontSize: 16,
- fontWeight: FontWeight.w500,
- height: 1.5,
- ),
- super.messageBorderRadius = 20,
- super.messageInsetsHorizontal = 0,
- super.messageInsetsVertical = 0,
- super.messageMaxWidth = 1000,
- super.primaryColor = primary,
- super.receivedEmojiMessageTextStyle = const TextStyle(fontSize: 40),
- super.receivedMessageBodyBoldTextStyle,
- super.receivedMessageBodyCodeTextStyle,
- super.receivedMessageBodyLinkTextStyle,
- super.receivedMessageBodyTextStyle = const TextStyle(
- color: neutral0,
- fontSize: 16,
- fontWeight: FontWeight.w500,
- height: 1.5,
- ),
- super.receivedMessageCaptionTextStyle = const TextStyle(
- color: neutral2,
- fontSize: 12,
- fontWeight: FontWeight.w500,
- height: 1.333,
- ),
- super.receivedMessageDocumentIconColor = primary,
- super.receivedMessageLinkDescriptionTextStyle = const TextStyle(
- color: neutral0,
- fontSize: 14,
- fontWeight: FontWeight.w400,
- height: 1.428,
- ),
- super.receivedMessageLinkTitleTextStyle = const TextStyle(
- color: neutral0,
- fontSize: 16,
- fontWeight: FontWeight.w800,
- height: 1.375,
- ),
- super.secondaryColor = secondary,
- super.seenIcon,
- super.sendButtonIcon,
- super.sendButtonMargin,
- super.sendingIcon,
- super.sentEmojiMessageTextStyle = const TextStyle(fontSize: 40),
- super.sentMessageBodyBoldTextStyle,
- super.sentMessageBodyCodeTextStyle,
- super.sentMessageBodyLinkTextStyle,
- super.sentMessageBodyTextStyle = const TextStyle(
- color: neutral7,
- fontSize: 16,
- fontWeight: FontWeight.w500,
- height: 1.5,
- ),
- super.sentMessageCaptionTextStyle = const TextStyle(
- color: neutral7WithOpacity,
- fontSize: 12,
- fontWeight: FontWeight.w500,
- height: 1.333,
- ),
- super.sentMessageDocumentIconColor = neutral7,
- super.sentMessageLinkDescriptionTextStyle = const TextStyle(
- color: neutral7,
- fontSize: 14,
- fontWeight: FontWeight.w400,
- height: 1.428,
- ),
- super.sentMessageLinkTitleTextStyle = const TextStyle(
- color: neutral7,
- fontSize: 16,
- fontWeight: FontWeight.w800,
- height: 1.375,
- ),
- super.statusIconPadding = const EdgeInsets.symmetric(horizontal: 4),
- super.systemMessageTheme = const SystemMessageTheme(
- margin: EdgeInsets.only(
- bottom: 24,
- top: 8,
- left: 8,
- right: 8,
- ),
- textStyle: TextStyle(
- color: neutral2,
- fontSize: 12,
- fontWeight: FontWeight.w800,
- height: 1.333,
- ),
- ),
- super.typingIndicatorTheme = const TypingIndicatorTheme(
- animatedCirclesColor: neutral1,
- animatedCircleSize: 5.0,
- bubbleBorder: BorderRadius.all(Radius.circular(27.0)),
- bubbleColor: neutral7,
- countAvatarColor: primary,
- countTextColor: secondary,
- multipleUserTextStyle: TextStyle(
- fontSize: 12,
- fontWeight: FontWeight.w500,
- color: neutral2,
- ),
- ),
- super.unreadHeaderTheme = const UnreadHeaderTheme(
- color: secondary,
- textStyle: TextStyle(
- color: neutral2,
- fontSize: 12,
- fontWeight: FontWeight.w500,
- height: 1.333,
- ),
- ),
- super.userAvatarImageBackgroundColor = Colors.transparent,
- super.userAvatarNameColors = colors,
- super.userAvatarTextStyle = const TextStyle(
- color: neutral7,
- fontSize: 12,
- fontWeight: FontWeight.w800,
- height: 1.333,
- ),
- super.userNameTextStyle = const TextStyle(
- fontSize: 12,
- fontWeight: FontWeight.w800,
- height: 1.333,
- ),
- super.highlightMessageColor,
- });
+ required super.primaryColor,
+ required super.secondaryColor,
+ }) : super(
+ backgroundColor: Colors.transparent,
+ // TODO: think how to offset the default 12 pixels set by chat package
+ bubbleMargin: const EdgeInsets.symmetric(vertical: 4.0),
+ messageMaxWidth: double.infinity,
+ // unused
+ dateDividerMargin: EdgeInsets.zero,
+ dateDividerTextStyle: const TextStyle(),
+ attachmentButtonIcon: null,
+ attachmentButtonMargin: null,
+ deliveredIcon: null,
+ documentIcon: null,
+ emptyChatPlaceholderTextStyle: const TextStyle(),
+ errorColor: error,
+ errorIcon: null,
+ inputBackgroundColor: neutral0,
+ inputSurfaceTintColor: neutral0,
+ inputElevation: 0,
+ inputBorderRadius: BorderRadius.zero,
+ inputContainerDecoration: null,
+ inputMargin: EdgeInsets.zero,
+ inputPadding: EdgeInsets.zero,
+ inputTextColor: neutral7,
+ inputTextCursorColor: null,
+ inputTextDecoration: const InputDecoration(),
+ inputTextStyle: const TextStyle(),
+ messageBorderRadius: 0,
+ messageInsetsHorizontal: 0,
+ messageInsetsVertical: 0,
+ receivedEmojiMessageTextStyle: const TextStyle(),
+ receivedMessageBodyBoldTextStyle: null,
+ receivedMessageBodyCodeTextStyle: null,
+ receivedMessageBodyLinkTextStyle: null,
+ receivedMessageBodyTextStyle: const TextStyle(),
+ receivedMessageDocumentIconColor: primary,
+ receivedMessageCaptionTextStyle: const TextStyle(),
+ receivedMessageLinkDescriptionTextStyle: const TextStyle(),
+ receivedMessageLinkTitleTextStyle: const TextStyle(),
+ seenIcon: null,
+ sendButtonIcon: null,
+ sendButtonMargin: null,
+ sendingIcon: null,
+ sentEmojiMessageTextStyle: const TextStyle(),
+ sentMessageBodyBoldTextStyle: null,
+ sentMessageBodyCodeTextStyle: null,
+ sentMessageBodyLinkTextStyle: null,
+ sentMessageBodyTextStyle: const TextStyle(),
+ sentMessageCaptionTextStyle: const TextStyle(),
+ sentMessageDocumentIconColor: neutral7,
+ sentMessageLinkDescriptionTextStyle: const TextStyle(),
+ sentMessageLinkTitleTextStyle: const TextStyle(),
+ statusIconPadding: EdgeInsets.zero,
+ systemMessageTheme: const SystemMessageTheme(
+ margin: EdgeInsets.zero,
+ textStyle: TextStyle(),
+ ),
+ typingIndicatorTheme: const TypingIndicatorTheme(
+ animatedCirclesColor: neutral1,
+ animatedCircleSize: 0.0,
+ bubbleBorder: BorderRadius.zero,
+ bubbleColor: neutral7,
+ countAvatarColor: primary,
+ countTextColor: secondary,
+ multipleUserTextStyle: TextStyle(),
+ ),
+ unreadHeaderTheme: const UnreadHeaderTheme(
+ color: secondary,
+ textStyle: TextStyle(),
+ ),
+ userAvatarImageBackgroundColor: Colors.transparent,
+ userAvatarNameColors: colors,
+ userAvatarTextStyle: const TextStyle(),
+ userNameTextStyle: const TextStyle(),
+ highlightMessageColor: null,
+ );
}
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_user_invalid_message.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_user_invalid_message.dart
index 39ea8c29b9..9d381a9af9 100644
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_user_invalid_message.dart
+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_user_invalid_message.dart
@@ -1,7 +1,9 @@
+import 'package:appflowy/generated/flowy_svgs.g.dart';
import 'package:appflowy/plugins/ai_chat/application/chat_entity.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flutter/material.dart';
import 'package:flutter_chat_types/flutter_chat_types.dart';
+import 'package:universal_platform/universal_platform.dart';
class ChatInvalidUserMessage extends StatelessWidget {
const ChatInvalidUserMessage({
@@ -14,17 +16,33 @@ class ChatInvalidUserMessage extends StatelessWidget {
Widget build(BuildContext context) {
final errorMessage = message.metadata?[sendMessageErrorKey] ?? "";
return Center(
- child: Column(
- children: [
- const Divider(height: 20, thickness: 1),
- Padding(
- padding: const EdgeInsets.all(8.0),
- child: FlowyText(
- errorMessage,
- fontSize: 14,
+ child: Container(
+ margin: const EdgeInsets.only(top: 16.0, bottom: 24.0),
+ constraints: UniversalPlatform.isDesktop
+ ? const BoxConstraints(maxWidth: 480)
+ : const BoxConstraints(),
+ padding: const EdgeInsets.all(8.0),
+ decoration: const BoxDecoration(
+ color: Color(0x80FFE7EE),
+ borderRadius: BorderRadius.all(Radius.circular(8.0)),
+ ),
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ const FlowySvg(
+ FlowySvgs.warning_filled_s,
+ blendMode: null,
),
- ),
- ],
+ const HSpace(8.0),
+ Flexible(
+ child: FlowyText(
+ errorMessage,
+ lineHeight: 1.4,
+ maxLines: null,
+ ),
+ ),
+ ],
+ ),
),
);
}
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_welcome_page.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_welcome_page.dart
index 5524f1ffbe..7120c2c47f 100644
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_welcome_page.dart
+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_welcome_page.dart
@@ -1,24 +1,18 @@
import 'package:appflowy/generated/flowy_svgs.g.dart';
import 'package:appflowy/generated/locale_keys.g.dart';
+import 'package:appflowy/util/debounce.dart';
+import 'package:appflowy/util/theme_extension.dart';
import 'package:appflowy_backend/protobuf/flowy-user/user_profile.pb.dart';
import 'package:easy_localization/easy_localization.dart';
+import 'package:flowy_infra/theme_extension.dart';
import 'package:flowy_infra_ui/flowy_infra_ui.dart';
-import 'package:flowy_infra_ui/style_widget/hover.dart';
import 'package:flutter/material.dart';
-
-import 'chat_input/chat_input.dart';
-
-class WelcomeQuestion {
- WelcomeQuestion({
- required this.text,
- required this.iconData,
- });
- final String text;
- final FlowySvgData iconData;
-}
+import 'package:flutter/rendering.dart';
+import 'package:time/time.dart';
+import 'package:universal_platform/universal_platform.dart';
class ChatWelcomePage extends StatelessWidget {
- ChatWelcomePage({
+ const ChatWelcomePage({
required this.userProfile,
required this.onSelectedQuestion,
super.key,
@@ -27,112 +21,323 @@ class ChatWelcomePage extends StatelessWidget {
final void Function(String) onSelectedQuestion;
final UserProfilePB userProfile;
- final List<WelcomeQuestion> items = [
- WelcomeQuestion(
- text: LocaleKeys.chat_question1.tr(),
- iconData: FlowySvgs.chat_lightbulb_s,
- ),
- WelcomeQuestion(
- text: LocaleKeys.chat_question2.tr(),
- iconData: FlowySvgs.chat_scholar_s,
- ),
- WelcomeQuestion(
- text: LocaleKeys.chat_question3.tr(),
- iconData: FlowySvgs.chat_question_s,
- ),
- WelcomeQuestion(
- text: LocaleKeys.chat_question4.tr(),
- iconData: FlowySvgs.chat_feather_s,
- ),
+ static final List<String> desktopItems = [
+ LocaleKeys.chat_question1.tr(),
+ LocaleKeys.chat_question2.tr(),
+ LocaleKeys.chat_question3.tr(),
+ LocaleKeys.chat_question4.tr(),
+ ];
+
+ static final List<List<String>> mobileItems = [
+ [
+ LocaleKeys.chat_question1.tr(),
+ LocaleKeys.chat_question2.tr(),
+ ],
+ [
+ LocaleKeys.chat_question3.tr(),
+ LocaleKeys.chat_question4.tr(),
+ ],
+ [
+ LocaleKeys.chat_question5.tr(),
+ LocaleKeys.chat_question6.tr(),
+ ],
];
+
@override
Widget build(BuildContext context) {
- return AnimatedOpacity(
- opacity: 1.0,
- duration: const Duration(seconds: 3),
- child: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 10),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- const Spacer(),
- Opacity(
- opacity: 0.8,
- child: FlowyText(
- fontSize: 15,
- LocaleKeys.chat_questionDetail.tr(args: [userProfile.name]),
- ),
- ),
- const VSpace(18),
- Opacity(
- opacity: 0.6,
- child: FlowyText(
- LocaleKeys.chat_questionTitle.tr(),
- ),
- ),
- const VSpace(8),
- Wrap(
- direction: Axis.vertical,
- spacing: isMobile ? 12.0 : 0.0,
- children: items
- .map(
- (i) => WelcomeQuestionWidget(
- question: i,
- onSelected: onSelectedQuestion,
- ),
- )
- .toList(),
- ),
- const VSpace(20),
- ],
+ return Column(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ const FlowySvg(
+ FlowySvgs.flowy_logo_xl,
+ size: Size.square(32),
+ blendMode: null,
+ ),
+ const VSpace(16),
+ FlowyText(
+ fontSize: 15,
+ LocaleKeys.chat_questionDetail.tr(args: [userProfile.name]),
+ ),
+ UniversalPlatform.isDesktop ? const VSpace(32 - 16) : const VSpace(24),
+ ...UniversalPlatform.isDesktop
+ ? buildDesktopSampleQuestions(context)
+ : buildMobileSampleQuestions(context),
+ ],
+ );
+ }
+
+ Iterable<Widget> buildDesktopSampleQuestions(BuildContext context) {
+ return desktopItems.map(
+ (question) => Padding(
+ padding: const EdgeInsets.only(top: 16.0),
+ child: WelcomeSampleQuestion(
+ question: question,
+ onSelected: onSelectedQuestion,
),
),
);
}
+
+ Iterable<Widget> buildMobileSampleQuestions(BuildContext context) {
+ return [
+ _AutoScrollingSampleQuestions(
+ key: const ValueKey('inf_scroll_1'),
+ onSelected: onSelectedQuestion,
+ questions: mobileItems[0],
+ offset: 60.0,
+ ),
+ const VSpace(8),
+ _AutoScrollingSampleQuestions(
+ key: const ValueKey('inf_scroll_2'),
+ onSelected: onSelectedQuestion,
+ questions: mobileItems[1],
+ offset: -50.0,
+ reverse: true,
+ ),
+ const VSpace(8),
+ _AutoScrollingSampleQuestions(
+ key: const ValueKey('inf_scroll_3'),
+ onSelected: onSelectedQuestion,
+ questions: mobileItems[2],
+ offset: 120.0,
+ ),
+ ];
+ }
}
-class WelcomeQuestionWidget extends StatelessWidget {
- const WelcomeQuestionWidget({
+class WelcomeSampleQuestion extends StatelessWidget {
+ const WelcomeSampleQuestion({
required this.question,
required this.onSelected,
super.key,
});
final void Function(String) onSelected;
- final WelcomeQuestion question;
+ final String question;
@override
Widget build(BuildContext context) {
- return InkWell(
- onTap: () => onSelected(question.text),
- child: GestureDetector(
- behavior: HitTestBehavior.opaque,
- child: FlowyHover(
- // Make the hover effect only available on mobile
- isSelected: () => isMobile,
- style: HoverStyle(
- borderRadius: BorderRadius.circular(6),
+ final isLightMode = Theme.of(context).isLightMode;
+ return DecoratedBox(
+ decoration: BoxDecoration(
+ borderRadius: BorderRadius.circular(16),
+ boxShadow: [
+ BoxShadow(
+ offset: const Offset(0, 1),
+ blurRadius: 2,
+ spreadRadius: -2,
+ color: isLightMode
+ ? const Color(0x051F2329)
+ : Theme.of(context).shadowColor.withOpacity(0.02),
+ ),
+ BoxShadow(
+ offset: const Offset(0, 2),
+ blurRadius: 4,
+ color: isLightMode
+ ? const Color(0x051F2329)
+ : Theme.of(context).shadowColor.withOpacity(0.02),
+ ),
+ BoxShadow(
+ offset: const Offset(0, 2),
+ blurRadius: 8,
+ spreadRadius: 2,
+ color: isLightMode
+ ? const Color(0x051F2329)
+ : Theme.of(context).shadowColor.withOpacity(0.02),
+ ),
+ ],
+ ),
+ child: TextButton(
+ onPressed: () => onSelected(question),
+ style: ButtonStyle(
+ padding: WidgetStatePropertyAll(
+ EdgeInsets.symmetric(
+ horizontal: 16,
+ vertical: UniversalPlatform.isDesktop ? 8 : 0,
+ ),
),
- child: Padding(
- padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 8),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- FlowySvg(
- question.iconData,
- size: const Size.square(18),
- blendMode: null,
- ),
- const HSpace(16),
- FlowyText(
- question.text,
- maxLines: null,
- ),
- ],
+ backgroundColor: WidgetStateProperty.resolveWith<Color?>((state) {
+ if (state.contains(WidgetState.hovered)) {
+ return isLightMode
+ ? const Color(0xFFF9FAFD)
+ : AFThemeExtension.of(context).lightGreyHover;
+ }
+ return Theme.of(context).colorScheme.surface;
+ }),
+ overlayColor: WidgetStateColor.transparent,
+ shape: WidgetStatePropertyAll(
+ RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(16),
+ side: BorderSide(color: Theme.of(context).dividerColor),
),
),
),
+ child: FlowyText(
+ question,
+ color: isLightMode
+ ? Theme.of(context).hintColor
+ : const Color(0xFF666D76),
+ ),
),
);
}
}
+
+class _AutoScrollingSampleQuestions extends StatefulWidget {
+ const _AutoScrollingSampleQuestions({
+ super.key,
+ required this.questions,
+ this.offset = 0.0,
+ this.reverse = false,
+ required this.onSelected,
+ });
+
+ final List<String> questions;
+ final void Function(String) onSelected;
+ final double offset;
+ final bool reverse;
+
+ @override
+ State<_AutoScrollingSampleQuestions> createState() =>
+ _AutoScrollingSampleQuestionsState();
+}
+
+class _AutoScrollingSampleQuestionsState
+ extends State<_AutoScrollingSampleQuestions> {
+ final restartAutoScrollDebounce = Debounce(duration: 3.seconds);
+ late final ScrollController scrollController;
+
+ bool userIntervened = false;
+
+ @override
+ void initState() {
+ super.initState();
+ scrollController = ScrollController(
+ onAttach: (_) => startScroll(),
+ initialScrollOffset: widget.offset,
+ );
+ }
+
+ @override
+ void dispose() {
+ scrollController.dispose();
+ super.dispose();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return NotificationListener<ScrollNotification>(
+ onNotification: (notification) {
+ if (notification is ScrollUpdateNotification) {
+ return false;
+ }
+ if (notification is ScrollEndNotification && !userIntervened) {
+ startScroll();
+ } else if (notification is UserScrollNotification &&
+ notification.direction == ScrollDirection.idle) {
+ scheduleRestart();
+ }
+ return false;
+ },
+ child: SizedBox(
+ height: 36,
+ child: Stack(
+ children: [
+ InfiniteScrollView(
+ centerKey: UniqueKey(),
+ scrollController: scrollController,
+ itemCount: widget.questions.length,
+ itemBuilder: (context, index) {
+ return WelcomeSampleQuestion(
+ question: widget.questions[index],
+ onSelected: widget.onSelected,
+ );
+ },
+ separatorBuilder: (context, index) => const HSpace(8),
+ ),
+ Listener(
+ behavior: HitTestBehavior.translucent,
+ onPointerDown: (event) {
+ userIntervened = true;
+ scrollController.jumpTo(scrollController.offset);
+ },
+ ),
+ ],
+ ),
+ ),
+ );
+ }
+
+ void startScroll() {
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ final delta = widget.reverse ? -250 : 250;
+ scrollController.animateTo(
+ scrollController.offset + delta,
+ duration: 20.seconds,
+ curve: Curves.linear,
+ );
+ });
+ }
+
+ void scheduleRestart() {
+ restartAutoScrollDebounce.call(() {
+ userIntervened = false;
+ startScroll();
+ });
+ }
+}
+
+class InfiniteScrollView extends StatelessWidget {
+ const InfiniteScrollView({
+ super.key,
+ required this.itemCount,
+ required this.centerKey,
+ required this.itemBuilder,
+ required this.separatorBuilder,
+ this.scrollController,
+ });
+
+ final int itemCount;
+ final Widget Function(BuildContext context, int index) itemBuilder;
+ final Widget Function(BuildContext context, int index) separatorBuilder;
+ final Key centerKey;
+
+ final ScrollController? scrollController;
+
+ @override
+ Widget build(BuildContext context) {
+ return CustomScrollView(
+ scrollDirection: Axis.horizontal,
+ controller: scrollController,
+ center: centerKey,
+ anchor: 0.5,
+ slivers: [
+ _buildList(isForward: false),
+ SliverToBoxAdapter(
+ child: separatorBuilder.call(context, 0),
+ ),
+ SliverToBoxAdapter(
+ key: centerKey,
+ child: itemBuilder.call(context, 0),
+ ),
+ SliverToBoxAdapter(
+ child: separatorBuilder.call(context, 0),
+ ),
+ _buildList(isForward: true),
+ ],
+ );
+ }
+
+ Widget _buildList({required bool isForward}) {
+ return SliverList.separated(
+ itemBuilder: (context, index) {
+ index = (index + 1) % itemCount;
+ return itemBuilder(context, index);
+ },
+ separatorBuilder: (context, index) {
+ index = (index + 1) % itemCount;
+ return separatorBuilder(context, index);
+ },
+ );
+ }
+}
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/layout_define.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/layout_define.dart
new file mode 100644
index 0000000000..1cd7fd4eb6
--- /dev/null
+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/layout_define.dart
@@ -0,0 +1,64 @@
+import 'package:flutter/material.dart';
+import 'package:universal_platform/universal_platform.dart';
+
+class AIChatUILayout {
+ static double get messageWidthRatio => 0.94; // Chat adds extra 0.06
+
+ static EdgeInsets safeAreaInsets(BuildContext context) {
+ final query = MediaQuery.of(context);
+ return UniversalPlatform.isMobile
+ ? EdgeInsets.fromLTRB(
+ query.padding.left,
+ 0,
+ query.padding.right,
+ query.viewInsets.bottom + query.padding.bottom,
+ )
+ : const EdgeInsets.only(bottom: 16);
+ }
+}
+
+class DesktopAIPromptSizes {
+ static const promptFrameRadius = BorderRadius.all(Radius.circular(8));
+
+ static const attachedFilesBarPadding =
+ EdgeInsets.only(top: 8.0, left: 8.0, right: 8.0);
+ static const attachedFilesPreviewHeight = 48.0;
+ static const attachedFilesPreviewSpacing = 12.0;
+
+ static const textFieldMinHeight = 36.0;
+ static const textFieldContentPadding =
+ EdgeInsetsDirectional.fromSTEB(12.0, 12.0, 12.0, 4.0);
+
+ static const actionBarHeight = 28.0;
+ static const actionBarButtonSize = 24.0;
+ static const actionBarIconSize = 16.0;
+ static const actionBarButtonSpacing = 4.0;
+ static const sendButtonSize = 20.0;
+}
+
+class MobileAIPromptSizes {
+ static const promptFrameRadius =
+ BorderRadius.vertical(top: Radius.circular(8.0));
+
+ static const attachedFilesBarHeight = 68.0;
+ static const attachedFilesBarPadding =
+ EdgeInsets.only(top: 8.0, left: 8.0, right: 8.0, bottom: 4.0);
+ static const attachedFilesPreviewHeight = 56.0;
+ static const attachedFilesPreviewSpacing = 8.0;
+
+ static const textFieldMinHeight = 48.0;
+ static const textFieldContentPadding = EdgeInsets.all(8.0);
+
+ static const mentionIconSize = 20.0;
+ static const sendButtonSize = 32.0;
+}
+
+class DesktopAIConvoSizes {
+ static const avatarSize = 32.0;
+
+ static const avatarAndChatBubbleSpacing = 12.0;
+
+ static const actionBarIconSize = 24.0;
+ static const actionBarIconSpacing = 8.0;
+ static const actionBarIconRadius = BorderRadius.all(Radius.circular(8.0));
+}
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 f8669ffa09..a05a4ad287 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
@@ -1,7 +1,6 @@
import 'package:appflowy/mobile/application/page_style/document_page_style_bloc.dart';
import 'package:appflowy/plugins/document/presentation/editor_configuration.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/plugins.dart';
-import 'package:appflowy/plugins/document/presentation/editor_style.dart';
import 'package:appflowy/shared/markdown_to_document.dart';
import 'package:appflowy/util/theme_extension.dart';
import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
@@ -11,6 +10,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:markdown_widget/markdown_widget.dart';
+import '../chat_editor_style.dart';
import 'selectable_highlight.dart';
enum AIMarkdownType {
@@ -98,8 +98,8 @@ class _AppFlowyEditorMarkdownState extends State<_AppFlowyEditorMarkdown> {
@override
Widget build(BuildContext context) {
// don't lazy load the styleCustomizer and blockBuilders,
- // it needs the context to get the theme.
- final styleCustomizer = EditorStyleCustomizer(
+ // it needs the context to get the theme.
+ final styleCustomizer = ChatEditorStyleCustomizer(
context: context,
padding: EdgeInsets.zero,
);
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/message/ai_message_bubble.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/message/ai_message_bubble.dart
index d13cd94071..75945bb542 100644
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/message/ai_message_bubble.dart
+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/message/ai_message_bubble.dart
@@ -2,80 +2,117 @@ import 'dart:convert';
import 'package:appflowy/generated/flowy_svgs.g.dart';
import 'package:appflowy/generated/locale_keys.g.dart';
-import 'package:appflowy/plugins/ai_chat/application/chat_entity.dart';
+import 'package:appflowy/mobile/presentation/bottom_sheet/bottom_sheet.dart';
+import 'package:appflowy/mobile/presentation/widgets/flowy_mobile_quick_action_button.dart';
import 'package:appflowy/plugins/ai_chat/presentation/chat_avatar.dart';
-import 'package:appflowy/plugins/ai_chat/presentation/chat_input/chat_input.dart';
-import 'package:appflowy/plugins/ai_chat/presentation/chat_popmenu.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/copy_and_paste/clipboard_service.dart';
import 'package:appflowy/shared/markdown_to_document.dart';
import 'package:appflowy/startup/startup.dart';
-import 'package:appflowy/workspace/presentation/home/toast.dart';
+import 'package:appflowy/util/theme_extension.dart';
import 'package:appflowy/workspace/presentation/widgets/dialogs.dart';
import 'package:easy_localization/easy_localization.dart';
-import 'package:flowy_infra/size.dart';
import 'package:flowy_infra/theme_extension.dart';
-import 'package:flowy_infra_ui/style_widget/icon_button.dart';
-import 'package:flowy_infra_ui/widget/flowy_tooltip.dart';
+import 'package:flowy_infra_ui/flowy_infra_ui.dart';
import 'package:flutter/material.dart';
-import 'package:flutter/services.dart';
import 'package:flutter_chat_types/flutter_chat_types.dart';
-import 'package:styled_widget/styled_widget.dart';
+import 'package:universal_platform/universal_platform.dart';
-const _leftPadding = 16.0;
+import '../layout_define.dart';
+/// Wraps an AI response message with the avatar and actions. On desktop,
+/// the actions will be displayed below the response if the response is the
+/// last message in the chat. For other AI responses, the actions will be shown
+/// on hover. On mobile, the actions will be displayed in a bottom sheet on
+/// long press.
class ChatAIMessageBubble extends StatelessWidget {
const ChatAIMessageBubble({
super.key,
required this.message,
required this.child,
- this.customMessageType,
+ required this.showActions,
+ this.isLastMessage = false,
});
final Message message;
final Widget child;
- final OnetimeShotType? customMessageType;
+ final bool showActions;
+ final bool isLastMessage;
@override
Widget build(BuildContext context) {
- const padding = EdgeInsets.symmetric(horizontal: _leftPadding);
- final childWithPadding = Padding(padding: padding, child: child);
- final widget = isMobile
- ? _wrapPopMenu(childWithPadding)
- : _wrapHover(childWithPadding);
-
- return Row(
- mainAxisSize: MainAxisSize.min,
+ final avatarAndMessage = Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
- const ChatBorderedCircleAvatar(
- child: FlowySvg(
- FlowySvgs.flowy_logo_s,
- size: Size.square(20),
- blendMode: null,
- ),
- ),
- Expanded(child: widget),
+ const ChatAIAvatar(),
+ const HSpace(DesktopAIConvoSizes.avatarAndChatBubbleSpacing),
+ Expanded(child: child),
],
);
+
+ return showActions
+ ? UniversalPlatform.isMobile
+ ? _wrapPopMenu(avatarAndMessage)
+ : isLastMessage
+ ? _wrapBottomActions(avatarAndMessage)
+ : _wrapHover(avatarAndMessage)
+ : avatarAndMessage;
}
- ChatAIMessageHover _wrapHover(Padding child) {
+ Widget _wrapBottomActions(Widget child) {
+ return ChatAIBottomInlineActions(
+ message: message,
+ child: child,
+ );
+ }
+
+ Widget _wrapHover(Widget child) {
return ChatAIMessageHover(
message: message,
- customMessageType: customMessageType,
child: child,
);
}
- ChatPopupMenu _wrapPopMenu(Padding childWithPadding) {
- return ChatPopupMenu(
- onAction: (action) {
- if (action == ChatMessageAction.copy && message is TextMessage) {
- Clipboard.setData(ClipboardData(text: (message as TextMessage).text));
- showMessageToast(LocaleKeys.grid_row_copyProperty.tr());
- }
- },
- builder: (context) => childWithPadding,
+ Widget _wrapPopMenu(Widget child) {
+ return ChatAIMessagePopup(
+ message: message,
+ child: child,
+ );
+ }
+}
+
+class ChatAIBottomInlineActions extends StatelessWidget {
+ const ChatAIBottomInlineActions({
+ super.key,
+ required this.child,
+ required this.message,
+ });
+
+ final Widget child;
+ final Message message;
+
+ @override
+ Widget build(BuildContext context) {
+ return Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ child,
+ const VSpace(16.0),
+ Padding(
+ padding: const EdgeInsetsDirectional.only(
+ start: DesktopAIConvoSizes.avatarSize +
+ DesktopAIConvoSizes.avatarAndChatBubbleSpacing,
+ ),
+ child: AIResponseActionBar(
+ showDecoration: false,
+ children: [
+ CopyButton(
+ textMessage: message as TextMessage,
+ ),
+ ],
+ ),
+ ),
+ const VSpace(32.0),
+ ],
);
}
}
@@ -85,81 +122,208 @@ class ChatAIMessageHover extends StatefulWidget {
super.key,
required this.child,
required this.message,
- this.customMessageType,
});
final Widget child;
final Message message;
- final bool autoShowHover = true;
- final OnetimeShotType? customMessageType;
@override
State<ChatAIMessageHover> createState() => _ChatAIMessageHoverState();
}
class _ChatAIMessageHoverState extends State<ChatAIMessageHover> {
- bool _isHover = false;
+ final controller = OverlayPortalController();
+ final layerLink = LayerLink();
+
+ bool hoverBubble = false;
+ bool hoverActionBar = false;
+
+ ScrollPosition? scrollPosition;
@override
void initState() {
super.initState();
- _isHover = widget.autoShowHover ? false : true;
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ addScrollListener();
+ controller.show();
+ });
}
@override
Widget build(BuildContext context) {
- final List<Widget> children = [
- DecoratedBox(
- decoration: const BoxDecoration(
- color: Colors.transparent,
- borderRadius: Corners.s6Border,
- ),
- child: Padding(
- padding: const EdgeInsets.only(bottom: 30),
- child: widget.child,
- ),
- ),
- ];
-
- if (_isHover) {
- children.addAll(_buildOnHoverItems());
- }
-
return MouseRegion(
- cursor: SystemMouseCursors.click,
opaque: false,
- onEnter: (p) => setState(() {
- if (widget.autoShowHover) {
- _isHover = true;
+ onEnter: (_) {
+ if (!hoverBubble && isBottomOfWidgetVisible(context)) {
+ setState(() => hoverBubble = true);
}
- }),
- onExit: (p) => setState(() {
- if (widget.autoShowHover) {
- _isHover = false;
+ },
+ onHover: (_) {
+ if (!hoverBubble && isBottomOfWidgetVisible(context)) {
+ setState(() => hoverBubble = true);
+ }
+ },
+ onExit: (_) {
+ if (hoverBubble) {
+ setState(() => hoverBubble = false);
}
- }),
- child: Stack(
- alignment: AlignmentDirectional.centerStart,
- children: children,
+ },
+ child: OverlayPortal(
+ controller: controller,
+ overlayChildBuilder: (_) {
+ return CompositedTransformFollower(
+ showWhenUnlinked: false,
+ link: layerLink,
+ targetAnchor: Alignment.bottomLeft,
+ offset: const Offset(
+ DesktopAIConvoSizes.avatarSize +
+ DesktopAIConvoSizes.avatarAndChatBubbleSpacing,
+ 0,
+ ),
+ child: Align(
+ alignment: Alignment.topLeft,
+ child: MouseRegion(
+ opaque: false,
+ onEnter: (_) {
+ if (!hoverActionBar && isBottomOfWidgetVisible(context)) {
+ setState(() => hoverActionBar = true);
+ }
+ },
+ onExit: (_) {
+ if (hoverActionBar) {
+ setState(() => hoverActionBar = false);
+ }
+ },
+ child: Container(
+ constraints: const BoxConstraints(
+ maxWidth: 784,
+ maxHeight: 28,
+ ),
+ alignment: Alignment.topLeft,
+ child: hoverBubble || hoverActionBar
+ ? AIResponseActionBar(
+ showDecoration: true,
+ children: [
+ CopyButton(
+ textMessage: widget.message as TextMessage,
+ ),
+ ],
+ )
+ : null,
+ ),
+ ),
+ ),
+ );
+ },
+ child: CompositedTransformTarget(
+ link: layerLink,
+ child: widget.child,
+ ),
),
);
}
- List<Widget> _buildOnHoverItems() {
- final List<Widget> children = [];
- if (widget.customMessageType != null) {
- //
- } else {
- if (widget.message is TextMessage) {
- children.add(
- CopyButton(
- textMessage: widget.message as TextMessage,
- ).positioned(left: _leftPadding, bottom: 0),
- );
- }
+ void addScrollListener() {
+ if (!mounted) {
+ return;
+ }
+ scrollPosition = Scrollable.maybeOf(context)?.position;
+ scrollPosition?.addListener(handleScroll);
+ }
+
+ void handleScroll() {
+ if (!mounted) {
+ return;
+ }
+ if ((hoverActionBar || hoverBubble) && !isBottomOfWidgetVisible(context)) {
+ setState(() {
+ hoverBubble = false;
+ hoverActionBar = false;
+ });
+ }
+ }
+
+ bool isBottomOfWidgetVisible(BuildContext context) {
+ if (Scrollable.maybeOf(context) == null) {
+ return false;
}
+ final scrollableRenderBox =
+ Scrollable.of(context).context.findRenderObject() as RenderBox;
+ final scrollableHeight = scrollableRenderBox.size.height;
+ final scrollableOffset = scrollableRenderBox.localToGlobal(Offset.zero);
+
+ final messageRenderBox = context.findRenderObject() as RenderBox;
+ final messageOffset = messageRenderBox.localToGlobal(Offset.zero);
+ final messageHeight = messageRenderBox.size.height;
+
+ return messageOffset.dy + messageHeight + 28 <=
+ scrollableOffset.dy + scrollableHeight;
+ }
+
+ @override
+ void dispose() {
+ scrollPosition?.isScrollingNotifier.removeListener(handleScroll);
+ super.dispose();
+ }
+}
+
+class AIResponseActionBar extends StatelessWidget {
+ const AIResponseActionBar({
+ super.key,
+ required this.showDecoration,
+ required this.children,
+ });
+
+ final List<Widget> children;
+ final bool showDecoration;
+
+ @override
+ Widget build(BuildContext context) {
+ final isLightMode = Theme.of(context).isLightMode;
+
+ final child = SeparatedRow(
+ mainAxisSize: MainAxisSize.min,
+ separatorBuilder: () =>
+ const HSpace(DesktopAIConvoSizes.actionBarIconSpacing),
+ children: children,
+ );
- return children;
+ return showDecoration
+ ? Container(
+ padding: const EdgeInsets.all(2.0),
+ decoration: BoxDecoration(
+ borderRadius: DesktopAIConvoSizes.actionBarIconRadius,
+ border: Border.all(color: Theme.of(context).dividerColor),
+ color: Theme.of(context).cardColor,
+ boxShadow: [
+ BoxShadow(
+ offset: const Offset(0, 1),
+ blurRadius: 2,
+ spreadRadius: -2,
+ color: isLightMode
+ ? const Color(0x051F2329)
+ : Theme.of(context).shadowColor.withOpacity(0.02),
+ ),
+ BoxShadow(
+ offset: const Offset(0, 2),
+ blurRadius: 4,
+ color: isLightMode
+ ? const Color(0x051F2329)
+ : Theme.of(context).shadowColor.withOpacity(0.02),
+ ),
+ BoxShadow(
+ offset: const Offset(0, 2),
+ blurRadius: 8,
+ spreadRadius: 2,
+ color: isLightMode
+ ? const Color(0x051F2329)
+ : Theme.of(context).shadowColor.withOpacity(0.02),
+ ),
+ ],
+ ),
+ child: child,
+ )
+ : child;
}
}
@@ -175,12 +339,14 @@ class CopyButton extends StatelessWidget {
return FlowyTooltip(
message: LocaleKeys.settings_menu_clickToCopy.tr(),
child: FlowyIconButton(
- width: 24,
+ width: DesktopAIConvoSizes.actionBarIconSize,
hoverColor: AFThemeExtension.of(context).lightGreyHover,
fillColor: Theme.of(context).cardColor,
- icon: const FlowySvg(
+ radius: DesktopAIConvoSizes.actionBarIconRadius,
+ icon: FlowySvg(
FlowySvgs.copy_s,
- size: Size.square(20),
+ color: Theme.of(context).hintColor,
+ size: const Size.square(16),
),
onPressed: () async {
final document = customMarkdownToDocument(textMessage.text);
@@ -201,3 +367,65 @@ class CopyButton extends StatelessWidget {
);
}
}
+
+class ChatAIMessagePopup extends StatelessWidget {
+ const ChatAIMessagePopup({
+ super.key,
+ required this.child,
+ required this.message,
+ });
+
+ final Widget child;
+ final Message message;
+
+ @override
+ Widget build(BuildContext context) {
+ return GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onLongPress: () {
+ showMobileBottomSheet(
+ context,
+ showDragHandle: true,
+ backgroundColor: AFThemeExtension.of(context).background,
+ builder: (bottomSheetContext) {
+ return Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ MobileQuickActionButton(
+ onTap: () async {
+ if (message is! TextMessage) {
+ return;
+ }
+ final textMessage = message as TextMessage;
+ final document = customMarkdownToDocument(textMessage.text);
+ await getIt<ClipboardService>().setData(
+ ClipboardServiceData(
+ plainText: textMessage.text,
+ inAppJson: jsonEncode(document.toJson()),
+ ),
+ );
+ if (bottomSheetContext.mounted) {
+ Navigator.of(bottomSheetContext).pop();
+ }
+ if (context.mounted) {
+ showToastNotification(
+ context,
+ message: LocaleKeys.grid_url_copiedNotification.tr(),
+ );
+ }
+ },
+ icon: FlowySvgs.copy_s,
+ iconSize: const Size.square(20),
+ text: LocaleKeys.button_copy.tr(),
+ ),
+ ],
+ );
+ },
+ );
+ },
+ child: IgnorePointer(
+ child: child,
+ ),
+ );
+ }
+}
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/message/ai_metadata.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/message/ai_metadata.dart
index 6d4f85d616..e0a5d3177f 100644
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/message/ai_metadata.dart
+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/message/ai_metadata.dart
@@ -1,3 +1,4 @@
+import 'package:appflowy/generated/flowy_svgs.g.dart';
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/plugins/ai_chat/application/chat_entity.dart';
import 'package:appflowy/plugins/ai_chat/application/chat_message_service.dart';
@@ -6,8 +7,9 @@ import 'package:flowy_infra_ui/style_widget/button.dart';
import 'package:flowy_infra_ui/style_widget/text.dart';
import 'package:flowy_infra_ui/widget/spacing.dart';
import 'package:flutter/material.dart';
+import 'package:time/time.dart';
-class AIMessageMetadata extends StatelessWidget {
+class AIMessageMetadata extends StatefulWidget {
const AIMessageMetadata({
required this.sources,
required this.onSelectedMetadata,
@@ -15,58 +17,91 @@ class AIMessageMetadata extends StatelessWidget {
});
final List<ChatMessageRefSource> sources;
- final Function(ChatMessageRefSource metadata) onSelectedMetadata;
+ final void Function(ChatMessageRefSource metadata) onSelectedMetadata;
+
+ @override
+ State<AIMessageMetadata> createState() => _AIMessageMetadataState();
+}
+
+class _AIMessageMetadataState extends State<AIMessageMetadata> {
+ bool isExpanded = true;
+
@override
Widget build(BuildContext context) {
- final title = sources.length == 1
- ? LocaleKeys.chat_referenceSource.tr(args: [sources.length.toString()])
- : LocaleKeys.chat_referenceSources
- .tr(args: [sources.length.toString()]);
- return Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- if (sources.isNotEmpty)
- Opacity(
- opacity: 0.5,
- child: FlowyText(title, fontSize: 12),
+ return AnimatedSize(
+ duration: 150.milliseconds,
+ alignment: AlignmentDirectional.topStart,
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ const VSpace(8.0),
+ ConstrainedBox(
+ constraints: const BoxConstraints(
+ maxHeight: 24,
+ maxWidth: 240,
+ ),
+ child: FlowyButton(
+ margin: const EdgeInsets.all(4.0),
+ useIntrinsicWidth: true,
+ radius: BorderRadius.circular(8.0),
+ text: FlowyText(
+ LocaleKeys.chat_referenceSource.plural(
+ widget.sources.length,
+ namedArgs: {'count': '${widget.sources.length}'},
+ ),
+ fontSize: 12,
+ color: Theme.of(context).hintColor,
+ ),
+ rightIcon: FlowySvg(
+ isExpanded ? FlowySvgs.arrow_up_s : FlowySvgs.arrow_down_s,
+ size: const Size.square(10),
+ ),
+ onTap: () {
+ setState(() => isExpanded = !isExpanded);
+ },
+ ),
),
- const VSpace(6),
- Wrap(
- spacing: 8.0,
- runSpacing: 4.0,
- children: sources
- .map(
- (m) => SizedBox(
- height: 24,
- child: FlowyButton(
- margin: const EdgeInsets.symmetric(
- horizontal: 6,
- vertical: 4,
+ if (isExpanded) ...[
+ const VSpace(4.0),
+ Wrap(
+ spacing: 8.0,
+ runSpacing: 4.0,
+ children: widget.sources.map(
+ (m) {
+ return ConstrainedBox(
+ constraints: const BoxConstraints(
+ maxHeight: 24,
+ maxWidth: 240,
),
- useIntrinsicWidth: true,
- radius: BorderRadius.circular(6),
- text: Opacity(
- opacity: 0.5,
- child: FlowyText(
+ child: FlowyButton(
+ margin: const EdgeInsets.all(4.0),
+ useIntrinsicWidth: true,
+ radius: BorderRadius.circular(8.0),
+ text: FlowyText(
m.name,
- fontSize: 14,
- lineHeight: 1.0,
+ fontSize: 12,
overflow: TextOverflow.ellipsis,
),
+ leftIcon: FlowySvg(
+ FlowySvgs.icon_document_s,
+ size: const Size.square(16),
+ color: Theme.of(context).hintColor,
+ ),
+ disable: m.source != appflowySource,
+ onTap: () {
+ if (m.source != appflowySource) {
+ return;
+ }
+ widget.onSelectedMetadata(m);
+ },
),
- disable: m.source != appflowySoruce,
- onTap: () {
- if (m.source != appflowySoruce) {
- return;
- }
- onSelectedMetadata(m);
- },
- ),
- ),
- )
- .toList(),
- ),
- ],
+ );
+ },
+ ).toList(),
+ ),
+ ],
+ ],
+ ),
);
}
}
diff --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.dart
index 4b711e4fda..cb6b383fe6 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
@@ -1,88 +1,112 @@
+import 'package:appflowy/generated/flowy_svgs.g.dart';
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/plugins/ai_chat/application/chat_ai_message_bloc.dart';
import 'package:appflowy/plugins/ai_chat/application/chat_entity.dart';
+import 'package:appflowy/plugins/ai_chat/application/chat_message_stream.dart';
import 'package:appflowy/plugins/ai_chat/presentation/chat_loading.dart';
import 'package:appflowy/plugins/ai_chat/presentation/message/ai_markdown_text.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:fixnum/fixnum.dart';
-import 'package:flowy_infra_ui/style_widget/button.dart';
import 'package:flowy_infra_ui/style_widget/text.dart';
import 'package:flowy_infra_ui/widget/spacing.dart';
+import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_chat_types/flutter_chat_types.dart';
+import 'package:universal_platform/universal_platform.dart';
+import 'ai_message_bubble.dart';
import 'ai_metadata.dart';
+/// [ChatAIMessageWidget] includes both the text of the AI response as well as
+/// the avatar, decorations and hover effects that are also rendered. This is
+/// different from [ChatUserMessageWidget] which only contains the message and
+/// has to be separately wrapped with a bubble since the hover effects need to
+/// know the current streaming status of the message.
class ChatAIMessageWidget extends StatelessWidget {
const ChatAIMessageWidget({
super.key,
required this.user,
required this.messageUserId,
required this.message,
+ required this.stream,
required this.questionId,
required this.chatId,
required this.refSourceJsonString,
required this.onSelectedMetadata,
+ this.isLastMessage = false,
});
final User user;
final String messageUserId;
- /// message can be a striing or Stream<String>
- final dynamic message;
+ final Message message;
+ final AnswerStream? stream;
final Int64? questionId;
final String chatId;
final String? refSourceJsonString;
final void Function(ChatMessageRefSource metadata) onSelectedMetadata;
+ final bool isLastMessage;
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (context) => ChatAIMessageBloc(
- message: message,
+ message: stream ?? (message as TextMessage).text,
refSourceJsonString: refSourceJsonString,
chatId: chatId,
questionId: questionId,
- )..add(const ChatAIMessageEvent.initial()),
+ ),
child: BlocBuilder<ChatAIMessageBloc, ChatAIMessageState>(
builder: (context, state) {
- return state.messageState.when(
- onError: (err) {
- return StreamingError(
- onRetryPressed: () {
- context.read<ChatAIMessageBloc>().add(
- const ChatAIMessageEvent.retry(),
+ return Padding(
+ padding: UniversalPlatform.isMobile
+ ? const EdgeInsets.symmetric(horizontal: 16)
+ : EdgeInsets.zero,
+ child: state.messageState.when(
+ loading: () {
+ return ChatAIMessageBubble(
+ message: message,
+ showActions: false,
+ child: const Padding(
+ padding: EdgeInsets.only(top: 8.0),
+ child: ChatAILoading(),
+ ),
+ );
+ },
+ ready: () {
+ return state.text.isEmpty
+ ? const SizedBox.shrink()
+ : ChatAIMessageBubble(
+ message: message,
+ isLastMessage: isLastMessage,
+ showActions: stream == null && state.text.isNotEmpty,
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ AIMarkdownText(markdown: state.text),
+ if (state.sources.isNotEmpty)
+ AIMessageMetadata(
+ sources: state.sources,
+ onSelectedMetadata: onSelectedMetadata,
+ ),
+ ],
+ ),
);
- },
- );
- },
- onAIResponseLimit: () {
- return FlowyText(
- LocaleKeys.sideBar_askOwnerToUpgradeToAIMax.tr(),
- lineHeight: 1.5,
- maxLines: 10,
- );
- },
- ready: () {
- if (state.text.isEmpty) {
- return const ChatAILoading();
- } else {
- return Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- AIMarkdownText(markdown: state.text),
- AIMessageMetadata(
- sources: state.sources,
- onSelectedMetadata: onSelectedMetadata,
- ),
- ],
+ },
+ onError: (err) {
+ return StreamingError(
+ onRetry: () {
+ context
+ .read<ChatAIMessageBloc>()
+ .add(const ChatAIMessageEvent.retry());
+ },
);
- }
- },
- loading: () {
- return const ChatAILoading();
- },
+ },
+ onAIResponseLimit: () {
+ return const AIResponseLimitReachedError();
+ },
+ ),
);
},
),
@@ -90,59 +114,124 @@ class ChatAIMessageWidget extends StatelessWidget {
}
}
-class StreamingError extends StatelessWidget {
+class StreamingError extends StatefulWidget {
const StreamingError({
- required this.onRetryPressed,
+ required this.onRetry,
super.key,
});
- final void Function() onRetryPressed;
+ final VoidCallback onRetry;
+
@override
- Widget build(BuildContext context) {
- return Column(
- children: [
- const Divider(height: 4, thickness: 1),
- const VSpace(16),
- Center(
- child: Column(
- children: [
- _aiUnvaliable(),
- const VSpace(10),
- _retryButton(),
- ],
- ),
- ),
- ],
- );
+ State<StreamingError> createState() => _StreamingErrorState();
+}
+
+class _StreamingErrorState extends State<StreamingError> {
+ late final TapGestureRecognizer recognizer;
+
+ @override
+ void initState() {
+ super.initState();
+ recognizer = TapGestureRecognizer()..onTap = widget.onRetry;
}
- FlowyButton _retryButton() {
- return FlowyButton(
- radius: BorderRadius.circular(20),
- useIntrinsicWidth: true,
- text: Padding(
- padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
- child: FlowyText(
- LocaleKeys.chat_regenerateAnswer.tr(),
- fontSize: 14,
+ @override
+ void dispose() {
+ recognizer.dispose();
+ super.dispose();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return Center(
+ child: Container(
+ margin: const EdgeInsets.only(top: 16.0, bottom: 24.0),
+ padding: const EdgeInsets.all(8.0),
+ decoration: const BoxDecoration(
+ color: Color(0x80FFE7EE),
+ borderRadius: BorderRadius.all(Radius.circular(8.0)),
+ ),
+ constraints: _errorConstraints(),
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ const FlowySvg(
+ FlowySvgs.warning_filled_s,
+ blendMode: null,
+ ),
+ const HSpace(8.0),
+ Flexible(
+ child: RichText(
+ text: TextSpan(
+ children: [
+ TextSpan(
+ text: LocaleKeys.chat_aiServerUnavailable.tr(),
+ style: Theme.of(context).textTheme.bodyMedium,
+ ),
+ TextSpan(
+ text: " ",
+ style: Theme.of(context).textTheme.bodyMedium,
+ ),
+ TextSpan(
+ text: LocaleKeys.chat_retry.tr(),
+ recognizer: recognizer,
+ mouseCursor: SystemMouseCursors.click,
+ style: Theme.of(context).textTheme.bodyMedium?.copyWith(
+ fontWeight: FontWeight.w600,
+ decoration: TextDecoration.underline,
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ ],
),
- ),
- onTap: onRetryPressed,
- iconPadding: 0,
- leftIcon: const Icon(
- Icons.refresh,
- size: 20,
),
);
}
+}
+
+class AIResponseLimitReachedError extends StatelessWidget {
+ const AIResponseLimitReachedError({
+ super.key,
+ });
- Padding _aiUnvaliable() {
- return Padding(
- padding: const EdgeInsets.all(8.0),
- child: FlowyText(
- LocaleKeys.chat_aiServerUnavailable.tr(),
- fontSize: 14,
+ @override
+ Widget build(BuildContext context) {
+ return Center(
+ child: Container(
+ margin: const EdgeInsets.only(top: 16.0, bottom: 24.0),
+ constraints: _errorConstraints(),
+ padding: const EdgeInsets.all(8.0),
+ decoration: const BoxDecoration(
+ color: Color(0x80FFE7EE),
+ borderRadius: BorderRadius.all(Radius.circular(8.0)),
+ ),
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ const FlowySvg(
+ FlowySvgs.warning_filled_s,
+ blendMode: null,
+ ),
+ const HSpace(8.0),
+ Flexible(
+ child: FlowyText(
+ LocaleKeys.sideBar_askOwnerToUpgradeToAIMax.tr(),
+ lineHeight: 1.4,
+ maxLines: null,
+ ),
+ ),
+ ],
+ ),
),
);
}
}
+
+BoxConstraints _errorConstraints() {
+ return UniversalPlatform.isDesktop
+ ? const BoxConstraints(maxWidth: 480)
+ : const BoxConstraints();
+}
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/message/other_user_message_bubble.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/message/other_user_message_bubble.dart
deleted file mode 100644
index 899c0bec3c..0000000000
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/message/other_user_message_bubble.dart
+++ /dev/null
@@ -1,211 +0,0 @@
-import 'dart:convert';
-
-import 'package:appflowy/generated/flowy_svgs.g.dart';
-import 'package:appflowy/generated/locale_keys.g.dart';
-import 'package:appflowy/plugins/ai_chat/application/chat_member_bloc.dart';
-import 'package:appflowy/plugins/ai_chat/presentation/chat_avatar.dart';
-import 'package:appflowy/plugins/ai_chat/presentation/chat_input/chat_input.dart';
-import 'package:appflowy/plugins/ai_chat/presentation/chat_popmenu.dart';
-import 'package:appflowy/plugins/document/presentation/editor_plugins/copy_and_paste/clipboard_service.dart';
-import 'package:appflowy/shared/markdown_to_document.dart';
-import 'package:appflowy/startup/startup.dart';
-import 'package:appflowy/workspace/presentation/home/toast.dart';
-import 'package:appflowy/workspace/presentation/widgets/dialogs.dart';
-import 'package:easy_localization/easy_localization.dart';
-import 'package:flowy_infra/size.dart';
-import 'package:flowy_infra/theme_extension.dart';
-import 'package:flowy_infra_ui/style_widget/icon_button.dart';
-import 'package:flowy_infra_ui/widget/flowy_tooltip.dart';
-import 'package:flutter/material.dart';
-import 'package:flutter/services.dart';
-import 'package:flutter_bloc/flutter_bloc.dart';
-import 'package:flutter_chat_types/flutter_chat_types.dart';
-import 'package:styled_widget/styled_widget.dart';
-
-const _leftPadding = 16.0;
-
-class OtherUserMessageBubble extends StatelessWidget {
- const OtherUserMessageBubble({
- super.key,
- required this.message,
- required this.child,
- });
-
- final Message message;
- final Widget child;
-
- @override
- Widget build(BuildContext context) {
- const padding = EdgeInsets.symmetric(horizontal: _leftPadding);
- final childWithPadding = Padding(padding: padding, child: child);
- final widget = isMobile
- ? _wrapPopMenu(childWithPadding)
- : _wrapHover(childWithPadding);
-
- if (context.read<ChatMemberBloc>().state.members[message.author.id] ==
- null) {
- context
- .read<ChatMemberBloc>()
- .add(ChatMemberEvent.getMemberInfo(message.author.id));
- }
-
- return Row(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- BlocConsumer<ChatMemberBloc, ChatMemberState>(
- listenWhen: (previous, current) {
- return previous.members[message.author.id] !=
- current.members[message.author.id];
- },
- listener: (context, state) {},
- builder: (context, state) {
- final member = state.members[message.author.id];
- return ChatUserAvatar(
- iconUrl: member?.info.avatarUrl ?? "",
- name: member?.info.name ?? "",
- defaultName: "",
- );
- },
- ),
- Expanded(child: widget),
- ],
- );
- }
-
- OtherUserMessageHover _wrapHover(Padding child) {
- return OtherUserMessageHover(
- message: message,
- child: child,
- );
- }
-
- ChatPopupMenu _wrapPopMenu(Padding childWithPadding) {
- return ChatPopupMenu(
- onAction: (action) {
- if (action == ChatMessageAction.copy && message is TextMessage) {
- Clipboard.setData(ClipboardData(text: (message as TextMessage).text));
- showMessageToast(LocaleKeys.grid_row_copyProperty.tr());
- }
- },
- builder: (context) => childWithPadding,
- );
- }
-}
-
-class OtherUserMessageHover extends StatefulWidget {
- const OtherUserMessageHover({
- super.key,
- required this.child,
- required this.message,
- });
-
- final Widget child;
- final Message message;
- final bool autoShowHover = true;
-
- @override
- State<OtherUserMessageHover> createState() => _OtherUserMessageHoverState();
-}
-
-class _OtherUserMessageHoverState extends State<OtherUserMessageHover> {
- bool _isHover = false;
-
- @override
- void initState() {
- super.initState();
- _isHover = widget.autoShowHover ? false : true;
- }
-
- @override
- Widget build(BuildContext context) {
- final List<Widget> children = [
- DecoratedBox(
- decoration: const BoxDecoration(
- color: Colors.transparent,
- borderRadius: Corners.s6Border,
- ),
- child: Padding(
- padding: const EdgeInsets.only(bottom: 30),
- child: widget.child,
- ),
- ),
- ];
-
- if (_isHover) {
- children.addAll(_buildOnHoverItems());
- }
-
- return MouseRegion(
- cursor: SystemMouseCursors.click,
- opaque: false,
- onEnter: (p) => setState(() {
- if (widget.autoShowHover) {
- _isHover = true;
- }
- }),
- onExit: (p) => setState(() {
- if (widget.autoShowHover) {
- _isHover = false;
- }
- }),
- child: Stack(
- alignment: AlignmentDirectional.centerStart,
- children: children,
- ),
- );
- }
-
- List<Widget> _buildOnHoverItems() {
- final List<Widget> children = [];
- if (widget.message is TextMessage) {
- children.add(
- CopyButton(
- textMessage: widget.message as TextMessage,
- ).positioned(left: _leftPadding, bottom: 0),
- );
- }
-
- return children;
- }
-}
-
-class CopyButton extends StatelessWidget {
- const CopyButton({
- super.key,
- required this.textMessage,
- });
- final TextMessage textMessage;
-
- @override
- Widget build(BuildContext context) {
- return FlowyTooltip(
- message: LocaleKeys.settings_menu_clickToCopy.tr(),
- child: FlowyIconButton(
- width: 24,
- hoverColor: AFThemeExtension.of(context).lightGreyHover,
- fillColor: Theme.of(context).cardColor,
- icon: FlowySvg(
- FlowySvgs.ai_copy_s,
- size: const Size.square(14),
- color: Theme.of(context).colorScheme.primary,
- ),
- onPressed: () async {
- final document = customMarkdownToDocument(textMessage.text);
- await getIt<ClipboardService>().setData(
- ClipboardServiceData(
- plainText: textMessage.text,
- inAppJson: jsonEncode(document.toJson()),
- ),
- );
- if (context.mounted) {
- showToastNotification(
- context,
- message: LocaleKeys.grid_url_copiedNotification.tr(),
- );
- }
- },
- ),
- );
- }
-}
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/message/user_message_bubble.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/message/user_message_bubble.dart
index 08c627b0b7..9410820137 100644
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/message/user_message_bubble.dart
+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/message/user_message_bubble.dart
@@ -1,28 +1,30 @@
+import 'package:appflowy/generated/flowy_svgs.g.dart';
import 'package:appflowy/plugins/ai_chat/application/chat_entity.dart';
import 'package:appflowy/plugins/ai_chat/application/chat_member_bloc.dart';
import 'package:appflowy/plugins/ai_chat/application/chat_user_message_bubble_bloc.dart';
import 'package:appflowy/plugins/ai_chat/presentation/chat_avatar.dart';
+import 'package:appflowy/plugins/ai_chat/presentation/layout_define.dart';
import 'package:flowy_infra_ui/style_widget/text.dart';
import 'package:flowy_infra_ui/widget/spacing.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_chat_types/flutter_chat_types.dart';
+import 'package:universal_platform/universal_platform.dart';
class ChatUserMessageBubble extends StatelessWidget {
const ChatUserMessageBubble({
super.key,
required this.message,
required this.child,
+ this.isCurrentUser = true,
});
final Message message;
final Widget child;
+ final bool isCurrentUser;
@override
Widget build(BuildContext context) {
- const borderRadius = BorderRadius.all(Radius.circular(6));
- final backgroundColor =
- Theme.of(context).colorScheme.surfaceContainerHighest;
if (context.read<ChatMemberBloc>().state.members[message.author.id] ==
null) {
context
@@ -36,60 +38,80 @@ class ChatUserMessageBubble extends StatelessWidget {
),
child: BlocBuilder<ChatUserMessageBubbleBloc, ChatUserMessageBubbleState>(
builder: (context, state) {
- return Column(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.end,
- children: [
- if (state.files.isNotEmpty) ...[
- Padding(
- padding: const EdgeInsets.only(right: defaultAvatarSize + 32),
- child: _MessageFileList(files: state.files),
- ),
- const VSpace(6),
- ],
- Row(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Flexible(
- child: DecoratedBox(
- decoration: BoxDecoration(
- borderRadius: borderRadius,
- color: backgroundColor,
- ),
- child: Padding(
- padding: const EdgeInsets.symmetric(
- horizontal: 16,
- vertical: 12,
- ),
- child: child,
- ),
- ),
- ),
+ return Padding(
+ padding: UniversalPlatform.isMobile
+ ? const EdgeInsets.symmetric(horizontal: 16)
+ : EdgeInsets.zero,
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.end,
+ children: [
+ if (state.files.isNotEmpty) ...[
Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16),
- child: BlocConsumer<ChatMemberBloc, ChatMemberState>(
- listenWhen: (previous, current) =>
- previous.members[message.author.id] !=
- current.members[message.author.id],
- listener: (context, state) {},
- builder: (context, state) {
- final member = state.members[message.author.id];
- return ChatUserAvatar(
- iconUrl: member?.info.avatarUrl ?? "",
- name: member?.info.name ?? "",
- );
- },
- ),
+ padding: const EdgeInsets.only(right: 32),
+ child: _MessageFileList(files: state.files),
),
+ const VSpace(6),
],
- ),
- ],
+ Row(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: getChildren(context),
+ ),
+ ],
+ ),
);
},
),
);
}
+
+ List<Widget> getChildren(BuildContext context) {
+ if (isCurrentUser) {
+ return [
+ const Spacer(),
+ _buildBubble(context),
+ const HSpace(DesktopAIConvoSizes.avatarAndChatBubbleSpacing),
+ _buildAvatar(),
+ ];
+ } else {
+ return [
+ _buildAvatar(),
+ const HSpace(DesktopAIConvoSizes.avatarAndChatBubbleSpacing),
+ _buildBubble(context),
+ const Spacer(),
+ ];
+ }
+ }
+
+ Widget _buildAvatar() {
+ return BlocBuilder<ChatMemberBloc, ChatMemberState>(
+ builder: (context, state) {
+ final member = state.members[message.author.id];
+ return ChatUserAvatar(
+ iconUrl: member?.info.avatarUrl ?? "",
+ name: member?.info.name ?? "",
+ );
+ },
+ );
+ }
+
+ Widget _buildBubble(BuildContext context) {
+ return Flexible(
+ flex: 5,
+ child: Container(
+ decoration: BoxDecoration(
+ borderRadius: const BorderRadius.all(Radius.circular(16.0)),
+ color: Theme.of(context).colorScheme.surfaceContainerHighest,
+ ),
+ padding: const EdgeInsets.symmetric(
+ horizontal: 16.0,
+ vertical: 8.0,
+ ),
+ child: child,
+ ),
+ );
+ }
}
class _MessageFileList extends StatelessWidget {
@@ -137,7 +159,11 @@ class _MessageFile extends StatelessWidget {
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
- SizedBox.square(dimension: 16, child: file.fileType.icon),
+ FlowySvg(
+ FlowySvgs.page_m,
+ size: const Size.square(16),
+ color: Theme.of(context).hintColor,
+ ),
const HSpace(6),
Flexible(
child: ConstrainedBox(
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.dart
index c804441188..f28708a4ef 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
@@ -22,24 +22,20 @@ class ChatUserMessageWidget extends StatelessWidget {
..add(const ChatUserMessageEvent.initial()),
child: BlocBuilder<ChatUserMessageBloc, ChatUserMessageState>(
builder: (context, state) {
- final List<Widget> children = [];
- children.add(
- Flexible(
- child: TextMessageText(
- text: state.text,
- ),
- ),
- );
-
- if (!state.messageState.isFinish) {
- children.add(const HSpace(6));
- children.add(const CircularProgressIndicator.adaptive());
- }
-
return Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.end,
- children: children,
+ children: [
+ Flexible(
+ child: TextMessageText(
+ text: state.text,
+ ),
+ ),
+ if (!state.messageState.isFinish) ...[
+ const HSpace(6),
+ const CircularProgressIndicator.adaptive(),
+ ],
+ ],
);
},
),
@@ -61,8 +57,7 @@ class TextMessageText extends StatelessWidget {
Widget build(BuildContext context) {
return FlowyText(
text,
- fontSize: 16,
- fontWeight: FontWeight.w500,
+ lineHeight: 1.4,
maxLines: null,
selectable: true,
color: AFThemeExtension.of(context).textColor,
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/mention/mobile_page_selector_sheet.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/mention/mobile_page_selector_sheet.dart
index ae493d402a..c8a392fb71 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/mention/mobile_page_selector_sheet.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/mention/mobile_page_selector_sheet.dart
@@ -25,8 +25,9 @@ Future<ViewPB?> showPageSelectorSheet(
showHeader: true,
showCloseButton: true,
showDragHandle: true,
- builder: (context) => Container(
- margin: const EdgeInsets.only(top: 12.0),
+ useSafeArea: false,
+ backgroundColor: Theme.of(context).colorScheme.surface,
+ builder: (context) => ConstrainedBox(
constraints: const BoxConstraints(
maxHeight: 340,
minHeight: 80,
@@ -112,27 +113,29 @@ class _MobilePageSelectorBodyState extends State<_MobilePageSelectorBody> {
}
return Flexible(
- child: ListView(
- children: filtered
- .map(
- (view) => FlowyOptionTile.checkbox(
- leftIcon: view.icon.value.isNotEmpty
- ? EmojiText(
- emoji: view.icon.value,
- fontSize: 18,
- textAlign: TextAlign.center,
- lineHeight: 1.3,
- )
- : FlowySvg(
- view.layout.icon,
- size: const Size.square(20),
- ),
- text: view.name,
- isSelected: view.id == widget.selectedViewId,
- onTap: () => Navigator.of(context).pop(view),
- ),
- )
- .toList(),
+ child: ListView.builder(
+ itemCount: filtered.length,
+ itemBuilder: (context, index) {
+ final view = filtered.elementAt(index);
+ return FlowyOptionTile.checkbox(
+ leftIcon: view.icon.value.isNotEmpty
+ ? EmojiText(
+ emoji: view.icon.value,
+ fontSize: 18,
+ textAlign: TextAlign.center,
+ lineHeight: 1.3,
+ )
+ : FlowySvg(
+ view.layout.icon,
+ size: const Size.square(20),
+ ),
+ text: view.name,
+ showTopBorder: index != 0,
+ showBottomBorder: false,
+ isSelected: view.id == widget.selectedViewId,
+ onTap: () => Navigator.of(context).pop(view),
+ );
+ },
),
);
},
diff --git a/frontend/appflowy_flutter/lib/workspace/application/settings/appearance/mobile_appearance.dart b/frontend/appflowy_flutter/lib/workspace/application/settings/appearance/mobile_appearance.dart
index 0f6a42b563..63235ba217 100644
--- a/frontend/appflowy_flutter/lib/workspace/application/settings/appearance/mobile_appearance.dart
+++ b/frontend/appflowy_flutter/lib/workspace/application/settings/appearance/mobile_appearance.dart
@@ -53,7 +53,7 @@ class MobileAppearance extends BaseAppearance {
//Snack bar
surface: Colors.white,
onSurface: _onSurfaceColor, // text/body color
- surfaceContainerHighest: const Color.fromARGB(255, 216, 216, 216),
+ surfaceContainerHighest: theme.sidebarBg,
)
: ColorScheme(
brightness: brightness,
@@ -69,6 +69,7 @@ class MobileAppearance extends BaseAppearance {
//Snack bar
surface: const Color(0xFF171A1F),
onSurface: const Color(0xffC5C6C7), // text/body color
+ surfaceContainerHighest: theme.sidebarBg,
);
final hintColor = brightness == Brightness.light
? const Color(0x991F2329)
diff --git a/frontend/appflowy_flutter/pubspec.lock b/frontend/appflowy_flutter/pubspec.lock
index 745cecd002..f78522353d 100644
--- a/frontend/appflowy_flutter/pubspec.lock
+++ b/frontend/appflowy_flutter/pubspec.lock
@@ -1812,14 +1812,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.4"
- shimmer:
- dependency: "direct main"
- description:
- name: shimmer
- sha256: "5f88c883a22e9f9f299e5ba0e4f7e6054857224976a5d9f839d4ebdc94a14ac9"
- url: "https://pub.dev"
- source: hosted
- version: "3.0.0"
simple_gesture_detector:
dependency: transitive
description:
diff --git a/frontend/appflowy_flutter/pubspec.yaml b/frontend/appflowy_flutter/pubspec.yaml
index d3313c5ad5..c5dc07be7a 100644
--- a/frontend/appflowy_flutter/pubspec.yaml
+++ b/frontend/appflowy_flutter/pubspec.yaml
@@ -123,7 +123,6 @@ dependencies:
share_plus: ^10.0.2
shared_preferences: ^2.2.2
sheet:
- shimmer: ^3.0.0
sized_context: ^1.0.0+4
string_validator: ^1.0.0
styled_widget: ^0.4.1
diff --git a/frontend/resources/flowy_icons/16x/ai_at.svg b/frontend/resources/flowy_icons/16x/ai_at.svg
new file mode 100644
index 0000000000..72128f6c9c
--- /dev/null
+++ b/frontend/resources/flowy_icons/16x/ai_at.svg
@@ -0,0 +1,4 @@
+<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M5.5 8C5.5 8.66304 5.76339 9.29893 6.23223 9.76777C6.70107 10.2366 7.33696 10.5 8 10.5C8.66304 10.5 9.29893 10.2366 9.76777 9.76777C10.2366 9.29893 10.5 8.66304 10.5 8C10.5 7.33696 10.2366 6.70107 9.76777 6.23223C9.29893 5.76339 8.66304 5.5 8 5.5C7.33696 5.5 6.70107 5.76339 6.23223 6.23223C5.76339 6.70107 5.5 7.33696 5.5 8Z" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M10.5 5.50001V8.62501C10.5 9.12229 10.6976 9.5992 11.0492 9.95083C11.4008 10.3025 11.8777 10.5 12.375 10.5C12.8723 10.5 13.3492 10.3025 13.7008 9.95083C14.0525 9.5992 14.25 9.12229 14.25 8.62501V8.00001C14.25 6.59207 13.7746 5.22538 12.9009 4.12136C12.0271 3.01734 10.8062 2.24068 9.43596 1.9172C8.06569 1.59372 6.62634 1.74238 5.35111 2.3391C4.07588 2.93582 3.03949 3.94563 2.40984 5.20492C1.78019 6.46422 1.59418 7.89922 1.88195 9.27743C2.16971 10.6556 2.91439 11.8963 3.99534 12.7985C5.07628 13.7006 6.43016 14.2113 7.83762 14.2479C9.24508 14.2845 10.6237 13.8448 11.75 13" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
+</svg>
diff --git a/frontend/resources/flowy_icons/16x/ai_attachment.svg b/frontend/resources/flowy_icons/16x/ai_attachment.svg
index 60a3cd5177..d998bbd621 100644
--- a/frontend/resources/flowy_icons/16x/ai_attachment.svg
+++ b/frontend/resources/flowy_icons/16x/ai_attachment.svg
@@ -1 +1,3 @@
-<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="-0.5 -0.5 13.2 13.2" id="Paperclip-1--Streamline-Flex.svg" height="13.2" width="13.2"><desc>Paperclip 1 Streamline Icon: https://streamlinehq.com</desc><g id="paperclip-1--attachment-link-paperclip-unlink"><path id="Vector 201" stroke="#000000" stroke-linecap="round" stroke-linejoin="round" d="M6.100165571428572 4.376418857142857 3.9434931428571427 6.5331c-0.5104741428571429 0.5104654285714285 -0.5104741428571429 1.3381047142857143 0 1.848578857142857 0.5104654285714285 0.5104654285714285 1.3381047142857143 0.5104654285714285 1.848578857142857 0l3.5431065714285714 -3.5431152857142862c0.935827142857143 -0.935862 0.935827142857143 -2.4531934285714287 0 -3.3890554285714285 -0.935862 -0.935866357142857 -2.453202142857143 -0.935866357142857 -3.389064142857143 0L2.0949055714285714 5.300708285714285c-1.3612516000000001 1.3612585714285714 -1.3612524714285714 3.568256 0 4.929514571428571 1.3612585714285714 1.3612585714285714 3.5682908571428573 1.3612585714285714 4.929549428571429 0l4.313353571428571 -4.313318714285714" stroke-width="1"></path></g></svg>
\ No newline at end of file
+<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M5.20789 11.9705L10.6031 6.80618C11.2508 6.18618 11.2508 5.18087 10.6031 4.56087C9.95533 3.94087 8.90514 3.9408 8.25739 4.56087L2.90127 9.68781C1.67058 10.8658 1.67058 12.7759 2.90127 13.9539C4.13202 15.1321 6.12739 15.1321 7.35814 13.9539L12.7924 8.75218C14.6061 7.01605 14.6061 4.2013 12.7924 2.46518C10.9787 0.729055 8.03808 0.729055 6.22439 2.46518L1.8457 6.65649" stroke="black" stroke-linecap="round"/>
+</svg>
diff --git a/frontend/resources/flowy_icons/16x/ai_chat_outlined.svg b/frontend/resources/flowy_icons/16x/ai_chat_outlined.svg
new file mode 100644
index 0000000000..3be82d4bf2
--- /dev/null
+++ b/frontend/resources/flowy_icons/16x/ai_chat_outlined.svg
@@ -0,0 +1,5 @@
+<svg width="17" height="17" viewBox="0 0 17 17" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M6.5 6.06201H11.1667C11.5 6.06201 11.8333 6.32764 11.8333 6.72868C11.8333 7.06201 11.5755 7.39535 11.1667 7.39534H6.51302C6.09865 7.39535 5.83333 7.06201 5.83333 6.72868C5.83333 6.32764 6.16667 6.06201 6.5 6.06201Z" fill="black"/>
+<path d="M6.5 8.72868H9.15885C9.57031 8.72868 9.83333 9.06201 9.83333 9.39535C9.83333 9.72868 9.57031 10.062 9.16667 10.062H6.5C6.16667 10.062 5.83333 9.79653 5.83333 9.39535C5.83333 8.99416 6.16667 8.72868 6.5 8.72868Z" fill="black"/>
+<path d="M2.76088 13.8836L3.46384 12.8777C2.32857 11.711 1.60305 10.1638 1.51107 8.45342C1.50372 8.32386 1.5 8.19335 1.5 8.06201C1.5 4.19602 4.72439 1.06201 8.70189 1.06201C8.72413 1.06201 8.74635 1.06211 8.76854 1.06231C8.79012 1.06211 8.81171 1.06201 8.83333 1.06201C10.574 1.06201 12.1663 1.69737 13.391 2.74883C14.3416 3.54217 15.0769 4.5724 15.5 5.74532C15.5145 5.78564 15.8333 7.10668 15.8333 8.06201C15.8333 11.645 13.1413 14.5993 9.66957 15.0126L9.66791 15.0128C9.39425 15.0453 9.11574 15.062 8.83333 15.062L8.69835 15.0617C8.56267 15.0614 8.38169 15.0609 8.3441 15.0617C8.33953 15.0618 8.33708 15.062 8.33708 15.062H3.40299C2.77997 15.062 2.41082 14.3845 2.76088 13.8836ZM8.3408 13.7283C8.35765 13.7281 8.37817 13.728 8.39845 13.728C8.44025 13.7279 8.49549 13.728 8.55174 13.7281L8.83333 13.7287C11.9629 13.7287 14.5 11.1916 14.5 8.06201C14.5 7.70427 14.4372 7.22782 14.3597 6.79581C14.3225 6.58852 14.285 6.40744 14.2563 6.27777C14.2435 6.21991 14.2328 6.17374 14.2251 6.14142C13.8818 5.22135 13.2962 4.40641 12.5367 3.77253L12.5295 3.76654L12.5224 3.76045C11.5304 2.90871 10.2435 2.39535 8.83333 2.39535C8.81574 2.39535 8.79817 2.39542 8.78063 2.39558L8.76871 2.39569L8.75679 2.39559C8.73852 2.39543 8.72021 2.39535 8.70189 2.39535C5.42478 2.39535 2.83333 4.96788 2.83333 8.06201C2.83333 8.16816 2.83634 8.27349 2.84226 8.37793L2.84248 8.38181C2.91624 9.7534 3.49725 11.0002 4.41943 11.9479L5.18819 12.7379L4.49581 13.7287H8.3143C8.32535 13.7284 8.33506 13.7283 8.3408 13.7283ZM14.2152 6.10117L14.216 6.10405C14.2116 6.08819 14.2109 6.08427 14.2152 6.10117Z" fill="black"/>
+</svg>
diff --git a/frontend/resources/flowy_icons/16x/ai_check_filled.svg b/frontend/resources/flowy_icons/16x/ai_check_filled.svg
new file mode 100644
index 0000000000..79efe0bd0a
--- /dev/null
+++ b/frontend/resources/flowy_icons/16x/ai_check_filled.svg
@@ -0,0 +1,10 @@
+<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
+ <g clip-path="url(#clip0_3494_21449)">
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M15.35 8A7.35 7.35 0 1 1 0.65 8a7.35 7.35 0 0 1 14.7 0M11.002 5.742a0.56 0.56 0 0 1 0 0.79L7.278 10.256a0.56 0.56 0 0 1 -0.79 0L5 8.768a0.558 0.558 0 1 1 0.79 -0.79l1.094 1.094 1.664 -1.665 1.665 -1.665a0.56 0.56 0 0 1 0.79 0" fill="black"/>
+ </g>
+ <defs>
+ <clipPath id="clip0_3494_21449">
+ <path width="16" height="16" fill="white" d="M0 0H16V16H0V0z"/>
+ </clipPath>
+ </defs>
+</svg>
diff --git a/frontend/resources/flowy_icons/16x/ai_close.svg b/frontend/resources/flowy_icons/16x/ai_close.svg
new file mode 100644
index 0000000000..9941c80abc
--- /dev/null
+++ b/frontend/resources/flowy_icons/16x/ai_close.svg
@@ -0,0 +1,3 @@
+<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M4.10968 3.35641C3.9014 3.14813 3.56371 3.14813 3.35543 3.35641C3.14715 3.56468 3.14715 3.90237 3.35543 4.11065L7.24497 8.0002L3.35543 11.8897C3.14715 12.098 3.14715 12.4357 3.35543 12.644C3.56371 12.8523 3.9014 12.8523 4.10968 12.644L7.99922 8.75444L11.8888 12.644C12.097 12.8523 12.4347 12.8523 12.643 12.644C12.8513 12.4357 12.8513 12.098 12.643 11.8897L8.75347 8.0002L12.643 4.11065C12.8513 3.90237 12.8513 3.56468 12.643 3.35641C12.4347 3.14813 12.097 3.14813 11.8888 3.35641L7.99922 7.24595L4.10968 3.35641Z" fill="black" stroke="black" stroke-width="0.15" stroke-linecap="round" stroke-linejoin="round"/>
+</svg>
diff --git a/frontend/resources/flowy_icons/16x/ai_close_filled.svg b/frontend/resources/flowy_icons/16x/ai_close_filled.svg
new file mode 100644
index 0000000000..9bf64c2bd8
--- /dev/null
+++ b/frontend/resources/flowy_icons/16x/ai_close_filled.svg
@@ -0,0 +1,10 @@
+<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
+ <g clip-path="url(#clip0_3544_30046)">
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M15.35 8A7.35 7.35 0 1 1 0.65 8a7.35 7.35 0 0 1 14.7 0M5.773 5.773a0.55 0.55 0 0 1 0.78 0L8 7.221l1.448 -1.448a0.551 0.551 0 0 1 0.78 0.78L8.78 8l1.448 1.448a0.55 0.55 0 1 1 -0.78 0.78L8 8.78l-1.447 1.448a0.551 0.551 0 1 1 -0.78 -0.78L7.221 8 5.773 6.553a0.55 0.55 0 0 1 0 -0.78" fill="black"/>
+ </g>
+ <defs>
+ <clipPath id="clip0_3544_30046">
+ <path width="16" height="16" fill="white" d="M0 0H16V16H0V0z"/>
+ </clipPath>
+ </defs>
+</svg>
diff --git a/frontend/resources/flowy_icons/16x/ai_dislike.svg b/frontend/resources/flowy_icons/16x/ai_dislike.svg
new file mode 100644
index 0000000000..5754775e88
--- /dev/null
+++ b/frontend/resources/flowy_icons/16x/ai_dislike.svg
@@ -0,0 +1,3 @@
+<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M1.84673 9.2077L2.35761 9.25189C2.33398 9.52552 2.09898 9.73183 1.82467 9.72002C1.5503 9.7082 1.33398 9.48227 1.33398 9.2077H1.84673ZM13.6314 7.96114L13.149 5.1717L14.1597 4.99695L14.642 7.78639L13.6314 7.96114ZM8.85148 1.67595H5.67311V0.650391H8.85148V1.67595ZM5.04998 2.24864L4.49467 8.67058L3.47292 8.5822L4.02817 2.16027L5.04998 2.24864ZM13.149 5.1717C12.8025 3.16802 10.9958 1.67595 8.85148 1.67595V0.650391C11.4675 0.650391 13.7235 2.4752 14.1597 4.99695L13.149 5.1717ZM8.85817 12.7179L8.40505 9.95258L9.41717 9.78683L9.8703 12.5521L8.85817 12.7179ZM4.70998 9.19989L5.69367 10.0476L5.02417 10.8245L4.04048 9.97683L4.70998 9.19989ZM7.48336 12.8055L7.80861 14.0594L6.81586 14.3169L6.49061 13.0631L7.48336 12.8055ZM8.29986 14.3054L8.39898 14.2735L8.71267 15.25L8.61355 15.2818L8.29986 14.3054ZM6.99073 11.5448C7.20398 11.9441 7.36961 12.367 7.48336 12.8055L6.49061 13.0631C6.39742 12.7036 6.26155 12.3565 6.08611 12.028L6.99073 11.5448ZM8.39898 14.2735C8.60848 14.2063 8.75724 14.0444 8.80611 13.8559L9.79892 14.1134C9.65836 14.6549 9.24392 15.0793 8.71267 15.25L8.39898 14.2735ZM7.80861 14.0594C7.83261 14.1516 7.89923 14.2365 8.00011 14.2851L7.55486 15.209C7.19111 15.0338 6.91786 14.7103 6.81586 14.3169L7.80861 14.0594ZM8.00011 14.2851C8.09217 14.3295 8.20061 14.3372 8.29986 14.3054L8.61355 15.2818C8.26505 15.3938 7.8848 15.368 7.55486 15.209L8.00011 14.2851ZM9.47273 8.69489H13.0152V9.72045H9.47273V8.69489ZM3.02192 1.5692L2.35761 9.25189L1.33586 9.16352L2.00017 1.48089L3.02192 1.5692ZM2.35955 1.49633V9.2077H1.33398V1.49633H2.35955ZM2.00017 1.48089C1.99117 1.5852 2.07336 1.67595 2.17955 1.67595V0.650391C2.67586 0.650391 3.06461 1.0757 3.02192 1.5692L2.00017 1.48089ZM9.8703 12.5521C9.95542 13.0718 9.93111 13.6036 9.79892 14.1134L8.80611 13.8559C8.90255 13.4844 8.92023 13.0968 8.85817 12.7179L9.8703 12.5521ZM5.67311 1.67595C5.34905 1.67595 5.07805 1.9242 5.04998 2.24864L4.02817 2.16027C4.10198 1.30658 4.81592 0.650391 5.67311 0.650391V1.67595ZM5.69367 10.0476C6.15848 10.4481 6.65961 10.9248 6.99073 11.5448L6.08611 12.028C5.8493 11.5846 5.47217 11.2105 5.02417 10.8245L5.69367 10.0476ZM14.642 7.78639C14.8166 8.79589 14.0403 9.72045 13.0152 9.72045V8.69489C13.4025 8.69489 13.6978 8.34502 13.6314 7.96114L14.642 7.78639ZM2.17955 1.67595C2.27948 1.67595 2.35955 1.59502 2.35955 1.49633H1.33398C1.33398 1.0297 1.71198 0.650391 2.17955 0.650391V1.67595ZM8.40505 9.95258C8.29723 9.29427 8.80467 8.69489 9.47273 8.69489V9.72045C9.43867 9.72045 9.41136 9.75139 9.41717 9.78683L8.40505 9.95258ZM4.49467 8.67058C4.4773 8.87158 4.55755 9.06852 4.70998 9.19989L4.04048 9.97683C3.63823 9.63014 3.42717 9.1112 3.47292 8.5822L4.49467 8.67058Z" fill="black"/>
+</svg>
diff --git a/frontend/resources/flowy_icons/16x/ai_expand.svg b/frontend/resources/flowy_icons/16x/ai_expand.svg
new file mode 100644
index 0000000000..83df4e9234
--- /dev/null
+++ b/frontend/resources/flowy_icons/16x/ai_expand.svg
@@ -0,0 +1,11 @@
+<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
+<g clip-path="url(#clip0_3622_33848)">
+<path d="M5.94811 10.0508L1.16211 14.8368M1.16211 14.8368H5.16673M1.16211 14.8368V10.8322" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M10.0508 5.94909L14.8368 1.16309M14.8368 1.16309H10.8322M14.8368 1.16309V5.16771" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
+</g>
+<defs>
+<clipPath id="clip0_3622_33848">
+<rect width="16" height="16" fill="white"/>
+</clipPath>
+</defs>
+</svg>
diff --git a/frontend/resources/flowy_icons/16x/ai_image.svg b/frontend/resources/flowy_icons/16x/ai_image.svg
new file mode 100644
index 0000000000..79f6081090
--- /dev/null
+++ b/frontend/resources/flowy_icons/16x/ai_image.svg
@@ -0,0 +1,12 @@
+<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
+<g clip-path="url(#clip0_3551_49504)">
+<path d="M2.01758 8.00012C2.01758 5.17988 2.01758 3.76982 2.89367 2.89367C3.76982 2.01758 5.17988 2.01758 8.00012 2.01758C10.8203 2.01758 12.2304 2.01758 13.1065 2.89367C13.9827 3.76982 13.9827 5.17988 13.9827 8.00012C13.9827 10.8203 13.9827 12.2304 13.1065 13.1065C12.2305 13.9827 10.8203 13.9827 8.00012 13.9827C5.17988 13.9827 3.76982 13.9827 2.89367 13.1065C2.01758 12.2305 2.01758 10.8203 2.01758 8.00012Z" stroke="black"/>
+<path d="M9.19727 5.60711C9.1953 6.52816 10.1912 7.10599 10.9898 6.64716C11.3621 6.43328 11.5912 6.03641 11.5903 5.60711C11.5923 4.68601 10.5964 4.10824 9.79774 4.56707C9.42548 4.78089 9.19634 5.17782 9.19727 5.60711Z" fill="black" stroke="black" stroke-width="0.2"/>
+<path d="M2.01758 8.29931L3.06545 7.38242C3.61063 6.90544 4.43231 6.93278 4.94451 7.44498L7.51088 10.0114C7.92197 10.4225 8.5692 10.4786 9.04492 10.1442L9.22331 10.0189C9.90784 9.53777 10.834 9.59349 11.4559 10.1532L13.3844 11.8888" stroke="black" stroke-linecap="round"/>
+</g>
+<defs>
+<clipPath id="clip0_3551_49504">
+<rect width="14" height="14" fill="white" transform="translate(1 1)"/>
+</clipPath>
+</defs>
+</svg>
diff --git a/frontend/resources/flowy_icons/16x/ai_like.svg b/frontend/resources/flowy_icons/16x/ai_like.svg
new file mode 100644
index 0000000000..b7a92725aa
--- /dev/null
+++ b/frontend/resources/flowy_icons/16x/ai_like.svg
@@ -0,0 +1,3 @@
+<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M1.8468 6.79307L2.35767 6.74888C2.33405 6.47532 2.09905 6.26888 1.82467 6.28076C1.55036 6.29257 1.33398 6.51844 1.33398 6.79307H1.8468ZM13.6315 8.03963L13.1491 10.829L14.1597 11.0038L14.6421 8.21438L13.6315 8.03963ZM8.85155 14.3248H5.67317V15.3504H8.85155V14.3248ZM5.05005 13.7522L4.49473 7.33019L3.47298 7.41851L4.02823 13.8405L5.05005 13.7522ZM13.1491 10.829C12.8026 12.8327 10.9959 14.3248 8.85155 14.3248V15.3504C11.4676 15.3504 13.7236 13.5255 14.1597 11.0038L13.1491 10.829ZM8.85823 3.28282L8.40511 6.04819L9.41723 6.21401L9.87036 3.44863L8.85823 3.28282ZM4.71005 6.80088L5.69373 5.95319L5.02423 5.17632L4.04055 6.02394L4.71005 6.80088ZM7.48342 3.19526L7.80867 1.94138L6.81598 1.68388L6.49067 2.93769L7.48342 3.19526ZM8.29992 1.69538L8.39905 1.72726L8.71273 0.750819L8.61361 0.718944L8.29992 1.69538ZM6.9908 4.45594C7.20405 4.05669 7.36973 3.63369 7.48342 3.19526L6.49067 2.93769C6.39748 3.29713 6.26161 3.64432 6.08617 3.97276L6.9908 4.45594ZM8.39905 1.72726C8.60855 1.79451 8.75724 1.95632 8.80617 2.14488L9.79898 1.88738C9.65848 1.34588 9.24398 0.921444 8.71273 0.750819L8.39905 1.72726ZM7.80867 1.94138C7.83267 1.84907 7.8993 1.76426 8.00017 1.71563L7.55492 0.791757C7.19117 0.967007 6.91798 1.29051 6.81598 1.68388L7.80867 1.94138ZM8.00017 1.71563C8.0923 1.67126 8.20073 1.66351 8.29992 1.69538L8.61361 0.718944C8.26511 0.607007 7.88492 0.632757 7.55492 0.791757L8.00017 1.71563ZM9.47286 7.30588H13.0152V6.28026H9.47286V7.30588ZM3.02198 14.4315L2.35767 6.74888L1.33592 6.83726L2.00023 14.5199L3.02198 14.4315ZM2.35961 14.5044V6.79307H1.33398L1.33405 14.5044H2.35961ZM2.00023 14.5199C1.99123 14.4156 2.07342 14.3248 2.17961 14.3248V15.3504C2.67592 15.3504 3.06467 14.925 3.02198 14.4315L2.00023 14.5199ZM9.87036 3.44863C9.95548 2.92894 9.93117 2.39713 9.79898 1.88738L8.80617 2.14488C8.90261 2.51644 8.9203 2.90401 8.85823 3.28282L9.87036 3.44863ZM5.67317 14.3248C5.34911 14.3248 5.07811 14.0766 5.05005 13.7522L4.02823 13.8405C4.10205 14.6941 4.81598 15.3504 5.67317 15.3504V14.3248ZM5.69373 5.95319C6.15855 5.55263 6.65967 5.07588 6.9908 4.45594L6.08617 3.97276C5.84936 4.41607 5.47223 4.79026 5.02423 5.17632L5.69373 5.95319ZM14.6421 8.21438C14.8167 7.20488 14.0404 6.28026 13.0152 6.28026V7.30588C13.4027 7.30588 13.6979 7.65569 13.6315 8.03963L14.6421 8.21438ZM2.17961 14.3248C2.27955 14.3248 2.35961 14.4058 2.35961 14.5044H1.33405C1.33405 14.9711 1.71205 15.3504 2.17961 15.3504V14.3248ZM8.40511 6.04819C8.2973 6.70657 8.8048 7.30588 9.47286 7.30588V6.28026C9.43873 6.28026 9.41142 6.24938 9.41723 6.21401L8.40511 6.04819ZM4.49473 7.33019C4.47736 7.12919 4.55761 6.93226 4.71005 6.80088L4.04055 6.02394C3.6383 6.37057 3.42723 6.88951 3.47298 7.41851L4.49473 7.33019Z" fill="black"/>
+</svg>
diff --git a/frontend/resources/flowy_icons/16x/ai_list.svg b/frontend/resources/flowy_icons/16x/ai_list.svg
new file mode 100644
index 0000000000..ee31345b13
--- /dev/null
+++ b/frontend/resources/flowy_icons/16x/ai_list.svg
@@ -0,0 +1,8 @@
+<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M5.5 4.25H13.625" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M5.5 8H13.625" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M5.5 11.75H13.625" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M2.375 4.25H2.38125" stroke="black" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M2.375 8H2.38125" stroke="black" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M2.375 11.75H2.38125" stroke="black" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
+</svg>
diff --git a/frontend/resources/flowy_icons/16x/ai_number_list.svg b/frontend/resources/flowy_icons/16x/ai_number_list.svg
new file mode 100644
index 0000000000..c226e339f7
--- /dev/null
+++ b/frontend/resources/flowy_icons/16x/ai_number_list.svg
@@ -0,0 +1,8 @@
+<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M6.75 4.25H13.625" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M6.75 8H13.625" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M6.75 11.75H13.625" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M3 4.25H3.625V6.75" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M3 6.75H4.25" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M4.25 11.7495H3C3 11.1245 4.25 10.4995 4.25 9.87455C4.25 9.24955 3.625 8.93705 3 9.24955" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
+</svg>
diff --git a/frontend/resources/flowy_icons/16x/ai_page.svg b/frontend/resources/flowy_icons/16x/ai_page.svg
new file mode 100644
index 0000000000..09598791b9
--- /dev/null
+++ b/frontend/resources/flowy_icons/16x/ai_page.svg
@@ -0,0 +1,4 @@
+<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M13.6673 6.74503V10.0183C13.6673 13.2916 12.534 14.6009 9.70065 14.6009H6.30065C3.46732 14.6009 2.33398 13.2916 2.33398 10.0183V6.09038C2.33398 2.81712 3.46732 1.50781 6.30065 1.50781H9.13398" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M13.6173 6.66608H11.3507C9.65065 6.66608 9.08398 6.00787 9.08398 4.03323V1.68666C9.08398 1.58813 9.20647 1.54266 9.27075 1.61733L13.6173 6.66608Z" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
+</svg>
diff --git a/frontend/resources/flowy_icons/16x/ai_paragraph.svg b/frontend/resources/flowy_icons/16x/ai_paragraph.svg
new file mode 100644
index 0000000000..fc184ace91
--- /dev/null
+++ b/frontend/resources/flowy_icons/16x/ai_paragraph.svg
@@ -0,0 +1,5 @@
+<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M8.75586 2.3252V14.4311" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M11.7832 2.3252V14.4311" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M13.2969 2.3252H6.10908C3.48807 2.3252 1.84996 5.16255 3.16044 7.43241C3.76862 8.4858 4.89272 9.13472 6.10908 9.13477H8.75721" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
+</svg>
diff --git a/frontend/resources/flowy_icons/16x/ai_reset.svg b/frontend/resources/flowy_icons/16x/ai_reset.svg
new file mode 100644
index 0000000000..a589eda1fe
--- /dev/null
+++ b/frontend/resources/flowy_icons/16x/ai_reset.svg
@@ -0,0 +1,3 @@
+<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M13.0051 4.57673L12.449 4.02061C9.99206 1.56373 6.00856 1.56373 3.55169 4.02061C1.09475 6.47748 1.09475 10.461 3.55169 12.9179C6.00856 15.3749 9.99206 15.3749 12.449 12.9179C13.8778 11.4891 14.4756 9.54411 14.2426 7.68323M13.0051 4.57673H9.6685M13.0051 4.57673V1.24023" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
+</svg>
diff --git a/frontend/resources/flowy_icons/16x/ai_retry.svg b/frontend/resources/flowy_icons/16x/ai_retry.svg
new file mode 100644
index 0000000000..cfc50452af
--- /dev/null
+++ b/frontend/resources/flowy_icons/16x/ai_retry.svg
@@ -0,0 +1,6 @@
+<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M2.38672 3.43945H11.6134C12.7201 3.43945 13.6134 4.33279 13.6134 5.43945V7.65279" stroke="black" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M4.49339 1.33301L2.38672 3.43966L4.49339 5.54635" stroke="black" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M13.6134 12.56H4.38672C3.28005 12.56 2.38672 11.6667 2.38672 10.56V8.34668" stroke="black" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M11.5059 14.6665L13.6125 12.5598L11.5059 10.4531" stroke="black" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
+</svg>
diff --git a/frontend/resources/flowy_icons/16x/ai_retry_filled.svg b/frontend/resources/flowy_icons/16x/ai_retry_filled.svg
new file mode 100644
index 0000000000..021f724b01
--- /dev/null
+++ b/frontend/resources/flowy_icons/16x/ai_retry_filled.svg
@@ -0,0 +1,11 @@
+<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
+ <g clip-path="url(#clip0_3532_93841)">
+ <path fill="black" d="M8 0.65A7.35 7.35 0 1 1 0.65 8a7.35 7.35 0 0 1 14.7 0z"/>
+ <path d="m11.182 5.696-0.354-0.354a4 4 0 1 0 1.14 2.329m-0.787-1.975h-2.121m2.121 0V3.574" stroke="white" stroke-width="1.12" stroke-linecap="round" stroke-linejoin="round"/>
+ </g>
+ <defs>
+ <clipPath id="clip0_3532_93841">
+ <path d="M0 0H16V16H0V0z"/>
+ </clipPath>
+ </defs>
+</svg>
diff --git a/frontend/resources/flowy_icons/16x/ai_retry_font.svg b/frontend/resources/flowy_icons/16x/ai_retry_font.svg
new file mode 100644
index 0000000000..1c622f4040
--- /dev/null
+++ b/frontend/resources/flowy_icons/16x/ai_retry_font.svg
@@ -0,0 +1,4 @@
+<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M7.93913 2.16989C6.3343 2.16989 4.96504 2.73674 3.83136 3.87042C2.69767 5.00411 2.13083 6.37336 2.13083 7.97819C2.13083 8.98158 2.36243 9.90038 2.82562 10.7346C3.28881 11.5687 3.91116 12.2337 4.69267 12.7297V11.7547C4.69267 11.592 4.74729 11.4556 4.85654 11.3455C4.96578 11.2355 5.10109 11.1805 5.26245 11.1805C5.42397 11.1805 5.56075 11.2355 5.67279 11.3455C5.78498 11.4556 5.84107 11.592 5.84107 11.7547V14.2688C5.84107 14.4701 5.77305 14.6387 5.63701 14.7748C5.50082 14.911 5.33217 14.9791 5.13105 14.9791H2.6167C2.454 14.9791 2.31767 14.9244 2.20769 14.8152C2.09756 14.706 2.04249 14.5706 2.04249 14.4093C2.04249 14.2478 2.09756 14.111 2.20769 13.9989C2.31767 13.8868 2.454 13.8307 2.6167 13.8307H4.23397C3.25782 13.227 2.47182 12.4136 1.87597 11.3905C1.28027 10.3675 0.982422 9.23747 0.982422 8.00028C0.982422 7.04621 1.16624 6.14449 1.53388 5.29511C1.90152 4.44558 2.40144 3.70479 3.03366 3.07272C3.66572 2.44051 4.40659 1.94058 5.25627 1.57294C6.10595 1.2053 7.00885 1.02148 7.96497 1.02148C9.43537 1.02148 10.7524 1.42902 11.9162 2.2441C13.08 3.05903 13.9181 4.10629 14.4303 5.38588C14.496 5.53355 14.4963 5.6785 14.4312 5.82073C14.366 5.96296 14.2614 6.06727 14.1176 6.13367C13.9737 6.20022 13.8305 6.19926 13.6878 6.1308C13.5453 6.06219 13.4411 5.95596 13.3753 5.81212C12.9541 4.74645 12.2553 3.873 11.279 3.19176C10.3027 2.51051 9.18942 2.16989 7.93913 2.16989Z" fill="black"/>
+<path d="M8.65266 14.3423L11.2145 7.60975C11.2591 7.50867 11.3193 7.43207 11.3949 7.37995C11.4705 7.32782 11.5567 7.30176 11.6533 7.30176H12.0177C12.1204 7.30176 12.2098 7.32913 12.2859 7.38389C12.3619 7.43864 12.4223 7.51655 12.4669 7.61763L14.9796 14.3309C15.0412 14.4879 15.0306 14.635 14.9476 14.7725C14.8647 14.9099 14.7339 14.9786 14.5554 14.9786C14.4458 14.9786 14.35 14.9513 14.268 14.8967C14.1861 14.842 14.126 14.764 14.0876 14.6628L13.4639 12.9301H10.1671L9.53286 14.6756C9.50203 14.7629 9.44686 14.8352 9.36736 14.8926C9.28786 14.9499 9.19591 14.9786 9.09152 14.9786C8.91468 14.9786 8.78263 14.9106 8.69539 14.7745C8.60814 14.6384 8.5939 14.4943 8.65266 14.3423ZM10.4678 12.0719H13.1609L11.8817 8.49181H11.8095L10.4678 12.0719Z" fill="black"/>
+</svg>
diff --git a/frontend/resources/flowy_icons/16x/ai_save.svg b/frontend/resources/flowy_icons/16x/ai_save.svg
new file mode 100644
index 0000000000..ad228863b2
--- /dev/null
+++ b/frontend/resources/flowy_icons/16x/ai_save.svg
@@ -0,0 +1,11 @@
+<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
+<g clip-path="url(#clip0_3480_64260)">
+<path d="M1.21484 10.2617C1.21484 12.3939 1.21484 13.46 1.87722 14.1223C2.53966 14.7848 3.60572 14.7848 5.73791 14.7848H10.261C12.3932 14.7848 13.4593 14.7848 14.1217 14.1223C14.7841 13.46 14.7841 12.3938 14.7841 10.2617" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M7.99975 1.21582V11.0158M7.99975 11.0158L11.0151 7.71776M7.99975 11.0158L4.98438 7.71776" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
+</g>
+<defs>
+<clipPath id="clip0_3480_64260">
+<rect width="16" height="16" fill="white"/>
+</clipPath>
+</defs>
+</svg>
diff --git a/frontend/resources/flowy_icons/16x/ai_send_filled.svg b/frontend/resources/flowy_icons/16x/ai_send_filled.svg
new file mode 100644
index 0000000000..5f86dd3528
--- /dev/null
+++ b/frontend/resources/flowy_icons/16x/ai_send_filled.svg
@@ -0,0 +1,10 @@
+<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
+ <g clip-path="url(#clip0)">
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M15.35 8A7.35 7.35 0 1 1 0.65 8a7.35 7.35 0 0 1 14.7 0M8.472 3.906q1.054 1.053 2.107 2.107l0.723 0.723a0.666 0.666 0 0 1 -0.938 0.947l-1.696 -1.696v5.219a0.666 0.666 0 0 1 -1.334 0V5.986L5.643 7.678a0.666 0.666 0 0 1 -0.944 -0.942L7.53 3.904a0.666 0.666 0 0 1 0.942 0" fill="black"/>
+ </g>
+ <defs>
+ <clipPath id="clip0">
+ <path width="16" height="16" d="M0 0H16V16H0V0z"/>
+ </clipPath>
+ </defs>
+</svg>
diff --git a/frontend/resources/flowy_icons/16x/ai_sparks.svg b/frontend/resources/flowy_icons/16x/ai_sparks.svg
new file mode 100644
index 0000000000..dc23a6c287
--- /dev/null
+++ b/frontend/resources/flowy_icons/16x/ai_sparks.svg
@@ -0,0 +1,3 @@
+<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M13.2756 1.18518C13.1733 0.938319 12.8237 0.93826 12.7213 1.18508L12.5887 1.50482C12.3856 1.99453 11.9964 2.38357 11.5066 2.58646L11.1845 2.71991C10.9375 2.82221 10.9376 3.17207 11.1846 3.27429L11.5037 3.40634C11.9944 3.60942 12.3842 3.99934 12.5871 4.49014L12.7197 4.8108C12.8219 5.05791 13.1719 5.05797 13.2742 4.8109L13.4059 4.49274C13.6088 4.00235 13.9984 3.61274 14.4888 3.40971L14.8109 3.27635C15.0578 3.17411 15.0579 2.82435 14.811 2.72202L14.491 2.58944C14.0012 2.38643 13.612 1.99719 13.409 1.5073L13.2756 1.18518ZM7.03777 1.53065C7.33105 0.823135 8.3333 0.823306 8.62633 1.53092L9.20152 2.91991C9.92828 4.67492 11.3222 6.06949 13.0769 6.79701L14.4669 7.37331C15.1743 7.66662 15.1741 8.66875 14.4666 8.96181L13.0774 9.53723C11.3209 10.2648 9.92565 11.6607 9.19883 13.4175L8.6259 14.8024C8.3329 15.5106 7.32966 15.5104 7.03689 14.8021L6.46187 13.4108C5.73517 11.6526 4.33898 10.2555 2.58115 9.52777L1.19689 8.95468C0.489187 8.66168 0.489017 7.6593 1.19662 7.36606L2.5888 6.78913C4.34324 6.06207 5.73723 4.66819 6.46444 2.91382L7.03777 1.53065ZM7.99301 3.46585C7.93083 3.33103 7.7326 3.33098 7.67035 3.46577C6.72861 5.50464 5.17868 7.05429 3.13202 7.99873C2.9972 8.06095 2.99723 8.25919 3.13206 8.32139C5.18189 9.267 6.72982 10.8225 7.67032 12.8649C7.73247 12.9998 7.93091 12.9999 7.99313 12.8649C8.93402 10.8247 10.4843 9.27314 12.532 8.32853C12.6668 8.26635 12.6668 8.06817 12.532 8.00594C10.4909 7.06352 8.93832 5.51531 7.99301 3.46585Z" fill="black"/>
+</svg>
diff --git a/frontend/resources/flowy_icons/16x/ai_stop_filled.svg b/frontend/resources/flowy_icons/16x/ai_stop_filled.svg
new file mode 100644
index 0000000000..33c0fe090c
--- /dev/null
+++ b/frontend/resources/flowy_icons/16x/ai_stop_filled.svg
@@ -0,0 +1,10 @@
+<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
+ <g clip-path="url(#clip0_3584_82155)">
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M15.35 8A7.35 7.35 0 1 1 0.65 8a7.35 7.35 0 0 1 14.7 0M5.628 5.47c-0.429 0.43 -0.429 1.12 -0.429 2.503 0 1.382 0 2.074 0.43 2.503s1.12 0.43 2.503 0.43c1.382 0 2.074 0 2.504 -0.43 0.429 -0.43 0.429 -1.121 0.429 -2.504 0 -1.382 0 -2.073 -0.43 -2.502s-1.12 -0.43 -2.503 -0.43c-1.382 0 -2.074 0 -2.504 0.43" fill="black"/>
+ </g>
+ <defs>
+ <clipPath id="clip0_3584_82155">
+ <path width="16" height="16" fill="white" d="M0 0H16V16H0V0z"/>
+ </clipPath>
+ </defs>
+</svg>
diff --git a/frontend/resources/flowy_icons/16x/ai_stream_stop.svg b/frontend/resources/flowy_icons/16x/ai_stream_stop.svg
deleted file mode 100644
index 55c7355ab7..0000000000
--- a/frontend/resources/flowy_icons/16x/ai_stream_stop.svg
+++ /dev/null
@@ -1 +0,0 @@
-<svg width="64px" height="64px" viewBox="0 0 24.00 24.00" fill="none" xmlns="http://www.w3.org/2000/svg" stroke="#000000" stroke-width="0.00024000000000000003" data-darkreader-inline-stroke="" style="--darkreader-inline-stroke: #e8e6e3;"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path fill-rule="evenodd" clip-rule="evenodd" d="M9 8C8.44772 8 8 8.44772 8 9V15C8 15.5523 8.44772 16 9 16H15C15.5523 16 16 15.5523 16 15V9C16 8.44772 15.5523 8 15 8H9ZM6 9C6 7.34315 7.34315 6 9 6H15C16.6569 6 18 7.34315 18 9V15C18 16.6569 16.6569 18 15 18H9C7.34315 18 6 16.6569 6 15V9Z" fill="#333333" style="--darkreader-inline-fill: #262a2b;" data-darkreader-inline-fill=""></path> </g></svg>
\ No newline at end of file
diff --git a/frontend/resources/flowy_icons/16x/ai_table.svg b/frontend/resources/flowy_icons/16x/ai_table.svg
new file mode 100644
index 0000000000..993e1d5764
--- /dev/null
+++ b/frontend/resources/flowy_icons/16x/ai_table.svg
@@ -0,0 +1,12 @@
+<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
+<g clip-path="url(#clip0_3551_49501)">
+<path d="M3.49719 2.21191H12.5009C12.5009 2.21191 13.7872 2.21191 13.7872 3.49816V12.5019C13.7872 12.5019 13.7872 13.7882 12.5009 13.7882H3.49719C3.49719 13.7882 2.21094 13.7882 2.21094 12.5019V3.49816C2.21094 3.49816 2.21094 2.21191 3.49719 2.21191Z" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M2.21094 8H13.7872" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M8 2.21191V13.7882" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
+</g>
+<defs>
+<clipPath id="clip0_3551_49501">
+<rect width="14" height="14" fill="white" transform="translate(1 1)"/>
+</clipPath>
+</defs>
+</svg>
diff --git a/frontend/resources/flowy_icons/16x/ai_text.svg b/frontend/resources/flowy_icons/16x/ai_text.svg
new file mode 100644
index 0000000000..0198b267b8
--- /dev/null
+++ b/frontend/resources/flowy_icons/16x/ai_text.svg
@@ -0,0 +1,5 @@
+<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M2.375 4.25H13.625" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M2.375 8H13.625" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
+<path d="M2.375 11.75H13.625" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
+</svg>
diff --git a/frontend/resources/flowy_icons/16x/ai_text_image.svg b/frontend/resources/flowy_icons/16x/ai_text_image.svg
new file mode 100644
index 0000000000..166048108f
--- /dev/null
+++ b/frontend/resources/flowy_icons/16x/ai_text_image.svg
@@ -0,0 +1,15 @@
+<svg width="22" height="16" viewBox="0 0 22 16" fill="none" xmlns="http://www.w3.org/2000/svg">
+<g clip-path="url(#clip0_3551_49505)">
+<path d="M1.49414 7.99955C1.49414 5.38076 1.49414 4.07142 2.30766 3.25785C3.12122 2.44434 4.43057 2.44434 7.04935 2.44434C9.66809 2.44434 10.9775 2.44434 11.791 3.25785C12.6046 4.07142 12.6046 5.38076 12.6046 7.99955C12.6046 10.6183 12.6046 11.9277 11.791 12.7412C10.9775 13.5548 9.66809 13.5548 7.04935 13.5548C4.43057 13.5548 3.12122 13.5548 2.30766 12.7412C1.49414 11.9277 1.49414 10.6183 1.49414 7.99955Z" stroke="black"/>
+<path d="M8.16211 5.77817C8.16028 6.63343 9.08501 7.16999 9.82662 6.74393C10.1723 6.54533 10.3851 6.17681 10.3842 5.77817C10.386 4.92286 9.4613 4.38636 8.71969 4.81242C8.37402 5.01097 8.16125 5.37954 8.16211 5.77817Z" fill="black" stroke="black" stroke-width="0.2"/>
+<path d="M1.49414 8.27689L2.46716 7.42549C2.9734 6.98257 3.73639 7.00796 4.212 7.48358L6.59507 9.86664C6.97679 10.2484 7.57779 10.3005 8.01953 9.98999L8.18518 9.8736C8.82081 9.42688 9.68084 9.47863 10.2583 9.99837L12.0491 11.61" stroke="black" stroke-linecap="round"/>
+</g>
+<path d="M21.4512 3.51465H14.5488" stroke="black" stroke-linecap="round"/>
+<path d="M19.3805 8H14.5488" stroke="black" stroke-linecap="round"/>
+<path d="M18 12.4854H14.5488" stroke="black" stroke-linecap="round"/>
+<defs>
+<clipPath id="clip0_3551_49505">
+<rect width="13" height="13" fill="white" transform="translate(0.548828 1.5)"/>
+</clipPath>
+</defs>
+</svg>
diff --git a/frontend/resources/flowy_icons/16x/ai_undo.svg b/frontend/resources/flowy_icons/16x/ai_undo.svg
new file mode 100644
index 0000000000..c3f51de34d
--- /dev/null
+++ b/frontend/resources/flowy_icons/16x/ai_undo.svg
@@ -0,0 +1,3 @@
+<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M1.2793 5.06004H10.5193C12.8389 5.06004 14.7193 6.94041 14.7193 9.26004C14.7193 11.5796 12.8389 13.46 10.5193 13.46H4.6393M1.2793 5.06004L3.7993 2.54004M1.2793 5.06004L3.7993 7.58004" stroke="black" stroke-linecap="round" stroke-linejoin="round"/>
+</svg>
diff --git a/frontend/resources/flowy_icons/16x/chat_feather.svg b/frontend/resources/flowy_icons/16x/chat_feather.svg
deleted file mode 100644
index 7a960957c0..0000000000
--- a/frontend/resources/flowy_icons/16x/chat_feather.svg
+++ /dev/null
@@ -1 +0,0 @@
-<svg xmlns="http://www.w3.org/2000/svg" viewBox="-0.5 -0.5 16 16" fill="none" stroke="#f254bc" stroke-linecap="round" stroke-linejoin="round" id="Feather--Streamline-Lucide.svg" height="16" width="16"><desc>Feather Streamline Icon: https://streamlinehq.com</desc><path d="M7.91875 11.875a1.25 1.25 0 0 0 0.885 -0.3675l3.84625 -3.8575a3.75 3.75 0 0 0 -5.30625 -5.30625L3.49125 6.19625A1.25 1.25 0 0 0 3.125 7.08V11.25a0.625 0.625 0 0 0 0.625 0.625z" stroke-width="1"></path><path d="M10 5 1.25 13.75" stroke-width="1"></path><path d="M10.9375 9.375H5.625" stroke-width="1"></path></svg>
\ No newline at end of file
diff --git a/frontend/resources/flowy_icons/16x/chat_lightbulb.svg b/frontend/resources/flowy_icons/16x/chat_lightbulb.svg
deleted file mode 100644
index dc5d1806e4..0000000000
--- a/frontend/resources/flowy_icons/16x/chat_lightbulb.svg
+++ /dev/null
@@ -1 +0,0 @@
-<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 16 16" id="Lightbulb--Streamline-Flex.svg" height="16" width="16"><desc>Lightbulb Streamline Icon: https://streamlinehq.com</desc><g id="lightbulb--lighting-light-incandescent-bulb-lights"><path id="Vector" stroke="#a44afd" stroke-linecap="round" stroke-linejoin="round" d="M13.284685714285715 5.819314285714285c0.006171428571428572 -0.8796571428571429 -0.2233142857142857 -1.7449142857142856 -0.6645714285714286 -2.505931428571428 -0.44125714285714285 -0.7610171428571428 -1.0781714285714286 -1.3900571428571427 -1.8445942857142856 -1.8218171428571428C10.009074285714284 1.0598102857142857 9.141039999999998 0.8410719999999999 8.261531428571429 0.858062857142857c-0.87952 0.016989714285714285 -1.7384571428571427 0.26909028571428567 -2.487645714285714 0.7301314285714285 -0.7491885714285714 0.46103999999999995 -1.3613142857142855 1.1142057142857142 -1.772822857142857 1.8916914285714284 -0.41152 0.7774971428571428 -0.6074285714285713 1.6509714285714285 -0.5673828571428571 2.5297371428571425 0.04004571428571429 0.8787657142857143 0.3145828571428571 1.7308 0.7950971428571428 2.467645714285714 0.85808 1.3157942857142855 1.366102857142857 1.7994742857142856 1.366102857142857 3.36536 0 0.14514285714285713 0.05769142857142857 0.28445714285714285 0.16037714285714286 0.3872 0.10269714285714285 0.10262857142857143 0.24197714285714284 0.16034285714285715 0.3872 0.16034285714285715H10.570742857142855c0.14522285714285713 0 0.2845028571428571 -0.05771428571428572 0.3871885714285714 -0.16034285714285715 0.10268571428571428 -0.10274285714285714 0.16037714285714286 -0.24205714285714283 0.16037714285714286 -0.3872 0 -1.603622857142857 0.5683199999999999 -2.0796571428571426 1.420662857142857 -3.44352 0.48365714285714284 -0.77384 0.7419428571428571 -1.667245714285714 0.7457142857142857 -2.5797942857142857Z" stroke-width="1"></path><path id="Vector_2" stroke="#a44afd" stroke-linecap="round" stroke-linejoin="round" d="m6.853794285714285 15.142857142857142 3.005405714285714 0" stroke-width="1"></path></g></svg>
\ No newline at end of file
diff --git a/frontend/resources/flowy_icons/16x/chat_pen.svg b/frontend/resources/flowy_icons/16x/chat_pen.svg
deleted file mode 100644
index d26493b164..0000000000
--- a/frontend/resources/flowy_icons/16x/chat_pen.svg
+++ /dev/null
@@ -1 +0,0 @@
-<svg xmlns="http://www.w3.org/2000/svg" viewBox="-0.5 -0.5 16 16" fill="none" stroke="#f254bc" stroke-linecap="round" stroke-linejoin="round" id="Pen-Line--Streamline-Lucide.svg" height="16" width="16"><desc>Pen Line Streamline Icon: https://streamlinehq.com</desc><path d="M7.83775 14.08125H14.75675" stroke-width="1"></path><path d="M11.297250000000002 1.3964375000000002C12.1849375 0.5087499999999999 13.70075 0.914875 14.025625 2.1275C14.1764375 2.6903125 14.015562500000001 3.29075 13.603562499999999 3.70275L3.993875 13.312437500000001L0.91875 14.08125L1.6875624999999999 11.006125Z" stroke-width="1"></path></svg>
\ No newline at end of file
diff --git a/frontend/resources/flowy_icons/16x/chat_question.svg b/frontend/resources/flowy_icons/16x/chat_question.svg
deleted file mode 100644
index db16cb1f9d..0000000000
--- a/frontend/resources/flowy_icons/16x/chat_question.svg
+++ /dev/null
@@ -1 +0,0 @@
-<svg xmlns="http://www.w3.org/2000/svg" viewBox="-0.5 -0.5 16 16" fill="none" stroke="#00c8ff" stroke-linecap="round" stroke-linejoin="round" id="Message-Circle-Question--Streamline-Lucide.svg" height="16" width="16"><desc>Message Circle Question Streamline Icon: https://streamlinehq.com</desc><path d="M4.9781875 12.750812499999999C9.291625 14.9635 14.382874999999999 11.677 14.1424375 6.835062499999999C13.901937499999999 1.993125 8.510124999999999 -0.7728124999999999 4.437125 1.8564375C1.718 3.6116875 0.772 7.1421875 2.2491875 10.0218125L0.84975 14.15025Z" stroke-width="1"></path><path d="M5.810874999999999 5.0536875000000006C6.347125 3.5293124999999996 8.3325 3.1570625000000003 9.3845 4.3836875C9.711625 4.765 9.8910625 5.2510625 9.8903125 5.7534375C9.8903125 7.152937499999999 7.791125 7.852625 7.791125 7.852625" stroke-width="1"></path><path d="M7.847062500000001 10.6515625H7.8540624999999995" stroke-width="1"></path></svg>
\ No newline at end of file
diff --git a/frontend/resources/flowy_icons/16x/chat_scholar.svg b/frontend/resources/flowy_icons/16x/chat_scholar.svg
deleted file mode 100644
index 49fb435836..0000000000
--- a/frontend/resources/flowy_icons/16x/chat_scholar.svg
+++ /dev/null
@@ -1,3 +0,0 @@
-<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="-0.5 -0.5 16 16" height="16" width="16" id="School--Streamline-Rounded----Material-Symbols.svg">
- <path fill="#ffba00" d="M3.437625 10.906312499999999C3.2917812499999997 10.82296875 3.1745937499999997 10.70903125 3.0860593749999996 10.564437499999999C2.9975187500000002 10.419968749999999 2.953246875 10.257875 2.953246875 10.0781875V6.8906875L1.3907468749999998 6.0313125C1.3074125 5.97921875 1.2449124999999999 5.9191875000000005 1.203246875 5.851156250000001C1.16158125 5.78325 1.140746875 5.707718750000001 1.140746875 5.62459375C1.140746875 5.5415625 1.16158125 5.46621875 1.203246875 5.3985C1.2449124999999999 5.330781249999999 1.3074125 5.27090625 1.3907468749999998 5.218812499999999L7.031375 2.1250625000000003C7.10428125 2.08339375 7.1783125000000005 2.05475 7.253406249999999 2.039125C7.3284062500000005 2.0235 7.4054375 2.0156875 7.4845 2.0156875C7.5635625 2.0156875 7.64059375 2.0235 7.71559375 2.039125C7.7906875 2.05475 7.864718750000001 2.08339375 7.937625000000001 2.1250625000000003L14.125125 5.4844375C14.208468750000002 5.5365312499999995 14.27096875 5.598875 14.312625 5.671468750000001C14.35428125 5.7439687500000005 14.375125 5.82225 14.375125 5.9063125V10.1094375C14.375125 10.242249999999999 14.32990625 10.353562499999999 14.2395 10.44334375C14.1491875 10.53325 14.037218750000001 10.5781875 13.9035625 10.5781875C13.77003125 10.5781875 13.65896875 10.53325 13.5704375 10.44334375C13.48190625 10.353562499999999 13.437625 10.242249999999999 13.437625 10.1094375V6.1719375L12.01575 6.8906875V10.0781875C12.01575 10.257875 11.97146875 10.419968749999999 11.882937499999999 10.564437499999999C11.79440625 10.70903125 11.67721875 10.82296875 11.531374999999999 10.906312499999999L7.937625000000001 12.8750625C7.864718750000001 12.916718750000001 7.7906875 12.945374999999999 7.71559375 12.961C7.64059375 12.976624999999999 7.5635625 12.984437499999999 7.4845 12.984437499999999C7.4054375 12.984437499999999 7.3284062500000005 12.976624999999999 7.253406249999999 12.961C7.1783125000000005 12.945374999999999 7.10428125 12.916718750000001 7.031375 12.8750625L3.437625 10.906312499999999ZM7.4845 8.3125625L12.406375 5.6250625L7.4845 2.9844375000000003L2.593871875 5.6250625L7.4845 8.3125625ZM7.4845 12.0625625L11.07825 10.0781875V7.4531875L7.937625000000001 9.1406875C7.864718750000001 9.182343750000001 7.7917812500000005 9.211 7.718875 9.226625C7.64596875 9.24225 7.56784375 9.2500625 7.4845 9.2500625C7.4011562500000005 9.2500625 7.32565625 9.24225 7.257937500000001 9.226625C7.1902187500000005 9.211 7.11990625 9.182343750000001 7.047 9.1406875L3.89075 7.4219375V10.0781875L7.4845 12.0625625Z" stroke-width="1"></path>
-</svg>
\ No newline at end of file
diff --git a/frontend/resources/flowy_icons/16x/file_md.svg b/frontend/resources/flowy_icons/16x/file_md.svg
deleted file mode 100644
index 0414453c10..0000000000
--- a/frontend/resources/flowy_icons/16x/file_md.svg
+++ /dev/null
@@ -1 +0,0 @@
-<svg xmlns="http://www.w3.org/2000/svg" viewBox="-0.5 -0.5 16 16" fill="currentColor" id="File-Md-Light--Streamline-Phosphor.svg" height="16" width="16"><desc>File Md Light Streamline Icon: https://streamlinehq.com</desc><path d="m13.858470703125 4.312119140625001 -4.03529296875 -4.03529296875c-0.081005859375 -0.08110546875 -0.19090429687500002 -0.1267265625 -0.30553125000000003 -0.126826171875H2.599998046875c-0.55715625 0 -1.0088203125 0.4516640625 -1.0088203125 1.0088203125v5.188236328125c0 0.332830078125 0.36029296875 0.54084375 0.64852734375 0.374431640625 0.13376953125 -0.077232421875 0.21617578125 -0.219966796875 0.21617578125 -0.374431640625V1.158826171875c0 -0.079599609375 0.0645234375 -0.14412304687500002 0.1441171875 -0.14412304687500002h6.485296875v3.6029414062500003c0 0.23878710937500003 0.19357031249999998 0.432357421875 0.4323515625 0.432357421875h3.6029414062500003v9.367646484375001c0 0.33282421875 0.36029296875 0.540837890625 0.6485332031250001 0.37442578125000003 0.13376953125 -0.077232421875 0.21617578125 -0.2199609375 0.21617578125 -0.37442578125000003V4.61764453125c-0.00010546875 -0.114626953125 -0.045720703125 -0.22452539062500002 -0.126826171875 -0.305525390625Zm-3.90847265625 -2.686353515625L12.50953125 4.18529296875h-2.559533203125Zm-1.0088203125 7.171294921875h-1.152943359375c-0.23878710937500003 -0.00001171875 -0.4323515625 0.19355859375 -0.4323515625 0.4323515625v4.03529296875c0 0.23878124999999997 0.19357031249999998 0.4323515625 0.4323515625 0.4323515625h1.152943359375c1.886009765625 0 3.064763671875 -2.0416640625 2.1217617187499997 -3.675 -0.4376484375 -0.758033203125 -1.2464648437499999 -1.22499609375 -2.1217617187499997 -1.22499609375Zm0 4.03529296875H8.220585937500001v-3.17058984375h0.720591796875c1.220361328125 0.000744140625 1.982279296875 1.32228515625 1.3714570312499998 2.37877734375 -0.28313671875 0.48972070312500005 -0.8057753906249999 0.791466796875 -1.3714570312499998 0.7918125Zm-3.02647265625 -3.6029414062500003v4.03529296875c0 0.33282421875 -0.36029296875 0.54084375 -0.64852734375 0.374431640625 -0.13376953125 -0.077232421875 -0.21617578125 -0.219966796875 -0.21617578125 -0.374431640625v-2.666173828125L3.819234375 12.359648437499999c-0.172072265625 0.24651562500000002 -0.53698828125 0.24651562500000002 -0.709060546875 0l-1.23076171875 -1.7611171875v2.666173828125c0 0.33282421875 -0.36029296875 0.54084375 -0.64852734375 0.374431640625 -0.13377539062500002 -0.077232421875 -0.21618164062499998 -0.219966796875 -0.21618164062499998 -0.374431640625v-4.03529296875c-0.00032226562499999996 -0.33282421875 0.359771484375 -0.541189453125 0.648169921875 -0.37505859375 0.055013671874999996 0.031693359375 0.10237500000000001 0.075111328125 0.13871484374999998 0.12717773437500002l1.663119140625 2.377939453125 1.66311328125 -2.377939453125c0.1905 -0.27291796875 0.604998046875 -0.237275390625 0.746103515625 0.06416015625 0.026923828125 0.05750390625 0.040845703125 0.12022851562499999 0.04078125 0.183720703125Z" stroke-width="1"></path></svg>
\ No newline at end of file
diff --git a/frontend/resources/flowy_icons/16x/file_pdf.svg b/frontend/resources/flowy_icons/16x/file_pdf.svg
deleted file mode 100644
index 04684dc74a..0000000000
--- a/frontend/resources/flowy_icons/16x/file_pdf.svg
+++ /dev/null
@@ -1 +0,0 @@
-<svg xmlns="http://www.w3.org/2000/svg" viewBox="-0.5 -0.5 16 16" fill="currentColor" id="File-Pdf-Light--Streamline-Phosphor.svg" height="16" width="16"><desc>File Pdf Light Streamline Icon: https://streamlinehq.com</desc><path d="M14.537232421875 10.00212890625c0 0.259095703125 -0.21005273437500002 0.46913671875 -0.4691484375 0.4691484375h-2.03298046875v1.56383203125h1.407451171875c0.3611484375 0 0.5868691406250001 0.39095507812499997 0.406294921875 0.70372265625 -0.083806640625 0.145154296875 -0.2386875 0.23457421875 -0.406294921875 0.23457421875h-1.407451171875v1.4074453125c0 0.3611484375 -0.39095507812499997 0.5868691406250001 -0.70372265625 0.406294921875 -0.145154296875 -0.083806640625 -0.23457421875 -0.238681640625 -0.23457421875 -0.406294921875V10.00212890625c0 -0.2591015625 0.210046875 -0.4691484375 0.4691484375 -0.4691484375h2.5021289062500003c0.259107421875 0 0.4691484375 0.210046875 0.4691484375 0.4691484375ZM4.215955078125 11.565955078125c0 1.12278515625 -0.9101953125000001 2.03298046875 -2.032974609375 2.03298046875H1.401064453125v0.781916015625c0 0.3611484375 -0.39095507812499997 0.5868691406250001 -0.70372265625 0.406294921875 -0.145154296875 -0.083806640625 -0.23457421875 -0.238681640625 -0.23457421875 -0.406294921875V10.00212890625c0 -0.259107421875 0.21004101562500002 -0.4691484375 0.4691484375 -0.4691484375h1.2510644531250001c1.122744140625 0.000046875 2.032974609375 0.9102304687499999 2.032974609375 2.032974609375Zm-0.938296875 0c0 -0.604552734375 -0.49012500000000003 -1.0946484374999998 -1.094677734375 -1.094677734375H1.401064453125v2.189361328125h0.781916015625c0.604552734375 -0.000029296875 1.094677734375 -0.49012500000000003 1.094677734375 -1.094677734375Zm6.568083984375 0.62553515625c0 1.46820703125 -1.190296875 2.6584453125 -2.658509765625 2.658509765625h-1.2510644531250001c-0.259107421875 0.00001171875 -0.4691484375 -0.21003515625 -0.4691484375 -0.4691484375V10.00212890625c0 -0.259107421875 0.210046875 -0.4691484375 0.4691484375 -0.4691484375h1.2510644531250001c1.46825390625 0 2.658509765625 1.1902558593750001 2.658509765625 2.658509765625Zm-0.938296875 0c0 -0.950015625 -0.77019140625 -1.7201718750000001 -1.720212890625 -1.720212890625h-0.781916015625v3.44042578125h0.781916015625c0.950021484375 -0.000041015625 1.720212890625 -0.770197265625 1.720212890625 -1.720212890625ZM0.462767578125 6.874470703125V1.24468359375c0 -0.604576171875 0.4901015625 -1.0946835937500001 1.094677734375 -1.0946835937500001h7.506386718750001c0.12465234375 -0.000099609375 0.24421875 0.04941796875 0.33230859375 0.137619140625l4.378728515625 4.37872265625c0.08772070312500001 0.088025390625 0.13693359375 0.2072578125 0.136833984375 0.331529296875v1.876599609375c0 0.3611484375 -0.3909609375 0.5868691406250001 -0.70372265625 0.406294921875 -0.145154296875 -0.083806640625 -0.23457421875 -0.2386875 -0.23457421875 -0.406294921875V5.46701953125h-3.90957421875c-0.259107421875 0 -0.4691484375 -0.21004101562500002 -0.4691484375 -0.4691484375V1.088296875H1.5574453125c-0.0863671875 0 -0.156380859375 0.070013671875 -0.156380859375 0.15638671875000001v5.629787109375c0 0.3611484375 -0.3909609375 0.5868691406250001 -0.70372265625 0.406294921875 -0.145154296875 -0.083806640625 -0.23457421875 -0.2386875 -0.23457421875 -0.406294921875Zm9.070212890625001 -2.3457480468750003h2.777361328125l-2.777361328125 -2.777361328125Z" stroke-width="1"></path></svg>
\ No newline at end of file
diff --git a/frontend/resources/flowy_icons/16x/file_txt.svg b/frontend/resources/flowy_icons/16x/file_txt.svg
deleted file mode 100644
index 27c5aec523..0000000000
--- a/frontend/resources/flowy_icons/16x/file_txt.svg
+++ /dev/null
@@ -1 +0,0 @@
-<svg xmlns="http://www.w3.org/2000/svg" viewBox="-0.5 -0.5 16 16" fill="currentColor" id="File-Txt-Light--Streamline-Phosphor.svg" height="16" width="16"><desc>File Txt Light Streamline Icon: https://streamlinehq.com</desc><path d="M1.245193359375 7.34302734375c0.25908984375 0.00001171875 0.46911328124999996 -0.210017578125 0.46911328124999996 -0.46911328124999996V1.24458984375c0 -0.086361328125 0.0700078125 -0.15636914062499999 0.15636914062499999 -0.15636914062499999h7.036658203125v3.909251953125c0 0.25908984375 0.210017578125 0.46912499999999996 0.469107421875 0.46911328124999996h3.909251953125v1.407328125c0 0.361125 0.39092578125 0.5868222656250001 0.703669921875 0.406265625 0.145142578125 -0.08380078125 0.23455078125 -0.2386640625 0.23455078125 -0.406265625V4.99747265625c-0.00010546875 -0.12437109375 -0.04960546875 -0.24360937500000002 -0.1376015625 -0.331505859375l-4.378365234375001 -4.3783593750000005c-0.087890625 -0.088001953125 -0.207134765625 -0.13749609375 -0.331505859375 -0.137607421875H1.8706757812500001c-0.604529296875 0 -1.0945898437500001 0.49006640625 -1.0945898437500001 1.0945898437500001v5.62932421875c0 0.25908984375 0.210017578125 0.46912499999999996 0.469107421875 0.46911328124999996Zm8.600361328125 -5.5917949218750005 2.7771328125 2.7771328125h-2.7771328125Zm-0.4003125 8.522167968749999 -1.36901953125 1.917099609375 1.36901953125 1.916314453125c0.21065625000000002 0.293712890625 0.02436328125 0.705322265625 -0.335326171875 0.740900390625 -0.16693359375 0.01651171875 -0.329994140625 -0.05729296875 -0.4277578125 -0.19360546874999998L7.5 12.997371093749999l-1.182158203125 1.6551796875c-0.21065625000000002 0.29370703125 -0.660263671875 0.249240234375 -0.809302734375 -0.08005078125000001 -0.0691640625 -0.152818359375 -0.051550781250000004 -0.3309375 0.046218749999999996 -0.46725l1.36901953125 -1.9147500000000002 -1.36901953125 -1.916314453125c-0.21065625000000002 -0.293712890625 -0.02436328125 -0.705322265625 0.335326171875 -0.740900390625 0.16693359375 -0.01651171875 0.329994140625 0.05729296875 0.4277578125 0.19360546874999998L7.5 11.38362890625l1.182158203125 -1.6551738281250001c0.21065625000000002 -0.293712890625 0.660263671875 -0.24924609375 0.809302734375 0.08004492187500001 0.0691640625 0.152818359375 0.051550781250000004 0.3309375 -0.046218749999999996 0.46725Zm-4.9162734375 -0.272080078125c0 0.259072265625 -0.21003515625 0.46909570312500004 -0.46911328124999996 0.469107421875h-1.0945898437500001v3.909251953125c0 0.361125 -0.39092578125 0.5868222656250001 -0.7036640625 0.406265625 -0.145142578125 -0.08380078125 -0.23455664062499998 -0.2386640625 -0.23455664062499998 -0.406265625v-3.909251953125h-1.0945898437500001c-0.361125 0 -0.5868222656250001 -0.39092578125 -0.40625976562500005 -0.7036640625 0.08380078125 -0.1451484375 0.23865234375000002 -0.23456249999999998 0.40625976562500005 -0.23455664062499998h3.127400390625c0.259078125 0.00001171875 0.46911328124999996 0.21003515625 0.46911328124999996 0.46911328124999996Zm10.007689453125 0c0 0.259072265625 -0.21003515625 0.46909570312500004 -0.46911328124999996 0.469107421875h-1.0945898437500001v3.909251953125c0 0.361125 -0.39092578125 0.5868222656250001 -0.7036640625 0.406265625 -0.145142578125 -0.08380078125 -0.23455664062499998 -0.2386640625 -0.23455664062499998 -0.406265625v-3.909251953125h-1.0945898437500001c-0.361125 0 -0.5868222656250001 -0.39092578125 -0.40625976562500005 -0.7036640625 0.08380078125 -0.1451484375 0.23865234375000002 -0.23456249999999998 0.40625976562500005 -0.23455664062499998h3.127400390625c0.259078125 0.00001171875 0.46911328124999996 0.21003515625 0.46911328124999996 0.46911328124999996Z" stroke-width="1"></path></svg>
\ No newline at end of file
diff --git a/frontend/resources/flowy_icons/16x/file_unknown.svg b/frontend/resources/flowy_icons/16x/file_unknown.svg
deleted file mode 100644
index cc4225f5f0..0000000000
--- a/frontend/resources/flowy_icons/16x/file_unknown.svg
+++ /dev/null
@@ -1 +0,0 @@
-<svg xmlns="http://www.w3.org/2000/svg" viewBox="-0.5 -0.5 16 16" fill="currentColor" id="File-X-Light--Streamline-Phosphor.svg" height="16" width="16"><desc>File X Light Streamline Icon: https://streamlinehq.com</desc><path d="m13.570236328125 4.312119140625001 -4.03529296875 -4.03529296875c-0.081005859375 -0.08110546875 -0.19090429687500002 -0.1267265625 -0.30553125000000003 -0.126826171875H2.3117636718749996c-0.55715625 0 -1.0088203125 0.4516640625 -1.0088203125 1.0088203125v12.682353515625001c0 0.557162109375 0.4516640625 1.008826171875 1.0088203125 1.008826171875h10.37647265625c0.55715625 0 1.0088203125 -0.4516640625 1.0088203125 -1.008826171875V4.61764453125c-0.000099609375 -0.114626953125 -0.04571484375 -0.22452539062500002 -0.1268203125 -0.305525390625Zm-3.90847265625 -2.686353515625 2.55952734375 2.55952734375h-2.55952734375Zm3.17058984375 12.215408203125001c0 0.07959375 -0.064529296875 0.1441171875 -0.1441171875 0.14412304687500002H2.3117636718749996c-0.07959375 0 -0.1441171875 -0.0645234375 -0.1441171875 -0.14412304687500002V1.158826171875c0 -0.079599609375 0.0645234375 -0.14412304687500002 0.1441171875 -0.14412304687500002h6.485296875v3.6029414062500003c0 0.23878710937500003 0.19357031249999998 0.432357421875 0.4323515625 0.432357421875h3.6029414062500003Zm-3.29741015625 -6.646705078125c0.1685859375 0.168802734375 0.1685859375 0.442259765625 0 0.6110625000000001l-1.423166015625 1.4238808593749999 1.423166015625 1.4238808593749999c0.24349218749999998 0.2268984375 0.150046875 0.632302734375 -0.16819921875 0.7297265625 -0.15816796875 0.048416015625 -0.33009375 0.0023496093749999997 -0.44286328125 -0.1186640625L7.5 9.841189453125l-1.4238808593749999 1.423166015625c-0.243498046875 0.2268984375 -0.6413027343750001 0.1051171875 -0.7160566406250001 -0.21920507812499998 -0.03226171875 -0.139951171875 0.007083984375 -0.28678125 0.10499414062500001 -0.391857421875l1.423166015625 -1.4238808593749999 -1.423166015625 -1.4238808593749999c-0.24349218749999998 -0.226904296875 -0.150046875 -0.632302734375 0.16819921875 -0.7297265625 0.15816796875 -0.048416015625 0.33009375 -0.0023496093749999997 0.44286328125 0.1186640625L7.5 8.617634765624999l1.4238808593749999 -1.423166015625c0.168802734375 -0.168591796875 0.442259765625 -0.168591796875 0.6110625000000001 0Z" stroke-width="1"></path></svg>
\ No newline at end of file
diff --git a/frontend/resources/flowy_icons/16x/warning_filled.svg b/frontend/resources/flowy_icons/16x/warning_filled.svg
new file mode 100644
index 0000000000..b9b65cc1d7
--- /dev/null
+++ b/frontend/resources/flowy_icons/16x/warning_filled.svg
@@ -0,0 +1,5 @@
+<svg width="16" height="17" viewBox="0 0 16 17" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M15.3327 8.12533C15.3327 12.1754 12.0494 15.4587 7.99935 15.4587C3.94926 15.4587 0.666016 12.1754 0.666016 8.12533C0.666016 4.07524 3.94926 0.791992 7.99935 0.791992C12.0494 0.791992 15.3327 4.07524 15.3327 8.12533Z" fill="#FB006D"/>
+<path d="M8.00065 4.79199C7.63246 4.79199 7.33398 5.09047 7.33398 5.45866V8.79199C7.33398 9.16018 7.63246 9.45866 8.00065 9.45866C8.36884 9.45866 8.66732 9.16018 8.66732 8.79199V5.45866C8.66732 5.09047 8.36884 4.79199 8.00065 4.79199Z" fill="white"/>
+<path d="M8.00065 10.1253C7.63246 10.1253 7.33398 10.4238 7.33398 10.792C7.33398 11.1602 7.63246 11.4587 8.00065 11.4587C8.36884 11.4587 8.66732 11.1602 8.66732 10.792C8.66732 10.4238 8.36884 10.1253 8.00065 10.1253Z" fill="white"/>
+</svg>
diff --git a/frontend/resources/translations/ar-SA.json b/frontend/resources/translations/ar-SA.json
index b3546eb033..d760fb8014 100644
--- a/frontend/resources/translations/ar-SA.json
+++ b/frontend/resources/translations/ar-SA.json
@@ -691,9 +691,7 @@
"createNew": "إنشاء جديد",
"orSelectOne": "أو حدد خيارًا",
"typeANewOption": "اكتب خيارًا جديدًا",
- "tagName": "اسم العلامة",
- "colorPannelTitle": "لوحة الالوان",
- "pannelTitle": "لوحة الخيارات"
+ "tagName": "اسم العلامة"
},
"checklist": {
"taskHint": "وصف المهمة",
diff --git a/frontend/resources/translations/de-DE.json b/frontend/resources/translations/de-DE.json
index a7211b4fda..c722447891 100644
--- a/frontend/resources/translations/de-DE.json
+++ b/frontend/resources/translations/de-DE.json
@@ -190,11 +190,13 @@
"chatWithFilePrompt": "Möchtest du mit der Datei chatten?",
"indexFileSuccess": "Datei erfolgreich indiziert",
"inputActionNoPages": "Keine Seitenergebnisse",
- "referenceSource": "{} Quelle gefunden",
- "referenceSources": "{} Quellen gefunden",
+ "referenceSource": {
+ "zero": "0 Quellen gefunden",
+ "one": "{count} Quelle gefunden",
+ "other": "{count} Quellen gefunden"
+ },
"clickToMention": "Klicke hier, um eine Seite zu erwähnen",
"uploadFile": "Lade PDF-, md- oder txt-Dateien in den Chat hoch",
- "questionTitle": "Ideen",
"questionDetail": "Hallo {}! Wie kann ich dir heute helfen?",
"indexingFile": "Indizierung {}"
},
diff --git a/frontend/resources/translations/en.json b/frontend/resources/translations/en.json
index f1e3131865..c23c8e82a6 100644
--- a/frontend/resources/translations/en.json
+++ b/frontend/resources/translations/en.json
@@ -178,26 +178,32 @@
"inputMessageHint": "Ask @:appName AI",
"inputLocalAIMessageHint": "Ask @:appName Local AI",
"unsupportedCloudPrompt": "This feature is only available when using @:appName Cloud",
- "relatedQuestion": "Related",
+ "relatedQuestion": "Suggested",
"serverUnavailable": "Service Temporarily Unavailable. Please try again later.",
- "aiServerUnavailable": "🌈 Uh-oh! 🌈. A unicorn ate our response. Please retry!",
+ "aiServerUnavailable": "Connection lost. Please check your internet and",
+ "retry": "Retry",
"clickToRetry": "Click to retry",
"regenerateAnswer": "Regenerate",
"question1": "How to use Kanban to manage tasks",
"question2": "Explain the GTD method",
"question3": "Why use Rust",
"question4": "Recipe with what's in my kitchen",
+ "question5": "Create an illustration for my page",
+ "question6": "Draw up a to-do list for my upcoming week",
"aiMistakePrompt": "AI can make mistakes. Check important info.",
"chatWithFilePrompt": "Do you want to chat with the file?",
"indexFileSuccess": "Indexing file successfully",
"inputActionNoPages": "No page results",
- "referenceSource": "{} source found",
- "referenceSources": "{} sources found",
- "clickToMention": "Click to mention a page",
- "uploadFile": "Upload PDFs, md or txt files to chat with",
- "questionTitle": "Ideas",
+ "referenceSource": {
+ "zero": "0 sources gefunden",
+ "one": "{count} source found",
+ "other": "{count} sources found"
+ },
+ "clickToMention": "Mention a page",
+ "uploadFile": "Attach PDFs, text or markdown files",
"questionDetail": "Hi {}! How can I help you today?",
- "indexingFile": "Indexing {}"
+ "indexingFile": "Indexing {}",
+ "generatingResponse": "Generating response"
},
"trash": {
"text": "Trash",
@@ -328,7 +334,7 @@
"aiResponseLimit": "You have run out of free AI responses.\n\nGo to Settings -> Plan -> Click AI Max or Pro Plan to get more AI responses",
"askOwnerToUpgradeToPro": "Your workspace is running out of free storage. Please ask your workspace owner to upgrade to the Pro Plan",
"askOwnerToUpgradeToProIOS": "Your workspace is running out of free storage.",
- "askOwnerToUpgradeToAIMax": "Your workspace is running out of free AI responses. Please ask your workspace owner to upgrade the plan or purchase AI add-ons",
+ "askOwnerToUpgradeToAIMax": "Your workspace has ran out of free AI responses. Please ask your workspace owner to upgrade the plan or purchase AI add-ons",
"askOwnerToUpgradeToAIMaxIOS": "Your workspace is running out of free AI responses.",
"purchaseStorageSpace": "Purchase Storage Space",
"purchaseAIResponse": "Purchase ",
@@ -368,6 +374,7 @@
"upload": "Upload",
"edit": "Edit",
"delete": "Delete",
+ "copy": "Copy",
"duplicate": "Duplicate",
"putback": "Put Back",
"update": "Update",
@@ -1036,7 +1043,7 @@
"cloudAppFlowy": "@:appName Cloud",
"cloudAppFlowySelfHost": "@:appName Cloud Self-hosted",
"appFlowyCloudUrlCanNotBeEmpty": "The cloud url can't be empty",
- "clickToCopy": "Click to copy",
+ "clickToCopy": "Copy to clipboard",
"selfHostStart": "If you don't have a server, please refer to the",
"selfHostContent": "document",
"selfHostEnd": "for guidance on how to self-host your own server",
diff --git a/frontend/resources/translations/fr-FR.json b/frontend/resources/translations/fr-FR.json
index 0089ccab54..372f7fa0c8 100644
--- a/frontend/resources/translations/fr-FR.json
+++ b/frontend/resources/translations/fr-FR.json
@@ -182,12 +182,14 @@
"chatWithFilePrompt": "Voulez-vous discuter avec le fichier ?",
"indexFileSuccess": "Indexation du fichier réussie",
"inputActionNoPages": "Aucun résultat de page",
- "referenceSource": "{} source trouvée",
- "referenceSources": "{} sources trouvées",
+ "referenceSource": {
+ "zero": "0 sources trouvées",
+ "one": "{count} source trouvée",
+ "other": "{count} sources trouvées"
+ },
"clickToMention": "Cliquez pour mentionner une page",
"uploadFile": "Téléchargez des fichiers PDF, MD ou TXT pour discuter avec",
- "questionTitle": "Idées",
- "questionDetail": "Bonjour {} ! Comment puis-je vous aider aujourd'hui ?",
+ "questionDetail": "Bonjour {}! Comment puis-je vous aider aujourd'hui?",
"indexingFile": "Indexation {}"
},
"trash": {
diff --git a/frontend/resources/translations/it-IT.json b/frontend/resources/translations/it-IT.json
index 2c5a7b065f..d6877ecd59 100644
--- a/frontend/resources/translations/it-IT.json
+++ b/frontend/resources/translations/it-IT.json
@@ -176,11 +176,13 @@
"chatWithFilePrompt": "Vuoi chattare col file?",
"indexFileSuccess": "Indicizzazione file completata con successo",
"inputActionNoPages": "Nessuna pagina risultante",
- "referenceSource": "{} fonte trovata",
- "referenceSources": "{} fonti trovate",
+ "referenceSource": {
+ "zero": "0 fonti trovate",
+ "one": "{count} fonte trovata",
+ "other": "{count} fonti trovate"
+ },
"clickToMention": "Clicca per menzionare una pagina",
"uploadFile": "Carica file PDF, MD o TXT con la quale chattare",
- "questionTitle": "Idee",
"questionDetail": "Salve {}! Come posso aiutarti oggi?",
"indexingFile": "Indicizzazione {}"
},
diff --git a/frontend/resources/translations/ja-JP.json b/frontend/resources/translations/ja-JP.json
index dc8842e195..949f32e2c4 100644
--- a/frontend/resources/translations/ja-JP.json
+++ b/frontend/resources/translations/ja-JP.json
@@ -177,11 +177,11 @@
"chatWithFilePrompt": "ファイルとチャットしますか?",
"indexFileSuccess": "ファイルのインデックス作成が成功しました",
"inputActionNoPages": "ページ結果がありません",
- "referenceSource": "{} 件のソースが見つかりました",
- "referenceSources": "{} 件のソースが見つかりました",
+ "referenceSource": {
+ "other": "{count} 件のソースが見つかりました"
+ },
"clickToMention": "ページをメンションするにはクリック",
"uploadFile": "PDF、md、txtファイルをアップロードしてチャット",
- "questionTitle": "アイデア",
"questionDetail": "こんにちは、{}!今日はどんなお手伝いをしましょうか?",
"indexingFile": "{}をインデックス作成中"
},
diff --git a/frontend/resources/translations/pt-BR.json b/frontend/resources/translations/pt-BR.json
index ce4e53322e..51b585f14b 100644
--- a/frontend/resources/translations/pt-BR.json
+++ b/frontend/resources/translations/pt-BR.json
@@ -180,11 +180,13 @@
"chatWithFilePrompt": "Você quer conversar com o arquivo?",
"indexFileSuccess": "Arquivo indexado com sucesso",
"inputActionNoPages": "Nenhum resultado",
- "referenceSource": "{} fonte encontrada",
- "referenceSources": "{} fontes encontradas",
+ "referenceSource": {
+ "zero": "0 fontes encontradas",
+ "one": "{count} fonte encontrada",
+ "other": "{count} fontes encontradas"
+ },
"clickToMention": "Clique para mencionar uma página",
"uploadFile": "Carregue arquivos PDFs, md ou txt para conversar",
- "questionTitle": "Ideias",
"questionDetail": "Olá {}! Como posso te ajudar hoje?",
"indexingFile": "Indexando {}"
},
@@ -966,9 +968,7 @@
"createNew": "Crie um novo",
"orSelectOne": "Ou selecione uma opção",
"typeANewOption": "Digite uma nova opção",
- "tagName": "Nome da etiqueta",
- "colorPannelTitle": "Cores",
- "pannelTitle": "Escolha uma opção ou crie uma"
+ "tagName": "Nome da etiqueta"
},
"checklist": {
"taskHint": "Descrição da tarefa",
diff --git a/frontend/resources/translations/uk-UA.json b/frontend/resources/translations/uk-UA.json
index 93fa367a03..35b801cb87 100644
--- a/frontend/resources/translations/uk-UA.json
+++ b/frontend/resources/translations/uk-UA.json
@@ -180,11 +180,13 @@
"chatWithFilePrompt": "Хочете поспілкуватися з файлом?",
"indexFileSuccess": "Файл успішно індексується",
"inputActionNoPages": "Сторінка не знайдена",
- "referenceSource": "{} джерело знайдено",
- "referenceSources": "{} джерел знайдено",
+ "referenceSource": {
+ "zero": "0 джерел знайдено",
+ "one": "{count} джерело знайдено",
+ "other": "{count} джерел знайдено"
+ },
"clickToMention": "Натисніть, щоб згадати сторінку",
"uploadFile": "Завантажуйте PDF-файли, файли md або txt для спілкування в чаті",
- "questionTitle": "Ідеї",
"questionDetail": "Привіт {}! Чим я можу тобі допомогти сьогодні?",
"indexingFile": "Індексація {}"
},
diff --git a/frontend/resources/translations/vi-VN.json b/frontend/resources/translations/vi-VN.json
index 924061c921..ea6ceeeca4 100644
--- a/frontend/resources/translations/vi-VN.json
+++ b/frontend/resources/translations/vi-VN.json
@@ -181,11 +181,13 @@
"chatWithFilePrompt": "Bạn có muốn trò chuyện với tập tin không?",
"indexFileSuccess": "Đang lập chỉ mục tệp thành công",
"inputActionNoPages": "Không có kết quả trang",
- "referenceSource": "{} nguồn đã tìm thấy",
- "referenceSources": "{} nguồn được tìm thấy",
+ "referenceSource": {
+ "zero": "0 nguồn được tìm thấy",
+ "one": "{count} nguồn đã tìm thấy",
+ "other": "{count} nguồn được tìm thấy"
+ },
"clickToMention": "Nhấp để đề cập đến một trang",
"uploadFile": "Tải lên các tệp PDF, md hoặc txt để trò chuyện",
- "questionTitle": "Ý tưởng",
"questionDetail": "Xin chào {}! Tôi có thể giúp gì cho bạn hôm nay?",
"indexingFile": "Đang lập chỉ mục {}"
},
diff --git a/frontend/resources/translations/zh-TW.json b/frontend/resources/translations/zh-TW.json
index 5cac15ec1e..fa9626e089 100644
--- a/frontend/resources/translations/zh-TW.json
+++ b/frontend/resources/translations/zh-TW.json
@@ -179,7 +179,6 @@
"aiMistakePrompt": "AI 可能會犯錯,請檢查重要資訊。",
"clickToMention": "單擊以提及頁面",
"uploadFile": "上傳 PDF、md 或 txt 檔案以進行聊天",
- "questionTitle": "想法",
"questionDetail": "{} 你好!我能為您提供什麼幫助?"
},
"trash": {