fix: resolve codex approval response ID mismatch #66
+177
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When executing commands like
lsin Codex, approval requests are displayed on the mobile app, but selecting YES does not work. The command execution hangs waiting for approval, even though the user has approved the request.Root Cause
The issue was an ID mismatch between the permission request registration and the permission response handling. This likely appeared after codex-cli version updates (verified with codex-cli 0.58.0):
codexMcpClient.tsregistered permission requests usingcodex_call_idexec_approval_requestevent usescodex_mcp_tool_call_idas itscall_idcallIdfrom thetool-callmessage, which corresponds tocodex_mcp_tool_call_idcodex_call_id)Solution
Changed the permission request registration to use
codex_mcp_tool_call_id(with fallback tocodex_call_idfor backward compatibility) to match the ID that will be used in:exec_approval_requestevent'scall_idtool-callmessage sent to the mobile appThis ensures the permission response ID matches the registered permission request ID.
Changes
src/codex/codexMcpClient.ts: Usecodex_mcp_tool_call_idinstead ofcodex_call_idwhen registering permission requestssrc/codex/__tests__/permissionApprovalFlow.test.ts: Added comprehensive tests for the permission approval flowTesting
Test Results
$ yarn test src/codex/__tests__/permissionApprovalFlow.test.ts ✓ src/codex/__tests__/permissionApprovalFlow.test.ts (4 tests) 166ms ✓ should register permission request with correct ID and resolve when permission response matches ✓ should not resolve permission request when response ID does not match ✓ should handle permission denial correctly ✓ should handle multiple permission requests with different IDsType Check
Manual Testing Steps
happy daemon startlsthat requires approvalReal Device Testing
✅ Verified on real device: Approval flow (OK/NG) works correctly after this fix
Note: This issue likely appeared after codex-cli version updates. Verified working with codex-cli 0.58.0.
Backward Compatibility
The fix includes a fallback to
codex_call_idifcodex_mcp_tool_call_idis not available, ensuring compatibility with older Codex versions or different deployment configurations.Test Results
All tests related to this change pass:
permissionApprovalFlow.test.ts- All 4 tests pass