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
test(web_chat): add coverage for event bus, state, presentation, and ingress
Steven Enamakel8a028fb2cc5b
diff --git a/crates/openhuman-core/src/web_chat/event_bus_tests.rs b/crates/openhuman-core/src/web_chat/event_bus_tests.rsindex 8599c08517..276561e6ec 100644--- a/crates/openhuman-core/src/web_chat/event_bus_tests.rs+++ b/crates/openhuman-core/src/web_chat/event_bus_tests.rs@@ -533,7 +533,7 @@ async fn plan_review_surface_bridges_plan_review_decided() {#[tokio::test]async fn publish_web_channel_event_stamps_ts_when_unset() {let mut web_rx = subscribe_web_channel_events();- let before = crate::web_chat::progress_bridge::unix_epoch_ms();+ let before = crate::web_chat::progress::unix_epoch_ms();publish_web_channel_event(WebChannelEvent {event: "ts_stamp_probe".to_string(),@@ -542,7 +542,7 @@ async fn publish_web_channel_event_stamps_ts_when_unset() {});let ev = find_agent_web_event(&mut web_rx, "ts_stamp_probe", "thread-ts-stamp-probe").await;- let after = crate::web_chat::progress_bridge::unix_epoch_ms();+ let after = crate::web_chat::progress::unix_epoch_ms();let ts = ev.ts.expect("publish_web_channel_event must stamp ts when unset");diff --git a/crates/openhuman-core/src/web_chat/ops/state_tests.rs b/crates/openhuman-core/src/web_chat/ops/state_tests.rsindex 004601c4a9..c55f8f67d5 100644--- a/crates/openhuman-core/src/web_chat/ops/state_tests.rs+++ b/crates/openhuman-core/src/web_chat/ops/state_tests.rs@@ -1,4 +1,5 @@use super::*;+use crate::web_chat::runner::runtime;use crate::core::runtime::{context::CoreContext, ContextOverlay, DomainSet};use crate::tools::toolpacks::ToolGroups;@@ -19,34 +20,19 @@ async fn each_agent_context_owns_its_turn_tables() {let alpha = agent(&root, "alpha");let beta = agent(&root, "beta");- let (alpha_sessions, alpha_in_flight, alpha_parallel) = {+ let (alpha_sessions, alpha_runtime) = {let scope_ctx = crate::core::runtime::DispatchCtx::new(Arc::clone(&alpha));-- (- thread_sessions(&scope_ctx),- in_flight(&scope_ctx),- parallel_in_flight(&scope_ctx),- )+ (thread_sessions(&scope_ctx), runtime(&scope_ctx))};- let (beta_sessions, beta_in_flight, beta_parallel) = {+ let (beta_sessions, beta_runtime) = {let scope_ctx = crate::core::runtime::DispatchCtx::new(beta);-- (- thread_sessions(&scope_ctx),- in_flight(&scope_ctx),- parallel_in_flight(&scope_ctx),- )- };- let alpha_again = {- let scope_ctx = crate::core::runtime::DispatchCtx::new(alpha);-- in_flight(&scope_ctx)+ (thread_sessions(&scope_ctx), runtime(&scope_ctx))};+ let alpha_again = runtime(&crate::core::runtime::DispatchCtx::new(alpha));assert!(!Arc::ptr_eq(&alpha_sessions, &beta_sessions));- assert!(!Arc::ptr_eq(&alpha_in_flight, &beta_in_flight));- assert!(!Arc::ptr_eq(&alpha_parallel, &beta_parallel));- assert!(Arc::ptr_eq(&alpha_in_flight, &alpha_again));+ assert!(!Arc::ptr_eq(&alpha_runtime, &beta_runtime));+ assert!(Arc::ptr_eq(&alpha_runtime, &alpha_again));}#[tokio::test]@@ -96,7 +82,6 @@ async fn a_user_cancel_under_the_fence_placeholder_id_keeps_the_callers_client()track_parallel_turn_for_test(&crate::core::runtime::DispatchCtx::ambient(),"fence-thread",- "fence-req",token.clone(),).await;@@ -111,12 +96,19 @@ async fn a_user_cancel_under_the_fence_placeholder_id_keeps_the_callers_client().await.unwrap();- assert!(token.is_cancelled());- let mut seen = None;- while let Ok(event) = events.try_recv() {- if event.event == "chat_cancelled" && event.request_id == "fence-req" {- seen = Some(event.client_id);+ let seen = tokio::time::timeout(std::time::Duration::from_secs(10), async {+ loop {+ match events.recv().await {+ Ok(event) if event.event == "chat_cancelled" && event.thread_id == "fence-thread" => {+ return event.client_id;+ }+ Ok(_) | Err(tokio::sync::broadcast::error::RecvError::Lagged(_)) => continue,+ Err(error) => panic!("event stream closed: {error}"),+ }}- }- assert_eq!(seen.as_deref(), Some("profile-fence"));+ })+ .await+ .expect("the cancelled turn announces itself");+ assert_eq!(seen, "profile-fence");+ assert!(token.is_cancelled());}diff --git a/crates/openhuman-core/src/web_chat/presentation_tests.rs b/crates/openhuman-core/src/web_chat/presentation_tests.rsindex 70389f8645..23beca225a 100644--- a/crates/openhuman-core/src/web_chat/presentation_tests.rs+++ b/crates/openhuman-core/src/web_chat/presentation_tests.rs@@ -60,10 +60,11 @@ async fn chat_done_carries_timing_when_a_snapshot_is_supplied() {subagents: Vec::new(),reasoning_tokens: 0,};- let timing = crate::web_chat::turn_timing::TurnTimingSnapshot {+ let timing = tinychannels_bus::web::TurnTimingSnapshot {first_token_ms: Some(120),first_tool_ms: None,total_ms: Some(2000),+ ..Default::default()};test_support::deliver_response_with_timing_for_test(diff --git a/crates/openhuman-core/src/web_chat/web_tests_start_chat_ingress_tests.rs b/crates/openhuman-core/src/web_chat/web_tests_start_chat_ingress_tests.rsindex 05786a009b..25662899e2 100644--- a/crates/openhuman-core/src/web_chat/web_tests_start_chat_ingress_tests.rs+++ b/crates/openhuman-core/src/web_chat/web_tests_start_chat_ingress_tests.rs@@ -626,19 +626,19 @@ fn timeout_bound_tag_separates_the_two_harness_ceilings() {// budget on real work vs one call wedged against its own ceiling. Tagging// them alike would rebuild the conflation in the dashboard (#5804).assert_eq!(- super::super::ops::timeout_bound_tag(+ super::super::turn_events::timeout_bound_tag("run timed out: tool call for run `agent_turn` exceeded its remaining wall-clock budget (26375 ms)"),"run_remaining");assert_eq!(- super::super::ops::timeout_bound_tag(+ super::super::turn_events::timeout_bound_tag("run timed out: model call for run `abc` exceeded its per-model-call ceiling (120000 ms)"),"per_model_call");assert_eq!(- super::super::ops::timeout_bound_tag("openrouter API error (500 Internal Server Error)"),+ super::super::turn_events::timeout_bound_tag("openrouter API error (500 Internal Server Error)"),"none","a non-timeout error must not carry a timeout bound");@@ -663,7 +663,7 @@ fn hosted_timeout_bound_reaches_the_sentry_tag_and_keeps_the_user_class() {};let err = crate::agent::tinyagents::hosted_error::run_error_from_hosted(hosted);let flattened = format!("run_chat_task failed error=tinyagents harness run failed: {err}");- assert_eq!(super::super::ops::timeout_bound_tag(&flattened), tag);+ assert_eq!(super::super::turn_events::timeout_bound_tag(&flattened), tag);assert_eq!(super::super::web_errors::classify_inference_error(&flattened).error_type,"turn_timeout"