Skip to content

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

feat(tui): handle channel_outbound events as turn completion

Steven Enamakelcadb49e462fd
diff --git a/crates/openhuman-tui/src/app_tests.rs b/crates/openhuman-tui/src/app_tests.rs
index c9b3490784..aa9b4e3554 100644
--- a/crates/openhuman-tui/src/app_tests.rs
+++ b/crates/openhuman-tui/src/app_tests.rs
@@ -150,7 +150,7 @@ fn failed_account_thread_replacement_rejects_old_and_unscoped_activity() {
handle_web_event(
&web_event(json!({
"event":"text_delta","client_id":"client","thread_id":thread,
- "delta":"old secret"
+ "request_id":"old-turn","delta":"old secret"
})),
&mut state,
&mut ui,
diff --git a/crates/openhuman-tui/src/event_view.rs b/crates/openhuman-tui/src/event_view.rs
index ef567e90f9..1300fc57c7 100644
--- a/crates/openhuman-tui/src/event_view.rs
+++ b/crates/openhuman-tui/src/event_view.rs
@@ -82,12 +82,25 @@ impl WebEventView {
E::ChatCancelled { cancel_reason, .. } => {
view.message.clone_from(cancel_reason);
}
- E::TextDelta { delta, .. }
- | E::ThinkingDelta { delta, .. }
- | E::SubagentTextDelta { delta, .. }
- | E::SubagentThinkingDelta { delta, .. } => {
+ E::TextDelta { delta, .. } | E::ThinkingDelta { delta, .. } => {
view.delta.clone_from(delta);
}
+ E::SubagentTextDelta {
+ delta,
+ skill_id,
+ subagent,
+ ..
+ }
+ | E::SubagentThinkingDelta {
+ delta,
+ skill_id,
+ subagent,
+ ..
+ } => {
+ view.delta.clone_from(delta);
+ view.skill_id.clone_from(skill_id);
+ view.subagent = subagent.as_ref().map(&subagent_view);
+ }
E::IterationStart { message, .. } | E::RunModeChanged { message, .. } => {
view.message.clone_from(message);
}
diff --git a/crates/openhuman-tui/src/state.rs b/crates/openhuman-tui/src/state.rs
index 85b4444619..07e2481bb1 100644
--- a/crates/openhuman-tui/src/state.rs
+++ b/crates/openhuman-tui/src/state.rs
@@ -304,9 +304,10 @@ impl TranscriptState {
format!("artifact · {status}{suffix}"),
));
}
- "chat_done" => {
+ "chat_done" | "channel_outbound" => {
log::debug!(
- "[tui] state: chat_done full_response={}",
+ "[tui] state: {} full_response={}",
+ ev.event,
ev.full_response.is_some()
);
// `full_response` is authoritative — it replaces whatever the
diff --git a/crates/openhuman-tui/src/state_events.rs b/crates/openhuman-tui/src/state_events.rs
index a12478dd11..2e526d51c1 100644
--- a/crates/openhuman-tui/src/state_events.rs
+++ b/crates/openhuman-tui/src/state_events.rs
@@ -30,6 +30,7 @@ const REDUCED: &[&str] = &[
"artifact_ready",
"artifact_failed",
"chat_done",
+ "channel_outbound",
"chat_error",
];
diff --git a/crates/openhuman-tui/src/state_tests.rs b/crates/openhuman-tui/src/state_tests.rs
index f2f0a12595..3d3175d413 100644
--- a/crates/openhuman-tui/src/state_tests.rs
+++ b/crates/openhuman-tui/src/state_tests.rs
@@ -150,6 +150,24 @@ fn chat_done_without_prior_deltas_still_shows_full_response() {
assert!(!s.is_streaming());
}
+#[test]
+fn channel_outbound_finishes_turn_with_its_final_response() {
+ let mut state = TranscriptState::new(CLIENT);
+ state.begin_user_turn("hi");
+ state.apply_event(&text_delta("partial"));
+ state.apply_event(&ev(
+ "channel_outbound",
+ serde_json::json!({"full_response":"final reply"}),
+ ));
+ let assistant = state
+ .entries()
+ .iter()
+ .find(|entry| entry.kind == EntryKind::Assistant)
+ .expect("channel_outbound carries the delivered assistant reply");
+ assert_eq!(assistant.text, "final reply");
+ assert!(!state.is_streaming());
+}
+
#[test]
fn chat_error_pushes_error_entry_and_ends_stream() {
let mut s = TranscriptState::new(CLIENT);
@@ -367,7 +385,8 @@ fn child_activity_accumulates_output_and_failed_status_in_one_record() {
state.apply_event(&ev(
event,
serde_json::json!({
- "skill_id":"task","request_id":"turn","delta":delta,"message":"Timed out"
+ "skill_id":null,"request_id":"turn","delta":delta,"message":"Timed out",
+ "subagent":{"task_id":"task"}
}),
));
}
diff --git a/crates/openhuman-tui/src/viewport_tests.rs b/crates/openhuman-tui/src/viewport_tests.rs
index 23b8ff16b9..d4a819461a 100644
--- a/crates/openhuman-tui/src/viewport_tests.rs
+++ b/crates/openhuman-tui/src/viewport_tests.rs
@@ -164,7 +164,8 @@ fn changing_an_old_tools_height_updates_prefix_lookup_without_rebuilding_history
let mut state = TranscriptState::new("test");
let event = |name: &str, fields: serde_json::Value| {
let mut value = serde_json::json!({
- "event":name,"client_id":"test","tool_call_id":"old","tool_name":"tool"
+ "event":name,"client_id":"test","thread_id":"thread","request_id":"turn",
+ "tool_call_id":"old","tool_name":"tool"
});
value
.as_object_mut()