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: fix flashing window
Nathan86b67a1b650e
diff --git a/frontend/rust-lib/flowy-ai/src/local_ai/controller.rs b/frontend/rust-lib/flowy-ai/src/local_ai/controller.rsindex 11a0e9a480..842db994b8 100644--- a/frontend/rust-lib/flowy-ai/src/local_ai/controller.rs+++ b/frontend/rust-lib/flowy-ai/src/local_ai/controller.rs@@ -16,6 +16,7 @@ use std::collections::HashMap;use crate::local_ai::watch::is_plugin_ready;use crate::stream_message::StreamMessage;use appflowy_local_ai::ollama_plugin::OllamaAIPlugin;+use appflowy_plugin::core::plugin::RunningState;use arc_swap::ArcSwapOption;use futures_util::SinkExt;use lib_infra::util::get_operating_system;@@ -97,11 +98,16 @@ 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 ready = is_plugin_ready();- let lack_of_resource = cloned_llm_res.get_lack_of_resource().await;let new_state = RunningStatePB::from(state);let enabled = cloned_store_preferences.get_bool(&key).unwrap_or(true);+ let mut ready = false;+ let mut lack_of_resource = None;+ if enabled {+ ready = is_plugin_ready();+ lack_of_resource = cloned_llm_res.get_lack_of_resource().await;+ }+chat_notification_builder(APPFLOWY_AI_NOTIFICATION_KEY,ChatNotification::UpdateLocalAIState,@@ -259,9 +265,14 @@ impl LocalAIController {pub async fn get_local_ai_state(&self) -> LocalAIPB {let start = std::time::Instant::now();let enabled = self.is_enabled();- let is_app_downloaded = is_plugin_ready();- let state = self.ai_plugin.get_plugin_running_state();- let lack_of_resource = self.resource.get_lack_of_resource().await;+ let mut is_plugin_executable_ready = false;+ let mut state = RunningState::ReadyToConnect;+ let mut lack_of_resource = None;+ if enabled {+ is_plugin_executable_ready = is_plugin_ready();+ state = self.ai_plugin.get_plugin_running_state();+ lack_of_resource = self.resource.get_lack_of_resource().await;+ }let elapsed = start.elapsed();debug!("[AI Plugin] get local ai state, elapsed: {:?}, thread: {:?}",@@ -270,7 +281,7 @@ impl LocalAIController {);LocalAIPB {enabled,- is_plugin_executable_ready: is_app_downloaded,+ is_plugin_executable_ready,state: RunningStatePB::from(state),lack_of_resource,}diff --git a/frontend/rust-lib/flowy-ai/src/local_ai/resource.rs b/frontend/rust-lib/flowy-ai/src/local_ai/resource.rsindex 4a9403d670..0fc09bbc8d 100644--- a/frontend/rust-lib/flowy-ai/src/local_ai/resource.rs+++ b/frontend/rust-lib/flowy-ai/src/local_ai/resource.rs@@ -237,21 +237,15 @@ impl LocalAIResourceController {#[instrument(level = "info", skip_all)]pub async fn get_plugin_config(&self, rag_enabled: bool) -> FlowyResult<OllamaPluginConfig> {if !self.is_resource_ready().await {- return Err(FlowyError::local_ai().with_context("Local AI resources are not ready"));+ return Err(FlowyError::new(+ ErrorCode::AppFlowyLAINotReady,+ "AppFlowyLAI not found",+ ));}let llm_setting = self.get_llm_setting();let bin_path = match get_operating_system() {- OperatingSystem::MacOS | OperatingSystem::Windows => {- if !is_plugin_ready() {- return Err(FlowyError::new(- ErrorCode::AppFlowyLAINotReady,- "AppFlowyLAI not found",- ));- }-- ollama_plugin_path()- },+ OperatingSystem::MacOS | OperatingSystem::Windows => ollama_plugin_path(),_ => {return Err(FlowyError::local_ai_unavailable()