Add AcceptWithOverrideCommand for approval decision

This commit is contained in:
Qiyao Qin
2026-03-13 00:19:41 -07:00
parent 76d8d174b1
commit 671cc4644b
22 changed files with 272 additions and 9 deletions
@@ -882,6 +882,8 @@ pub struct ConfigEdit {
pub enum CommandExecutionApprovalDecision {
/// User approved the command.
Accept,
/// User approved the command, but wants to execute a different argv vector.
AcceptWithOverrideCommand { command: Vec<String> },
/// User approved the command and future prompts in the same session-scoped
/// approval cache should run without prompting.
AcceptForSession,
@@ -904,6 +906,9 @@ impl From<CoreReviewDecision> for CommandExecutionApprovalDecision {
fn from(value: CoreReviewDecision) -> Self {
match value {
CoreReviewDecision::Approved => Self::Accept,
CoreReviewDecision::ApprovedOverrideCommand { command } => {
Self::AcceptWithOverrideCommand { command }
}
CoreReviewDecision::ApprovedExecpolicyAmendment {
proposed_execpolicy_amendment,
} => Self::AcceptWithExecpolicyAmendment {
@@ -5691,6 +5696,27 @@ mod tests {
);
}
#[test]
fn command_execution_request_approval_response_accepts_override_command() {
let response = serde_json::from_value::<CommandExecutionRequestApprovalResponse>(json!({
"decision": {
"acceptWithOverrideCommand": {
"command": ["echo", "hi"]
}
}
}))
.expect("override command response should deserialize");
assert_eq!(
response,
CommandExecutionRequestApprovalResponse {
decision: CommandExecutionApprovalDecision::AcceptWithOverrideCommand {
command: vec!["echo".to_string(), "hi".to_string()],
},
}
);
}
#[test]
fn permissions_request_approval_response_accepts_partial_macos_grants() {
let cases = vec![