core-agent-ide/codex-rs/app-server/tests/suite
Owen Lin d6c30ed25e
[app-server] feat: v2 apply_patch approval flow (#6760)
This PR adds the API V2 version of the apply_patch approval flow, which
centers around `ThreadItem::FileChange`.

This PR wires the new RPC (`item/fileChange/requestApproval`, V2 only)
and related events (`item/started`, `item/completed` for
`ThreadItem::FileChange`, which are emitted in both V1 and V2) through
the app-server
protocol. The new approval RPC is only sent when the user initiates a
turn with the new `turn/start` API so we don't break backwards
compatibility with VSCE.

Similar to https://github.com/openai/codex/pull/6758, the approach I
took was to make as few changes to the Codex core as possible,
leveraging existing `EventMsg` core events, and translating those in
app-server. I did have to add a few additional fields to
`EventMsg::PatchApplyBegin` and `EventMsg::PatchApplyEnd`, but those
were fairly lightweight.

However, the `EventMsg`s emitted by core are the following:
```
1) Auto-approved (no request for approval)

- EventMsg::PatchApplyBegin
- EventMsg::PatchApplyEnd

2) Approved by user
- EventMsg::ApplyPatchApprovalRequest
- EventMsg::PatchApplyBegin
- EventMsg::PatchApplyEnd

3) Declined by user
- EventMsg::ApplyPatchApprovalRequest
- EventMsg::PatchApplyBegin
- EventMsg::PatchApplyEnd
```

For a request triggering an approval, this would result in:
```
item/fileChange/requestApproval
item/started
item/completed
```

which is different from the `ThreadItem::CommandExecution` flow
introduced in https://github.com/openai/codex/pull/6758, which does the
below and is preferable:
```
item/started
item/commandExecution/requestApproval
item/completed
```

To fix this, we leverage `TurnSummaryStore` on codex_message_processor
to store a little bit of state, allowing us to fire `item/started` and
`item/fileChange/requestApproval` whenever we receive the underlying
`EventMsg::ApplyPatchApprovalRequest`, and no-oping when we receive the
`EventMsg::PatchApplyBegin` later.

This is much less invasive than modifying the order of EventMsg within
core (I tried).

The resulting payloads:
```
{
  "method": "item/started",
  "params": {
    "item": {
      "changes": [
        {
          "diff": "Hello from Codex!\n",
          "kind": "add",
          "path": "/Users/owen/repos/codex/codex-rs/APPROVAL_DEMO.txt"
        }
      ],
      "id": "call_Nxnwj7B3YXigfV6Mwh03d686",
      "status": "inProgress",
      "type": "fileChange"
    }
  }
}
```

```
{
  "id": 0,
  "method": "item/fileChange/requestApproval",
  "params": {
    "grantRoot": null,
    "itemId": "call_Nxnwj7B3YXigfV6Mwh03d686",
    "reason": null,
    "threadId": "019a9e11-8295-7883-a283-779e06502c6f",
    "turnId": "1"
  }
}
```

```
{
  "id": 0,
  "result": {
    "decision": "accept"
  }
}
```

```
{
  "method": "item/completed",
  "params": {
    "item": {
      "changes": [
        {
          "diff": "Hello from Codex!\n",
          "kind": "add",
          "path": "/Users/owen/repos/codex/codex-rs/APPROVAL_DEMO.txt"
        }
      ],
      "id": "call_Nxnwj7B3YXigfV6Mwh03d686",
      "status": "completed",
      "type": "fileChange"
    }
  }
}
```
2025-11-19 20:13:31 -08:00
..
v2 [app-server] feat: v2 apply_patch approval flow (#6760) 2025-11-19 20:13:31 -08:00
archive_conversation.rs Fixes intermittent test failures in CI (#6282) 2025-11-05 13:12:25 -08:00
auth.rs chore: use anyhow::Result for all app-server integration tests (#5836) 2025-10-28 08:10:23 -07:00
codex_message_processor_flow.rs chore: use anyhow::Result for all app-server integration tests (#5836) 2025-10-28 08:10:23 -07:00
config.rs feat: arcticfox in the wild (#6906) 2025-11-19 16:31:06 +00:00
create_conversation.rs chore: use anyhow::Result for all app-server integration tests (#5836) 2025-10-28 08:10:23 -07:00
fuzzy_file_search.rs chore: use anyhow::Result for all app-server integration tests (#5836) 2025-10-28 08:10:23 -07:00
interrupt.rs [app-server] feat: v2 Turn APIs (#6216) 2025-11-06 16:36:36 +00:00
list_resume.rs [app-server] feat: v2 Thread APIs (#6214) 2025-11-05 20:28:43 +00:00
login.rs chore: use anyhow::Result for all app-server integration tests (#5836) 2025-10-28 08:10:23 -07:00
mod.rs chore: move relevant tests to app-server/tests/suite/v2 (#6289) 2025-11-06 10:53:17 -08:00
send_message.rs Update user instruction message format (#6010) 2025-10-30 18:44:02 -07:00
set_default_model.rs feat: arcticfox in the wild (#6906) 2025-11-19 16:31:06 +00:00
user_agent.rs chore: use anyhow::Result for all app-server integration tests (#5836) 2025-10-28 08:10:23 -07:00
user_info.rs chore: use anyhow::Result for all app-server integration tests (#5836) 2025-10-28 08:10:23 -07:00