Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
fix(flutter): some ai chat bugs (#6969)
Richard Shiuee8f2940024e6
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/chat_page.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/chat_page.dartindex 9c6ccc688d..11f772c60a 100644--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/chat_page.dart+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/chat_page.dart@@ -1,6 +1,8 @@+import 'dart:async';import 'dart:io';import 'package:appflowy/generated/locale_keys.g.dart';+import 'package:appflowy/mobile/application/mobile_router.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/ai_prompt_input_bloc.dart';@@ -219,7 +221,8 @@ class _ChatContentPage extends StatelessWidget {chatId: view.id,refSourceJsonString: refSourceJsonString,isLastMessage: isLastMessage,- onSelectedMetadata: _onSelectMetadata,+ onSelectedMetadata: (metadata) =>+ _onSelectMetadata(context, metadata),);},);@@ -320,7 +323,10 @@ class _ChatContentPage extends StatelessWidget {);}- void _onSelectMetadata(ChatMessageRefSource metadata) async {+ void _onSelectMetadata(+ BuildContext context,+ ChatMessageRefSource metadata,+ ) async {if (isURL(metadata.name)) {late Uri uri;try {@@ -335,16 +341,22 @@ class _ChatContentPage extends StatelessWidget {Log.error("failed to open url $err");}} else {- await ViewBackendService.getView(metadata.id).fold(- (sidebarView) {- getIt<TabsBloc>().add(- TabsEvent.openSecondaryPlugin(- plugin: sidebarView.plugin(),- ),- );- },- (err) => Log.error("Failed to get view: $err"),- );+ final sidebarView =+ await ViewBackendService.getView(metadata.id).toNullable();+ if (sidebarView == null) {+ return;+ }+ if (UniversalPlatform.isDesktop) {+ getIt<TabsBloc>().add(+ TabsEvent.openSecondaryPlugin(+ plugin: sidebarView.plugin(),+ ),+ );+ } else {+ if (context.mounted) {+ unawaited(context.pushView(sidebarView));+ }+ }}}}diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/chat_mention_page_menu.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/chat_mention_page_menu.dartindex 14db6e1a1c..10ce04f256 100644--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/chat_mention_page_menu.dart+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/presentation/chat_input/chat_mention_page_menu.dart@@ -6,8 +6,8 @@ import 'package:appflowy/workspace/application/view_title/view_title_bar_bloc.daimport 'package:appflowy/workspace/presentation/home/menu/sidebar/space/space_icon.dart';import 'package:appflowy_backend/protobuf/flowy-folder/protobuf.dart';import 'package:easy_localization/easy_localization.dart' hide TextDirection;-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:scroll_to_index/scroll_to_index.dart';@@ -273,21 +273,18 @@ class _ChatMentionPageItem extends StatelessWidget {child: GestureDetector(onTap: onTap,behavior: HitTestBehavior.opaque,- child: Container(- height: _itemHeight,- decoration: BoxDecoration(- color: isSelected- ? AFThemeExtension.of(context).lightGreyHover- : Colors.transparent,- borderRadius: BorderRadius.circular(4.0),- ),- padding: const EdgeInsets.all(4.0),- child: Row(- children: [- MentionViewIcon(view: view),- const HSpace(8.0),- Expanded(child: MentionViewTitleAndAncestors(view: view)),- ],+ child: FlowyHover(+ isSelected: () => isSelected,+ child: Container(+ height: _itemHeight,+ padding: const EdgeInsets.all(4.0),+ child: Row(+ children: [+ MentionViewIcon(view: view),+ const HSpace(8.0),+ Expanded(child: MentionViewTitleAndAncestors(view: view)),+ ],+ ),),),),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.dartindex 37c97015a8..9da09d8c1e 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@@ -425,9 +425,7 @@ class ChatAIMessagePopup extends StatelessWidget {},);},- child: IgnorePointer(- child: child,- ),+ child: child,);}}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.dartindex 1b58869688..c3c831ac61 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@@ -8,6 +8,7 @@ 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_core/flutter_chat_core.dart';+import 'package:universal_platform/universal_platform.dart';import '../layout_define.dart';import 'ai_markdown_text.dart';@@ -82,7 +83,10 @@ class ChatAIMessageWidget extends StatelessWidget {child: Column(crossAxisAlignment: CrossAxisAlignment.start,children: [- AIMarkdownText(markdown: state.text),+ IgnorePointer(+ ignoring: UniversalPlatform.isMobile,+ child: AIMarkdownText(markdown: state.text),+ ),if (state.sources.isNotEmpty)AIMessageMetadata(sources: state.sources,diff --git a/frontend/appflowy_flutter/pubspec.lock b/frontend/appflowy_flutter/pubspec.lockindex 9e05d06614..6f27fb5484 100644--- a/frontend/appflowy_flutter/pubspec.lock+++ b/frontend/appflowy_flutter/pubspec.lock@@ -318,10 +318,10 @@ packages:dependency: transitivedescription:name: charcode- sha256: fb98c0f6d12c920a02ee2d998da788bca066ca5f148492b7085ee23372b12306+ sha256: fb0f1107cac15a5ea6ef0a6ef71a807b9e4267c713bb93e00e92d737cc8dbd8aurl: "https://pub.dev"source: hosted- version: "1.3.1"+ version: "1.4.0"checked_yaml:dependency: transitivedescription: