Group adjacent computer actions in the TUI (#43576)

## What changed

Render adjacent `cua_repl` calls as a compact “Using computer” or “Used computer” group with action and failure counts. Show the current action while running, and prioritize failures and screenshots in completed previews while preserving their chronological order.

Keep full call arguments and output in the expanded transcript, with a `ctrl+t` hint for hidden actions. End groups at other history items and turn boundaries, preserve completed results when pending actions are interrupted, and use the same grouping for live events and history replay.

## Testing

Add unit and snapshot coverage for live/replay parity, grouping boundaries, out-of-order completion, interruption, failure and screenshot previews, full transcript details, and narrow-terminal and Unicode rendering.

GitOrigin-RevId: 8e61ccf4c9f6d1a4d56d674a6d41ca5160d42c82
This commit is contained in:
Felipe Coury authored and copyberry committed 2026-09-07 20:01:28 +00:00
1 parent a51608398d
commit 4110342321
21 files changed
+656 -18

No files matched your search

+22 -10
View File
@@ -1202,14 +1202,16 @@ impl ChatWidget {
} }
} }
fn flush_completed_command_activity(&mut self) { fn flush_completed_tool_activity(&mut self) {
if self if self.transcript.active_cell.as_ref().is_some_and(|cell| {
.transcript cell.as_any()
.active_cell .downcast_ref::<ExecCell>()
.as_ref() .is_some_and(|cell| !cell.is_active())
.and_then(|cell| cell.as_any().downcast_ref::<ExecCell>()) || cell
.is_some_and(|cell| !cell.is_active()) .as_any()
{ .downcast_ref::<history_cell::ComputerActivityCell>()
.is_some_and(|cell| !cell.is_active())
}) {
self.flush_active_cell(); self.flush_active_cell();
} }
} }
@@ -1247,10 +1249,15 @@ impl ChatWidget {
.transcript .transcript
.active_cell .active_cell
.as_ref() .as_ref()
.is_some_and(|active_cell| active_cell.as_any().is::<ExecCell>()) .is_some_and(|active_cell| {
active_cell.as_any().is::<ExecCell>()
|| active_cell
.as_any()
.is::<history_cell::ComputerActivityCell>()
})
&& !cell.transcript_lines(history_width).is_empty() && !cell.transcript_lines(history_width).is_empty()
{ {
self.flush_completed_command_activity(); self.flush_completed_tool_activity();
} }
self.app_event_tx.send(AppEvent::InsertHistoryCell(cell)); self.app_event_tx.send(AppEvent::InsertHistoryCell(cell));
} }
@@ -1389,6 +1396,11 @@ impl ChatWidget {
exec.mark_failed(); exec.mark_failed();
} else if let Some(tool) = cell.as_any_mut().downcast_mut::<McpToolCallCell>() { } else if let Some(tool) = cell.as_any_mut().downcast_mut::<McpToolCallCell>() {
tool.mark_failed(); tool.mark_failed();
} else if let Some(computer) = cell
.as_any_mut()
.downcast_mut::<history_cell::ComputerActivityCell>()
{
computer.mark_failed();
} }
self.add_boxed_history(cell); self.add_boxed_history(cell);
self.request_pending_usage_output_insertion(); self.request_pending_usage_output_insertion();
@@ -376,7 +376,12 @@ impl ChatWidget {
Some(exec_cell) if exec_cell.is_active() => { Some(exec_cell) if exec_cell.is_active() => {
ExecEndTarget::OrphanHistoryWhileActiveExec ExecEndTarget::OrphanHistoryWhileActiveExec
} }
None if cell.as_any().is::<McpToolCallCell>() => { None if cell.as_any().is::<McpToolCallCell>()
|| cell
.as_any()
.downcast_ref::<history_cell::ComputerActivityCell>()
.is_some_and(history_cell::ComputerActivityCell::is_active) =>
{
ExecEndTarget::OrphanHistoryWhileActiveExec ExecEndTarget::OrphanHistoryWhileActiveExec
} }
Some(_) | None => ExecEndTarget::NewCell, Some(_) | None => ExecEndTarget::NewCell,
@@ -79,7 +79,7 @@ impl ChatWidget {
if active_cell_is_empty { if active_cell_is_empty {
self.active_hook_cell = None; self.active_hook_cell = None;
} }
self.flush_completed_command_activity(); self.flush_completed_tool_activity();
self.bump_active_cell_revision(); self.bump_active_cell_revision();
self.app_event_tx self.app_event_tx
.send(AppEvent::InsertHistoryCell(Box::new(completed_cell))); .send(AppEvent::InsertHistoryCell(Box::new(completed_cell)));
+2
View File
@@ -243,6 +243,8 @@ mod compaction_tests;
#[path = "tests/completion_styling_tests.rs"] #[path = "tests/completion_styling_tests.rs"]
mod completion_styling; mod completion_styling;
mod composer_submission; mod composer_submission;
#[path = "tests/computer_activity_tests.rs"]
mod computer_activity_tests;
#[path = "tests/config_errors_tests.rs"] #[path = "tests/config_errors_tests.rs"]
mod config_errors; mod config_errors;
mod exec_flow; mod exec_flow;
@@ -0,0 +1,99 @@
use super::*;
fn computer_item(
id: &str,
status: codex_app_server_protocol::McpToolCallStatus,
) -> AppServerThreadItem {
AppServerThreadItem::McpToolCall {
id: id.to_string(),
server: "cua_repl".to_string(),
tool: "js".to_string(),
status,
arguments: json!({"title": format!("Inspect page {id}"), "code": "await cua.getState()"}),
app_context: None,
mcp_app_resource_uri: None,
plugin_id: None,
read_only_hint: None,
result: Some(Box::new(codex_app_server_protocol::McpToolCallResult {
content: vec![json!({"type": "text", "text": format!("Full output for {id}")})],
structured_content: None,
meta: None,
})),
error: None,
duration_ms: Some(5),
}
}
#[tokio::test]
async fn computer_activity_live_and_replay_group_identically() {
use codex_app_server_protocol::McpToolCallStatus;
let mut outputs = Vec::new();
for replay in [false, true] {
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
for id in ["1", "2", "3", "4"] {
let item = computer_item(id, McpToolCallStatus::Completed);
if replay {
chat.replay_thread_item(item, "turn-1".to_string(), ReplayKind::ThreadSnapshot);
} else {
chat.on_mcp_tool_call_started(computer_item(id, McpToolCallStatus::InProgress));
chat.on_mcp_tool_call_completed(item);
}
}
assert!(drain_insert_history(&mut rx).is_empty());
let cell = chat.transcript.active_cell.as_ref().expect("group");
outputs.push((
cell.display_lines(/*width*/ 80),
cell.transcript_lines(/*width*/ 100),
));
chat.finalize_turn();
let cells = drain_insert_history(&mut rx);
assert_eq!(cells.len(), 1);
assert_eq!(cells[0], outputs.last().unwrap().0);
}
assert_eq!(outputs[0], outputs[1]);
insta::assert_snapshot!(
"computer_activity_replayed",
lines_to_single_string(&outputs[0].0)
);
}
#[tokio::test]
async fn computer_activity_preserves_boundaries_and_expanded_output() {
use codex_app_server_protocol::McpToolCallStatus;
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
chat.on_mcp_tool_call_completed(computer_item("1", McpToolCallStatus::Completed));
chat.prepare_assistant_message();
let cells = drain_insert_history(&mut rx);
assert!(lines_to_single_string(&cells[0]).contains("Used computer · 1 action"));
chat.on_mcp_tool_call_completed(computer_item("2", McpToolCallStatus::Completed));
let mut other = computer_item("other", McpToolCallStatus::Completed);
if let AppServerThreadItem::McpToolCall { server, .. } = &mut other {
*server = "another_server".to_string();
}
chat.on_mcp_tool_call_completed(other);
let cells = drain_insert_history(&mut rx);
assert_eq!(cells.len(), 2);
assert!(lines_to_single_string(&cells[0]).contains("Used computer · 1 action"));
assert!(lines_to_single_string(&cells[1]).contains("another_server"));
chat.on_mcp_tool_call_completed(computer_item("3", McpToolCallStatus::Completed));
let transcript = chat.active_cell_transcript_lines(/*width*/ 100).unwrap();
assert!(lines_to_single_string(&transcript).contains("Full output for 3"));
assert!(lines_to_single_string(&transcript).contains("await cua.getState()"));
}
#[tokio::test]
async fn computer_activity_out_of_order_completion_and_interruption() {
use codex_app_server_protocol::McpToolCallStatus;
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
chat.on_mcp_tool_call_started(computer_item("1", McpToolCallStatus::InProgress));
chat.on_mcp_tool_call_started(computer_item("2", McpToolCallStatus::InProgress));
chat.on_mcp_tool_call_completed(computer_item("2", McpToolCallStatus::Completed));
assert!(active_blob(&chat).contains("Using computer"));
chat.finalize_turn();
let cells = drain_insert_history(&mut rx);
assert_eq!(cells.len(), 1);
insta::assert_snapshot!(
"computer_activity_partial_interruption",
lines_to_single_string(&cells[0])
);
}
@@ -1271,10 +1271,15 @@ async fn failed_repl_mcp_tool_call_preserves_status_and_result() {
/*replay_kind*/ None, /*replay_kind*/ None,
); );
chat.flush_active_cell();
let cells = drain_insert_history(&mut rx); let cells = drain_insert_history(&mut rx);
let [lines] = cells.as_slice() else { let [lines] = cells.as_slice() else {
panic!("expected one completed MCP tool call for {server}"); panic!("expected one completed MCP tool call for {server}");
}; };
if server == "cua_repl" {
insta::assert_snapshot!("failed_computer_activity", lines_to_single_string(lines));
continue;
}
insta::allow_duplicates! { insta::allow_duplicates! {
insta::assert_snapshot!(lines_to_single_string(lines), @r#" insta::assert_snapshot!(lines_to_single_string(lines), @r#"
• Called Inspect workspace • Called Inspect workspace
@@ -0,0 +1,7 @@
---
source: tui/src/chatwidget/tests/computer_activity_tests.rs
expression: "lines_to_single_string(&cells[0])"
---
• Used computer · 2 actions · 1 failed
├ Failed: Inspect page 1 — interrupted
└ Inspect page 2
@@ -0,0 +1,8 @@
---
source: tui/src/chatwidget/tests/computer_activity_tests.rs
expression: "lines_to_single_string(&outputs[0].0)"
---
• Used computer · 4 actions
├ Inspect page 3
├ Inspect page 4
└ 2 more · ctrl+t
@@ -0,0 +1,6 @@
---
source: tui/src/chatwidget/tests/history_replay.rs
expression: lines_to_single_string(lines)
---
• Used computer · 1 action · 1 failed
└ Failed: Inspect workspace — permission denied
+48 -5
View File
@@ -173,14 +173,26 @@ impl ChatWidget {
return; return;
}; };
self.flush_answer_stream_with_separator(); self.flush_answer_stream_with_separator();
let invocation = McpInvocation {
server,
tool,
arguments: Some(arguments),
};
if invocation.is_computer_activity() {
let call = history_cell::new_active_mcp_tool_call(
id,
invocation,
self.local_settings.tui.animations,
);
self.update_computer_activity(|cell| cell.start(call));
self.bump_active_cell_revision();
self.request_redraw();
return;
}
self.flush_active_cell(); self.flush_active_cell();
self.transcript.active_cell = Some(Box::new(history_cell::new_active_mcp_tool_call( self.transcript.active_cell = Some(Box::new(history_cell::new_active_mcp_tool_call(
id, id,
McpInvocation { invocation,
server,
tool,
arguments: Some(arguments),
},
self.local_settings.tui.animations, self.local_settings.tui.animations,
))); )));
self.bump_active_cell_revision(); self.bump_active_cell_revision();
@@ -224,6 +236,19 @@ impl ChatWidget {
(None, None) => Err("MCP tool call completed without a result".to_string()), (None, None) => Err("MCP tool call completed without a result".to_string()),
}; };
if invocation.is_computer_activity() {
let call = history_cell::new_active_mcp_tool_call(
id,
invocation,
self.local_settings.tui.animations,
);
self.update_computer_activity(|cell| cell.complete(call, duration, result));
self.bump_active_cell_revision();
self.transcript.had_work_activity = true;
self.request_redraw();
return;
}
let extra_cell = match self let extra_cell = match self
.transcript .transcript
.active_cell .active_cell
@@ -250,6 +275,24 @@ impl ChatWidget {
} }
} }
/// Reuse only adjacent computer calls; all other active cells form a transcript boundary.
fn update_computer_activity(
&mut self,
update: impl FnOnce(&mut history_cell::ComputerActivityCell),
) {
if let Some(cell) = self.transcript.active_cell.as_mut().and_then(|cell| {
cell.as_any_mut()
.downcast_mut::<history_cell::ComputerActivityCell>()
}) {
update(cell);
} else {
self.flush_active_cell();
let mut cell = history_cell::ComputerActivityCell::default();
update(&mut cell);
self.transcript.active_cell = Some(Box::new(cell));
}
}
pub(crate) fn handle_queued_item_started_now(&mut self, item: ThreadItem) { pub(crate) fn handle_queued_item_started_now(&mut self, item: ThreadItem) {
match item { match item {
item @ ThreadItem::CommandExecution { .. } => { item @ ThreadItem::CommandExecution { .. } => {
@@ -0,0 +1,218 @@
//! Compact adjacent computer calls without discarding their chronological transcript details.
//!
//! Only CUA calls enter this cell. Other history items and turn boundaries end the group.
//! Preview selection favors failures and images, but never changes the order of retained rows.
use super::*;
#[derive(Debug, Default)]
pub(crate) struct ComputerActivityCell {
calls: Vec<McpToolCallCell>,
}
impl ComputerActivityCell {
pub(crate) fn start(&mut self, call: McpToolCallCell) {
if !self
.calls
.iter()
.any(|existing| existing.call_id == call.call_id)
{
self.calls.push(call);
}
}
/// Completion-only replay follows the same path as a live start followed by completion.
pub(crate) fn complete(
&mut self,
call: McpToolCallCell,
duration: Duration,
result: Result<codex_protocol::mcp::CallToolResult, String>,
) {
let id = call.call_id.clone();
self.start(call);
if let Some(call) = self.calls.iter_mut().find(|call| call.call_id == id) {
// Images are represented in the action preview and full MCP transcript. Inserting a
// separate image-output history cell here would prematurely break adjacent grouping.
let _ = call.complete(duration, result);
}
}
pub(crate) fn is_active(&self) -> bool {
self.calls.iter().any(|call| call.result.is_none())
}
pub(crate) fn mark_failed(&mut self) {
for call in &mut self.calls {
if call.result.is_none() {
call.mark_failed();
}
}
}
}
fn has_image(call: &McpToolCallCell) -> bool {
matches!(&call.result, Some(Ok(result)) if result.has_image)
}
/// Keep previews on one physical row, including grapheme clusters and narrow terminals.
fn preview(text: &str, width: usize) -> String {
let normalized = text.split_whitespace().collect::<Vec<_>>().join(" ");
let (prefix, rest, _) = take_prefix_by_width(&normalized, width);
if rest.is_empty() {
prefix
} else if width == 0 {
String::new()
} else {
let (prefix, _, _) = take_prefix_by_width(&normalized, width.saturating_sub(1));
format!("{prefix}…")
}
}
fn error_preview(call: &McpToolCallCell) -> Option<&str> {
let text = match call.result.as_ref()? {
Err(error) => error.as_str(),
Ok(result) => result
.content
.iter()
.filter_map(result::McpContentBlock::text)
.find(|text| text.starts_with("Script error:"))
.or_else(|| {
result
.content
.iter()
.find_map(|block| block.text().filter(|text| !text.trim().is_empty()))
})?,
};
// CUA errors can append entire API manuals. The first nonempty line is the diagnostic;
// preserve subsequent lines only in the full transcript, without inventing a paraphrase.
text.strip_prefix("Script error:")
.unwrap_or(text)
.lines()
.map(str::trim)
.find(|line| !line.is_empty())
}
impl HistoryCell for ComputerActivityCell {
fn display_lines(&self, width: u16) -> Vec<Line<'static>> {
if width == 0 {
return Vec::new();
}
let active = self.calls.iter().rposition(|call| call.result.is_none());
let failures = self
.calls
.iter()
.filter(|call| call.success() == Some(false))
.count();
let count = self.calls.len();
let bullet = active
.and_then(|index| {
let call = &self.calls[index];
activity_indicator(
Some(call.start_time),
MotionMode::from_animations_enabled(call.animations_enabled),
ReducedMotionIndicator::StaticBullet,
)
})
.unwrap_or_else(|| "•".dim());
let label = if active.is_some() {
"Using computer"
} else {
"Used computer"
};
let unit = if count == 1 { "action" } else { "actions" };
let mut header = vec![
bullet,
" ".into(),
label.bold(),
format!(" · {count} {unit}").dim(),
];
if failures > 0 {
header.push(format!(" · {failures} failed").red());
}
let mut lines = adaptive_wrap_line(
&Line::from(header),
RtOptions::new(usize::from(width).max(1)).subsequent_indent(" ".into()),
)
.iter()
.map(line_to_static)
.collect::<Vec<_>>();
let mut selected = if let Some(index) = active {
vec![index]
} else {
let mut indices = (0..count).collect::<Vec<_>>();
indices.sort_by_key(|&index| {
let call = &self.calls[index];
std::cmp::Reverse((call.success() == Some(false), has_image(call), index))
});
indices.truncate(if count > 3 { 2 } else { 3 });
indices
};
selected.sort_unstable();
let hidden = count - selected.len();
let visible = selected.len();
for (row_index, index) in selected.into_iter().enumerate() {
let call = &self.calls[index];
let title = call
.invocation
.arguments
.as_ref()
.and_then(|args| args.get("title"))
.and_then(serde_json::Value::as_str)
.filter(|title| !title.trim().is_empty())
.unwrap_or("Computer action");
let failed = call.success() == Some(false);
let summary = if failed {
match error_preview(call) {
Some(error) if width < 60 => format!("Failed: {error}"),
Some(error) => {
let title = preview(title, usize::from(width) / 3);
format!("Failed: {title} — {error}")
}
None => format!("Failed: {title}"),
}
} else if has_image(call) {
format!("Captured screenshot · {title}")
} else {
title.to_string()
};
let summary = preview(&summary, usize::from(width).saturating_sub(4));
let row = if failed { summary.red() } else { summary.dim() };
let prefix = if row_index + 1 == visible && (hidden == 0 || active.is_some()) {
" └ "
} else {
" ├ "
};
lines.push(vec![prefix.dim(), row].into());
}
if hidden > 0 && active.is_none() {
let summary = preview(
&format!("{hidden} more · ctrl+t"),
usize::from(width).saturating_sub(4),
);
lines.push(vec![" └ ".dim(), summary.dim()].into());
}
lines
}
fn transcript_lines(&self, width: u16) -> Vec<Line<'static>> {
self.calls
.iter()
.flat_map(|call| call.transcript_lines(width))
.collect()
}
fn raw_lines(&self) -> Vec<Line<'static>> {
plain_lines(self.transcript_lines(u16::MAX))
}
fn transcript_animation_tick(&self) -> Option<u64> {
self.calls
.iter()
.filter_map(HistoryCell::transcript_animation_tick)
.max()
}
}
#[cfg(test)]
#[path = "computer_activity_tests.rs"]
mod tests;
@@ -0,0 +1,152 @@
use super::*;
use codex_protocol::mcp::CallToolResult;
use pretty_assertions::assert_eq;
use serde_json::json;
fn call(id: &str, title: &str) -> McpToolCallCell {
McpToolCallCell::new(
id.to_string(),
McpInvocation {
server: "cua_repl".to_string(),
tool: "js".to_string(),
arguments: Some(json!({"title": title, "code": "await cua.getState()"})),
},
/*animations_enabled*/ false,
)
}
fn result(text: &str) -> Result<CallToolResult, String> {
Ok(CallToolResult {
content: vec![json!({"type": "text", "text": text})],
structured_content: None,
is_error: Some(false),
meta: None,
})
}
fn render(cell: &ComputerActivityCell, width: u16) -> String {
cell.display_lines(width)
.iter()
.map(ToString::to_string)
.collect::<Vec<_>>()
.join("\n")
}
#[test]
fn computer_activity_active_and_interrupted() {
let mut cell = ComputerActivityCell::default();
cell.complete(call("1", "Opened Chrome"), Duration::ZERO, result("ready"));
cell.start(call("2", "Load the terminal"));
cell.start(call("2", "Duplicate start"));
insta::assert_snapshot!("computer_activity_active", render(&cell, /*width*/ 80));
cell.mark_failed();
insta::assert_snapshot!("computer_activity_interrupted", render(&cell, /*width*/ 80));
assert_eq!(
cell.calls
.iter()
.map(McpToolCallCell::success)
.collect::<Vec<_>>(),
vec![Some(true), Some(false)]
);
}
#[test]
fn computer_activity_prioritizes_errors_and_images_without_reordering() {
let mut cell = ComputerActivityCell::default();
cell.complete(
call("1", "Open browser"),
Duration::ZERO,
Err("No browser is available\n\n## Computer Use\nFull tool documentation".to_string()),
);
cell.complete(
call("2", "Connect to Chrome"),
Duration::ZERO,
result("connected"),
);
cell.complete(
call("3", "Reproduce the clear-command bug"),
Duration::ZERO,
result("reproduced"),
);
let mut image = result("screenshot metadata").unwrap();
image.content.push(json!({"type": "image", "mimeType": "image/png", "data": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR4nGP4z8DwHwAFAAH/iZk9HQAAAABJRU5ErkJggg=="}));
cell.complete(
call("4", "Capture the reproduced bug"),
Duration::ZERO,
Ok(image),
);
cell.complete(
call("5", "Check the final page"),
Duration::ZERO,
result("checked"),
);
insta::assert_snapshot!("computer_activity_mixed", render(&cell, /*width*/ 90));
insta::assert_snapshot!("computer_activity_narrow", render(&cell, /*width*/ 24));
let transcript = cell
.transcript_lines(/*width*/ 100)
.iter()
.map(ToString::to_string)
.collect::<Vec<_>>()
.join("\n");
insta::assert_snapshot!("computer_activity_expanded", transcript);
assert!(transcript.contains("Full tool documentation"));
assert_eq!(
cell.raw_lines(),
plain_lines(cell.transcript_lines(u16::MAX))
);
assert!(
cell.display_lines(/*width*/ 24)
.iter()
.all(|line| line.width() <= 24)
);
}
#[test]
fn computer_activity_completed_and_transport_errors_keep_full_details() {
let mut cell = ComputerActivityCell::default();
cell.complete(
call("1", "Inspect page"),
Duration::ZERO,
result("A successful result with details"),
);
cell.complete(call("2", "Reload page"), Duration::ZERO, result("Loaded"));
insta::assert_snapshot!("computer_activity_success", render(&cell, /*width*/ 80));
let mut failure =
result("Browser state changed\nRe-query the browser before continuing").unwrap();
failure.is_error = Some(true);
cell.complete(
call("3", "Inspect refreshed page"),
Duration::ZERO,
Ok(failure),
);
insta::assert_snapshot!(
"computer_activity_failed_result",
render(&cell, /*width*/ 90)
);
cell.mark_failed();
assert_eq!(
cell.calls
.iter()
.map(McpToolCallCell::success)
.collect::<Vec<_>>(),
vec![Some(true), Some(true), Some(false)]
);
}
#[test]
fn computer_activity_preview_handles_unicode_and_long_diagnostics() {
assert_eq!(preview(" 你好\nworld ", /*width*/ 6), "你好 …");
let mut cell = ComputerActivityCell::default();
cell.complete(
call("1", "检查浏览器"),
Duration::ZERO,
Err("diagnostic ".repeat(200)),
);
insta::assert_snapshot!("computer_activity_unicode", render(&cell, /*width*/ 24));
assert!(
cell.display_lines(/*width*/ 24)
.iter()
.all(|line| line.width() <= 24)
);
assert!(cell.transcript_lines(/*width*/ 100).len() > 20);
}
+13 -1
View File
@@ -7,6 +7,10 @@ use codex_protocol::mcp::is_node_repl_backed_server;
#[path = "mcp_result.rs"] #[path = "mcp_result.rs"]
mod result; mod result;
#[path = "computer_activity.rs"]
mod computer_activity;
pub(crate) use computer_activity::ComputerActivityCell;
use crate::style::StatusTone; use crate::style::StatusTone;
use crate::style::accent_style; use crate::style::accent_style;
use crate::style::status_style; use crate::style::status_style;
@@ -56,6 +60,12 @@ pub(crate) struct McpInvocation {
pub(crate) arguments: Option<serde_json::Value>, pub(crate) arguments: Option<serde_json::Value>,
} }
impl McpInvocation {
pub(crate) fn is_computer_activity(&self) -> bool {
self.server == "cua_repl"
}
}
#[derive(Clone, Copy, Eq, PartialEq)] #[derive(Clone, Copy, Eq, PartialEq)]
enum McpToolCallRenderMode { enum McpToolCallRenderMode {
/// Compact presentation used in normal conversation history. /// Compact presentation used in normal conversation history.
@@ -125,7 +135,9 @@ impl McpToolCallCell {
} }
fn result_kind(&self) -> McpResultKind { fn result_kind(&self) -> McpResultKind {
if is_node_repl_backed_server(&self.invocation.server) && self.invocation.tool == "js" { if self.invocation.is_computer_activity()
|| (is_node_repl_backed_server(&self.invocation.server) && self.invocation.tool == "js")
{
McpResultKind::NodeRepl McpResultKind::NodeRepl
} else { } else {
McpResultKind::Standard McpResultKind::Standard
@@ -0,0 +1,6 @@
---
source: tui/src/history_cell/computer_activity_tests.rs
expression: "render(&cell, 80)"
---
• Using computer · 2 actions
└ Load the terminal
@@ -0,0 +1,17 @@
---
source: tui/src/history_cell/computer_activity_tests.rs
expression: transcript
---
• Called cua_repl.js({"title":"Open browser","code":"await cua.getState()"})
└ Error: No browser is available
## Computer Use
Full tool documentation
• Called cua_repl.js({"title":"Connect to Chrome","code":"await cua.getState()"})
└ connected
• Called cua_repl.js({"title":"Reproduce the clear-command bug","code":"await cua.getState()"})
└ reproduced
• Called cua_repl.js({"title":"Capture the reproduced bug","code":"await cua.getState()"})
└ screenshot metadata
<image content>
• Called cua_repl.js({"title":"Check the final page","code":"await cua.getState()"})
└ checked
@@ -0,0 +1,8 @@
---
source: tui/src/history_cell/computer_activity_tests.rs
expression: "render(&cell, 90)"
---
• Used computer · 3 actions · 1 failed
├ Inspect page
├ Reload page
└ Failed: Inspect refreshed page — Browser state changed
@@ -0,0 +1,7 @@
---
source: tui/src/history_cell/computer_activity_tests.rs
expression: "render(&cell, 80)"
---
• Used computer · 2 actions · 1 failed
├ Opened Chrome
└ Failed: Load the terminal — interrupted
@@ -0,0 +1,8 @@
---
source: tui/src/history_cell/computer_activity_tests.rs
expression: "render(&cell, 90)"
---
• Used computer · 5 actions · 1 failed
├ Failed: Open browser — No browser is available
├ Captured screenshot · Capture the reproduced bug
└ 3 more · ctrl+t
@@ -0,0 +1,9 @@
---
source: tui/src/history_cell/computer_activity_tests.rs
expression: "render(&cell, 24)"
---
• Used computer · 5
actions · 1 failed
├ Failed: No browser …
├ Captured screenshot…
└ 3 more · ctrl+t
@@ -0,0 +1,7 @@
---
source: tui/src/history_cell/computer_activity_tests.rs
expression: "render(&cell, 80)"
---
• Used computer · 2 actions
├ Inspect page
└ Reload page
@@ -0,0 +1,7 @@
---
source: tui/src/history_cell/computer_activity_tests.rs
expression: "render(&cell, 24)"
---
• Used computer · 1
action · 1 failed
└ Failed: diagnostic …