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(web_chat): split event bus into channel module
Steven Enamakel8cbbbccd728b
diff --git a/crates/openhuman-core/src/web_chat/event_bus.rs b/crates/openhuman-core/src/web_chat/event_bus.rsindex bd8fce0680..94fb407a5d 100644--- a/crates/openhuman-core/src/web_chat/event_bus.rs+++ b/crates/openhuman-core/src/web_chat/event_bus.rs@@ -8,37 +8,13 @@ use std::sync::{Arc, OnceLock};use tokio::sync::broadcast;use crate::core::events::DomainEvent;-use crate::core::runtime::DispatchCtx;use crate::web_chat::WebChannelEvent;use tinybus::EventHandler;use tinybus::SubscriptionHandle;-static EVENT_BUS: Lazy<broadcast::Sender<WebChannelEvent>> = Lazy::new(|| {- let (tx, _rx) = broadcast::channel(512);- tx-});--pub fn subscribe_web_channel_events() -> broadcast::Receiver<WebChannelEvent> {- EVENT_BUS.subscribe()-}--/// Publish `event` to every subscribed socket bridge and the JSON-RPC-/// `/events` stream, stamping `ts` (epoch ms) when the caller left it unset-/// so every emitted event carries a wall-clock time the frontend can use for-/// ordering/latency display without guessing at receive time.-pub fn publish_web_channel_event(event: WebChannelEvent) {- publish_web_channel_event_in(&DispatchCtx::ambient(), event);-}--/// [`publish_web_channel_event`] with the tenant stamped from `ctx`: the one-/// the calling turn runs under, rather than the calling task's own scope.-pub fn publish_web_channel_event_in(ctx: &DispatchCtx, mut event: WebChannelEvent) {- if event.ts.is_none() {- event.ts = Some(crate::web_chat::progress_bridge::unix_epoch_ms());- }- event.stamp_tenant(ctx.tenant().ok());- let _ = EVENT_BUS.send(event);-}+pub use super::event_bus_channel::{+ publish_web_channel_event, publish_web_channel_event_in, subscribe_web_channel_events,+};static APPROVAL_SURFACE_HANDLE: OnceLock<SubscriptionHandle> = OnceLock::new();diff --git a/crates/openhuman-core/src/web_chat/event_bus_channel.rs b/crates/openhuman-core/src/web_chat/event_bus_channel.rsnew file mode 100644index 0000000000..214912336a--- /dev/null+++ b/crates/openhuman-core/src/web_chat/event_bus_channel.rs@@ -0,0 +1,34 @@+//! The process-wide `WebChannelEvent` broadcast channel and its publishers.++use once_cell::sync::Lazy;+use tokio::sync::broadcast;++use crate::core::runtime::DispatchCtx;+use crate::web_chat::WebChannelEvent;++static EVENT_BUS: Lazy<broadcast::Sender<WebChannelEvent>> = Lazy::new(|| {+ let (tx, _rx) = broadcast::channel(512);+ tx+});++pub fn subscribe_web_channel_events() -> broadcast::Receiver<WebChannelEvent> {+ EVENT_BUS.subscribe()+}++/// Publish `event` to every subscribed socket bridge and the JSON-RPC+/// `/events` stream, stamping `ts` (epoch ms) when the caller left it unset+/// so every emitted event carries a wall-clock time the frontend can use for+/// ordering/latency display without guessing at receive time.+pub fn publish_web_channel_event(event: WebChannelEvent) {+ publish_web_channel_event_in(&DispatchCtx::ambient(), event);+}++/// [`publish_web_channel_event`] with the tenant stamped from `ctx`: the one+/// the calling turn runs under, rather than the calling task's own scope.+pub fn publish_web_channel_event_in(ctx: &DispatchCtx, mut event: WebChannelEvent) {+ if event.ts.is_none() {+ event.ts = Some(crate::web_chat::progress_bridge::unix_epoch_ms());+ }+ event.stamp_tenant(ctx.tenant().ok());+ let _ = EVENT_BUS.send(event);+}