mirror of
https://github.com/openai/codex.git
synced 2026-04-24 22:54:54 +00:00
4.2 KiB
4.2 KiB
PR #1675: Update render name in tui for approval_policy to match with config values
- URL: https://github.com/openai/codex/pull/1675
- Author: pbezglasny
- Created: 2025-07-24 19:41:10 UTC
- Updated: 2025-07-24 21:18:05 UTC
- Changes: +6/-3, Files changed: 3, Commits: 4
Description
Currently, codex on start shows the value for the approval policy as name of AskForApproval enum, which differs from approval_policy config values.
E.g. "untrusted" becomes "UnlessTrusted", "on-failure" -> "OnFailure", "never" -> "Never".
This PR changes render names of the approval policy to match with configuration values.
Full Diff
diff --git a/codex-rs/core/src/protocol.rs b/codex-rs/core/src/protocol.rs
index 0c375e455d..3111b42292 100644
--- a/codex-rs/core/src/protocol.rs
+++ b/codex-rs/core/src/protocol.rs
@@ -11,6 +11,7 @@ use std::str::FromStr;
use mcp_types::CallToolResult;
use serde::Deserialize;
use serde::Serialize;
+use strum_macros::Display;
use uuid::Uuid;
use crate::config_types::ReasoningEffort as ReasoningEffortConfig;
@@ -123,14 +124,16 @@ pub enum Op {
/// Determines the conditions under which the user is consulted to approve
/// running the command proposed by Codex.
-#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
+#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize, Display)]
#[serde(rename_all = "kebab-case")]
+#[strum(serialize_all = "kebab-case")]
pub enum AskForApproval {
/// Under this policy, only "known safe" commands—as determined by
/// `is_safe_command()`—that **only read files** are auto‑approved.
/// Everything else will ask the user to approve.
#[default]
#[serde(rename = "untrusted")]
+ #[strum(serialize = "untrusted")]
UnlessTrusted,
/// *All* commands are auto‑approved, but they are expected to run inside a
diff --git a/codex-rs/exec/src/event_processor.rs b/codex-rs/exec/src/event_processor.rs
index a7edb96af2..741f89d7cb 100644
--- a/codex-rs/exec/src/event_processor.rs
+++ b/codex-rs/exec/src/event_processor.rs
@@ -25,7 +25,7 @@ pub(crate) fn create_config_summary_entries(config: &Config) -> Vec<(&'static st
("workdir", config.cwd.display().to_string()),
("model", config.model.clone()),
("provider", config.model_provider_id.clone()),
- ("approval", format!("{:?}", config.approval_policy)),
+ ("approval", config.approval_policy.to_string()),
("sandbox", summarize_sandbox_policy(&config.sandbox_policy)),
];
if config.model_provider.wire_api == WireApi::Responses
diff --git a/codex-rs/tui/src/history_cell.rs b/codex-rs/tui/src/history_cell.rs
index b481313405..13bec71b46 100644
--- a/codex-rs/tui/src/history_cell.rs
+++ b/codex-rs/tui/src/history_cell.rs
@@ -156,7 +156,7 @@ impl HistoryCell {
("workdir", config.cwd.display().to_string()),
("model", config.model.clone()),
("provider", config.model_provider_id.clone()),
- ("approval", format!("{:?}", config.approval_policy)),
+ ("approval", config.approval_policy.to_string()),
("sandbox", summarize_sandbox_policy(&config.sandbox_policy)),
];
if config.model_provider.wire_api == WireApi::Responses
Review Comments
codex-rs/exec/src/event_processor.rs
- Created: 2025-07-24 20:31:09 UTC | Link: https://github.com/openai/codex/pull/1675#discussion_r2229515238
@@ -25,7 +25,13 @@ pub(crate) fn create_config_summary_entries(config: &Config) -> Vec<(&'static st
("workdir", config.cwd.display().to_string()),
("model", config.model.clone()),
("provider", config.model_provider_id.clone()),
- ("approval", format!("{:?}", config.approval_policy)),
+ (
+ "approval",
+ serde_json::to_string(&config.approval_policy)
I like this direction, but instead of this complexity, what about adding
#[strum(serialize_all = "kebab-case")]to theAskForApprovalenum?