Skip to content

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

refactor(tests): update web_channel_event usage in tests

Steven Enamakeledc622dd1d33
diff --git a/crates/openhuman-core/src/web_chat/web_tests_error_copy_fixture_tests.rs b/crates/openhuman-core/src/web_chat/web_tests_error_copy_fixture_tests.rs
index cc05ec9a3b..bb98341203 100644
--- a/crates/openhuman-core/src/web_chat/web_tests_error_copy_fixture_tests.rs
+++ b/crates/openhuman-core/src/web_chat/web_tests_error_copy_fixture_tests.rs
@@ -870,13 +870,18 @@ fn provider_detail_travels_as_a_param_and_the_message_still_quotes_it() {
fn chat_error_event_serializes_copy_key_and_params_to_literal_json() {
let classified =
classify_inference_error("openrouter API error (429 Too Many Requests): Retry-After: 30");
- let event = WebChannelEvent {
- event: "chat_error".to_string(),
+ let event = WebChannelEvent::ChatError {
+ context: crate::web_chat::WebEventContext::default(),
message: Some(classified.message.clone()),
error_type: Some(classified.error_type.to_string()),
+ error_source: None,
+ error_retryable: None,
+ error_retry_after_ms: None,
+ error_provider: None,
+ error_fallback_available: None,
copy_key: Some(classified.copy_key.to_string()),
copy_params: classified.copy_params,
- ..Default::default()
+ guardrail: None,
};
let json = serde_json::to_value(&event).expect("serializes");
assert_eq!(json["copy_key"], "chat_error.rate_limited");
@@ -888,6 +893,19 @@ fn chat_error_event_serializes_copy_key_and_params_to_literal_json() {
assert_eq!(json["message"], classified.message);
// Older emitters (cancellation, guardrail) carry neither key.
- let bare = serde_json::to_value(WebChannelEvent::default()).expect("serializes");
+ let bare = serde_json::to_value(WebChannelEvent::ChatError {
+ context: crate::web_chat::WebEventContext::default(),
+ message: None,
+ error_type: None,
+ error_source: None,
+ error_retryable: None,
+ error_retry_after_ms: None,
+ error_provider: None,
+ error_fallback_available: None,
+ copy_key: None,
+ copy_params: None,
+ guardrail: None,
+ })
+ .expect("serializes");
assert!(bare.get("copy_key").is_none() && bare.get("copy_params").is_none());
}
diff --git a/crates/openhuman-rpc/src/server/http/events_tests.rs b/crates/openhuman-rpc/src/server/http/events_tests.rs
index 5306f9eb89..2ab1661a44 100644
--- a/crates/openhuman-rpc/src/server/http/events_tests.rs
+++ b/crates/openhuman-rpc/src/server/http/events_tests.rs
@@ -109,15 +109,21 @@ async fn events_stream_forwards_only_the_bound_client() {
assert_eq!(response.status(), StatusCode::OK);
let mut body = response.into_body().into_data_stream();
- publish_web_channel_event(WebChannelEvent {
- event: "wrong_client_probe".into(),
- client_id: "another-client".into(),
- ..Default::default()
+ publish_web_channel_event(WebChannelEvent::UserError {
+ context: crate::core_host::web_chat::WebEventContext {
+ client_id: "another-client".into(),
+ ..Default::default()
+ },
+ error_type: Some("wrong_client_probe".into()),
+ error_source: None,
});
- publish_web_channel_event(WebChannelEvent {
- event: "right_client_probe".into(),
- client_id: "stream-client".into(),
- ..Default::default()
+ publish_web_channel_event(WebChannelEvent::UserError {
+ context: crate::core_host::web_chat::WebEventContext {
+ client_id: "stream-client".into(),
+ ..Default::default()
+ },
+ error_type: Some("right_client_probe".into()),
+ error_source: None,
});
let chunk = tokio::time::timeout(std::time::Duration::from_secs(1), body.next())
@@ -126,7 +132,8 @@ async fn events_stream_forwards_only_the_bound_client() {
.expect("SSE body chunk")
.expect("SSE bytes");
let event = String::from_utf8_lossy(&chunk);
- assert!(event.contains("event: right_client_probe"));
+ assert!(event.contains("event: user_error"));
+ assert!(event.contains("right_client_probe"));
assert!(!event.contains("wrong_client_probe"));
}
diff --git a/crates/openhuman-tui/src/app/thread_actions.rs b/crates/openhuman-tui/src/app/thread_actions.rs
index ddf4bd92c6..1ce683c79c 100644
--- a/crates/openhuman-tui/src/app/thread_actions.rs
+++ b/crates/openhuman-tui/src/app/thread_actions.rs
@@ -47,7 +47,7 @@ pub(super) fn send_message(
log::error!("[tui] openhuman.channel_web_chat failed: {e}");
// Surface the failure in-transcript via a synthetic chat_error so
// the reducer clears the streaming state and shows the reason.
- web_chat::publish_web_channel_event(WebChannelEvent {
+ web_chat::publish_web_channel_event(WebChannelEvent::ChatError {
context: web_chat::WebEventContext {
client_id: cid,
thread_id: tid,