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(proactive): register web-only subscriber outside channels group
Steven Enamakelc9e49ea14132
diff --git a/crates/openhuman-core/src/channels/proactive.rs b/crates/openhuman-core/src/channels/proactive.rsindex 9bf00e5e1e..865b289606 100644--- a/crates/openhuman-core/src/channels/proactive.rs+++ b/crates/openhuman-core/src/channels/proactive.rs@@ -43,6 +43,13 @@ fn proactive_approval_gate() -> Option<Arc<crate::security::approval::ApprovalGa/// `bootstrap_core_runtime` (desktop/JSON-RPC) and domain-level/// startup — only the first call takes effect.pub fn register_web_only_proactive_subscriber() {+ if crate::core::bus::BUS.get().is_none() {+ tracing::warn!(+ "[proactive] deferred web-only subscriber registration — bus not initialized"+ );+ return;+ }+use std::sync::Once;static REGISTERED: Once = Once::new();REGISTERED.call_once(|| {diff --git a/crates/openhuman-core/src/core/runtime/subscribers.rs b/crates/openhuman-core/src/core/runtime/subscribers.rsindex 5265572a3b..ca4b64d5e7 100644--- a/crates/openhuman-core/src/core/runtime/subscribers.rs+++ b/crates/openhuman-core/src/core/runtime/subscribers.rs@@ -118,6 +118,14 @@ pub(super) fn register_domain_subscribers(let plan = DomainSubscriberPlan::for_domains(domains);log::debug!("[event_bus] register_domain_subscribers: domains={domains:?} plan={plan:?}");+ // Proactive messages always have a web destination, including web-only+ // cores where no external channel listeners are configured and+ // `start_channels` never runs. Keep this independent of the Channels+ // DomainGroup; channel startup still registers the external-channel leg+ // when it has concrete channel instances.+ #[cfg(feature = "channels")]+ crate::channels::proactive::register_web_only_proactive_subscriber();+// `subscribe_global` returns `None` only before the process-global bus is// initialized. Because that bus is a monotonic `OnceLock`, checking it here// guarantees the registrations in the guarded block cannot later lose bus@@ -316,9 +324,6 @@ pub(super) fn register_domain_subscribers("[event_bus] failed to register channel subscriber — bus not initialized");}- // Web-only proactive message subscriber (no external channel- // instances are registered here in the desktop runtime).- crate::channels::proactive::register_web_only_proactive_subscriber();}} else {log::debug!(diff --git a/crates/openhuman-core/src/core/runtime/subscribers_tests.rs b/crates/openhuman-core/src/core/runtime/subscribers_tests.rsindex 74cef0b0a2..cfde9b2a23 100644--- a/crates/openhuman-core/src/core/runtime/subscribers_tests.rs+++ b/crates/openhuman-core/src/core/runtime/subscribers_tests.rs@@ -233,10 +233,21 @@ async fn proactive_message_reaches_web_on_channelless_core_boot() {job_name: Some("morning-briefing".into()),});- let event = tokio::time::timeout(std::time::Duration::from_secs(2), web_events.recv())- .await- .expect("proactive message should reach the web event stream")- .expect("web event stream should remain open");+ let event = tokio::time::timeout(std::time::Duration::from_secs(2), async {+ loop {+ let event = web_events+ .recv()+ .await+ .expect("web event stream should remain open");+ if event.event == "proactive_message"+ && event.full_response.as_deref() == Some("Your morning briefing is ready.")+ {+ break event;+ }+ }+ })+ .await+ .expect("proactive message should reach the web event stream");assert_eq!(event.event, "proactive_message");assert_eq!(event.full_response.as_deref(), Some("Your morning briefing is ready."));}