fix(codex): bidirectional runtime approval-mode switching for codex-native - #6228
Open
marktai wants to merge 1 commit into
Open
fix(codex): bidirectional runtime approval-mode switching for codex-native#6228marktai wants to merge 1 commit into
marktai wants to merge 1 commit into
Conversation
marktai
force-pushed
the
mt--codex-permission-mode-persist
branch
from
September 2, 2026 23:14
ae27942 to
4618818
Compare
…ative Add a running-session Approvals picker for codex-native that mirrors Codex's own /permissions popup and syncs both directions. - Web -> TUI: PATCH /v1/sessions forwards a codex_approval_mode_change; the runner drives the /permissions popup by keystroke (select the preset by its menu digit, plus the Full Access confirm) and confirms Codex echoed the switch before returning, so an unsupported preset fails loud instead of the label claiming a mode the TUI never entered. Approval is not a thread/settings/update field like model/effort, so the popup is the mechanism. - TUI -> web: the forwarder maps the approvalPolicy / sandbox / reviewer fields from thread/settings/updated to a preset value, and the server stamps the read-back label and publishes session.codex_approval_mode so the picker tracks a /permissions change made inside the TUI live (once the thread is subscribed, i.e. after the first turn). Presets mirror the popup in order (Ask for approval / Approve for me / Full Access / Read Only). Codex's set is version-dependent (0.146 omits Read Only), so this is the superset with position-stable menu digits. The web config modal's Approvals picker now resyncs to live store updates while open (only until the user edits), so an external change no longer needs a reopen. Tests: preset + threadSettings->preset mapping units, forwarder derivation/sync, server PATCH and external-event (TUI->web) integration; web vitest for the reader, store action + SSE, and the open-modal live-resync regression. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Mark Tai <mark.tai@databricks.com>
marktai
force-pushed
the
mt--codex-permission-mode-persist
branch
from
September 3, 2026 00:29
4618818 to
bb99b03
Compare
marktai
marked this pull request as ready for review
September 3, 2026 01:45
Collaborator
Author
|
@yaoharry is this analogous to how you did it? I'm not a huge fan of the terminal input and checking, but there wasn't another way. |
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.
Related issue
No linked issue yet (draft) — codex-native runtime approval-mode switching from the web.
Closes #
Summary
Adds a running-session Approvals picker for codex-native that mirrors Codex's own
/permissionspopup and syncs both directions:PATCH /v1/sessionsforwards acodex_approval_mode_change; the runner drives the/permissionspopup by keystroke (selects the preset by its menu digit, plus the Full Access confirm). Approval is not athread/settings/updatefield like model/effort, so the popup is the mechanism.approvalPolicy/sandbox/ reviewer fields fromthread/settings/updatedto a preset; the server stamps a read-back label and publishessession.codex_approval_mode, so a/permissionschange made inside the TUI tracks in the web picker live (once the thread is subscribed — after the first turn).Presets mirror the popup in order: Ask for approval / Approve for me / Full Access / Read Only. Codex's set is version-dependent (0.146 omits Read Only), so this is the superset with position-stable menu digits. The config modal's Approvals picker also now resyncs to live store updates while open (until the user edits), so an external change no longer needs a reopen.
ELI5: pick "how much Codex asks before it acts" from the web, and it flips the same switch the codex terminal's
/permissionsmenu does — and flipping it in the terminal makes the web catch up.Test Plan
uv run --group test pytest tests/test_codex_approval_modes.py tests/test_codex_native_forwarder.py tests/server/integration/test_sessions_endpoints.py(preset +threadSettings→preset mapping, forwarder derivation/sync, server PATCH + external-event TUI→web integration).ruff check/ruff format/pyrefly checkclean on changed files.web/):npx vitest runon touched files,npm run lint,npm run type-check,npm run build— all green, incl. an open-modal live-resync regression test.codex0.146): web pick → codex TUI switches for all three reachable presets (Full Access includes its confirm sub-dialog); a TUI/permissionschange → web picker updates live; the open-modal picker resyncs on an external change.Demo
Running-session Approvals picker mirroring Codex's
/permissionspresets:Type of change
Test coverage
Coverage notes
Manual verification ran against a live local server + real
codex0.146: both sync directions and the open-modal live-resync. Two behaviors worth calling out:/permissionschange isn't observed until a turn runs./permissions(0.146 does not). The picker offers the superset; on a build without it, selecting Read Only keys a non-existent menu row (a no-op).Changelog
Switch Codex approval mode (Ask for approval / Approve for me / Full Access / Read Only) from the web, kept in sync with the codex
/permissionsmenu both ways.This pull request and its description were written by Isaac.