Support cua_repl as a Node REPL-backed MCP server (#40257)

## What changed

- Recognize `cua_repl` alongside `node_repl` when collecting Guardian review evidence, applying computer-use policy, and capturing transcript images.
- Render `cua_repl.js` results with the compact REPL history and transcript views.
- Preserve failed MCP call status and result content when replaying app-server history.

## Testing

- Cover both REPL server names across Guardian policy, evidence, image capture, history rendering, and failed-call replay tests.

GitOrigin-RevId: 8c13a721f718add403b07e727c1634b59203c51a
This commit is contained in:
Ankush Gupta authored and copyberry committed 2026-08-23 17:02:21 +00:00
1 parent c9b19deb09
commit 2161ec272a
16 files changed
+260 -82

No files matched your search

@@ -1187,6 +1187,70 @@ async fn replayed_in_progress_mcp_tool_call_stays_active() {
assert!(!active.contains("MCP tool call completed without a result"));
}
#[tokio::test]
async fn failed_repl_mcp_tool_call_preserves_status_and_result() {
for server in ["node_repl", "cua_repl"] {
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
let _ = drain_insert_history(&mut rx);
chat.handle_server_notification(
ServerNotification::ItemCompleted(ItemCompletedNotification {
thread_id: "thread-1".to_string(),
turn_id: "turn-1".to_string(),
completed_at_ms: 0,
item: AppServerThreadItem::McpToolCall {
id: "mcp-failed".to_string(),
server: server.to_string(),
tool: "js".to_string(),
status: codex_app_server_protocol::McpToolCallStatus::Failed,
arguments: json!({"title": "Inspect workspace"}),
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": "Script failed"}),
json!({"type": "text", "text": r#"{"exit_code":0,"output":"ready","chunk_id":"chunk-1"}"#}),
json!({"type": "text", "text": "Script error:\npermission denied"}),
],
structured_content: None,
meta: None,
})),
error: None,
duration_ms: Some(5),
},
}),
/*replay_kind*/ None,
);
let cells = drain_insert_history(&mut rx);
let [lines] = cells.as_slice() else {
panic!("expected one completed MCP tool call for {server}");
};
insta::allow_duplicates! {
insta::assert_snapshot!(lines_to_single_string(lines), @r#"
• Called Inspect workspace
└ Script failed
{"exit_code": 0, "output": "ready", "chunk_id": "chunk-1"}
Script error:
permission denied
"#);
}
assert_eq!(
lines.first(),
Some(&Line::from(vec![
"•".red().bold(),
" ".into(),
"Called".bold(),
" ".into(),
"Inspect workspace".cyan(),
])),
"{server}",
);
}
}
#[tokio::test]
async fn deferred_mcp_lifecycle_events_keep_fifo_after_stream_finishes() {
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;