Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(web_chat): update tests for scoped event accessors

Steven Enamakel99d4ff9bd9eb
diff --git a/crates/openhuman-core/src/channels/providers/relay/ops_tests.rs b/crates/openhuman-core/src/channels/providers/relay/ops_tests.rs
index 2a3926f070..14d3e8a61a 100644
--- a/crates/openhuman-core/src/channels/providers/relay/ops_tests.rs
+++ b/crates/openhuman-core/src/channels/providers/relay/ops_tests.rs
@@ -206,7 +206,7 @@ async fn a_relayed_turn_runs_as_an_external_channel_and_keeps_its_thread() {
let mut outbound = Vec::new();
while let Ok(event) = events.try_recv() {
- if event.client_id == "gw-ops-test" {
+ if event.context().client_id == "gw-ops-test" {
outbound.push(event);
}
}
diff --git a/crates/openhuman-core/src/web_chat/progress_tests.rs b/crates/openhuman-core/src/web_chat/progress_tests.rs
index 4f8d4e43b8..89e8346ac4 100644
--- a/crates/openhuman-core/src/web_chat/progress_tests.rs
+++ b/crates/openhuman-core/src/web_chat/progress_tests.rs
@@ -617,11 +617,14 @@ mod tool_progress_tests {
let event = recv_for_thread(&mut events, thread_id).await;
assert_eq!(event.event_name(), "tool_progress");
assert_eq!(event.context().request_id, "req-tool-progress");
- assert_eq!(event.tool_call_id.as_deref(), Some("call-1"));
- assert_eq!(
- event.message.as_deref(),
- Some("running 15s · 2.0 KB output")
- );
+ assert!(matches!(
+ event.wire_event(),
+ crate::web_chat::WebChannelEvent::ToolProgress {
+ tool_call_id: Some(call_id),
+ message: Some(message),
+ ..
+ } if call_id == "call-1" && message == "running 15s · 2.0 KB output"
+ ));
drop(tx);
}
}
diff --git a/crates/openhuman-core/src/web_chat/web_tests_session_and_concurrency_tests.rs b/crates/openhuman-core/src/web_chat/web_tests_session_and_concurrency_tests.rs
index 5328ebd95f..2a6b68b9a4 100644
--- a/crates/openhuman-core/src/web_chat/web_tests_session_and_concurrency_tests.rs
+++ b/crates/openhuman-core/src/web_chat/web_tests_session_and_concurrency_tests.rs
@@ -670,9 +670,9 @@ async fn unscoped_cancel_stops_the_threads_detached_subagents() {
/// The terminal event (`chat_done` or `chat_error`) for `request_id`.
async fn terminal_event(
- rx: &mut tokio::sync::broadcast::Receiver<crate::web_chat::WebChannelEvent>,
+ rx: &mut tokio::sync::broadcast::Receiver<crate::web_chat::ScopedWebEvent>,
request_id: &str,
-) -> crate::web_chat::WebChannelEvent {
+) -> crate::web_chat::ScopedWebEvent {
loop {
let event = rx.recv().await.expect("event stream should stay open");
if event.context().request_id == request_id
@@ -684,11 +684,20 @@ async fn terminal_event(
}
/// A graceful, retryable `turn_timeout` whose user copy hides the marker.
-fn assert_turn_timeout(event: &crate::web_chat::WebChannelEvent) {
+fn assert_turn_timeout(event: &crate::web_chat::ScopedWebEvent) {
assert_eq!(event.event_name(), "chat_error", "{event:?}");
- assert_eq!(event.error_type.as_deref(), Some("turn_timeout"));
- assert_eq!(event.error_retryable, Some(true));
- let message = event.message.clone().unwrap_or_default();
+ let crate::web_chat::WebChannelEvent::ChatError {
+ error_type,
+ error_retryable,
+ message,
+ ..
+ } = event.wire_event()
+ else {
+ panic!("expected chat_error event: {event:?}");
+ };
+ assert_eq!(error_type.as_deref(), Some("turn_timeout"));
+ assert_eq!(*error_retryable, Some(true));
+ let message = message.clone();
assert!(
!message.contains("openhuman_turn_wall_clock_timeout"),
"internal marker must not leak into user copy: {message}"