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): update event assertions for scoped event API
Steven Enamakele0c6e0db3c29
diff --git a/crates/openhuman-core/src/web_chat/presentation_tests.rs b/crates/openhuman-core/src/web_chat/presentation_tests.rsindex 6a9e764638..d756edeeb1 100644--- a/crates/openhuman-core/src/web_chat/presentation_tests.rs+++ b/crates/openhuman-core/src/web_chat/presentation_tests.rs@@ -30,13 +30,18 @@ fn single_bubble_delivery_emits_one_unsegmented_chat_done() {}assert_eq!(mine.len(), 1, "exactly one terminal event, no chat_segment");let done = &mine[0];- assert_eq!(done.event, "chat_done");- assert_eq!(done.client_id, "system");- assert_eq!(done.thread_id, "thread-1");- assert_eq!(done.full_response.as_deref(), Some(text));- assert_eq!(done.segment_total, None);- assert_eq!(done.segment_index, None);- assert!(done.usage.is_none());+ assert_eq!(done.event_name(), "chat_done");+ assert_eq!(done.context().client_id, "system");+ assert_eq!(done.context().thread_id, "thread-1");+ assert!(matches!(+ done.wire_event(),+ crate::web_chat::WebChannelEvent::ChatDone {+ full_response: Some(response),+ usage: None,+ parts: None,+ ..+ } if response == text+ ));}// ── chat_done.timing ──────────────────────────────────────────────────────@@ -92,14 +97,24 @@ async fn chat_done_carries_timing_when_a_snapshot_is_supplied() {}};- let payload = done.timing.expect("chat_done.timing must be Some");+ let crate::web_chat::WebChannelEvent::ChatDone {+ timing: Some(payload), ..+ } = done.wire_event()+ else {+ panic!("chat_done.timing must be Some");+ };assert_eq!(payload.first_token_ms, Some(120));assert_eq!(payload.first_tool_ms, None);assert_eq!(payload.total_ms, Some(2000));// 40 output tokens / (2000ms / 1000) = 20 tokens/sec.assert_eq!(payload.tokens_per_second, Some(20.0));// The gauge numerator travels beside the spend totals, unsummed.- let usage = done.usage.expect("chat_done.usage must be Some");+ let crate::web_chat::WebChannelEvent::ChatDone {+ usage: Some(usage), ..+ } = done.wire_event()+ else {+ panic!("chat_done.usage must be Some");+ };assert_eq!((usage.input_tokens, usage.context_tokens), (100, 60));}@@ -136,7 +151,10 @@ async fn chat_done_omits_timing_when_no_snapshot_is_supplied() {}};- assert!(done.timing.is_none());+ assert!(matches!(+ done.wire_event(),+ crate::web_chat::WebChannelEvent::ChatDone { timing: None, .. }+ ));}// ── Delivery persists before it announces (#6034) ───────────────────────diff --git a/crates/openhuman-core/src/web_chat/suggestions_tests.rs b/crates/openhuman-core/src/web_chat/suggestions_tests.rsindex 191c1d2bb0..cf9c6bc9a1 100644--- a/crates/openhuman-core/src/web_chat/suggestions_tests.rs+++ b/crates/openhuman-core/src/web_chat/suggestions_tests.rs@@ -98,12 +98,15 @@ impl ChatModel<()> for ScriptedTextModel {}async fn drain_suggestions_event(- rx: &mut tokio::sync::broadcast::Receiver<WebChannelEvent>,+ rx: &mut tokio::sync::broadcast::Receiver<crate::web_chat::ScopedWebEvent>,thread_id: &str,-) -> Option<WebChannelEvent> {+) -> Option<crate::web_chat::ScopedWebEvent> {loop {match tokio::time::timeout(Duration::from_secs(2), rx.recv()).await {- Ok(Ok(ev)) if ev.event == "chat_suggestions" && ev.thread_id == thread_id => {+ Ok(Ok(ev))+ if ev.event_name() == "chat_suggestions"+ && ev.context().thread_id == thread_id =>+ {return Some(ev);}Ok(Ok(_)) => continue,diff --git a/crates/openhuman-core/src/web_chat/turn_events_tests.rs b/crates/openhuman-core/src/web_chat/turn_events_tests.rsindex 0941192c3c..1ff169addd 100644--- a/crates/openhuman-core/src/web_chat/turn_events_tests.rs+++ b/crates/openhuman-core/src/web_chat/turn_events_tests.rs@@ -30,7 +30,7 @@ fn events() -> (Arc<Shared>, WebEvents) {}async fn events_for(- rx: &mut tokio::sync::broadcast::Receiver<WebChannelEvent>,+ rx: &mut tokio::sync::broadcast::Receiver<crate::web_chat::ScopedWebEvent>,request_id: &str,count: usize,) -> Vec<WebChannelEvent> {@@ -98,11 +98,21 @@ async fn a_completed_turn_announces_one_chat_done_with_its_timing() {).await;let done = events_for(&mut rx, "events-done", 1).await.remove(0);- assert_eq!(done.event, "chat_done");- assert_eq!(done.client_id, "starter");- assert_eq!(done.full_response.as_deref(), Some("all done"));- assert_eq!(done.timing.expect("timing").total_ms, Some(1_000));- assert_eq!(done.seq, None, "terminal events sit outside the seq stream");+ assert_eq!(done.event_name(), "chat_done");+ assert_eq!(done.context().client_id, "starter");+ assert!(matches!(+ done.wire_event(),+ WebChannelEvent::ChatDone {+ full_response: Some(text),+ timing: Some(timing),+ ..+ } if text == "all done" && timing.total_ms == Some(1_000)+ ));+ assert_eq!(+ done.context().seq,+ None,+ "terminal events sit outside the seq stream"+ );assert!(shared.take("events-done").is_none(), "the slot is released");}