Skip to content

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

chore: more ai ui fixes (#6799)

Richard Shiue521d74e08292
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 f3114a8d01..82267b0915 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
@@ -86,7 +86,7 @@ class ChatBloc extends Bloc<ChatEvent, ChatState> {
// Loading messages
startLoadingPrevMessage: () async {
Int64? beforeMessageId;
- final oldestMessage = _getOlderstMessage();
+ final oldestMessage = _getOldestMessage();
if (oldestMessage != null) {
try {
beforeMessageId = Int64.parseInt(oldestMessage.id);
@@ -107,8 +107,7 @@ class ChatBloc extends Bloc<ChatEvent, ChatState> {
Log.debug("did load previous messages: ${messages.length}");
final onetimeMessages = _getOnetimeMessages();
final allMessages = _permanentMessages();
- final uniqueMessages = {...allMessages, ...messages}.toList()
- ..sort((a, b) => b.id.compareTo(a.id));
+ final uniqueMessages = {...allMessages, ...messages}.toList();
uniqueMessages.insertAll(0, onetimeMessages);
@@ -123,8 +122,7 @@ class ChatBloc extends Bloc<ChatEvent, ChatState> {
didLoadLatestMessages: (List<Message> messages) {
final onetimeMessages = _getOnetimeMessages();
final allMessages = _permanentMessages();
- final uniqueMessages = {...allMessages, ...messages}.toList()
- ..sort((a, b) => b.id.compareTo(a.id));
+ final uniqueMessages = {...allMessages, ...messages}.toList();
uniqueMessages.insertAll(0, onetimeMessages);
emit(
state.copyWith(
@@ -351,7 +349,7 @@ class ChatBloc extends Bloc<ChatEvent, ChatState> {
return messages;
}
- Message? _getOlderstMessage() {
+ Message? _getOldestMessage() {
// get the last message that is not a one-time message
final message = state.messages.lastWhereOrNull((element) {
return !(element.metadata?.containsKey(onetimeShotType) == true);
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 0dc51991fb..aae0ba7823 100644
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/chat_page.dart
+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/chat_page.dart
@@ -192,11 +192,13 @@ class _ChatContentPage extends StatelessWidget {
.add(const ChatEvent.startLoadingPrevMessage());
}
},
- emptyState: ChatWelcomePage(
- userProfile: userProfile,
- onSelectedQuestion: (question) => context
- .read<ChatBloc>()
- .add(ChatEvent.sendMessage(message: question)),
+ emptyState: TextFieldTapRegion(
+ child: ChatWelcomePage(
+ userProfile: userProfile,
+ onSelectedQuestion: (question) => context
+ .read<ChatBloc>()
+ .add(ChatEvent.sendMessage(message: question)),
+ ),
),
messageWidthRatio: AIChatUILayout.messageWidthRatio,
textMessageBuilder: (
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
index 230130a1b7..c66dcfc453 100644
--- 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
@@ -124,7 +124,7 @@ class _MobileAIPromptInputState extends State<MobileAIPromptInput> {
child: IntrinsicHeight(
child: Row(
children: [
- const HSpace(6.0),
+ const HSpace(8.0),
Expanded(child: _inputTextField(context)),
_mentionButton(),
const HSpace(6.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 3f7a429c0e..4e414a81bf 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
@@ -106,6 +106,7 @@ class _AppFlowyEditorMarkdownState extends State<_AppFlowyEditorMarkdown> {
shrinkWrap: true,
// the editor is not editable in the chat
editable: false,
+ disableKeyboardService: true,
editorStyle: editorStyle,
editorScrollController: scrollController,
blockComponentBuilders: blockBuilders,