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

+48 -5
View File
@@ -173,14 +173,26 @@ impl ChatWidget {
return;
};
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.transcript.active_cell = Some(Box::new(history_cell::new_active_mcp_tool_call(
id,
McpInvocation {
server,
tool,
arguments: Some(arguments),
},
invocation,
self.local_settings.tui.animations,
)));
self.bump_active_cell_revision();
@@ -224,6 +236,19 @@ impl ChatWidget {
(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
.transcript
.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) {
match item {
item @ ThreadItem::CommandExecution { .. } => {