Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
chore: show plugin version
Nathan34a858e94836
diff --git a/frontend/appflowy_flutter/lib/workspace/application/settings/ai/download_offline_ai_app_bloc.dart b/frontend/appflowy_flutter/lib/workspace/application/settings/ai/download_offline_ai_app_bloc.dartdeleted file mode 100644index 185a8c049f..0000000000--- a/frontend/appflowy_flutter/lib/workspace/application/settings/ai/download_offline_ai_app_bloc.dart+++ /dev/null@@ -1,41 +0,0 @@-import 'dart:async';--import 'package:appflowy_backend/dispatch/dispatch.dart';-import 'package:bloc/bloc.dart';-import 'package:freezed_annotation/freezed_annotation.dart';-import 'package:url_launcher/url_launcher.dart' show launchUrl;-part 'download_offline_ai_app_bloc.freezed.dart';--class DownloadOfflineAIBloc- extends Bloc<DownloadOfflineAIEvent, DownloadOfflineAIState> {- DownloadOfflineAIBloc() : super(const DownloadOfflineAIState()) {- on<DownloadOfflineAIEvent>(_handleEvent);- }-- Future<void> _handleEvent(- DownloadOfflineAIEvent event,- Emitter<DownloadOfflineAIState> emit,- ) async {- await event.when(- started: () async {- final result = await AIEventGetLocalAIDownloadLink().send();- await result.fold(- (app) async {- await launchUrl(Uri.parse(app.link));- },- (err) {},- );- },- );- }-}--@freezed-class DownloadOfflineAIEvent with _$DownloadOfflineAIEvent {- const factory DownloadOfflineAIEvent.started() = _Started;-}--@freezed-class DownloadOfflineAIState with _$DownloadOfflineAIState {- const factory DownloadOfflineAIState() = _DownloadOfflineAIState;-}diff --git a/frontend/appflowy_flutter/lib/workspace/application/settings/ai/local_ai_setting_panel_bloc.dart b/frontend/appflowy_flutter/lib/workspace/application/settings/ai/local_ai_setting_panel_bloc.dartindex f6d5ef949d..60c68b70c6 100644--- a/frontend/appflowy_flutter/lib/workspace/application/settings/ai/local_ai_setting_panel_bloc.dart+++ b/frontend/appflowy_flutter/lib/workspace/application/settings/ai/local_ai_setting_panel_bloc.dart@@ -44,7 +44,7 @@ class LocalAISettingPanelBloc) async {event.when(updateAIState: (LocalAIPB pluginState) {- if (pluginState.isPluginExecutableReady) {+ if (pluginState.pluginDownloaded) {emit(state.copyWith(runningState: pluginState.state,diff --git a/frontend/appflowy_flutter/lib/workspace/application/settings/ai/plugin_state_bloc.dart b/frontend/appflowy_flutter/lib/workspace/application/settings/ai/plugin_state_bloc.dartindex 4c3130ea00..d91d7151ab 100644--- a/frontend/appflowy_flutter/lib/workspace/application/settings/ai/plugin_state_bloc.dart+++ b/frontend/appflowy_flutter/lib/workspace/application/settings/ai/plugin_state_bloc.dart@@ -91,7 +91,11 @@ class PluginStateBloc extends Bloc<PluginStateEvent, PluginStateState> {);break;case RunningStatePB.Running:- emit(const PluginStateState(action: PluginStateAction.running()));+ emit(+ PluginStateState(+ action: PluginStateAction.running(aiState.pluginVersion),+ ),+ );break;case RunningStatePB.Stopped:emit(@@ -140,7 +144,7 @@ class PluginStateAction with _$PluginStateAction {const factory PluginStateAction.unknown() = _Unknown;const factory PluginStateAction.readToRun() = _ReadyToRun;const factory PluginStateAction.initializingPlugin() = _InitializingPlugin;- const factory PluginStateAction.running() = _PluginRunning;+ const factory PluginStateAction.running(String version) = _PluginRunning;const factory PluginStateAction.restartPlugin() = _RestartPlugin;const factory PluginStateAction.lackOfResource(String desc) = _LackOfResource;}diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/setting_ai_view/plugin_state.dart b/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/setting_ai_view/plugin_state.dartindex ab9303b429..b8461eb141 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/setting_ai_view/plugin_state.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/setting_ai_view/plugin_state.dart@@ -1,15 +1,11 @@-import 'package:appflowy/core/helpers/url_launcher.dart';import 'package:appflowy/generated/flowy_svgs.g.dart';import 'package:appflowy/generated/locale_keys.g.dart';-import 'package:appflowy/workspace/application/settings/ai/download_offline_ai_app_bloc.dart';import 'package:appflowy/workspace/application/settings/ai/plugin_state_bloc.dart';import 'package:appflowy/workspace/presentation/settings/pages/setting_ai_view/init_local_ai.dart';import 'package:easy_localization/easy_localization.dart';-import 'package:flowy_infra/size.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';@@ -27,7 +23,7 @@ class PluginStateIndicator extends StatelessWidget {unknown: () => const SizedBox.shrink(),readToRun: () => const _PrepareRunning(),initializingPlugin: () => const InitLocalAIIndicator(),- running: () => const _LocalAIRunning(),+ running: (version) => _LocalAIRunning(version: version),restartPlugin: () => const _RestartPluginButton(),lackOfResource: (desc) => _LackOfResource(desc: desc),);@@ -88,7 +84,9 @@ class _RestartPluginButton extends StatelessWidget {}class _LocalAIRunning extends StatelessWidget {- const _LocalAIRunning();+ const _LocalAIRunning({required this.version});++ final String version;@overrideWidget build(BuildContext context) {@@ -115,7 +113,11 @@ class _LocalAIRunning extends StatelessWidget {const HSpace(6),Flexible(child: FlowyText(- LocaleKeys.settings_aiPage_keys_localAIRunning.tr(),+ LocaleKeys.settings_aiPage_keys_localAIRunning.tr(+ args: [+ version,+ ],+ ),fontSize: 11,color: const Color(0xFF1E4620),maxLines: 3,@@ -131,95 +133,6 @@ class _LocalAIRunning extends StatelessWidget {}}-class OpenOrDownloadOfflineAIApp extends StatelessWidget {- const OpenOrDownloadOfflineAIApp({required this.onRetry, super.key});-- final VoidCallback onRetry;-- @override- Widget build(BuildContext context) {- return BlocProvider(- create: (context) => DownloadOfflineAIBloc(),- child: BlocBuilder<DownloadOfflineAIBloc, DownloadOfflineAIState>(- builder: (context, state) {- return Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- RichText(- maxLines: 3,- textAlign: TextAlign.left,- text: TextSpan(- children: <TextSpan>[- TextSpan(- text:- "${LocaleKeys.settings_aiPage_keys_offlineAIInstruction1.tr()} ",- style: Theme.of(context)- .textTheme- .bodySmall!- .copyWith(height: 1.5),- ),- TextSpan(- text:- " ${LocaleKeys.settings_aiPage_keys_offlineAIInstruction2.tr()} ",- style: Theme.of(context).textTheme.bodyMedium!.copyWith(- fontSize: FontSizes.s14,- color: Theme.of(context).colorScheme.primary,- height: 1.5,- ),- recognizer: TapGestureRecognizer()- ..onTap = () => afLaunchUrlString(- "https://docs.appflowy.io/docs/appflowy/product/appflowy-ai-offline",- ),- ),- TextSpan(- text:- " ${LocaleKeys.settings_aiPage_keys_offlineAIInstruction3.tr()} ",- style: Theme.of(context)- .textTheme- .bodySmall!- .copyWith(height: 1.5),- ),- TextSpan(- text:- "${LocaleKeys.settings_aiPage_keys_offlineAIDownload1.tr()} ",- style: Theme.of(context)- .textTheme- .bodySmall!- .copyWith(height: 1.5),- ),- TextSpan(- text:- " ${LocaleKeys.settings_aiPage_keys_offlineAIDownload2.tr()} ",- style: Theme.of(context).textTheme.bodyMedium!.copyWith(- fontSize: FontSizes.s14,- color: Theme.of(context).colorScheme.primary,- height: 1.5,- ),- recognizer: TapGestureRecognizer()- ..onTap =- () => context.read<DownloadOfflineAIBloc>().add(- const DownloadOfflineAIEvent.started(),- ),- ),- TextSpan(- text:- " ${LocaleKeys.settings_aiPage_keys_offlineAIDownload3.tr()} ",- style: Theme.of(context)- .textTheme- .bodySmall!- .copyWith(height: 1.5),- ),- ],- ),- ),- ],- );- },- ),- );- }-}-class _LackOfResource extends StatelessWidget {const _LackOfResource({required this.desc});diff --git a/frontend/resources/translations/ar-SA.json b/frontend/resources/translations/ar-SA.jsonindex 62708e664f..bb4534d855 100644--- a/frontend/resources/translations/ar-SA.json+++ b/frontend/resources/translations/ar-SA.json@@ -857,7 +857,7 @@"localAIStart": "بدأت الدردشة المحلية بالذكاء الاصطناعي...","localAILoading": "جاري تحميل نموذج الدردشة المحلية للذكاء الاصطناعي...","localAIStopped": "تم إيقاف الذكاء الاصطناعي المحلي",- "localAIRunning": "الذكاء الاصطناعي المحلي قيد التشغيل",+ "localAIRunning": "الذكاء الاصطناعي المحلي قيد التشغيل. الإصدار: {}","localAIInitializing": "يتم تهيئة الذكاء الاصطناعي المحلي وقد يستغرق الأمر بضع دقائق، حسب جهازك","localAINotReadyTextFieldPrompt": "لا يمكنك التحرير أثناء تحميل الذكاء الاصطناعي المحلي","failToLoadLocalAI": "فشل في بدء تشغيل الذكاء الاصطناعي المحلي",@@ -3217,4 +3217,4 @@"rewrite": "إعادة كتابة","insertBelow": "أدخل أدناه"}-}+}\ No newline at end of filediff --git a/frontend/resources/translations/en.json b/frontend/resources/translations/en.jsonindex 2b22da596c..8129157941 100644--- a/frontend/resources/translations/en.json+++ b/frontend/resources/translations/en.json@@ -857,7 +857,7 @@"localAIStart": "Local AI is starting. If it’s slow, try toggling it off and on","localAILoading": "Local AI Chat Model is loading...","localAIStopped": "Local AI stopped",- "localAIRunning": "Local AI is running",+ "localAIRunning": "Local AI is running. Version: {}","localAIInitializing": "Local AI is loading and may take a few minutes, depending on your device","localAINotReadyTextFieldPrompt": "You can not edit while Local AI is loading","failToLoadLocalAI": "Failed to start local AI",@@ -3202,4 +3202,4 @@"rewrite": "Rewrite","insertBelow": "Insert below"}-}+}\ No newline at end of filediff --git a/frontend/resources/translations/ko-KR.json b/frontend/resources/translations/ko-KR.jsonindex f956327073..7ed8373c72 100644--- a/frontend/resources/translations/ko-KR.json+++ b/frontend/resources/translations/ko-KR.json@@ -851,7 +851,7 @@"localAIStart": "로컬 AI가 시작 중입니다. 느리다면 껐다가 다시 켜보세요","localAILoading": "로컬 AI 채팅 모델이 로드 중입니다...","localAIStopped": "로컬 AI가 중지되었습니다",- "localAIRunning": "로컬 AI가 실행 중입니다",+ "localAIRunning": "로컬 AI가 실행 중입니다. 버전: {}","localAIInitializing": "로컬 AI가 로드 중이며 장치에 따라 몇 분이 소요될 수 있습니다","localAINotReadyTextFieldPrompt": "로컬 AI가 로드되는 동안 편집할 수 없습니다","failToLoadLocalAI": "로컬 AI를 시작하지 못했습니다",@@ -3185,4 +3185,4 @@"rewrite": "다시 작성","insertBelow": "아래에 삽입"}-}+}\ No newline at end of filediff --git a/frontend/rust-lib/Cargo.lock b/frontend/rust-lib/Cargo.lockindex 01b9251e23..6bc02bda8a 100644--- a/frontend/rust-lib/Cargo.lock+++ b/frontend/rust-lib/Cargo.lock@@ -345,7 +345,7 @@ dependencies = [[[package]]name = "af-local-ai"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-LocalAI?rev=a7d4ca96ec30cad941b67acb1e0e426d689c1270#a7d4ca96ec30cad941b67acb1e0e426d689c1270"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-LocalAI?rev=593bc3fbedf2a2c7e00ec28b10f2268c1983be65#593bc3fbedf2a2c7e00ec28b10f2268c1983be65"dependencies = ["af-plugin","anyhow",@@ -365,7 +365,7 @@ dependencies = [[[package]]name = "af-mcp"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-LocalAI?rev=a7d4ca96ec30cad941b67acb1e0e426d689c1270#a7d4ca96ec30cad941b67acb1e0e426d689c1270"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-LocalAI?rev=593bc3fbedf2a2c7e00ec28b10f2268c1983be65#593bc3fbedf2a2c7e00ec28b10f2268c1983be65"dependencies = ["anyhow","futures-util",@@ -379,7 +379,7 @@ dependencies = [[[package]]name = "af-plugin"version = "0.1.0"-source = "git+https://github.com/AppFlowy-IO/AppFlowy-LocalAI?rev=a7d4ca96ec30cad941b67acb1e0e426d689c1270#a7d4ca96ec30cad941b67acb1e0e426d689c1270"+source = "git+https://github.com/AppFlowy-IO/AppFlowy-LocalAI?rev=593bc3fbedf2a2c7e00ec28b10f2268c1983be65#593bc3fbedf2a2c7e00ec28b10f2268c1983be65"dependencies = ["anyhow","cfg-if",diff --git a/frontend/rust-lib/Cargo.toml b/frontend/rust-lib/Cargo.tomlindex b4a0a34b14..6baa7dea3e 100644--- a/frontend/rust-lib/Cargo.toml+++ b/frontend/rust-lib/Cargo.toml@@ -152,6 +152,6 @@ collab-importer = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFl# To update the commit ID, run:# scripts/tool/update_local_ai_rev.sh new_rev_id# ⚠️⚠️⚠️️-af-local-ai = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "a7d4ca96ec30cad941b67acb1e0e426d689c1270" }-af-plugin = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "a7d4ca96ec30cad941b67acb1e0e426d689c1270" }-af-mcp = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "a7d4ca96ec30cad941b67acb1e0e426d689c1270" }+af-local-ai = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "593bc3fbedf2a2c7e00ec28b10f2268c1983be65" }+af-plugin = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "593bc3fbedf2a2c7e00ec28b10f2268c1983be65" }+af-mcp = { version = "0.1", git = "https://github.com/AppFlowy-IO/AppFlowy-LocalAI", rev = "593bc3fbedf2a2c7e00ec28b10f2268c1983be65" }diff --git a/frontend/rust-lib/flowy-ai/src/entities.rs b/frontend/rust-lib/flowy-ai/src/entities.rsindex b24d0cb13e..30a3e5dd28 100644--- a/frontend/rust-lib/flowy-ai/src/entities.rs+++ b/frontend/rust-lib/flowy-ai/src/entities.rs@@ -585,20 +585,17 @@ pub struct LocalAIPB {#[pb(index = 1)]pub enabled: bool,- #[pb(index = 2)]- pub is_plugin_executable_ready: bool,-- #[pb(index = 3, one_of)]+ #[pb(index = 2, one_of)]pub lack_of_resource: Option<String>,- #[pb(index = 4)]+ #[pb(index = 3)]pub state: RunningStatePB,-}-#[derive(Default, ProtoBuf, Clone, Debug)]-pub struct LocalAIAppLinkPB {- #[pb(index = 1)]- pub link: String,+ #[pb(index = 4, one_of)]+ pub plugin_version: Option<String>,++ #[pb(index = 5)]+ pub plugin_downloaded: bool,}#[derive(Default, ProtoBuf, Validate, Clone, Debug)]diff --git a/frontend/rust-lib/flowy-ai/src/event_handler.rs b/frontend/rust-lib/flowy-ai/src/event_handler.rsindex ec8b7b4964..3150d3e378 100644--- a/frontend/rust-lib/flowy-ai/src/event_handler.rs+++ b/frontend/rust-lib/flowy-ai/src/event_handler.rs@@ -301,15 +301,6 @@ pub(crate) async fn get_local_ai_state_handler(data_result_ok(state)}-#[tracing::instrument(level = "debug", skip_all, err)]-pub(crate) async fn get_offline_app_handler(- ai_manager: AFPluginState<Weak<AIManager>>,-) -> DataResult<LocalAIAppLinkPB, FlowyError> {- let ai_manager = upgrade_ai_manager(ai_manager)?;- let link = ai_manager.local_ai.get_plugin_download_link().await?;- data_result_ok(LocalAIAppLinkPB { link })-}-#[tracing::instrument(level = "debug", skip_all, err)]pub(crate) async fn create_chat_context_handler(data: AFPluginData<CreateChatContextPB>,diff --git a/frontend/rust-lib/flowy-ai/src/event_map.rs b/frontend/rust-lib/flowy-ai/src/event_map.rsindex 0e24ca6a21..51c49eaabb 100644--- a/frontend/rust-lib/flowy-ai/src/event_map.rs+++ b/frontend/rust-lib/flowy-ai/src/event_map.rs@@ -34,7 +34,6 @@ pub fn init(ai_manager: Weak<AIManager>) -> AFPlugin {.event(AIEvent::RestartLocalAI, restart_local_ai_handler).event(AIEvent::ToggleLocalAI, toggle_local_ai_handler).event(AIEvent::GetLocalAIState, get_local_ai_state_handler)- .event(AIEvent::GetLocalAIDownloadLink, get_offline_app_handler).event(AIEvent::GetLocalAISetting, get_local_ai_setting_handler).event(AIEvent::UpdateLocalAISetting,@@ -97,9 +96,6 @@ pub enum AIEvent {#[event(output = "LocalAIPB")]GetLocalAIState = 19,- #[event(output = "LocalAIAppLinkPB")]- GetLocalAIDownloadLink = 22,-#[event(input = "CreateChatContextPB")]CreateChatContext = 23,diff --git a/frontend/rust-lib/flowy-ai/src/local_ai/controller.rs b/frontend/rust-lib/flowy-ai/src/local_ai/controller.rsindex c3f57e6fac..1bbe356e2b 100644--- a/frontend/rust-lib/flowy-ai/src/local_ai/controller.rs+++ b/frontend/rust-lib/flowy-ai/src/local_ai/controller.rs@@ -98,11 +98,11 @@ impl LocalAIController {if let Ok(workspace_id) = cloned_user_service.workspace_id() {let key = local_ai_enabled_key(&workspace_id);info!("[AI Plugin] state: {:?}", state);- let mut ready = false;+ let mut plugin_downloaded = false;let mut lack_of_resource = None;let enabled = cloned_store_preferences.get_bool(&key).unwrap_or(true);if !matches!(state, RunningState::UnexpectedStop { .. }) && enabled {- ready = is_plugin_ready();+ plugin_downloaded = is_plugin_ready();lack_of_resource = cloned_llm_res.get_lack_of_resource().await;}@@ -113,9 +113,10 @@ impl LocalAIController {).payload(LocalAIPB {enabled,- is_plugin_executable_ready: ready,+ plugin_downloaded,lack_of_resource,state: new_state,+ plugin_version: None,}).send();}@@ -274,12 +275,14 @@ impl LocalAIController {pub async fn get_local_ai_state(&self) -> LocalAIPB {let start = std::time::Instant::now();let enabled = self.is_enabled();- let mut is_plugin_executable_ready = false;+ let mut plugin_downloaded = false;let mut state = RunningState::ReadyToConnect;let mut lack_of_resource = None;+ let mut plugin_version = None;if enabled {- is_plugin_executable_ready = is_plugin_ready();+ plugin_downloaded = is_plugin_ready();state = self.ai_plugin.get_plugin_running_state();+ plugin_version = self.ai_plugin.plugin_info().await.ok().map(|v| v.version);lack_of_resource = self.resource.get_lack_of_resource().await;}let elapsed = start.elapsed();@@ -290,9 +293,10 @@ impl LocalAIController {);LocalAIPB {enabled,- is_plugin_executable_ready,+ plugin_downloaded,state: RunningStatePB::from(state),lack_of_resource,+ plugin_version,}}@@ -442,9 +446,10 @@ impl LocalAIController {).payload(LocalAIPB {enabled,- is_plugin_executable_ready: true,+ plugin_downloaded: true,state: RunningStatePB::Stopped,lack_of_resource: None,+ plugin_version: None,}).send();}@@ -466,9 +471,10 @@ async fn initialize_ai_plugin().payload(LocalAIPB {enabled: true,- is_plugin_executable_ready: true,+ plugin_downloaded: true,state: RunningStatePB::ReadyToRun,lack_of_resource: lack_of_resource.clone(),+ plugin_version: None,}).send();