Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(config): explicit-user clears check the layout; Tauri shows the refusal

M3gA-Mind08a37246abb1
diff --git a/crates/openhuman-app/src/local_data_reset.rs b/crates/openhuman-app/src/local_data_reset.rs
index b675573689..12d8149c92 100644
--- a/crates/openhuman-app/src/local_data_reset.rs
+++ b/crates/openhuman-app/src/local_data_reset.rs
@@ -319,17 +319,21 @@ async fn fetch_data_paths(user_id: Option<String>) -> Result<ResolvedDataPaths,
.send()
.await
.map_err(|e| format!("config_get_data_paths request failed: {e}"))?;
- if !res.status().is_success() {
- return Err(format!("config_get_data_paths http {}", res.status()));
- }
- let envelope: serde_json::Value = res
- .json()
+ let status = res.status().as_u16();
+ let body = res
+ .text()
.await
- .map_err(|e| format!("config_get_data_paths decode failed: {e}"))?;
- // JSON-RPC envelope wraps the `Outcome` result twice:
- // `{ "result": { "result": { ...paths... }, "logs": [...] } }`.
- let inner = envelope
- .pointer("/result/result")
+ .map_err(|e| format!("config_get_data_paths read failed: {e}"))?;
+ parse_data_paths(status, &body)
+}
+
+/// Decodes a `config_get_data_paths` response. A refusal arrives as a JSON-RPC
+/// error on `200 OK`; `decode_response` surfaces its message to the toast.
+fn parse_data_paths(status: u16, body: &str) -> Result<ResolvedDataPaths, String> {
+ let outcome = openhuman_rpc::decode_response(status, body)?;
+ // The `Outcome` is wrapped once more: `{ "result": { ...paths... }, "logs": [...] }`.
+ let inner = outcome
+ .get("result")
.ok_or_else(|| "config_get_data_paths missing /result/result".to_string())?;
let current = inner
.get("current_openhuman_dir")
diff --git a/crates/openhuman-app/src/local_data_reset_tests.rs b/crates/openhuman-app/src/local_data_reset_tests.rs
index 0723c9c447..60ad73f344 100644
--- a/crates/openhuman-app/src/local_data_reset_tests.rs
+++ b/crates/openhuman-app/src/local_data_reset_tests.rs
@@ -82,3 +82,27 @@ fn reset_local_data_delete_error_reports_reboot_schedule_counts() {
"missing lock cause: {msg}"
);
}
+
+#[test]
+fn data_paths_refusal_keeps_the_core_message() {
+ // The core answers a refused clear with a JSON-RPC error on `200 OK`.
+ let body = r#"{"jsonrpc":"2.0","id":1,"error":{"code":-32000,"message":"Clear App Data is not available on the legacy data layout"}}"#;
+ let err = parse_data_paths(200, body)
+ .err()
+ .expect("a refusal is an error");
+ assert!(err.contains("legacy data layout"), "{err}");
+}
+
+#[test]
+fn data_paths_parse_the_wrapped_outcome() {
+ let body = r#"{"jsonrpc":"2.0","id":1,"result":{"result":{
+ "current_openhuman_dir":"/h/.openhuman/users/u",
+ "default_openhuman_dir":"/h/.openhuman",
+ "active_workspace_marker_path":"/h/.openhuman/active_workspace.toml",
+ "active_user_marker_path":"/h/.openhuman/active_user.toml"},"logs":[]}}"#;
+ let paths = parse_data_paths(200, body).unwrap();
+ assert_eq!(
+ paths.current_openhuman_dir,
+ std::path::PathBuf::from("/h/.openhuman/users/u")
+ );
+}
diff --git a/crates/openhuman-core/src/config/schemas/controllers/workspace.rs b/crates/openhuman-core/src/config/schemas/controllers/workspace.rs
index f2cd6c9789..7c3fb4ab1b 100644
--- a/crates/openhuman-core/src/config/schemas/controllers/workspace.rs
+++ b/crates/openhuman-core/src/config/schemas/controllers/workspace.rs
@@ -162,7 +162,13 @@ async fn resolve_data_paths(
user_id.is_some()
);
match user_id.as_deref() {
- Some(id) => config_rpc::get_data_paths_for_user(id).await,
+ Some(id) => {
+ // The id picks the profile, but the loaded layout decides whether a
+ // per-user clear applies at all: a legacy root or a workspace
+ // outside `users/` is refused here too, not silently skipped.
+ config_rpc::get_data_paths_to_clear(ctx).await?;
+ config_rpc::get_data_paths_for_user(id).await
+ }
None => config_rpc::get_data_paths_to_clear(ctx).await,
}
}
diff --git a/crates/openhuman-core/src/platform/about_app/catalog_localai_settings_mobile.rs b/crates/openhuman-core/src/platform/about_app/catalog_localai_settings_mobile.rs
index 74ab2fa259..93c55a0ca8 100644
--- a/crates/openhuman-core/src/platform/about_app/catalog_localai_settings_mobile.rs
+++ b/crates/openhuman-core/src/platform/about_app/catalog_localai_settings_mobile.rs
@@ -209,7 +209,7 @@ Capability {
name: "Log Out and Clear App Data",
domain: "settings",
category: CapabilityCategory::Settings,
- description: "Sign out and permanently clear local app data, including workflow data.",
+ description: "Sign out and permanently clear the signed-in account's local app data, including workflow data. Other accounts on the device are kept. Not available on the legacy single-folder data layout.",
how_to: "Settings > Log Out & Clear App Data",
status: CapabilityStatus::Stable,
privacy: None,