feat(gateway): bridge managed Codex TUI approvals - #75482
Draft
Nicecsh wants to merge 1 commit into
Draft
Conversation
teknium1
reviewed
Jul 31, 2026
teknium1
left a comment
Contributor
There was a problem hiding this comment.
Thanks for isolating the native-PTY path from the existing app-server approval work. The current main PTY reader has no native Codex approval bridge, so the feature premise remains valid.
Problems
tools/process_registry.py:731, :747— this stale hunk bypasses current main'ssafe_commandrewrite. Current main applies_rewrite_compound_background()attools/process_registry.py:708-715and passessafe_commandto PTY spawn at:737, fixing theA && B &subshell-wait deadlock in commitd7512c8689a3(#68915). Here,pty_commandfalls back to rawcommandwhenever the Codex bridge is disabled, so unrelated PTYs lose that protection.
Suggested changes
- Build the Codex rewrite from
safe_command, or otherwise preservesafe_commandfor every non-bridged PTY path; add a PTY regression test for the compound-background case.
Automated hermes-sweeper review.
| pty_env["PYTHONUNBUFFERED"] = "1" | ||
| pty_proc = _PtyProcessCls.spawn( | ||
| [user_shell, "-lic", f"set +m; {command}"], | ||
| [user_shell, "-lic", f"set +m; {pty_command}"], |
Contributor
There was a problem hiding this comment.
On current main this argument is safe_command, produced by _rewrite_compound_background() to fix #68915. Because pty_command falls back to raw command when the bridge is ineligible, this regresses that protection for every other PTY command. Preserve safe_command as the fallback/input to the Codex rewrite.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this PR do?
Bridges approval prompts from native Codex TUI processes that Hermes launches in an owned PTY back to the originating Discord session.
Today, a Hermes agent can launch
codexwithpty: true, but any later native TUI command/file/permission approval exists only on that hidden PTY. The user sees no actionable prompt in Discord, and the background process can remain blocked indefinitely.This change gives eligible Codex PTYs process-local approval key bindings, recognizes fully rendered native approval screens, queues the request on Hermes' existing per-session approval FIFO, and sends the decision back through the PTY. It does not attach to unrelated/external Codex processes and does not change global Codex configuration.
Security and lifecycle properties:
codexcommand launched by Hermes for a Discord sessionRelated Issue
No issue filed. Related app-server approval work (#25889, #27636, and #66925) addresses the structured Codex app-server transport; this PR covers the separate native TUI PTY path.
Type of Change
Changes Made
tools/codex_tui_approval.pyfor safe command gating, version checks, process-local keymaps, screen detection, and decision-to-key mappingtools/process_registry.pyto prepare managed Codex PTYs, detect approvals, block unsafe concurrent stdin, and clean up process-owned requeststools/approval.pywith process-lifetime queue entries and source-scoped cancellationgateway/run.pyHow to Test
pty: true.Automated validation:
scripts/run_tests.sh tests/tools/test_codex_tui_approval.py tests/gateway/test_codex_pty_approval_bridge.py tests/tools/test_approval.py tests/gateway/test_discord_slash_commands.py tests/gateway/test_discord_exec_approval_content.py tests/gateway/test_discord_approval_mentions.py— 366 passedruff checkon all six changed files — passedpython -m py_compileon all six changed files — passedgit diff --check— passedChecklist
Code
pytest tests/ -qand all tests pass (targeted 366-test suite passes; full CI pending)Documentation & Housekeeping
cli-config.yaml.exampleupdate is N/A; no Hermes config keys were addedCONTRIBUTING.md/AGENTS.mdupdate is N/AScreenshots / Logs
The focused test run completed with
366 tests passed, 0 failed.