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.

fix: anon user can not locate its data (#7873)

Nathan.fooo7750f2257fdd
diff --git a/.github/workflows/ios_ci.yaml b/.github/workflows/ios_ci.yaml
index 43611cc141..ab604c23ce 100644
--- a/.github/workflows/ios_ci.yaml
+++ b/.github/workflows/ios_ci.yaml
@@ -26,28 +26,7 @@ concurrency:
cancel-in-progress: true
jobs:
- build-self-hosted:
- if: github.event.pull_request.head.repo.full_name == github.repository
- runs-on: self-hosted
-
- steps:
- - name: Checkout source code
- uses: actions/checkout@v2
-
- - name: Build AppFlowy
- working-directory: frontend
- run: |
- cargo make --profile development-ios-arm64-sim appflowy-core-dev-ios
- cargo make --profile development-ios-arm64-sim code_generation
-
- - uses: futureware-tech/simulator-action@v3
- id: simulator-action
- with:
- model: "iPhone 15"
- shutdown_after_job: false
-
integration-tests:
- if: github.event.pull_request.head.repo.full_name != github.repository
runs-on: macos-latest
steps:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6fc94de739..18b16c4cde 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,26 @@
# Release Notes
+## Version 0.9.1 - 01/05/2025
+### Desktop
+#### New Features
+- Added AppFlowy Prompt Library to AI Chat and Document's Ask AI
+- Revamped the desktop in-app notification center
+- Supported login with password, as well as forgot and change password options
+- Supported copying link to invite members
+- Improved the Settings' Members tab with new metadata: member avatar and joined time
+#### Bug Fixes
+- Fixed data loss when using anonymous local
+- Fixed crash when trying to delete an emoji
+- Fixed Windows scaling issue
+- Correctly displayed mention text by decoding web content
+### Mobile
+#### New Features
+- Supported workspace search
+- Improved UX for links in documents
+- Supported changing password in Mobile Settings
+- Added support for inviting members via links
+#### Bug Fixes
+- Correctly displayed mention text by decoding web content
+
## Version 0.9.0 - 30/04/2025
### Desktop
#### New Features
diff --git a/frontend/Makefile.toml b/frontend/Makefile.toml
index 3e53c0bba9..01a756a173 100644
--- a/frontend/Makefile.toml
+++ b/frontend/Makefile.toml
@@ -26,7 +26,7 @@ CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true
CARGO_MAKE_CRATE_FS_NAME = "dart_ffi"
CARGO_MAKE_CRATE_NAME = "dart-ffi"
LIB_NAME = "dart_ffi"
-APPFLOWY_VERSION = "0.9.0"
+APPFLOWY_VERSION = "0.9.1"
FLUTTER_DESKTOP_FEATURES = "dart"
PRODUCT_NAME = "AppFlowy"
MACOSX_DEPLOYMENT_TARGET = "11.0"
diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/space/shared_widget.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/space/shared_widget.dart
index 6c41062ed1..31fcf6c277 100644
--- a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/space/shared_widget.dart
+++ b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/space/shared_widget.dart
@@ -182,6 +182,7 @@ class SpaceCancelOrConfirmButton extends StatelessWidget {
final String confirmButtonName;
final Color? confirmButtonColor;
final WidgetBuilder? confirmButtonBuilder;
+
@override
Widget build(BuildContext context) {
final theme = AppFlowyTheme.of(context);
@@ -208,8 +209,16 @@ class SpaceCancelOrConfirmButton extends StatelessWidget {
borderRadius: BorderRadius.circular(8),
),
),
- child: AFFilledTextButton.destructive(
- text: confirmButtonName,
+ child: FlowyButton(
+ useIntrinsicWidth: true,
+ margin:
+ const EdgeInsets.symmetric(horizontal: 16.0, vertical: 9.0),
+ radius: BorderRadius.circular(8),
+ text: FlowyText.regular(
+ confirmButtonName,
+ lineHeight: 1.0,
+ color: Theme.of(context).colorScheme.onPrimary,
+ ),
onTap: onConfirm,
),
),
diff --git a/frontend/appflowy_flutter/pubspec.yaml b/frontend/appflowy_flutter/pubspec.yaml
index 3a89a4f980..fb086181d0 100644
--- a/frontend/appflowy_flutter/pubspec.yaml
+++ b/frontend/appflowy_flutter/pubspec.yaml
@@ -4,7 +4,7 @@ description: Bring projects, wikis, and teams together with AI. AppFlowy is an
your data. The best open source alternative to Notion.
publish_to: "none"
-version: 0.9.0
+version: 0.9.1
environment:
flutter: ">=3.27.4"
diff --git a/frontend/rust-lib/event-integration-test/src/user_event.rs b/frontend/rust-lib/event-integration-test/src/user_event.rs
index 082d5748a8..6e1bfcd80e 100644
--- a/frontend/rust-lib/event-integration-test/src/user_event.rs
+++ b/frontend/rust-lib/event-integration-test/src/user_event.rs
@@ -438,7 +438,10 @@ pub struct SignUpContext {
pub user_profile: UserProfilePB,
pub password: String,
}
-
+pub async fn use_local_mode() {
+ AuthenticatorType::Local.write_env();
+ AFCloudConfiguration::default().write_env();
+}
pub async fn use_localhost_af_cloud() {
AuthenticatorType::AppFlowyCloud.write_env();
let base_url =
diff --git a/frontend/rust-lib/event-integration-test/tests/asset/089_local.zip b/frontend/rust-lib/event-integration-test/tests/asset/089_local.zip
new file mode 100644
index 0000000000..30903eabda
Binary files /dev/null and b/frontend/rust-lib/event-integration-test/tests/asset/089_local.zip differ
diff --git a/frontend/rust-lib/event-integration-test/tests/user/af_cloud_test/workspace_test.rs b/frontend/rust-lib/event-integration-test/tests/user/af_cloud_test/workspace_test.rs
index fc96e90e55..023cf8fc30 100644
--- a/frontend/rust-lib/event-integration-test/tests/user/af_cloud_test/workspace_test.rs
+++ b/frontend/rust-lib/event-integration-test/tests/user/af_cloud_test/workspace_test.rs
@@ -1,10 +1,12 @@
use crate::user::af_cloud_test::util::get_synced_workspaces;
+use crate::util::unzip;
use collab::core::collab::DataSource::DocStateV1;
use collab::core::origin::CollabOrigin;
use collab_entity::CollabType;
use collab_folder::Folder;
-use event_integration_test::user_event::use_localhost_af_cloud;
+use event_integration_test::user_event::{use_local_mode, use_localhost_af_cloud};
use event_integration_test::EventIntegrationTest;
+use flowy_core::DEFAULT_NAME;
use flowy_user::entities::AFRolePB;
use flowy_user_pub::cloud::UserCloudServiceProvider;
use flowy_user_pub::entities::{AuthType, WorkspaceType};
@@ -415,3 +417,33 @@ async fn af_cloud_create_local_workspace_test() {
"Server should only see 2 workspaces (the default and server workspace, not the local one)"
);
}
+
+#[tokio::test]
+async fn af_cloud_open_089_anon_user_data_folder_test() {
+ let user_db_path = unzip("./tests/asset", "089_local").unwrap();
+ use_localhost_af_cloud().await;
+ let test =
+ EventIntegrationTest::new_with_user_data_path(user_db_path, DEFAULT_NAME.to_string()).await;
+
+ // After 0.8.9, we store user workspace into user_workspace_table and refactor the Session serde struct
+ // So, if everything is correct, we should be able to open the workspace and get the views
+ let workspaces = test.get_all_workspaces().await.items;
+ let views = test.get_all_views().await;
+ dbg!(&views);
+ assert!(views.iter().any(|view| view.name == "Anon 089 document"));
+ assert_eq!(workspaces.len(), 1);
+}
+
+#[tokio::test]
+async fn open_089_anon_user_data_folder_test() {
+ use_local_mode().await;
+ // Almost same as af_cloud_open_089_anon_user_data_folder_test but doesn't use af_cloud as the backend
+ let user_db_path = unzip("./tests/asset", "089_local").unwrap();
+ let test =
+ EventIntegrationTest::new_with_user_data_path(user_db_path, DEFAULT_NAME.to_string()).await;
+ let workspaces = test.get_all_workspaces().await.items;
+ let views = test.get_all_views().await;
+ dbg!(&views);
+ assert!(views.iter().any(|view| view.name == "Anon 089 document"));
+ assert_eq!(workspaces.len(), 1);
+}
diff --git a/frontend/rust-lib/flowy-user/src/migrations/anon_user_workspace.rs b/frontend/rust-lib/flowy-user/src/migrations/anon_user_workspace.rs
index 8f3ce99d73..1bb346d4f3 100644
--- a/frontend/rust-lib/flowy-user/src/migrations/anon_user_workspace.rs
+++ b/frontend/rust-lib/flowy-user/src/migrations/anon_user_workspace.rs
@@ -9,7 +9,7 @@ use flowy_sqlite::kv::KVStorePreferences;
use flowy_user_pub::entities::{AuthType, WorkspaceType};
use crate::migrations::migration::UserDataMigration;
-use crate::migrations::session_migration::get_session_workspace;
+use crate::migrations::session_migration::get_v0_session_workspace;
use flowy_user_pub::session::Session;
use flowy_user_pub::sql::{select_user_workspace, upsert_user_workspace};
@@ -43,7 +43,7 @@ impl UserDataMigration for AnonUserWorkspaceTableMigration {
// For historical reason, anon user doesn't have a workspace in user_workspace_table.
// So we need to create a new entry for the anon user in the user_workspace_table.
if matches!(user_auth_type, AuthType::Local) {
- if let Some(mut user_workspace) = get_session_workspace(store_preferences) {
+ if let Some(mut user_workspace) = get_v0_session_workspace(store_preferences) {
if select_user_workspace(&user_workspace.id, db).ok().is_none() {
user_workspace.workspace_type = WorkspaceType::Local;
upsert_user_workspace(user.user_id, WorkspaceType::Local, user_workspace, db)?;
diff --git a/frontend/rust-lib/flowy-user/src/migrations/session_migration.rs b/frontend/rust-lib/flowy-user/src/migrations/session_migration.rs
index f5e0342fb2..140ab7cd48 100644
--- a/frontend/rust-lib/flowy-user/src/migrations/session_migration.rs
+++ b/frontend/rust-lib/flowy-user/src/migrations/session_migration.rs
@@ -1,3 +1,4 @@
+use crate::user_manager::manager_history_user::ANON_USER;
use chrono::Utc;
use flowy_sqlite::kv::KVStorePreferences;
use flowy_user_pub::entities::{Role, UserWorkspace, WorkspaceType};
@@ -19,6 +20,15 @@ pub fn migrate_session(
if !store_preferences.get_bool_or_default(MIGRATION_SESSION)
&& store_preferences.set_bool(MIGRATION_SESSION, true).is_ok()
{
+ if let Some(anon_session) = store_preferences.get_object::<SessionBackup>(ANON_USER) {
+ let new_anon_session = Session {
+ user_id: anon_session.user_id,
+ user_uuid: anon_session.user_uuid,
+ workspace_id: anon_session.user_workspace.id,
+ };
+ let _ = store_preferences.set_object(ANON_USER, &new_anon_session);
+ }
+
if let Some(session) = store_preferences.get_object::<SessionBackup>(session_cache_key) {
let _ = store_preferences.set_object(SESSION_CACHE_KEY_BACKUP, &session);
let new_session = Session {
@@ -29,7 +39,6 @@ pub fn migrate_session(
let _ = store_preferences.set_object(session_cache_key, &new_session);
}
}
-
store_preferences.get_object::<Session>(session_cache_key)
}
@@ -39,7 +48,9 @@ struct SessionBackup {
user_uuid: Uuid,
user_workspace: UserWorkspace,
}
-pub fn get_session_workspace(store_preferences: &Arc<KVStorePreferences>) -> Option<UserWorkspace> {
+pub fn get_v0_session_workspace(
+ store_preferences: &Arc<KVStorePreferences>,
+) -> Option<UserWorkspace> {
store_preferences
.get_object::<SessionBackup>(SESSION_CACHE_KEY_BACKUP)
.map(|v| v.user_workspace)
diff --git a/frontend/rust-lib/flowy-user/src/services/data_import/appflowy_data_import.rs b/frontend/rust-lib/flowy-user/src/services/data_import/appflowy_data_import.rs
index 1e23b874ad..01f3f0c022 100644
--- a/frontend/rust-lib/flowy-user/src/services/data_import/appflowy_data_import.rs
+++ b/frontend/rust-lib/flowy-user/src/services/data_import/appflowy_data_import.rs
@@ -1,4 +1,4 @@
-use crate::migrations::session_migration::{get_session_workspace, migrate_session};
+use crate::migrations::session_migration::{get_v0_session_workspace, migrate_session};
use crate::services::data_import::importer::load_collab_by_object_ids;
use crate::services::db::UserDBPath;
@@ -108,7 +108,7 @@ pub(crate) fn prepare_import(
{
Ok(w) => w.database_storage_id,
Err(_) => {
- let session_workspace = get_session_workspace(&other_store_preferences)
+ let session_workspace = get_v0_session_workspace(&other_store_preferences)
.ok_or(anyhow!("Can't find the session workspace"))?;
session_workspace.workspace_database_id
},
diff --git a/frontend/rust-lib/flowy-user/src/user_manager/manager.rs b/frontend/rust-lib/flowy-user/src/user_manager/manager.rs
index f3e9578e57..5f33a097ab 100644
--- a/frontend/rust-lib/flowy-user/src/user_manager/manager.rs
+++ b/frontend/rust-lib/flowy-user/src/user_manager/manager.rs
@@ -151,7 +151,25 @@ impl UserManager {
);
let workspace_uuid = Uuid::parse_str(&session.workspace_id)?;
let mut conn = self.db_connection(session.user_id)?;
- let workspace_type = select_user_workspace_type(&session.workspace_id, &mut conn)?;
+ let workspace_type =
+ select_user_workspace_type(&session.workspace_id, &mut conn).or_else(|err| {
+ // Anonymous workspaces aren’t yet recorded in user_workspace_table,
+ // so calling select_user_workspace_type(...) will Err for anon users.
+ // As a temporary workaround, if we detect the current user is anonymous,
+ // we force the workspace type to WorkspaceType::Local.
+ // In the upcoming run_data_migration, we’ll insert proper anon‐user records
+ // and can remove this special case.
+ if self
+ .get_anon_user_id()
+ .ok()
+ .filter(|&anon_id| anon_id == session.user_id)
+ .is_some()
+ {
+ Ok(WorkspaceType::Local)
+ } else {
+ Err(err)
+ }
+ })?;
let uid = session.user_id;
let auth_type = AuthType::from(workspace_type);