From 83745d1be201273e81b9fa21c02536f8b34ff640 Mon Sep 17 00:00:00 2001 From: Jeremy Rose Date: Mon, 25 Aug 2025 15:14:48 -0700 Subject: [PATCH] fix merge --- codex-rs/core/src/codex.rs | 156 ------------------------------- codex-rs/tui/src/chatwidget.rs | 1 + codex-rs/tui/src/history_cell.rs | 50 +--------- 3 files changed, 2 insertions(+), 205 deletions(-) diff --git a/codex-rs/core/src/codex.rs b/codex-rs/core/src/codex.rs index a24e12a084..1ac95c8f38 100644 --- a/codex-rs/core/src/codex.rs +++ b/codex-rs/core/src/codex.rs @@ -1979,162 +1979,6 @@ async fn try_run_turn( let _ = sess.tx_event.send(event).await; } - // Run MCP, LocalShell, and non-apply exec tool calls fully in parallel. - let mut mcp_futs = Vec::new(); - let mut local_futs = Vec::new(); - let mut exec_parallel_futs = Vec::new(); - // Keep apply_patch exec calls sequential for diff tracking. - let mut exec_sequential_calls = Vec::new(); - - for sc in staged { - match sc { - StagedCall::Mcp { - item, - server, - tool, - args, - call_id, - } => { - let fut = handle_mcp_tool_call( - sess, - sub_id, - call_id.clone(), - server, - tool, - args, - None, - ); - mcp_futs.push(async move { - let response = fut.await; - ProcessedResponseItem { - item, - response: Some(response), - } - }); - } - StagedCall::LocalShell { - item, - id, - call_id, - action, - } => { - let effective_call_id = match (call_id, id) { - (Some(call_id), _) => call_id, - (None, Some(id)) => id, - (None, None) => String::new(), - }; - let LocalShellAction::Exec(action) = action; - let params = ShellToolCallParams { - command: action.command, - workdir: action.working_directory, - timeout_ms: action.timeout_ms, - with_escalated_permissions: None, - justification: None, - }; - let exec_params = to_exec_params(params, turn_context); - let fut = async move { - // Use a fresh tracker – non-apply_patch calls won't emit diffs anyway. - let mut tdt = TurnDiffTracker::new(); - let response = handle_container_exec_with_params( - exec_params, - sess, - turn_context, - &mut tdt, - sub_id.to_string(), - effective_call_id, - ) - .await; - ProcessedResponseItem { - item, - response: Some(response), - } - }; - local_futs.push(fut); - } - StagedCall::Exec { - item, - name, - args, - call_id, - } => { - if name == "apply_patch" { - exec_sequential_calls.push(StagedCall::Exec { - item, - name, - args, - call_id, - }); - } else { - let fut = async move { - let response = match parse_container_exec_arguments( - args, - turn_context, - &call_id, - ) { - Ok(params) => { - let mut tdt = TurnDiffTracker::new(); - handle_container_exec_with_params( - params, - sess, - turn_context, - &mut tdt, - sub_id.to_string(), - call_id, - ) - .await - } - Err(output) => *output, - }; - ProcessedResponseItem { - item, - response: Some(response), - } - }; - exec_parallel_futs.push(fut); - } - } - other => exec_sequential_calls.push(other), - } - } - - let mut processed: Vec = join_all(mcp_futs).await; - processed.extend(join_all(local_futs).await); - processed.extend(join_all(exec_parallel_futs).await); - - // Now handle exec/shell calls one by one so we can use the turn_diff_tracker safely. - for sc in exec_sequential_calls { - match sc { - StagedCall::Exec { - item, - name, - args, - call_id, - } => { - // Reuse existing logic for exec tools. - let response = handle_function_call( - sess, - turn_context, - turn_diff_tracker, - sub_id.to_string(), - name, - args, - call_id, - ) - .await; - processed.push(ProcessedResponseItem { - item, - response: Some(response), - }); - } - StagedCall::LocalShell { .. } => {} - StagedCall::Mcp { .. } => {} - } - } - - // Preserve original ordering: non-tool items were already pushed to `output` as they arrived; - // now append the processed tool-call items in their staged order. - output.extend(processed); - return Ok(output); } ResponseEvent::OutputTextDelta(delta) => { diff --git a/codex-rs/tui/src/chatwidget.rs b/codex-rs/tui/src/chatwidget.rs index 9135abfe2b..9f4d7dfbb6 100644 --- a/codex-rs/tui/src/chatwidget.rs +++ b/codex-rs/tui/src/chatwidget.rs @@ -643,6 +643,7 @@ impl ChatWidget { last_token_usage: TokenUsage::default(), stream: StreamController::new(config), running_commands: HashMap::new(), + running_mcp: HashMap::new(), pending_exec_completions: Vec::new(), task_complete_pending: false, interrupts: InterruptManager::new(), diff --git a/codex-rs/tui/src/history_cell.rs b/codex-rs/tui/src/history_cell.rs index 0299f58469..d45c8eb9b3 100644 --- a/codex-rs/tui/src/history_cell.rs +++ b/codex-rs/tui/src/history_cell.rs @@ -446,7 +446,6 @@ pub(crate) fn new_active_mcp_tool_call(invocation: McpInvocation) -> PlainHistor title_line, format_mcp_invocation(invocation), ]; -<<<<<<< HEAD PlainHistoryCell { lines } } @@ -467,61 +466,14 @@ impl RunningMcpCell { } } -impl HistoryCell for RunningMcpCell { - fn display_lines(&self) -> Vec> { - let mut lines: Vec> = Vec::new(); - lines.push(Line::from("")); - - // Spinner or final status marker - let running = self.is_running.load(Ordering::Relaxed); - let status = if running { - const FRAMES: &[char] = &['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']; - let idx = ((self.start_time.elapsed().as_millis() / 100) as usize) % FRAMES.len(); - Span::raw(format!("{}", FRAMES[idx])) - } else { - "✓".green() - }; - - let title = Line::from(vec![ - "tool".magenta(), - " ".into(), - status, - " ".into(), - "running...".dim(), - ]); - lines.push(title); - lines.push(format_mcp_invocation(self.invocation.clone())); - lines - } -} +// (second impl removed; defined above) pub(crate) fn new_web_search_call(query: String) -> PlainHistoryCell { let lines: Vec> = vec![Line::from(""), Line::from(vec!["🌐 ".into(), query.into()])]; -||||||| 097782c7 - -======= ->>>>>>> refs/remotes/origin/nornagon/parallel-tool-calls PlainHistoryCell { lines } } -#[derive(Debug)] -pub(crate) struct RunningMcpCell { - invocation: McpInvocation, - start_time: Instant, - is_running: Arc, -} - -impl RunningMcpCell { - pub(crate) fn new(invocation: McpInvocation, is_running: Arc) -> Self { - Self { - invocation, - start_time: Instant::now(), - is_running, - } - } -} - impl HistoryCell for RunningMcpCell { fn display_lines(&self) -> Vec> { let mut lines: Vec> = Vec::new();