Revert "chore: try to fix the mobile build"#7844
Conversation
This reverts commit 3f06f64.
Reviewer's Guide by SourceryThis pull request reverts a previous commit (3f06f64) that introduced platform-specific conditional compilation for local AI features, particularly those related to Ollama and desktop operating systems. The revert removes these conditional checks, restoring the code to its state before the problematic commit. No diagrams generated as the changes look simple and do not need a visual representation. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey @LucasXu0 - I've reviewed your changes - here's some feedback:
Overall Comments:
- Removing the desktop-specific conditional compilation might reintroduce the mobile build issues this revert relates to.
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟡 Complexity: 1 issue found
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| let resource_lack = cloned_llm_res.get_lack_of_resource().await; | ||
| (downloaded, resource_lack) | ||
| let key = crate::local_ai::controller::local_ai_enabled_key(&workspace_id.to_string()); | ||
| info!("[AI Plugin] state: {:?}", state); |
There was a problem hiding this comment.
issue (complexity): Consider extracting the inner loop of the spawned async task into a separate helper function to improve code structure and readability.
Consider extracting the inner loop of the spawned async task into its own helper function. This reduces nesting and makes the control flow easier to follow. For example:
```rust
async fn process_plugin_state(
mut running_state_rx: impl StreamExt<Item = RunningState> + Unpin,
cloned_llm_res: Arc<LocalAIResourceController>,
cloned_store_preferences: Weak<KVStorePreferences>,
cloned_local_ai: Arc<OllamaAIPlugin>,
cloned_user_service: Arc<dyn AIUserService>,
) {
while let Some(state) = running_state_rx.next().await {
// Early exit if workspace_id is not accessible
let workspace_id = match cloned_user_service.workspace_id() {
Ok(id) => id,
Err(_) => continue,
};
let key = crate::local_ai::controller::local_ai_enabled_key(&workspace_id.to_string());
info!("[AI Plugin] state: {:?}", state);
if let Some(store_preferences) = cloned_store_preferences.upgrade() {
let enabled = store_preferences.get_bool(&key).unwrap_or(true);
let (plugin_downloaded, lack_of_resource) = if !matches!(state, RunningState::UnexpectedStop { .. }) && enabled {
let downloaded = is_plugin_ready();
let resource_lack = cloned_llm_res.get_lack_of_resource().await;
(downloaded, resource_lack)
} else {
(false, None)
};
let plugin_version = if matches!(state, RunningState::Running { .. }) {
match cloned_local_ai.plugin_info().await {
Ok(info) => Some(info.version),
Err(_) => None,
}
} else {
None
};
let new_state = RunningStatePB::from(state);
chat_notification_builder(
APPFLOWY_AI_NOTIFICATION_KEY,
ChatNotification::UpdateLocalAIState,
)
.payload(LocalAIPB {
enabled,
plugin_downloaded,
lack_of_resource,
state: new_state,
plugin_version,
})
.send();
} else {
warn!("[AI Plugin] store preferences is dropped");
}
}
}Then call it from the spawn block like:
tokio::spawn(async move {
process_plugin_state(
running_state_rx,
cloned_llm_res,
cloned_store_preferences,
cloned_local_ai,
cloned_user_service,
)
.await;
});This extraction flattens the async task, reduces the nesting in your main flow, and keeps the functionality intact.
This reverts commit 3f06f64.
Feature Preview
PR Checklist
Summary by Sourcery
Chores: