From 6a0f709cff9af480045adc9700c85039fd4c88f0 Mon Sep 17 00:00:00 2001 From: Michael Bolin Date: Thu, 14 Aug 2025 16:09:12 -0700 Subject: [PATCH 1/2] fix: add call_id to ApprovalParams in mcp-server/src/wire_format.rs (#2322) Clients still need this field. --- codex-rs/mcp-server/src/codex_message_processor.rs | 6 ++++-- codex-rs/mcp-server/src/wire_format.rs | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/codex-rs/mcp-server/src/codex_message_processor.rs b/codex-rs/mcp-server/src/codex_message_processor.rs index a13f0f2677..2495feb9e0 100644 --- a/codex-rs/mcp-server/src/codex_message_processor.rs +++ b/codex-rs/mcp-server/src/codex_message_processor.rs @@ -306,13 +306,14 @@ async fn apply_bespoke_event_handling( let Event { id: event_id, msg } = event; match msg { EventMsg::ApplyPatchApprovalRequest(ApplyPatchApprovalRequestEvent { - call_id: _, + call_id, changes, reason, grant_root, }) => { let params = ApplyPatchApprovalParams { conversation_id, + call_id, file_changes: changes, reason, grant_root, @@ -327,13 +328,14 @@ async fn apply_bespoke_event_handling( }); } EventMsg::ExecApprovalRequest(ExecApprovalRequestEvent { - call_id: _, + call_id, command, cwd, reason, }) => { let params = ExecCommandApprovalParams { conversation_id, + call_id, command, cwd, reason, diff --git a/codex-rs/mcp-server/src/wire_format.rs b/codex-rs/mcp-server/src/wire_format.rs index 4a2346cb3f..95d55e8bf5 100644 --- a/codex-rs/mcp-server/src/wire_format.rs +++ b/codex-rs/mcp-server/src/wire_format.rs @@ -187,6 +187,9 @@ pub enum ServerRequest { #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] pub struct ApplyPatchApprovalParams { pub conversation_id: ConversationId, + /// Use to correlate this with [codex_core::protocol::PatchApplyBeginEvent] + /// and [codex_core::protocol::PatchApplyEndEvent]. + pub call_id: String, pub file_changes: HashMap, /// Optional explanatory reason (e.g. request for extra write access). #[serde(skip_serializing_if = "Option::is_none")] @@ -200,6 +203,9 @@ pub struct ApplyPatchApprovalParams { #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] pub struct ExecCommandApprovalParams { pub conversation_id: ConversationId, + /// Use to correlate this with [codex_core::protocol::ExecCommandBeginEvent] + /// and [codex_core::protocol::ExecCommandEndEvent]. + pub call_id: String, pub command: Vec, pub cwd: PathBuf, #[serde(skip_serializing_if = "Option::is_none")] From c5888ab9fa417935b44939c2dbda07d3436681bb Mon Sep 17 00:00:00 2001 From: Michael Bolin Date: Thu, 14 Aug 2025 16:43:30 -0700 Subject: [PATCH 2/2] fix: ensure rust-ci always "runs" when a PR is submitted --- .github/workflows/rust-ci.yml | 63 ++++++++++++++++++++++++++--------- 1 file changed, 48 insertions(+), 15 deletions(-) diff --git a/.github/workflows/rust-ci.yml b/.github/workflows/rust-ci.yml index 735a187a78..1861233abf 100644 --- a/.github/workflows/rust-ci.yml +++ b/.github/workflows/rust-ci.yml @@ -1,29 +1,60 @@ name: rust-ci on: - pull_request: - branches: - - main - paths: - - "codex-rs/**" - - ".github/**" + pull_request: {} push: branches: - main - workflow_dispatch: -# For CI, we build in debug (`--profile dev`) rather than release mode so we -# get signal faster. +# CI builds in debug (dev) for faster signal. jobs: - # CI that don't need specific targets + # --- Detect what changed (always runs) ------------------------------------- + changed: + name: Detect changed areas + runs-on: ubuntu-24.04 + outputs: + codex: ${{ steps.detect.outputs.codex }} + workflows: ${{ steps.detect.outputs.workflows }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Detect changed paths (no external action) + id: detect + shell: bash + run: | + set -euo pipefail + + if [[ "${{ github.event_name }}" == "pull_request" ]]; then + BASE_SHA='${{ github.event.pull_request.base.sha }}' + echo "Base SHA: $BASE_SHA" + # List files changed between base and current HEAD (merge-base aware) + mapfile -t files < <(git diff --name-only --no-renames "$BASE_SHA"...HEAD) + else + # On push / manual runs, default to running everything + files=("codex-rs/force" ".github/force") + fi + + codex=false + workflows=false + for f in "${files[@]}"; do + [[ $f == codex-rs/* ]] && codex=true + [[ $f == .github/* ]] && workflows=true + done + + echo "codex=$codex" >> "$GITHUB_OUTPUT" + echo "workflows=$workflows" >> "$GITHUB_OUTPUT" + + # --- CI that doesn't need specific targets --------------------------------- general: name: Format / etc runs-on: ubuntu-24.04 + needs: changed + if: ${{ needs.changed.outputs.codex == 'true' || needs.changed.outputs.workflows == 'true' || github.event_name == 'push' }} defaults: run: working-directory: codex-rs - steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@1.88 @@ -32,11 +63,13 @@ jobs: - name: cargo fmt run: cargo fmt -- --config imports_granularity=Item --check - # CI to validate on different os/targets + # --- CI to validate on different os/targets -------------------------------- lint_build_test: name: ${{ matrix.runner }} - ${{ matrix.target }}${{ matrix.profile == 'release' && ' (release)' || '' }} runs-on: ${{ matrix.runner }} timeout-minutes: 30 + needs: changed + if: ${{ needs.changed.outputs.codex == 'true' || needs.changed.outputs.workflows == 'true' || github.event_name == 'push' }} defaults: run: working-directory: codex-rs @@ -44,8 +77,6 @@ jobs: strategy: fail-fast: false matrix: - # Note: While Codex CLI does not support Windows today, we include - # Windows in CI to ensure the code at least builds there. include: - runner: macos-14 target: aarch64-apple-darwin @@ -113,7 +144,9 @@ jobs: id: build if: ${{ matrix.target == 'x86_64-unknown-linux-gnu' && matrix.profile != 'release' }} continue-on-error: true - run: find . -name Cargo.toml -mindepth 2 -maxdepth 2 -print0 | xargs -0 -n1 -I{} bash -c 'cd "$(dirname "{}")" && cargo build --profile ${{ matrix.profile }}' + run: | + find . -name Cargo.toml -mindepth 2 -maxdepth 2 -print0 \ + | xargs -0 -n1 -I{} bash -c 'cd "$(dirname "{}")" && cargo build --profile ${{ matrix.profile }}' - name: cargo test id: test