You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix approval popup not appearing when ACP agents request permission.
The root cause was that approval requests were being deferred during
active streaming, but in ACP mode the agent subprocess blocks waiting
for approval - causing a deadlock.
Changes:
- Handle approval requests immediately in TUI (not deferred)
- Add MOCK_AGENT_REQUEST_PERMISSION support to mock agent
- Enable test_acp_approval_request_displayed_in_tui test
- Update documentation for approval handling behavior
Copy file name to clipboardExpand all lines: codex-rs/acp/HANDOFF.md
+15-4Lines changed: 15 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,11 +21,22 @@
21
21
-`LocalBoxFuture` is `!Send`, requiring the dedicated worker thread pattern already in `connection.rs`
22
22
- Test snapshot changes for version numbers are pre-existing upstream issues, not caused by this work
23
23
24
-
## Critical Changes to Forthcoming Work
24
+
## Approval Bridging - COMPLETED
25
+
26
+
The approval bridging is now working end-to-end:
27
+
- Permission requests from ACP agents are displayed in the TUI approval popup
28
+
- User decisions are sent back to the agent via `Op::ExecApproval`
29
+
- The TUI handles approval requests immediately (not deferred) to avoid deadlock with blocking agent subprocess
30
+
- E2E test `test_acp_approval_request_displayed_in_tui` passes
31
+
32
+
Key changes:
33
+
- Modified `tui/src/chatwidget.rs` to handle approval requests immediately
34
+
- Added `MOCK_AGENT_REQUEST_PERMISSION` env var support to mock agent
35
+
- Removed `#[ignore]` from approval bridging E2E test
36
+
37
+
## Remaining Work
25
38
26
-
-**Approval bridging is incomplete**: The `submit()` method handles `Op::ExecApproval` and `Op::PatchApproval` by storing decisions in `pending_approvals`, but the actual bridging logic to forward these to the ACP connection's `ClientDelegate` is not yet wired up
27
39
-**MCP servers config**: The plan mentions passing `config.mcp_servers` to `NewSessionRequest`, but this is not yet implemented
28
40
-**Sandbox policy**: Currently read from config but not used - needs to be passed to agent
29
41
-**Error events need refinement**: Currently sends generic error text for unsupported Ops; may need structured error types
30
-
-**E2E tests not yet written**: The plan lists tests in `tui-pty-e2e/tests/acp_mode.rs` that still need implementation
31
-
-**Tool call display**: `ToolCall` and `ToolCallUpdate` translation returns empty vec - needs implementation to show tool execution in TUI
42
+
-**Tool call display**: `ToolCall` and `ToolCallUpdate` translation returns empty vec - needs implementation to show tool execution in TUI (E2E tests exist but fail)
@@ -113,6 +113,7 @@ The ACP module bridges permission requests to Codex's approval UI:
113
113
-`AcpConnection::take_approval_receiver()` exposes the receiver for TUI consumption
114
114
- Falls back to auto-approve if approval channel is closed (no UI listening)
115
115
- Falls back to deny if response channel is dropped (UI didn't respond)
116
+
-**Critical timing**: The agent subprocess blocks waiting for approval. Deferring approval display would deadlock (agent waits for approval, but TaskComplete never arrives until agent finishes)
Copy file name to clipboardExpand all lines: codex-rs/mock-acp-agent/docs.md
+10Lines changed: 10 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,6 +54,8 @@ Path: @/codex-rs/mock-acp-agent
54
54
|`MOCK_AGENT_STDERR_COUNT`| Emits N lines of `MOCK_AGENT_STDERR_LINE:{i}` to stderr during prompt |
55
55
|`MOCK_AGENT_RESPONSE`| Custom response text instead of default "Test message 1/2" (added for TUI testing) |
56
56
|`MOCK_AGENT_DELAY_MS`| Millisecond delay before completing stream to simulate realistic streaming (added for TUI testing) |
57
+
|`MOCK_AGENT_REQUEST_PERMISSION`| Triggers a permission request to the client before responding, used for testing ACP approval bridging |
58
+
|`MOCK_AGENT_SEND_TOOL_CALL`| Sends a tool call sequence (pending → in_progress → completed) for testing tool call display |
57
59
58
60
**Stderr Output for Testing:**
59
61
@@ -70,6 +72,14 @@ This allows tests to verify stderr capture by checking for known strings.
70
72
71
73
The agent can request file reads from the client via `conn.read_text_file()`. This exercises bidirectional client<->agent communication. Set `MOCK_AGENT_REQUEST_FILE=/path/to/file` to trigger.
72
74
75
+
**Permission Request Client Request:**
76
+
77
+
The agent can request permission from the client via `conn.request_permission()`. When `MOCK_AGENT_REQUEST_PERMISSION` is set:
78
+
- Creates a `ToolCallUpdate` describing a shell command execution
79
+
- Provides two `PermissionOption` choices: "Allow" (`AllowOnce`) and "Reject" (`RejectOnce`)
80
+
- Blocks waiting for the client's response, exercising the full approval bridging flow
81
+
- Sends a confirmation message indicating which option was selected
82
+
73
83
**Binary Name:**
74
84
75
85
Cargo renames hyphens to underscores in binary names, so the built artifact is `mock_acp_agent` (not `mock-acp-agent`). Tests in `@/codex-rs/acp/tests/integration.rs` use `mock_agent_binary_path()` helper to locate it.
Copy file name to clipboardExpand all lines: codex-rs/tui-pty-e2e/docs.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -144,7 +144,7 @@ This delay allows the PTY subprocess time to process input and update the displa
144
144
|`@/codex-rs/tui-pty-e2e/tests/prompt_flow.rs`| Prompt submission and agent responses |
145
145
|`@/codex-rs/tui-pty-e2e/tests/input_handling.rs`| Text editing, backspace, Ctrl-C clearing, arrow key navigation with snapshot testing |
146
146
|`@/codex-rs/tui-pty-e2e/tests/streaming.rs`| Prompt submission with timing delays, agent response streaming |
147
-
|`@/codex-rs/tui-pty-e2e/tests/acp_mode.rs`| ACP mode startup and response flow- validates TUI works with ACP wire API and mock agent; includes TDD marker test for approval bridging (`#[ignore]`)|
147
+
|`@/codex-rs/tui-pty-e2e/tests/acp_mode.rs`| ACP mode startup, response flow, and approval bridging - validates TUI works with ACP wire API and mock agent; includes test for permission request display|
148
148
|`@/codex-rs/tui-pty-e2e/tests/live_acp.rs`| Live authenticated ACP tests for Gemini and Claude with real API connections (opt-in, marked `#[ignore]`) |
149
149
150
150
**Snapshot Files:**
@@ -228,6 +228,7 @@ Tests control mock agent behavior via environment variables:
228
228
-`MOCK_AGENT_RESPONSE` - Custom response text instead of defaults
0 commit comments