Skip to content

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.

chore: fix ai page user profile refresh (#7317)

Nathan.fooo71a22dc46661
diff --git a/frontend/appflowy_flutter/lib/workspace/application/settings/ai/settings_ai_bloc.dart b/frontend/appflowy_flutter/lib/workspace/application/settings/ai/settings_ai_bloc.dart
index 8a4696606b..b414a71b81 100644
--- a/frontend/appflowy_flutter/lib/workspace/application/settings/ai/settings_ai_bloc.dart
+++ b/frontend/appflowy_flutter/lib/workspace/application/settings/ai/settings_ai_bloc.dart
@@ -109,10 +109,12 @@ class SettingsAIBloc extends Bloc<SettingsAIEvent, SettingsAIState> {
if (!models.contains(state.selectedAIModel)) {
// Use first model as default model if current selected model
// is not available
+ final selectedModel = models[0];
+ _updateUserWorkspaceSetting(model: selectedModel);
emit(
state.copyWith(
availableModels: models,
- selectedAIModel: models[0],
+ selectedAIModel: selectedModel,
),
);
} else {
diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/settings/settings_dialog.dart b/frontend/appflowy_flutter/lib/workspace/presentation/settings/settings_dialog.dart
index 84ba87144b..986e2a4dbd 100644
--- a/frontend/appflowy_flutter/lib/workspace/presentation/settings/settings_dialog.dart
+++ b/frontend/appflowy_flutter/lib/workspace/presentation/settings/settings_dialog.dart
@@ -141,6 +141,7 @@ class SettingsDialog extends StatelessWidget {
case SettingsPage.ai:
if (user.authenticator == AuthenticatorPB.AppFlowyCloud) {
return SettingsAIView(
+ key: ValueKey(user.hashCode),
userProfile: user,
currentWorkspaceMemberRole: currentWorkspaceMemberRole,
workspaceId: workspaceId,
diff --git a/frontend/rust-lib/flowy-server/src/af_cloud/impls/user/cloud_service_impl.rs b/frontend/rust-lib/flowy-server/src/af_cloud/impls/user/cloud_service_impl.rs
index 4f7ce7a3e9..208281fc5f 100644
--- a/frontend/rust-lib/flowy-server/src/af_cloud/impls/user/cloud_service_impl.rs
+++ b/frontend/rust-lib/flowy-server/src/af_cloud/impls/user/cloud_service_impl.rs
@@ -18,7 +18,7 @@ use client_api::entity::{
use client_api::entity::{QueryCollab, QueryCollabParams};
use client_api::{Client, ClientConfiguration};
use collab_entity::{CollabObject, CollabType};
-use tracing::instrument;
+use tracing::{instrument, trace};
use flowy_error::{ErrorCode, FlowyError, FlowyResult};
use flowy_user_pub::cloud::{UserCloudService, UserCollabParams, UserUpdate, UserUpdateReceiver};
@@ -586,6 +586,7 @@ where
workspace_id: &str,
workspace_settings: AFWorkspaceSettingsChange,
) -> Result<AFWorkspaceSettings, FlowyError> {
+ trace!("Sync workspace settings: {:?}", workspace_settings);
let workspace_id = workspace_id.to_string();
let try_get_client = self.server.try_get_client();
let client = try_get_client?;
diff --git a/frontend/rust-lib/flowy-user/src/entities/workspace.rs b/frontend/rust-lib/flowy-user/src/entities/workspace.rs
index 240b153e33..885ad6f3cf 100644
--- a/frontend/rust-lib/flowy-user/src/entities/workspace.rs
+++ b/frontend/rust-lib/flowy-user/src/entities/workspace.rs
@@ -393,7 +393,7 @@ impl From<AFWorkspaceSettings> for UseAISettingPB {
}
}
-#[derive(ProtoBuf, Default, Clone, Validate)]
+#[derive(ProtoBuf, Default, Clone, Validate, Debug)]
pub struct UpdateUserWorkspaceSettingPB {
#[pb(index = 1)]
#[validate(custom(function = "required_not_empty_str"))]
@@ -410,10 +410,10 @@ impl From<UpdateUserWorkspaceSettingPB> for AFWorkspaceSettingsChange {
fn from(value: UpdateUserWorkspaceSettingPB) -> Self {
let mut change = AFWorkspaceSettingsChange::new();
if let Some(disable_search_indexing) = value.disable_search_indexing {
- change = change.disable_search_indexing(disable_search_indexing);
+ change.disable_search_indexing = Some(disable_search_indexing);
}
if let Some(ai_model) = value.ai_model {
- change = change.ai_model(ai_model);
+ change.ai_model = Some(ai_model);
}
change
}