From 8cc7af4107e73ea6ad527f5dc73bbba0e8133014 Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Wed, 8 Jan 2025 11:31:26 +0800 Subject: [PATCH 1/3] chore: enable AI seach --- .../rust-lib/flowy-core/src/deps_resolve/search_deps.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/frontend/rust-lib/flowy-core/src/deps_resolve/search_deps.rs b/frontend/rust-lib/flowy-core/src/deps_resolve/search_deps.rs index e7759768184a4..b31853a8035f9 100644 --- a/frontend/rust-lib/flowy-core/src/deps_resolve/search_deps.rs +++ b/frontend/rust-lib/flowy-core/src/deps_resolve/search_deps.rs @@ -1,4 +1,5 @@ use flowy_folder::manager::FolderManager; +use flowy_search::document::handler::DocumentSearchHandler; use flowy_search::folder::handler::FolderSearchHandler; use flowy_search::folder::indexer::FolderIndexManagerImpl; use flowy_search::services::manager::SearchManager; @@ -9,11 +10,11 @@ pub struct SearchDepsResolver(); impl SearchDepsResolver { pub async fn resolve( folder_indexer: Arc, - _cloud_service: Arc, - _folder_manager: Arc, + cloud_service: Arc, + folder_manager: Arc, ) -> Arc { let folder_handler = Arc::new(FolderSearchHandler::new(folder_indexer)); - // let document_handler = Arc::new(DocumentSearchHandler::new(cloud_service, folder_manager)); - Arc::new(SearchManager::new(vec![folder_handler])) + let document_handler = Arc::new(DocumentSearchHandler::new(cloud_service, folder_manager)); + Arc::new(SearchManager::new(vec![folder_handler, document_handler])) } } From 1160d3d541067d2f16dff128198868100bacdae7 Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Wed, 8 Jan 2025 11:36:41 +0800 Subject: [PATCH 2/3] chore: remove unused code --- .../application/command_palette/command_palette_bloc.dart | 8 ++------ frontend/rust-lib/flowy-search/src/document/handler.rs | 5 +---- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/frontend/appflowy_flutter/lib/workspace/application/command_palette/command_palette_bloc.dart b/frontend/appflowy_flutter/lib/workspace/application/command_palette/command_palette_bloc.dart index 7787525847ba3..21d6a501c5d35 100644 --- a/frontend/appflowy_flutter/lib/workspace/application/command_palette/command_palette_bloc.dart +++ b/frontend/appflowy_flutter/lib/workspace/application/command_palette/command_palette_bloc.dart @@ -1,7 +1,5 @@ import 'dart:async'; -import 'package:flutter/foundation.dart'; - import 'package:appflowy/plugins/trash/application/trash_listener.dart'; import 'package:appflowy/plugins/trash/application/trash_service.dart'; import 'package:appflowy/workspace/application/command_palette/search_listener.dart'; @@ -10,6 +8,7 @@ import 'package:appflowy_backend/protobuf/flowy-folder/trash.pb.dart'; import 'package:appflowy_backend/protobuf/flowy-search/notification.pb.dart'; import 'package:appflowy_backend/protobuf/flowy-search/result.pb.dart'; import 'package:bloc/bloc.dart'; +import 'package:flutter/foundation.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; part 'command_palette_bloc.freezed.dart'; @@ -90,12 +89,9 @@ class CommandPaletteBloc _messagesReceived++; - final searchResults = _filterDuplicates(results.items); - searchResults.sort((a, b) => b.score.compareTo(a.score)); - emit( state.copyWith( - results: searchResults, + results: results.items, isLoading: _messagesReceived != results.sends.toInt(), ), ); diff --git a/frontend/rust-lib/flowy-search/src/document/handler.rs b/frontend/rust-lib/flowy-search/src/document/handler.rs index 3cb499a5cef2b..5fff107b74daf 100644 --- a/frontend/rust-lib/flowy-search/src/document/handler.rs +++ b/frontend/rust-lib/flowy-search/src/document/handler.rs @@ -81,10 +81,7 @@ impl SearchHandler for DocumentSearchHandler { id: result.object_id.clone(), data: view.name.clone(), icon, - // We reverse the score, the cloud search score is based on - // 1 being the worst result, and closer to 0 being good result, that is - // the opposite of local search. - score: 1.0 - result.score, + score: result.score, workspace_id: result.workspace_id, preview: result.preview, }); From a0d0794f95b0ee15fe85c9e057135f081b7358a0 Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Wed, 8 Jan 2025 11:54:51 +0800 Subject: [PATCH 3/3] fix: replace the old web base url with the new one --- .../appflowy_flutter/lib/env/cloud_env.dart | 2 +- frontend/appflowy_flutter/lib/env/env.dart | 2 +- .../lib/plugins/shared/share/constants.dart | 3 +-- .../lib/shared/patterns/common_patterns.dart | 2 +- .../command_palette/command_palette_bloc.dart | 25 ------------------- 5 files changed, 4 insertions(+), 30 deletions(-) diff --git a/frontend/appflowy_flutter/lib/env/cloud_env.dart b/frontend/appflowy_flutter/lib/env/cloud_env.dart index 12042d066dbeb..8f4d195eb7b14 100644 --- a/frontend/appflowy_flutter/lib/env/cloud_env.dart +++ b/frontend/appflowy_flutter/lib/env/cloud_env.dart @@ -159,7 +159,7 @@ Future _setAppFlowyCloudUrl(String? url) async { Future useBaseWebDomain(String? url) async { await getIt().set( KVKeys.kAppFlowyBaseShareDomain, - url ?? ShareConstants.baseWebDomain, + url ?? ShareConstants.defaultBaseWebDomain, ); } diff --git a/frontend/appflowy_flutter/lib/env/env.dart b/frontend/appflowy_flutter/lib/env/env.dart index 182139ed41bfe..18434f9aa6f68 100644 --- a/frontend/appflowy_flutter/lib/env/env.dart +++ b/frontend/appflowy_flutter/lib/env/env.dart @@ -48,7 +48,7 @@ abstract class Env { @EnviedField( obfuscate: false, varName: 'BASE_WEB_DOMAIN', - defaultValue: ShareConstants.baseWebDomain, + defaultValue: ShareConstants.defaultBaseWebDomain, ) static const String baseWebDomain = _Env.baseWebDomain; } diff --git a/frontend/appflowy_flutter/lib/plugins/shared/share/constants.dart b/frontend/appflowy_flutter/lib/plugins/shared/share/constants.dart index 4027f41474acb..90d2a21928816 100644 --- a/frontend/appflowy_flutter/lib/plugins/shared/share/constants.dart +++ b/frontend/appflowy_flutter/lib/plugins/shared/share/constants.dart @@ -2,9 +2,8 @@ import 'package:appflowy/env/cloud_env.dart'; import 'package:appflowy/startup/startup.dart'; class ShareConstants { - static const String baseWebDomain = 'appflowy.com'; static const String testBaseWebDomain = 'test.appflowy.com'; - static const String defaultBaseWebDomain = 'https://www.appflowy.com'; + static const String defaultBaseWebDomain = 'https://appflowy.com'; static String buildPublishUrl({ required String nameSpace, diff --git a/frontend/appflowy_flutter/lib/shared/patterns/common_patterns.dart b/frontend/appflowy_flutter/lib/shared/patterns/common_patterns.dart index 3edefb98557dc..4b07db8c78882 100644 --- a/frontend/appflowy_flutter/lib/shared/patterns/common_patterns.dart +++ b/frontend/appflowy_flutter/lib/shared/patterns/common_patterns.dart @@ -37,7 +37,7 @@ const _macOSVolumesPattern = '^/Volumes/[^/]+'; final macOSVolumesRegex = RegExp(_macOSVolumesPattern); const appflowySharePageLinkPattern = - r'^https://www\.appflowy\.com/app/([^/]+)/([^?]+)(?:\?blockId=(.+))?$'; + r'^https://appflowy\.com/app/([^/]+)/([^?]+)(?:\?blockId=(.+))?$'; final appflowySharePageLinkRegex = RegExp(appflowySharePageLinkPattern); const _numberedListPattern = r'^(\d+)\.'; diff --git a/frontend/appflowy_flutter/lib/workspace/application/command_palette/command_palette_bloc.dart b/frontend/appflowy_flutter/lib/workspace/application/command_palette/command_palette_bloc.dart index 21d6a501c5d35..18fba610185d2 100644 --- a/frontend/appflowy_flutter/lib/workspace/application/command_palette/command_palette_bloc.dart +++ b/frontend/appflowy_flutter/lib/workspace/application/command_palette/command_palette_bloc.dart @@ -129,31 +129,6 @@ class CommandPaletteBloc ); } - List _filterDuplicates(List results) { - final currentItems = [...state.results]; - final res = [...results]; - - for (final item in results) { - if (item.data.trim().isEmpty) { - continue; - } - - final duplicateIndex = currentItems.indexWhere((a) => a.id == item.id); - if (duplicateIndex == -1) { - continue; - } - - final duplicate = currentItems[duplicateIndex]; - if (item.score < duplicate.score) { - res.remove(item); - } else { - currentItems.remove(duplicate); - } - } - - return res..addAll(currentItems); - } - void _performSearch(String value) => add(CommandPaletteEvent.performSearch(search: value));