Skip to content

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

chore: files changed src/openhuman/desktop/app_state/ops_current_user_generation.rs,src/openhuman/de

Steven Enamakel87d23576049f
diff --git a/src/openhuman/desktop/app_state/ops_current_user_generation.rs b/src/openhuman/desktop/app_state/ops_current_user_generation.rs
index f497d36688..f0f02a8dbc 100644
--- a/src/openhuman/desktop/app_state/ops_current_user_generation.rs
+++ b/src/openhuman/desktop/app_state/ops_current_user_generation.rs
@@ -118,6 +118,17 @@ fn note_current_user_success_unless_stale(generation: u64, api_base: &str, token
true
}
+/// Clear the failure record only while the refresh still belongs to the
+/// current session generation.
+fn clear_current_user_failure_unless_stale(generation: u64) -> bool {
+ let mut failure = CURRENT_USER_FAILURE.lock();
+ if current_user_generation() != generation {
+ return false;
+ }
+ *failure = None;
+ true
+}
+
/// Publish a fresh `/auth/me` answer to the positive cache, and drop any
/// recorded outage, only if `generation` is still current — each check taken
/// under the lock that guards the record it gates.
diff --git a/src/openhuman/desktop/app_state/ops_part_02.rs b/src/openhuman/desktop/app_state/ops_part_02.rs
index 0b1ef951f9..9f3821716a 100644
--- a/src/openhuman/desktop/app_state/ops_part_02.rs
+++ b/src/openhuman/desktop/app_state/ops_part_02.rs
@@ -475,8 +475,9 @@ async fn refresh_current_user_now(
// Keep all post-fetch records behind the same generation checks as the
// positive cache. A logout (or a subsequent login) can land after the
// cache commit and must not have its failure/success records overwritten.
- if !publish_current_user_unless_stale(generation, &api_base, token, fetched.clone()) {
- return Ok(fetched);
+ clear_current_user_failure_unless_stale(generation);
+ if fetched.is_some() {
+ note_current_user_success_unless_stale(generation, &api_base, token);
}
Ok(fetched)