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
refactor(proactive): route web delivery through tenant-scoped dispatch
Steven Enamakelf0a1a42d1cac
diff --git a/crates/openhuman-core/src/channels/runtime/startup/start_channels.rs b/crates/openhuman-core/src/channels/runtime/startup/start_channels.rsindex 180573e918..abb142bb52 100644--- a/crates/openhuman-core/src/channels/runtime/startup/start_channels.rs+++ b/crates/openhuman-core/src/channels/runtime/startup/start_channels.rs@@ -228,9 +228,8 @@ async fn start_channels_inner(mut config: Config, session: CancellationToken) ->// here — `start_channels` is skipped when no channel is configured or// `OPENHUMAN_DISABLE_CHANNEL_LISTENERS` is set, which would otherwise leave// schedule/app-event workflows undispatched (issue B2 review).- // Register the proactive message subscriber so morning briefings,- // welcome messages, and other proactive agent output gets routed to- // the user's active channel (+ always to web).+ // Register external proactive delivery to the user's active channel.+ // Web delivery is registered unconditionally by core subscriber boot.let proactive_sub = crate::channels::proactive::ProactiveMessageSubscriber::new(Arc::clone(&channels_by_name),config.channels_config.active_channel.clone(),diff --git a/crates/openhuman-core/src/core/events.rs b/crates/openhuman-core/src/core/events.rsindex 4402e0e335..612c3f1c98 100644--- a/crates/openhuman-core/src/core/events.rs+++ b/crates/openhuman-core/src/core/events.rs@@ -394,8 +394,9 @@ pub enum DomainEvent {},/// A proactive message (morning briefing, welcome, cron output, etc.)- /// needs to be delivered to the user. The channels module routes it to- /// the user's active channel.+ /// needs to be delivered to the user. The web subscriber publishes it to+ /// the profile-scoped web stream; when configured, the optional channels+ /// subscriber also routes it to the user's active external channel.ProactiveMessageRequested {/// Identifies the source (e.g. `"cron:morning_briefing"`, `"cron:welcome"`).source: String,diff --git a/crates/openhuman-core/src/cron/scheduler/delivery.rs b/crates/openhuman-core/src/cron/scheduler/delivery.rsindex d77db3ba51..7b1f68d621 100644--- a/crates/openhuman-core/src/cron/scheduler/delivery.rs+++ b/crates/openhuman-core/src/cron/scheduler/delivery.rs@@ -194,9 +194,10 @@ pub(super) async fn deliver_run(}}- // Proactive delivery — the channels module decides where to send.- // Used by morning briefings, welcome messages, and other- // user-facing proactive agents.+ // Proactive delivery — independent web and optional external-channel+ // subscribers deliver the message to the tenant that ran this job.+ // Used by morning briefings, welcome messages, and other user-facing+ // proactive agents."proactive" => {if deliver_to_chat {let source = format!("cron:{}", job.id);diff --git a/crates/openhuman-core/src/web_chat/proactive.rs b/crates/openhuman-core/src/web_chat/proactive.rsindex a8cc884a91..e53ccc1714 100644--- a/crates/openhuman-core/src/web_chat/proactive.rs+++ b/crates/openhuman-core/src/web_chat/proactive.rs@@ -5,7 +5,8 @@//! the `channels` feature is disabled.use crate::core::events::DomainEvent;-use crate::web_chat::{publish_web_channel_event, WebChannelEvent};+use crate::core::runtime::DispatchCtx;+use crate::web_chat::{publish_web_channel_event_in, WebChannelEvent};use async_trait::async_trait;use std::sync::Arc;use tinybus::EventHandler;@@ -46,14 +47,19 @@ impl EventHandler<DomainEvent> for WebProactiveSubscriber {source,message,job_name,- ..+ tenant,} = eventelse {return;};+ let Some(ctx) = DispatchCtx::for_event(tenant.as_ref()) else {+ tracing::warn!(source = %source, "[proactive] skipping web delivery without a live tenant context");+ return;+ };+let thread_id = format!("proactive:{}", job_name.as_deref().unwrap_or("system"));- publish_web_channel_event(WebChannelEvent {+ publish_web_channel_event_in(&ctx, WebChannelEvent {event: "proactive_message".to_string(),client_id: "system".to_string(),thread_id,diff --git a/crates/openhuman-rpc/src/server/socketio.rs b/crates/openhuman-rpc/src/server/socketio.rsindex 2900bf3fb1..d7b36bb3de 100644--- a/crates/openhuman-rpc/src/server/socketio.rs+++ b/crates/openhuman-rpc/src/server/socketio.rs@@ -293,8 +293,8 @@ pub fn attach_socketio() -> (socketioxide::layer::SocketIoLayer, SocketIo) {// receives broadcast-style events that aren't tied to a// specific chat thread. Today this covers proactive messages// (welcome agent, morning briefing, cron-driven announcements)- // which `channels::proactive::ProactiveMessageSubscriber`- // emits with `client_id = "system"` — see `emit_web_channel_event`.+ // which `web_chat::proactive::WebProactiveSubscriber` emits with+ // `client_id = "system"` — see `emit_web_channel_event`.// If this join fails the welcome message silently disappears,// so we log both success and failure for diagnosability.let _ = join_room_logged(&socket, "system", &client_id);