The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(config): Clear App Data deletes only one user's folder
M3gA-Minddca06500c63f
diff --git a/crates/openhuman-core/src/config/ops/loader.rs b/crates/openhuman-core/src/config/ops/loader.rsindex a2a907785f..7bead8b779 100644--- a/crates/openhuman-core/src/config/ops/loader.rs+++ b/crates/openhuman-core/src/config/ops/loader.rs@@ -19,7 +19,9 @@ pub(crate) use paths::{active_workspace_marker_path, config_openhuman_dir, defaupub(crate) use reset_local_data::reset_local_data_for_paths;#[cfg(all(test, windows))]pub(crate) use reset_local_data::reset_local_data_remove_error;-pub use reset_local_data::{get_data_paths, get_data_paths_for_user, reset_local_data};+pub use reset_local_data::{+ get_data_paths, get_data_paths_for_user, get_data_paths_to_clear, reset_local_data,+};pub use runtime_flags::{agent_server_status, core_rpc_url_from_env, get_runtime_flags, set_browser_allow_all,RuntimeFlagsOut,diff --git a/crates/openhuman-core/src/config/ops/loader/reset_local_data.rs b/crates/openhuman-core/src/config/ops/loader/reset_local_data.rsindex eebddd2c34..7202f18562 100644--- a/crates/openhuman-core/src/config/ops/loader/reset_local_data.rs+++ b/crates/openhuman-core/src/config/ops/loader/reset_local_data.rs@@ -57,6 +57,37 @@ pub(crate) fn reset_local_data_marker_remove_error(path: &Path, error: &std::io:)}+/// Refuses any delete target that is not one user's own folder,+/// `<root>/users/<id>`. Every reset path goes through this before it touches+/// the disk, so a refusal deletes nothing.+///+/// On the legacy single-user layout the config dir is the shared root itself,+/// which also holds every account under `users/`: clearing it would wipe them+/// all, so that case is refused with its own message.+pub(crate) fn ensure_user_scoped_dir(current: &Path, root: &Path) -> Result<(), String> {+ let users_root = root.join("users");+ let plain_id = current+ .file_name()+ .and_then(|name| name.to_str())+ .is_some_and(is_plain_user_id);+ if plain_id && current.parent() == Some(users_root.as_path()) {+ return Ok(());+ }+ if current == root {+ return Err(format!(+ "Clear App Data is not available on the legacy data layout: {} is the shared \+ OpenHuman folder and holds every account's data. Nothing was removed; delete the \+ folder manually to start over.",+ root.display()+ ));+ }+ Err(format!(+ "refusing to clear {}: it is not a per-user data folder under {}. Nothing was removed.",+ current.display(),+ users_root.display()+ ))+}+/// Internal helper to reset local data for the **active user only**.////// Removes the current user's data directory (`~/.openhuman/users/<id>`) plus@@ -83,6 +114,9 @@ pub(crate) async fn reset_local_data_for_paths("[config] reset_local_data: starting (user-scoped)");+ // Before any marker is touched, so a refusal changes nothing.+ ensure_user_scoped_dir(current_openhuman_dir, default_openhuman_dir)?;+let mut removed_paths = Vec::new();// Remove the two shared root-level markers so the current user is signed@@ -165,16 +199,37 @@ pub async fn reset_local_data(ctx: &DispatchCtx) -> Result<Outcome<serde_json::V/// handles. See OPENHUMAN-TAURI-AF for the Windows file-locking failure/// that motivated the split.pub async fn get_data_paths(ctx: &DispatchCtx) -> Result<Outcome<serde_json::Value>, String> {+ let config = ctx.load_config().await?;+ Ok(data_paths(+ &config_openhuman_dir(&config),+ &default_openhuman_dir(),+ ))+}++/// [`get_data_paths`] for the Tauri `reset_local_data` command, which deletes+/// the returned `current_openhuman_dir`: refuses unless that is one user's own+/// folder (see [`ensure_user_scoped_dir`]), before the shell stops the core.+pub async fn get_data_paths_to_clear(+ ctx: &DispatchCtx,+) -> Result<Outcome<serde_json::Value>, String> {let config = ctx.load_config().await?;let current_openhuman_dir = config_openhuman_dir(&config);let default_openhuman_dir = default_openhuman_dir();- let active_workspace_marker = active_workspace_marker_path(&default_openhuman_dir);+ ensure_user_scoped_dir(¤t_openhuman_dir, &default_openhuman_dir)?;+ Ok(data_paths(¤t_openhuman_dir, &default_openhuman_dir))+}++fn data_paths(+ current_openhuman_dir: &Path,+ default_openhuman_dir: &Path,+) -> Outcome<serde_json::Value> {+ let active_workspace_marker = active_workspace_marker_path(default_openhuman_dir);// The active-user marker lives at the *shared* root `~/.openhuman`, not// inside the per-user dir. A clear removes it (to sign the current user// out) but must leave the sibling `users/<other>` dirs and the root// itself intact — see `reset_local_data_for_paths`.- let active_user_marker = crate::config::active_user_marker_path(&default_openhuman_dir);- Ok(Outcome::new(+ let active_user_marker = crate::config::active_user_marker_path(default_openhuman_dir);+ Outcome::new(json!({"current_openhuman_dir": current_openhuman_dir.display().to_string(),"default_openhuman_dir": default_openhuman_dir.display().to_string(),@@ -186,7 +241,7 @@ pub async fn get_data_paths(ctx: &DispatchCtx) -> Result<Outcome<serde_json::Valcurrent_openhuman_dir.display(),default_openhuman_dir.display())],- ))+ )}/// Like [`get_data_paths`], but resolves the current data dir directly from andiff --git a/crates/openhuman-core/src/config/ops/mod.rs b/crates/openhuman-core/src/config/ops/mod.rsindex b871707d06..43be3c7c2c 100644--- a/crates/openhuman-core/src/config/ops/mod.rs+++ b/crates/openhuman-core/src/config/ops/mod.rs@@ -82,8 +82,8 @@ pub use agent_paths::{pub use loader::{agent_server_status, client_config_json, core_rpc_url_from_env, get_config_snapshot,- get_dashboard_settings, get_data_paths, get_data_paths_for_user, get_runtime_flags,- load_and_get_client_config_snapshot, load_and_get_config_snapshot,+ get_dashboard_settings, get_data_paths, get_data_paths_for_user, get_data_paths_to_clear,+ get_runtime_flags, load_and_get_client_config_snapshot, load_and_get_config_snapshot,load_config_for_workspace_with_timeout, load_config_in, load_config_with_timeout,load_current_or_init, reload_config_from_paths, reload_config_snapshot_with_timeout,reset_local_data, set_browser_allow_all, snapshot_config_json, RuntimeFlagsOut,diff --git a/crates/openhuman-core/src/config/ops_loader_and_search_tests.rs b/crates/openhuman-core/src/config/ops_loader_and_search_tests.rsindex 8ae686eee1..aa08c2abf3 100644--- a/crates/openhuman-core/src/config/ops_loader_and_search_tests.rs+++ b/crates/openhuman-core/src/config/ops_loader_and_search_tests.rs@@ -583,3 +583,50 @@ async fn apply_search_settings_rejects_unknown_search_engine() {assert!(err.contains("unknown search engine"), "{err}");}++#[tokio::test]+async fn reset_local_data_refuses_the_shared_root_of_a_legacy_layout() {+ let temp = tempdir().unwrap();+ let default_openhuman_dir = temp.path().join("default-openhuman");+ // Legacy single-user layout: the config dir IS the shared root, which also+ // holds every signed-in account under `users/`.+ let sibling_file = default_openhuman_dir.join("users/other-user/config.toml");+ let user_marker = crate::config::active_user_marker_path(&default_openhuman_dir);+ tokio::fs::create_dir_all(sibling_file.parent().unwrap())+ .await+ .unwrap();+ tokio::fs::write(&sibling_file, "api_key = 'sibling'\n")+ .await+ .unwrap();+ tokio::fs::write(&user_marker, "user_id = 'other-user'\n")+ .await+ .unwrap();++ let err = reset_local_data_for_paths(&default_openhuman_dir, &default_openhuman_dir)+ .await+ .unwrap_err();++ assert!(err.contains("legacy"), "{err}");+ // A refusal changes nothing: not the root, not a sibling, not a marker.+ assert!(sibling_file.exists());+ assert!(user_marker.exists());+}++#[tokio::test]+async fn reset_local_data_refuses_a_target_outside_users() {+ let temp = tempdir().unwrap();+ let default_openhuman_dir = temp.path().join("default-openhuman");+ for target in [+ temp.path().join("elsewhere"),+ default_openhuman_dir.join("users"),+ default_openhuman_dir.join("users").join(".."),+ default_openhuman_dir.join("users/a/b"),+ ] {+ tokio::fs::create_dir_all(&target).await.unwrap();+ let err = reset_local_data_for_paths(&target, &default_openhuman_dir)+ .await+ .unwrap_err();+ assert!(err.contains("refusing"), "{target:?}: {err}");+ assert!(target.exists(), "{target:?} was deleted");+ }+}diff --git a/crates/openhuman-core/src/config/schemas/controllers/workspace.rs b/crates/openhuman-core/src/config/schemas/controllers/workspace.rsindex 19d229ec9e..f2cd6c9789 100644--- a/crates/openhuman-core/src/config/schemas/controllers/workspace.rs+++ b/crates/openhuman-core/src/config/schemas/controllers/workspace.rs@@ -145,7 +145,8 @@ pub(crate) fn handle_get_data_paths(/// removes the active-user marker *before* the reset resolves paths — without/// the explicit id the core would fall back to the pre-login `users/local` dir/// and leave the real user's data behind. Absent/blank → marker-based-/// resolution (the default used by the agent tool and diagnostics).+/// resolution, refused unless it is one user's folder: the Tauri shell deletes+/// the dir this returns.async fn resolve_data_paths(ctx: &DispatchCtx,params: Map<String, Value>,@@ -162,7 +163,7 @@ async fn resolve_data_paths();match user_id.as_deref() {Some(id) => config_rpc::get_data_paths_for_user(id).await,- None => config_rpc::get_data_paths(ctx).await,+ None => config_rpc::get_data_paths_to_clear(ctx).await,}}