diff --git a/codex-rs/core/src/codex.rs b/codex-rs/core/src/codex.rs index 1cf55a5b77..fdb71ca3e8 100644 --- a/codex-rs/core/src/codex.rs +++ b/codex-rs/core/src/codex.rs @@ -1587,17 +1587,16 @@ mod handlers { decision, ReviewDecision::Approved | ReviewDecision::ApprovedForSession ) + && let Err(err) = sess.persist_command_allow_prefix(&prefix).await { - if let Err(err) = sess.persist_command_allow_prefix(&prefix).await { - let message = format!("Failed to update execpolicy allow list: {err}"); - tracing::warn!("{message}"); - let warning = EventMsg::Warning(WarningEvent { message }); - sess.send_event_raw(Event { - id: id.clone(), - msg: warning, - }) - .await; - } + let message = format!("Failed to update execpolicy allow list: {err}"); + tracing::warn!("{message}"); + let warning = EventMsg::Warning(WarningEvent { message }); + sess.send_event_raw(Event { + id: id.clone(), + msg: warning, + }) + .await; } match decision { ReviewDecision::Abort => { diff --git a/codex-rs/core/src/default_client.rs b/codex-rs/core/src/default_client.rs index 25e60615bc..55707fad3d 100644 --- a/codex-rs/core/src/default_client.rs +++ b/codex-rs/core/src/default_client.rs @@ -329,7 +329,10 @@ mod tests { let originator_header = headers .get("originator") .expect("originator header missing"); - assert_eq!(originator_header.to_str().unwrap(), "codex_cli_rs"); + assert_eq!( + originator_header.to_str().unwrap(), + originator().value.as_str() + ); // User-Agent matches the computed Codex UA for that originator let expected_ua = get_codex_user_agent(); diff --git a/codex-rs/core/tests/suite/client.rs b/codex-rs/core/tests/suite/client.rs index 59b7e34171..cab8488420 100644 --- a/codex-rs/core/tests/suite/client.rs +++ b/codex-rs/core/tests/suite/client.rs @@ -14,6 +14,7 @@ use codex_core::ResponseItem; use codex_core::WireApi; use codex_core::auth::AuthCredentialsStoreMode; use codex_core::built_in_model_providers; +use codex_core::default_client::originator; use codex_core::error::CodexErr; use codex_core::model_family::find_family_for_model; use codex_core::protocol::EventMsg; @@ -367,7 +368,10 @@ async fn includes_conversation_id_and_model_headers_in_request() { request_conversation_id.to_str().unwrap(), conversation_id.to_string() ); - assert_eq!(request_originator.to_str().unwrap(), "codex_cli_rs"); + assert_eq!( + request_originator.to_str().unwrap(), + originator().value.as_str() + ); assert_eq!( request_authorization.to_str().unwrap(), "Bearer Test API Key" @@ -482,7 +486,10 @@ async fn chatgpt_auth_sends_correct_request() { request_conversation_id.to_str().unwrap(), conversation_id.to_string() ); - assert_eq!(request_originator.to_str().unwrap(), "codex_cli_rs"); + assert_eq!( + request_originator.to_str().unwrap(), + originator().value.as_str() + ); assert_eq!( request_authorization.to_str().unwrap(), "Bearer Access Token" diff --git a/codex-rs/tui/src/bottom_pane/approval_overlay.rs b/codex-rs/tui/src/bottom_pane/approval_overlay.rs index ca0239982d..3aac56864e 100644 --- a/codex-rs/tui/src/bottom_pane/approval_overlay.rs +++ b/codex-rs/tui/src/bottom_pane/approval_overlay.rs @@ -414,24 +414,24 @@ fn exec_options(allow_prefix: Option>) -> Vec { allow_prefix: None, }); - let (label, allow_prefix) = match allow_prefix { - Some(prefix) => ( - "Yes, and don't ask again for commands with this prefix".to_string(), - Some(prefix), - ), - None => ( - "Yes, and don't ask again for this command".to_string(), - None, - ), - }; options.push(ApprovalOption { - label, + label: "Yes, and don't ask again for this command".to_string(), decision: ReviewDecision::ApprovedForSession, display_shortcut: None, additional_shortcuts: vec![key_hint::plain(KeyCode::Char('a'))], - allow_prefix, + allow_prefix: None, }); + if let Some(prefix) = allow_prefix { + options.push(ApprovalOption { + label: "Yes, and don't ask again for commands with this prefix".to_string(), + decision: ReviewDecision::ApprovedForSession, + display_shortcut: None, + additional_shortcuts: vec![key_hint::plain(KeyCode::Char('p'))], + allow_prefix: Some(prefix), + }); + } + options.push(ApprovalOption { label: "No, and tell Codex what to do differently".to_string(), decision: ReviewDecision::Abort, @@ -522,7 +522,7 @@ mod tests { }, tx, ); - view.handle_key_event(KeyEvent::new(KeyCode::Char('a'), KeyModifiers::NONE)); + view.handle_key_event(KeyEvent::new(KeyCode::Char('p'), KeyModifiers::NONE)); let mut saw_op = false; while let Ok(ev) = rx.try_recv() { if let AppEvent::CodexOp(Op::ExecApproval { diff --git a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__approval_modal_exec.snap b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__approval_modal_exec.snap index 06b5e708df..9a0cf18f7f 100644 --- a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__approval_modal_exec.snap +++ b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__approval_modal_exec.snap @@ -10,7 +10,8 @@ expression: terminal.backend().vt100().screen().contents() $ echo hello world › 1. Yes, proceed (y) - 2. Yes, and don't ask again for commands with this prefix (a) - 3. No, and tell Codex what to do differently (esc) + 2. Yes, and don't ask again for this command (a) + 3. Yes, and don't ask again for commands with this prefix (p) + 4. No, and tell Codex what to do differently (esc) Press enter to confirm or esc to cancel