Fix: Add missing config support for execpolicy auto-allow prefixes #9006
+317
−17
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.
Fix: Add missing config support for execpolicy auto-allow prefixes
Bug Report
Issue: PR #7033 by @zhao-oai implemented TUI prefix allowance infrastructure (the
(p)option in approval prompts), but the feature was incomplete: it provided no way to configure prefix allowances via config file before execution.User Impact: Despite the TUI showing prefix-based approval options, users couldn't pre-configure commonly approved command patterns, forcing them to repeatedly approve safe commands during sessions.
History: This has been a highly requested feature for over a year:
execpolicy#1260 (opened June 6, 2025, 👍 57 reactions)What was broken
execpolicy.auto_allow_prefixes-cflag)How this fixes it
Core Changes
execpolicy.auto_allow_prefixesarray field inConfigTomland newExecPolicyConfigTomltypeapply_auto_allow_prefixes()to parse and apply prefix rules from config at session startshlex::split()to parse prefix strings into argv for execpolicy prefix rules (properly handles shell quoting)Documentation
Code CI changes
ScrollInputModeandReadModeto use#[derive(Default)]with#[default]attribute (removes manual implementations)Path::new()instead ofPathBuf::from()for better clarityThis was due to running the suggested
just fix -p codex-corecommands.Usage Example
Users can now configure auto-approved command prefixes in
~/.codex/config.tomlor.codex/config.toml:Afterwards commands like
git add .orcargo test --all-featureswill be auto-approved without prompting.Testing
All tests pass:
cargo test -p codex-core just fmt just fix -p codex-coreTest Coverage
✅ Prefix matches allow commands with additional trailing arguments
✅ Project config overrides global config as expected
✅ Invalid/empty prefixes are safely ignored with warnings
✅ Non-matching commands still require approval
✅ Proper shell tokenization (handles quotes, spaces, env vars)
Addressing User Feedback
This PR directly addresses my feedback from #1260:
#1260 (comment)
#1260 (comment)
Scope & Limitations
In Scope
✅ Completes execpolicy prefix allowance implementation from #7033
✅ Affects exec command approvals only
✅ Session-based (rules loaded at startup, not persisted to disk)
✅ Respects config layer precedence
Out of Scope
❌ No changes to apply_patch or other tool approvals
❌ No modifications to existing execpolicy rule files
❌ No persistence beyond current session (in-memory rules only)
❌ No TUI-based prefix detection improvements (addressed in config instead)
Related Work
(p)option (both can coexist)Checklist
just fmtjust fix -p coreexecpolicy#1260) and burndown issue (Rust CLI Cutover (Burndown List) #1262)Community Requested: This completes a highly requested feature with 57+ 👍 reactions over 7 months.