Skip to content

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

refactor(config): make refresh_context_after_conflict return a boxed future

Steven Enamakel69c9c0a7b6b3
diff --git a/crates/openhuman-core/src/config/schema/load/impl_load.rs b/crates/openhuman-core/src/config/schema/load/impl_load.rs
index 66e9195e40..05be616ce7 100644
--- a/crates/openhuman-core/src/config/schema/load/impl_load.rs
+++ b/crates/openhuman-core/src/config/schema/load/impl_load.rs
@@ -493,50 +493,52 @@ impl Config {
Ok(())
}
- async fn refresh_context_after_conflict(
- &self,
- expected: &super::super::ConfigDocumentSnapshot,
- ) {
- let Some(snapshot) = self
- .context_snapshot
- .as_ref()
- .and_then(std::sync::Weak::upgrade)
- else {
- return;
- };
- let (config_path, workspace_dir, runtime) = {
- let current = snapshot.lock().unwrap();
- if *current.document_snapshot.lock().unwrap() != *expected {
+ fn refresh_context_after_conflict<'a>(
+ &'a self,
+ expected: &'a super::super::ConfigDocumentSnapshot,
+ ) -> std::pin::Pin<Box<dyn std::future::Future<Output = ()> + Send + 'a>> {
+ Box::pin(async move {
+ let Some(snapshot) = self
+ .context_snapshot
+ .as_ref()
+ .and_then(std::sync::Weak::upgrade)
+ else {
return;
- }
- (
- current.config_path.clone(),
- current.workspace_dir.clone(),
- current.clone(),
- )
- };
- let Ok(mut refreshed) = Self::load_from_config_path(&config_path, &workspace_dir).await
- else {
- return;
- };
- if refreshed.document_snapshot.lock().unwrap().anchor != expected.anchor {
- return;
- }
- let overlay = runtime.context_overlay.lock().unwrap().clone();
- if let Some(overlay) = overlay {
- let Ok(merged) = overlay.reapply(&refreshed) else {
+ };
+ let (config_path, workspace_dir, runtime) = {
+ let current = snapshot.lock().unwrap();
+ if *current.document_snapshot.lock().unwrap() != *expected {
+ return;
+ }
+ (
+ current.config_path.clone(),
+ current.workspace_dir.clone(),
+ current.clone(),
+ )
+ };
+ let Ok(mut refreshed) = Self::load_from_config_path(&config_path, &workspace_dir).await
+ else {
return;
};
- refreshed = merged;
- } else {
- super::context_overlay::copy_runtime_bindings(&runtime, &mut refreshed);
- }
- refreshed.context_snapshot = Some(std::sync::Arc::downgrade(&snapshot));
+ if refreshed.document_snapshot.lock().unwrap().anchor != expected.anchor {
+ return;
+ }
+ let overlay = runtime.context_overlay.lock().unwrap().clone();
+ if let Some(overlay) = overlay {
+ let Ok(merged) = overlay.reapply(&refreshed) else {
+ return;
+ };
+ refreshed = merged;
+ } else {
+ super::context_overlay::copy_runtime_bindings(&runtime, &mut refreshed);
+ }
+ refreshed.context_snapshot = Some(std::sync::Arc::downgrade(&snapshot));
- let mut current = snapshot.lock().unwrap();
- if *current.document_snapshot.lock().unwrap() == *expected {
- *current = refreshed;
- }
+ let mut current = snapshot.lock().unwrap();
+ if *current.document_snapshot.lock().unwrap() == *expected {
+ *current = refreshed;
+ }
+ })
}
}